@knowsuchagency/fulcrum 2.1.0 → 2.1.2

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.
@@ -79,7 +79,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
79
79
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:s,tableCell:l,tableRow:o}};function s(m,b,y,v){return u(d(m,y,v),m.align)}function o(m,b,y,v){const _=f(m,y,v),E=u([_]);return E.slice(0,E.indexOf(`
80
80
  `))}function l(m,b,y,v){const _=y.enter("tableCell"),E=y.enter("phrasing"),C=y.containerPhrasing(m,{...v,before:a,after:a});return E(),_(),C}function u(m,b){return Zft(m,{align:b,alignDelimiters:r,padding:n,stringLength:i})}function d(m,b,y){const v=m.children;let _=-1;const E=[],C=b.enter("table");for(;++_<v.length;)E[_]=f(v[_],b,y);return C(),E}function f(m,b,y){const v=m.children;let _=-1;const E=[],C=b.enter("tableRow");for(;++_<v.length;)E[_]=l(v[_],m,b,y);return C(),E}function p(m,b,y){let v=t2e.inlineCode(m,b,y);return y.stack.includes("tableCell")&&(v=v.replace(/\|/g,"\\$&")),v}}function Fht(){return{exit:{taskListCheckValueChecked:hse,taskListCheckValueUnchecked:hse,paragraph:$ht}}}function Bht(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Uht}}}function hse(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function $ht(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 Uht(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=t2e.listItem(e,t,n,{...r,...o.current()});return a&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(d){return d+s}}function zht(){return[xft(),Uft(),Wft(),Rht(),Fht()]}function Hht(e){return{extensions:[_ft(),zft(e),qft(),jht(e),Bht()]}}const Vht={tokenize:Xht,partial:!0},n2e={tokenize:Zht,partial:!0},r2e={tokenize:Qht,partial:!0},i2e={tokenize:Jht,partial:!0},Wht={tokenize:ept,partial:!0},a2e={name:"wwwAutolink",tokenize:Kht,previous:o2e},s2e={name:"protocolAutolink",tokenize:Yht,previous:l2e},Xh={name:"emailAutolink",tokenize:Ght,previous:u2e},yf={};function qht(){return{text:yf}}let yg=48;for(;yg<123;)yf[yg]=Xh,yg++,yg===58?yg=65:yg===91&&(yg=97);yf[43]=Xh;yf[45]=Xh;yf[46]=Xh;yf[95]=Xh;yf[72]=[Xh,s2e];yf[104]=[Xh,s2e];yf[87]=[Xh,a2e];yf[119]=[Xh,a2e];function Ght(e,t,n){const r=this;let i,a;return s;function s(f){return!bB(f)||!u2e.call(r,r.previous)||xY(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(f))}function o(f){return bB(f)?(e.consume(f),o):f===64?(e.consume(f),l):n(f)}function l(f){return f===46?e.check(Wht,d,u)(f):f===45||f===95||ho(f)?(a=!0,e.consume(f),l):d(f)}function u(f){return e.consume(f),i=!0,l}function d(f){return a&&i&&co(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function Kht(e,t,n){const r=this;return i;function i(s){return s!==87&&s!==119||!o2e.call(r,r.previous)||xY(r.events)?n(s):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Vht,e.attempt(n2e,e.attempt(r2e,a),n),n)(s))}function a(s){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(s)}}function Yht(e,t,n){const r=this;let i="",a=!1;return s;function s(f){return(f===72||f===104)&&l2e.call(r,r.previous)&&!xY(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),e.consume(f),o):n(f)}function o(f){if(co(f)&&i.length<5)return i+=String.fromCodePoint(f),e.consume(f),o;if(f===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(f),l}return n(f)}function l(f){return f===47?(e.consume(f),a?u:(a=!0,l)):n(f)}function u(f){return f===null||DN(f)||_r(f)||Ro(f)||gD(f)?n(f):e.attempt(n2e,e.attempt(r2e,d),n)(f)}function d(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function Xht(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 Zht(e,t,n){let r,i,a;return s;function s(u){return u===46||u===95?e.check(i2e,l,o)(u):u===null||_r(u)||Ro(u)||u!==45&&gD(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 Qht(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(i2e,t,a)(s):s===null||_r(s)||Ro(s)?t(s):(e.consume(s),i)}function a(s){return s===41&&r++,e.consume(s),i}}function Jht(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||_r(o)||Ro(o)?t(o):n(o)}function i(o){return o===null||o===40||o===91||_r(o)||Ro(o)?t(o):r(o)}function a(o){return co(o)?s(o):n(o)}function s(o){return o===59?(e.consume(o),r):co(o)?(e.consume(o),s):n(o)}}function ept(e,t,n){return r;function r(a){return e.consume(a),i}function i(a){return ho(a)?n(a):t(a)}}function o2e(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||_r(e)}function l2e(e){return!co(e)}function u2e(e){return!(e===47||bB(e))}function bB(e){return e===43||e===45||e===46||e===95||ho(e)}function xY(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 tpt={tokenize:upt,partial:!0};function npt(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:spt,continuation:{tokenize:opt},exit:lpt}},text:{91:{name:"gfmFootnoteCall",tokenize:apt},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:rpt,resolveTo:ipt}}}}function rpt(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=qc(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 ipt(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 apt(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,s;return o;function o(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(f){if(a>999||f===93&&!s||f===null||f===91||_r(f))return n(f);if(f===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(qc(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return _r(f)||(s=!0),a++,e.consume(f),f===92?d:u}function d(f){return f===91||f===92||f===93?(e.consume(f),a++,u):u(f)}}function spt(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,s=0,o;return l;function l(b){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(b){return b===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",d):n(b)}function d(b){if(s>999||b===93&&!o||b===null||b===91||_r(b))return n(b);if(b===93){e.exit("chunkString");const y=e.exit("gfmFootnoteDefinitionLabelString");return a=qc(r.sliceSerialize(y)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return _r(b)||(o=!0),s++,e.consume(b),b===92?f:d}function f(b){return b===91||b===92||b===93?(e.consume(b),s++,d):d(b)}function p(b){return b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),i.includes(a)||i.push(a),cr(e,m,"gfmFootnoteDefinitionWhitespace")):n(b)}function m(b){return t(b)}}function opt(e,t,n){return e.check(Y1,t,e.attempt(tpt,t,n))}function lpt(e){e.exit("gfmFootnoteDefinition")}function upt(e,t,n){const r=this;return cr(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 cpt(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 d={type:"strikethrough",start:Object.assign({},s[u][1].start),end:Object.assign({},s[l][1].end)},f={type:"strikethroughText",start:Object.assign({},s[u][1].end),end:Object.assign({},s[l][1].start)},p=[["enter",d,o],["enter",s[u][1],o],["exit",s[u][1],o],["enter",f,o]],m=o.parser.constructs.insideSpan.null;m&&ru(p,p.length,0,bD(m,s.slice(u+1,l),o)),ru(p,p.length,0,[["exit",f,o],["enter",s[l][1],o],["exit",s[l][1],o],["exit",d,o]]),ru(s,u-1,l-u+3,p),l=u+p.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,d=this.events;let f=0;return p;function p(b){return u===126&&d[d.length-1][1].type!=="characterEscape"?l(b):(s.enter("strikethroughSequenceTemporary"),m(b))}function m(b){const y=k0(u);if(b===126)return f>1?l(b):(s.consume(b),f++,m);if(f<2&&!n)return l(b);const v=s.exit("strikethroughSequenceTemporary"),_=k0(b);return v._open=!_||_===2&&!!y,v._close=!y||y===2&&!!_,o(b)}}}class dpt{constructor(){this.map=[]}add(t,n,r){fpt(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 fpt(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 hpt(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 ppt(){return{flow:{null:{name:"table",tokenize:mpt,resolveAll:gpt}}}}function mpt(e,t,n){const r=this;let i=0,a=0,s;return o;function o(I){let P=r.events.length-1;for(;P>-1;){const j=r.events[P][1].type;if(j==="lineEnding"||j==="linePrefix")P--;else break}const L=P>-1?r.events[P][1].type:null,B=L==="tableHead"||L==="tableRow"?S:l;return B===S&&r.parser.lazy[r.now().line]?n(I):B(I)}function l(I){return e.enter("tableHead"),e.enter("tableRow"),u(I)}function u(I){return I===124||(s=!0,a+=1),d(I)}function d(I){return I===null?n(I):mn(I)?a>1?(a=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),m):n(I):Vn(I)?cr(e,d,"whitespace")(I):(a+=1,s&&(s=!1,i+=1),I===124?(e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),s=!0,d):(e.enter("data"),f(I)))}function f(I){return I===null||I===124||_r(I)?(e.exit("data"),d(I)):(e.consume(I),I===92?p:f)}function p(I){return I===92||I===124?(e.consume(I),f):f(I)}function m(I){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(I):(e.enter("tableDelimiterRow"),s=!1,Vn(I)?cr(e,b,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):b(I))}function b(I){return I===45||I===58?v(I):I===124?(s=!0,e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),y):k(I)}function y(I){return Vn(I)?cr(e,v,"whitespace")(I):v(I)}function v(I){return I===58?(a+=1,s=!0,e.enter("tableDelimiterMarker"),e.consume(I),e.exit("tableDelimiterMarker"),_):I===45?(a+=1,_(I)):I===null||mn(I)?T(I):k(I)}function _(I){return I===45?(e.enter("tableDelimiterFiller"),E(I)):k(I)}function E(I){return I===45?(e.consume(I),E):I===58?(s=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(I),e.exit("tableDelimiterMarker"),C):(e.exit("tableDelimiterFiller"),C(I))}function C(I){return Vn(I)?cr(e,T,"whitespace")(I):T(I)}function T(I){return I===124?b(I):I===null||mn(I)?!s||i!==a?k(I):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(I)):k(I)}function k(I){return n(I)}function S(I){return e.enter("tableRow"),N(I)}function N(I){return I===124?(e.enter("tableCellDivider"),e.consume(I),e.exit("tableCellDivider"),N):I===null||mn(I)?(e.exit("tableRow"),t(I)):Vn(I)?cr(e,N,"whitespace")(I):(e.enter("data"),R(I))}function R(I){return I===null||I===124||_r(I)?(e.exit("data"),N(I)):(e.consume(I),I===92?D:R)}function D(I){return I===92||I===124?(e.consume(I),R):R(I)}}function gpt(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],s=[0,0,0,0],o=!1,l=0,u,d,f;const p=new dpt;for(;++n<e.length;){const m=e[n],b=m[1];m[0]==="enter"?b.type==="tableHead"?(o=!1,l!==0&&(pse(p,t,l,u,d),d=void 0,l=0),u={type:"table",start:Object.assign({},b.start),end:Object.assign({},b.end)},p.add(n,0,[["enter",u,t]])):b.type==="tableRow"||b.type==="tableDelimiterRow"?(r=!0,f=void 0,a=[0,0,0,0],s=[0,n+1,0,0],o&&(o=!1,d={type:"tableBody",start:Object.assign({},b.start),end:Object.assign({},b.end)},p.add(n,0,[["enter",d,t]])),i=b.type==="tableDelimiterRow"?2:d?3:1):i&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")?(r=!1,s[2]===0&&(a[1]!==0&&(s[0]=s[1],f=cT(p,t,a,i,void 0,f),a=[0,0,0,0]),s[2]=n)):b.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(s[0]=s[1],f=cT(p,t,a,i,void 0,f)),a=s,s=[a[1],n,0,0])):b.type==="tableHead"?(o=!0,l=n):b.type==="tableRow"||b.type==="tableDelimiterRow"?(l=n,a[1]!==0?(s[0]=s[1],f=cT(p,t,a,i,n,f)):s[1]!==0&&(f=cT(p,t,s,i,n,f)),i=0):i&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")&&(s[3]=n)}for(l!==0&&pse(p,t,l,u,d),p.consume(t.events),n=-1;++n<t.events.length;){const m=t.events[n];m[0]==="enter"&&m[1].type==="table"&&(m[1]._align=hpt(t.events,n))}return e}function cT(e,t,n,r,i,a){const s=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",o="tableContent";n[0]!==0&&(a.end=Object.assign({},Sv(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const l=Sv(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=Sv(t.events,n[2]),d=Sv(t.events,n[3]),f={type:o,start:Object.assign({},u),end:Object.assign({},d)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const p=t.events[n[2]],m=t.events[n[3]];if(p[1].end=Object.assign({},m[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const b=n[2]+1,y=n[3]-n[2]-1;e.add(b,y,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return i!==void 0&&(a.end=Object.assign({},Sv(t.events,i)),e.add(i,0,[["exit",a,t]]),a=void 0),a}function pse(e,t,n,r,i){const a=[],s=Sv(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 Sv(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const bpt={name:"tasklistCheck",tokenize:vpt};function ypt(){return{text:{91:bpt}}}function vpt(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 _r(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 mn(l)?t(l):Vn(l)?e.check({tokenize:xpt},t,n)(l):n(l)}}function xpt(e,t,n){return cr(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function _pt(e){return pY([qht(),npt(),cpt(e),ppt(),ypt()])}const Spt={};function Ept(e){const t=this,n=e||Spt,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),s=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(_pt(n)),a.push(zht()),s.push(Hht(n))}const wpt=/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]/i,Cpt=/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)(\/.*)?\]/i,kpt=({legacyTitle:e=!1,tagName:t="div"}={})=>n=>{Gs(n,"blockquote",(r,i,a)=>{let s="",o="",l=!0,u=r.children.map(d=>{if(l&&d.type==="paragraph"){const f=d.children[0],p=f.type==="text"?f.value:"",m=e?Cpt:wpt,b=p.match(m);if(b&&(l=!1,s=b[1].toLocaleLowerCase(),o=e&&b[2]||s.toLocaleUpperCase(),p.includes(`
81
81
  `)&&(d.children[0]={type:"text",value:p.replace(m,"").replace(/^\n+/,"")}),!p.includes(`
82
- `))){const y=[];d.children.forEach((v,_)=>{_!=0&&(_==1&&v.type==="break"||y.push(v))}),d.children=[...y]}}return d});s&&(r.data={hName:t,hProperties:{class:`markdown-alert markdown-alert-${s}`,dir:"auto"}},u.unshift({type:"paragraph",children:[Tpt(s),{type:"text",value:o.replace(/^\//,"")}],data:{hProperties:{class:"markdown-alert-title",dir:"auto"}}})),r.children=[...u]})};function Tpt(e){let t=Apt[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 Apt={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 Npt(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 c2e(e){if(!e)return null;var t=e;return t.dataset.code&&t.classList.contains("copied")?t:t.parentElement?c2e(t.parentElement):null}function Opt(e){var t=n=>{var r=c2e(n.target);r&&(r.classList.add("active"),Npt(r.dataset.code,function(){setTimeout(()=>{r.classList.remove("active")},2e3)}))};x.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 Rpt=["prefixCls","className","source","style","disableCopy","skipHtml","onScroll","onMouseOver","pluginsFilter","rehypeRewrite","wrapperElement","warpperElement","urlTransform"],Ipt=e=>e;const Dpt=Z.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:d,wrapperElement:f={},warpperElement:p={},urlTransform:m}=e,b=FE(e,Rpt),y=Z.useRef(null);x.useImperativeHandle(t,()=>ur({},e,{mdp:y}),[y,e]);var v=(n||"")+" "+(r||"");Opt(y);var _=[...b.rehypePlugins||[]],E={allowElement:(k,S,N)=>b.allowElement?b.allowElement(k,S,N):/^[A-Za-z0-9]+$/.test(k.tagName)};o||_.push(bCe);var C=[kpt,...b.remarkPlugins||[],Ept],T=ur({},p,f);return c.jsx("div",ur({ref:y,onScroll:l,onMouseOver:u},T,{className:v,style:a,children:c.jsx(hft,ur({},E,b,{skipHtml:!o,urlTransform:m||Ipt,rehypePlugins:d?d("rehype",_):_,remarkPlugins:d?d("remark",C):C,children:i||""}))}))});var Ppt=function(t){return n=>{Gs(n,r=>{r.type==="element"&&r.tagName==="code"&&r.data&&r.data.meta&&(r.properties=ur({},r.properties,{"data-meta":String(r.data.meta)}))})}},Lpt=function(t){return n=>{Gs(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 Mpt=/[\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,jpt=Object.hasOwnProperty;class Fpt{constructor(){this.occurrences,this.reset()}slug(t,n){const r=this;let i=Bpt(t,n===!0);const a=i;for(;jpt.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 Bpt(e,t){return typeof e!="string"?"":(t||(e=e.toLowerCase()),e.replace(Mpt,"").replace(/ /g,"-"))}function d2e(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 $pt={},mse=new Fpt;function Upt(e){const n=(e||$pt).prefix||"";return function(r){mse.reset(),Gs(r,"element",function(i){d2e(i)&&!i.properties.id&&(i.properties.id=n+mse.slug(Nv(i)))})}}const f2e=(function(e){if(e==null)return Vpt;if(typeof e=="string")return Hpt(e);if(typeof e=="object")return zpt(e);if(typeof e=="function")return _Y(e);throw new Error("Expected function, string, or array as `test`")});function zpt(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=f2e(e[n]);return _Y(r);function r(...i){let a=-1;for(;++a<t.length;)if(t[a].apply(this,i))return!0;return!1}}function Hpt(e){return _Y(t);function t(n){return n.tagName===e}}function _Y(e){return t;function t(n,r,i){return!!(Wpt(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function Vpt(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function Wpt(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}const gse={type:"element",tagName:"span",properties:{className:["icon","icon-link"]},children:[]},qpt={};function Gpt(e){const t=e||qpt;let n=t.properties;const r=t.headingProperties,i=t.behavior||"prepend",a=t.content,s=t.group,o=f2e(t.test);let l;return i==="after"||i==="before"?l=d:i==="wrap"?l=f:(l=u,n||(n={ariaHidden:"true",tabIndex:-1})),function(p){Gs(p,"element",function(m,b,y){if(d2e(m)&&m.properties.id&&o(m,b,y))return Object.assign(m.properties,dT(r,m)),l(m,b,y)})};function u(p){const m=bse(a||gse,p);return p.children[i==="prepend"?"unshift":"push"](aM(p,dT(n,p),m)),[DS]}function d(p,m,b){if(typeof m!="number"||!b)return;const y=bse(a||gse,p),v=aM(p,dT(n,p),y);let _=i==="before"?[v,p]:[p,v];if(s){const E=h2e(s,p);E&&!Array.isArray(E)&&E.type==="element"&&(E.children=_,_=[E])}return b.children.splice(m,1,..._),[DS,m+_.length]}function f(p){let m=p.children,b=[];return typeof a=="function"?(m=[],b=a(p)):a&&(b=SY(a)),p.children=[aM(p,dT(n,p),Array.isArray(b)?[...m,...b]:[...m,b])],[DS]}}function SY(e){return Db(e)}function aM(e,t,n){return{type:"element",tagName:"a",properties:{...t,href:"#"+e.properties.id},children:n}}function bse(e,t){const n=h2e(e,t);return Array.isArray(n)?n:[n]}function h2e(e,t){return typeof e=="function"?e(t):SY(e)}function dT(e,t){return typeof e=="function"?e(t):e?SY(e):{}}const Kpt=(e={})=>{const{openDelimiter:t="rehype:ignore:start",closeDelimiter:n="rehype:ignore:end"}=e;return r=>{Gs(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 Ypt={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 Xpt(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 Zpt=(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=ur({class:"anchor"},a.properties),a.children=[Ypt])}if(n.type==="element"&&n.tagName==="pre"&&!e){var s=Twe(n.children);n.children.push(Xpt(s))}t&&t(n,r===null?void 0:r,i===null?void 0:i)},Qpt=[Upt,Gpt,Kpt];const gh=Z.forwardRef((e,t)=>{var n,r=[Ppt,bCe,Lpt,...Qpt,[hat,{rewrite:Zpt((n=e.disableCopy)!=null?n:!1,e.rehypeRewrite)}],[gat,{properties:"attr"}],...e.rehypePlugins||[],[swe,{ignoreMissing:!0}]];return c.jsx(Dpt,ur({},e,{rehypePlugins:r,ref:t}))});function Jpt({role:e,content:t,isStreaming:n,onClick:r}){const i=e==="user",{resolvedTheme:a}=Sl(),s=a==="dark",o=!i&&t&&r,l=x.useMemo(()=>({a:({href:u,children:d,...f})=>c.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",...f,children:d})}),[]);return c.jsxs("div",{className:`flex gap-3 py-3 animate-in fade-in-0 duration-200 ${i?"flex-row-reverse slide-in-from-right-2":"flex-row slide-in-from-left-2"}`,children:[c.jsx("div",{className:`w-8 h-8 flex-shrink-0 rounded-full flex items-center justify-center ${i?"bg-muted border border-border":"bg-gradient-to-br from-accent/30 to-accent/20 border border-accent/40"}`,style:i?void 0:{boxShadow:"0 0 10px color-mix(in oklch, var(--accent) 30%, transparent), 0 0 20px color-mix(in oklch, var(--accent) 15%, transparent)"},children:i?c.jsx(Hve,{className:"w-4 h-4 text-foreground"}):c.jsx(_m,{className:"w-4 h-4 text-accent"})}),c.jsx("div",{onClick:o?r:void 0,className:`flex-1 min-w-0 max-w-[85%] rounded-2xl px-4 py-3 text-sm overflow-hidden text-foreground ${i?"bg-muted/50 border border-border/50 rounded-tr-sm":"bg-card/50 border border-border/50 rounded-tl-sm"} ${o?"cursor-pointer hover:ring-2 hover:ring-offset-1 transition-all hover:ring-accent/40 hover:ring-offset-background":""}`,title:o?"Click to expand":void 0,children:i?c.jsx("p",{className:"whitespace-pre-wrap leading-relaxed",children:t}):t?c.jsx("div",{"data-color-mode":s?"dark":"light",children:c.jsx(gh,{source:t,style:{backgroundColor:"transparent",fontSize:"13px",lineHeight:"1.6",color:"var(--foreground)",fontFamily:"var(--font-sans)"},components:l,className:"prose-sm max-w-none [&_table]:block [&_table]:overflow-x-auto [&_table]:max-w-full [&_pre]:overflow-x-auto [&_pre]:bg-muted/50 [&_pre]:border [&_pre]:border-border/50 [&_pre]:text-xs [&_code]:text-xs [&_code]:text-accent [&_a]:text-accent [&_a:hover]:text-accent/80 [&_strong]:text-foreground [&_h1]:text-foreground [&_h2]:text-foreground [&_h3]:text-foreground [&_h4]:text-foreground [&_li]:text-foreground [&_table]:border-border [&_th]:bg-muted [&_th]:border-border [&_td]:border-border"})}):n?c.jsxs("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[c.jsx("span",{className:"animate-pulse",children:"Thinking"}),c.jsxs("span",{className:"inline-flex gap-0.5",children:[c.jsx("span",{className:"w-1 h-1 rounded-full animate-bounce bg-accent",style:{animationDelay:"0ms"}}),c.jsx("span",{className:"w-1 h-1 rounded-full animate-bounce bg-accent",style:{animationDelay:"150ms"}}),c.jsx("span",{className:"w-1 h-1 rounded-full animate-bounce bg-accent",style:{animationDelay:"300ms"}})]})]}):null})]})}function emt({onSend:e,isLoading:t,placeholder:n}){const{t:r}=Mt("assistant"),i=n??r("input.placeholder"),[a,s]=x.useState(""),o=x.useRef(null),l=x.useCallback(()=>{const f=o.current;f&&(f.style.height="auto",f.style.height=`${Math.min(f.scrollHeight,150)}px`)},[]);x.useEffect(()=>{l()},[a,l]);const u=x.useCallback(()=>{const f=a.trim();f&&!t&&(e(f),s(""),o.current&&(o.current.style.height="auto"))},[a,t,e]),d=x.useCallback(f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),u())},[u]);return c.jsxs("div",{className:"relative",children:[c.jsx("div",{className:"relative overflow-hidden",children:c.jsx("textarea",{ref:o,value:a,onChange:f=>s(f.target.value),onKeyDown:d,rows:3,disabled:t,className:"w-full px-6 py-4 bg-transparent border-none outline-none resize-none text-base font-sans font-normal leading-relaxed min-h-[100px] disabled:opacity-50 text-foreground placeholder-muted-foreground caret-current",placeholder:i,style:{scrollbarWidth:"none"}})}),c.jsx("div",{className:"px-4 pb-4",children:c.jsx("div",{className:"flex items-center justify-end",children:c.jsxs("button",{onClick:u,disabled:!a.trim()||t,className:"group relative p-3 border-none rounded-xl cursor-pointer transition-all duration-300 shadow-lg hover:scale-105 hover:shadow-xl active:scale-95 transform disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:scale-100 disabled:hover:shadow-lg bg-accent text-accent-foreground hover:bg-accent/90",style:{boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 0 0 0 color-mix(in oklch, var(--accent) 30%, transparent)"},children:[t?c.jsx(Bve,{className:"w-5 h-5 animate-spin"}):c.jsx(Uve,{className:"w-5 h-5 transition-all duration-300 group-hover:-translate-y-0.5 group-hover:translate-x-0.5 group-hover:rotate-12"}),c.jsx("div",{className:"absolute inset-0 rounded-xl opacity-0 group-hover:opacity-50 transition-opacity duration-300 blur-lg transform scale-110 bg-accent"}),c.jsx("div",{className:"absolute inset-0 rounded-xl overflow-hidden",children:c.jsx("div",{className:"absolute inset-0 bg-white/20 transform scale-0 group-active:scale-100 transition-transform duration-200 rounded-xl"})})]})})})]})}function tmt(e){const t=e.replace(/\/$/,"")||"/";return t==="/"||t==="/tasks"?"tasks":t.startsWith("/tasks/")&&t.split("/").length===3?"task":t==="/projects"?"projects":t.startsWith("/projects/")&&t.split("/").length===3?"project":t==="/repositories"?"repositories":t.startsWith("/repositories/")&&t.split("/").length===3?"repository":t==="/monitoring"?"monitoring":t==="/terminals"?"terminals":t==="/apps"?"apps":t.startsWith("/apps/")&&t.split("/").length===3&&t.split("/")[2]!=="new"?"app":t==="/jobs"?"jobs":t.startsWith("/jobs/")&&t.split("/").length===3&&t.split("/")[2]!=="new"?"job":t==="/settings"?"settings":"unknown"}function O_(e,t){const n=e.replace(/\/$/,"");if(!n.startsWith(t))return;const r=n.slice(t.length).split("/")[0];if(!(!r||r==="new"))return r}function nmt(){const e=Sa({select:t=>t.location});return x.useMemo(()=>{const{pathname:t,search:n}=e,r=tmt(t),i={pageType:r,path:t};switch(r){case"task":i.taskId=O_(t,"/tasks/");break;case"project":i.projectId=O_(t,"/projects/");break;case"repository":i.repositoryId=O_(t,"/repositories/");break;case"app":i.appId=O_(t,"/apps/");break;case"job":i.jobId=O_(t,"/jobs/");break}const a=n;if(r==="tasks"){const s={};typeof a.project=="string"&&(s.project=a.project),typeof a.tags=="string"&&(s.tags=a.tags.split(",").filter(Boolean)),typeof a.view=="string"&&(s.view=a.view),Object.keys(s).length>0&&(i.filters=s)}return r==="monitoring"&&typeof a.tab=="string"&&(i.activeTab=a.tab),i},[e])}const rmt=Am("h-5 gap-1 rounded-full border border-transparent px-2 py-0.5 text-[0.625rem] font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-2.5! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-colors overflow-hidden group/badge",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground bg-input/20 dark:bg-input/30",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function Xr({className:e,variant:t="default",render:n,...r}){return Vze({defaultTagName:"span",props:Yc({className:je(rmt({className:e,variant:t}))},r),render:n,state:{slot:"badge",variant:t}})}function p2e({delay:e=0,...t}){return c.jsx(Hze,{"data-slot":"tooltip-provider",delay:e,...t})}function rh({...e}){return c.jsx(p2e,{children:c.jsx(Ize,{"data-slot":"tooltip",...e})})}function ih({...e}){return c.jsx(Mze,{"data-slot":"tooltip-trigger",...e})}function ah({className:e,side:t="top",sideOffset:n=4,align:r="center",alignOffset:i=0,children:a,...s}){return c.jsx(Fze,{children:c.jsx(Bze,{align:r,alignOffset:i,side:t,sideOffset:n,className:"isolate z-50",children:c.jsxs(Uze,{"data-slot":"tooltip-content",className:je("data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-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 rounded-md px-3 py-1.5 text-xs **:data-[slot=kbd]:rounded-md bg-foreground text-background z-50 w-fit max-w-xs origin-(--transform-origin)",e),...s,children:[a,c.jsx(zze,{className:"size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground z-50 data-[side=bottom]:top-1 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5"})]})})})}const imt=ty(function(){const{t}=Mt("assistant"),{isOpen:n,isStreaming:r,messages:i,hasMessages:a,error:s,provider:o,model:l,opencodeModel:u,toggle:d,close:f,sendMessage:p,clearMessages:m,setProvider:b,setModel:y,setOpencodeModel:v}=REe(),_=nmt(),E=gn(),{resolvedTheme:C}=Sl(),T=C==="dark",k=x.useRef(null),S=x.useRef(null),N=x.useRef(null),[R,D]=x.useState(!1),[I,P]=x.useState(null),[L,B]=x.useState(""),j=x.useRef(null),$=x.useRef(!1),{providers:F,installed:z}=AI(),{data:q}=O1();x.useEffect(()=>{o==="opencode"&&!u&&q&&v(q)},[o,u,q,v]);const Y=x.useMemo(()=>i.find(ae=>ae.id===I),[i,I]),K=x.useMemo(()=>({a:({href:ae,children:oe,...se})=>c.jsx("a",{href:ae,target:"_blank",rel:"noopener noreferrer",...se,children:oe})}),[]);x.useEffect(()=>{$.current&&!r&&(E.invalidateQueries({queryKey:["tasks"]}),E.invalidateQueries({queryKey:["task-dependencies"]}),E.invalidateQueries({queryKey:["projects"]}),E.invalidateQueries({queryKey:["repositories"]}),E.invalidateQueries({queryKey:["apps"]})),$.current=r},[r,E]);const W=i[i.length-1]?.content;x.useEffect(()=>{k.current&&(k.current.scrollTop=k.current.scrollHeight)},[i.length,W]),x.useEffect(()=>{const ae=oe=>{(oe.metaKey||oe.ctrlKey)&&oe.shiftKey&&oe.key.toLowerCase()==="c"&&(oe.preventDefault(),d()),oe.key==="Escape"&&n&&!I&&f()};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[d,f,n,I]),x.useEffect(()=>{const ae=oe=>{if(S.current&&!S.current.contains(oe.target)){const se=oe.target;!se.closest(".floating-ai-button")&&!se.closest('[data-slot="dialog-overlay"]')&&!se.closest('[data-slot="dialog-content"]')&&f()}};if(n)return document.addEventListener("mousedown",ae),()=>document.removeEventListener("mousedown",ae)},[n,f]),x.useEffect(()=>{const ae=oe=>{N.current&&!N.current.contains(oe.target)&&(D(!1),B(""))};if(R)return document.addEventListener("mousedown",ae),()=>document.removeEventListener("mousedown",ae)},[R]),x.useEffect(()=>{R&&o==="opencode"&&j.current&&setTimeout(()=>j.current?.focus(),50)},[R,o]);const X=x.useCallback(ae=>{p(ae,_)},[p,_]),U=Rie.find(ae=>ae.id===l),Q=()=>{if(o==="claude")return U?.label||t("models.opus");if(u){const ae=u.split("/");return ae.length>1?ae[1]:u}return t("models.selectModel")},J=x.useMemo(()=>{const ae=Object.entries(F).sort(([se],[ue])=>se.localeCompare(ue));if(!L.trim())return ae;const oe=L.toLowerCase();return ae.map(([se,ue])=>{const fe=ue.filter(ce=>ce.toLowerCase().includes(oe)||se.toLowerCase().includes(oe));return[se,fe]}).filter(([,se])=>se.length>0)},[F,L]),re=z&&J.length>0;return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"fixed bottom-6 right-6 z-50 hidden sm:block",children:c.jsxs("button",{className:`floating-ai-button relative w-16 h-16 rounded-full flex items-center justify-center transition-all duration-500 transform ${n?"rotate-90":"rotate-0"} hover:scale-110`,onClick:d,style:{cursor:"pointer",background:T?"linear-gradient(135deg, var(--destructive) 0%, color-mix(in oklch, var(--destructive) 80%, black) 100%)":"linear-gradient(135deg, var(--accent) 0%, color-mix(in oklch, var(--accent) 80%, black) 100%)",boxShadow:T?"0 0 20px color-mix(in oklch, var(--destructive) 50%, transparent), 0 0 40px color-mix(in oklch, var(--destructive) 30%, transparent)":"0 0 20px color-mix(in oklch, var(--accent) 50%, transparent), 0 0 40px color-mix(in oklch, var(--accent) 30%, transparent)",border:"2px solid rgba(255, 255, 255, 0.2)"},children:[c.jsx("div",{className:"absolute inset-0 rounded-full bg-gradient-to-b from-white/20 to-transparent opacity-30"}),c.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-white/10"}),c.jsx("div",{className:"relative z-10",children:n?c.jsx(aF,{className:"w-7 h-7 text-white"}):c.jsx(_m,{className:"w-8 h-8 text-white"})}),c.jsx("div",{className:`absolute inset-0 rounded-full animate-pulse opacity-30 ${T?"bg-destructive":"bg-accent"}`}),!n&&c.jsx("div",{className:`absolute -inset-1 rounded-full animate-ping opacity-15 ${T?"bg-destructive":"bg-accent"}`})]})}),n&&c.jsx("div",{ref:S,className:"fixed bottom-6 right-6 sm:bottom-24 z-50 w-[420px] max-w-[calc(100vw-48px)] transition-all duration-300 origin-bottom-right",style:{animation:"popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards"},children:c.jsxs("div",{className:"film-grain relative flex flex-col font-sans rounded-3xl shadow-2xl overflow-hidden max-h-[min(600px,calc(100vh-140px))] bg-popover border border-border",style:{background:"var(--gradient-card)"},children:[c.jsxs("div",{className:"flex items-center justify-between px-3 sm:px-6 pt-3 sm:pt-4 pb-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),c.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:t("title")}),c.jsxs(rh,{children:[c.jsx(ih,{className:"flex items-center ml-1",children:c.jsx(Xr,{variant:"destructive",className:"text-[0.55rem] h-3.5 px-1 cursor-help leading-none border border-destructive/30",children:t("preview.badge")})}),c.jsx(ah,{side:"bottom",className:"max-w-[200px]",children:t("preview.tooltip")})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[re&&c.jsxs("div",{className:"hidden sm:flex items-center rounded-full p-0.5 bg-muted/60",children:[c.jsx("button",{onClick:()=>b("claude"),className:`px-2 py-1 text-[10px] font-medium rounded-full transition-all ${o==="claude"?"bg-accent/20 text-accent":"text-muted-foreground hover:text-foreground"}`,children:t("providers.claude")}),c.jsx("button",{onClick:()=>b("opencode"),className:`px-2 py-1 text-[10px] font-medium rounded-full transition-all ${o==="opencode"?"bg-accent/20 text-accent":"text-muted-foreground hover:text-foreground"}`,children:t("providers.opencode")})]}),c.jsxs("div",{ref:N,className:"relative",children:[c.jsxs("button",{onClick:()=>{const ae=!R;D(ae),ae||B("")},className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-2xl transition-colors bg-muted/60 text-foreground hover:bg-muted",children:[c.jsx("span",{className:"max-w-[60px] sm:max-w-[80px] truncate",children:Q()}),c.jsx(Lz,{className:`w-3 h-3 transition-transform flex-shrink-0 ${R?"rotate-180":""}`})]}),R&&c.jsxs("div",{className:"absolute top-full right-0 mt-1 w-48 max-h-64 overflow-y-auto rounded-xl shadow-xl backdrop-blur-sm z-10 animate-in fade-in-0 slide-in-from-top-1 duration-150 scrollbar-thin bg-popover/95 border border-border scrollbar-thumb-muted",children:[o==="claude"&&c.jsx(c.Fragment,{children:Rie.map(ae=>c.jsxs("button",{onClick:()=>{y(ae.id),D(!1)},className:`w-full px-3 py-2 text-left transition-colors flex items-center justify-between hover:bg-muted/50 ${l===ae.id?"bg-accent/10 text-accent":"text-foreground"}`,children:[c.jsxs("div",{children:[c.jsx("div",{className:"font-medium text-xs",children:ae.label}),c.jsx("div",{className:"text-[10px] text-muted-foreground",children:ae.description})]}),l===ae.id&&c.jsx(o0,{className:"w-3.5 h-3.5 flex-shrink-0 text-accent"})]},ae.id))}),o==="opencode"&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"sticky top-0 p-2 bg-popover/95",children:c.jsx("input",{ref:j,type:"text",value:L,onChange:ae=>B(ae.target.value),placeholder:t("models.filterModels"),className:"w-full px-2.5 py-1.5 text-xs rounded-lg outline-none transition-colors bg-muted border border-border text-foreground placeholder:text-muted-foreground focus:border-ring",onKeyDown:ae=>ae.stopPropagation()})}),J.length===0&&L&&c.jsx("div",{className:"px-3 py-4 text-xs text-center text-muted-foreground",children:t("models.noModelsMatch",{filter:L})}),J.map(([ae,oe])=>c.jsxs("div",{children:[c.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground bg-muted/50",children:ae}),oe.map(se=>{const ue=`${ae}/${se}`,fe=u===ue;return c.jsxs("button",{onClick:()=>{v(ue),D(!1),B("")},className:`w-full px-3 py-1.5 text-left transition-colors flex items-center justify-between hover:bg-muted/50 ${fe?"bg-accent/10 text-accent":"text-foreground"}`,children:[c.jsx("span",{className:"text-xs truncate",children:se}),fe&&c.jsx(o0,{className:"w-3.5 h-3.5 flex-shrink-0 ml-2 text-accent"})]},ue)})]},ae))]})]})]}),a&&c.jsx("button",{onClick:m,className:"p-1.5 rounded-full transition-colors hover:bg-muted",title:t("header.clearConversation"),children:c.jsx(zve,{className:"w-4 h-4 text-muted-foreground"})}),c.jsx("button",{onClick:f,className:"p-1.5 rounded-full transition-colors hover:bg-muted",children:c.jsx(aF,{className:"w-4 h-4 text-muted-foreground"})})]})]}),i.length>0&&c.jsxs("div",{ref:k,className:"overflow-y-auto px-4 py-2 max-h-[350px] scrollbar-thin scrollbar-track-transparent scrollbar-thumb-muted",children:[i.map(ae=>c.jsx(Jpt,{role:ae.role,content:ae.content,isStreaming:ae.isStreaming,onClick:ae.role==="assistant"?()=>P(ae.id):void 0},ae.id)),s&&c.jsx("div",{className:"mt-2 p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-red-400 text-sm",children:s})]}),i.length===0&&s&&c.jsx("div",{className:"mx-4 my-2 p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-red-400 text-sm",children:s}),c.jsx(emt,{onSend:X,isLoading:r,placeholder:a?" ":void 0}),c.jsxs("div",{className:"hidden sm:flex items-center justify-between px-4 pb-3 pt-1 text-xs gap-4 text-muted-foreground",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(gje,{className:"w-3 h-3"}),c.jsx("span",{children:t("input.shiftEnterHint").split("<kbd>").map((ae,oe)=>{if(oe===0)return ae;const[se,ue]=ae.split("</kbd>");return c.jsxs("span",{children:[c.jsx("kbd",{className:"px-1.5 py-0.5 rounded font-mono text-xs shadow-sm bg-muted border border-border text-muted-foreground",children:se}),ue]},oe)})})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("div",{className:"w-1.5 h-1.5 bg-green-500 rounded-full"}),c.jsx("span",{children:t("header.connected")})]})]}),T&&c.jsx("div",{className:"absolute inset-0 rounded-3xl pointer-events-none",style:{background:"linear-gradient(135deg, color-mix(in oklch, var(--destructive) 3%, transparent), transparent, color-mix(in oklch, var(--accent) 3%, transparent))"}})]})}),c.jsx("style",{children:`
82
+ `))){const y=[];d.children.forEach((v,_)=>{_!=0&&(_==1&&v.type==="break"||y.push(v))}),d.children=[...y]}}return d});s&&(r.data={hName:t,hProperties:{class:`markdown-alert markdown-alert-${s}`,dir:"auto"}},u.unshift({type:"paragraph",children:[Tpt(s),{type:"text",value:o.replace(/^\//,"")}],data:{hProperties:{class:"markdown-alert-title",dir:"auto"}}})),r.children=[...u]})};function Tpt(e){let t=Apt[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 Apt={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 Npt(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 c2e(e){if(!e)return null;var t=e;return t.dataset.code&&t.classList.contains("copied")?t:t.parentElement?c2e(t.parentElement):null}function Opt(e){var t=n=>{var r=c2e(n.target);r&&(r.classList.add("active"),Npt(r.dataset.code,function(){setTimeout(()=>{r.classList.remove("active")},2e3)}))};x.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 Rpt=["prefixCls","className","source","style","disableCopy","skipHtml","onScroll","onMouseOver","pluginsFilter","rehypeRewrite","wrapperElement","warpperElement","urlTransform"],Ipt=e=>e;const Dpt=Z.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:d,wrapperElement:f={},warpperElement:p={},urlTransform:m}=e,b=FE(e,Rpt),y=Z.useRef(null);x.useImperativeHandle(t,()=>ur({},e,{mdp:y}),[y,e]);var v=(n||"")+" "+(r||"");Opt(y);var _=[...b.rehypePlugins||[]],E={allowElement:(k,S,N)=>b.allowElement?b.allowElement(k,S,N):/^[A-Za-z0-9]+$/.test(k.tagName)};o||_.push(bCe);var C=[kpt,...b.remarkPlugins||[],Ept],T=ur({},p,f);return c.jsx("div",ur({ref:y,onScroll:l,onMouseOver:u},T,{className:v,style:a,children:c.jsx(hft,ur({},E,b,{skipHtml:!o,urlTransform:m||Ipt,rehypePlugins:d?d("rehype",_):_,remarkPlugins:d?d("remark",C):C,children:i||""}))}))});var Ppt=function(t){return n=>{Gs(n,r=>{r.type==="element"&&r.tagName==="code"&&r.data&&r.data.meta&&(r.properties=ur({},r.properties,{"data-meta":String(r.data.meta)}))})}},Lpt=function(t){return n=>{Gs(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 Mpt=/[\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,jpt=Object.hasOwnProperty;class Fpt{constructor(){this.occurrences,this.reset()}slug(t,n){const r=this;let i=Bpt(t,n===!0);const a=i;for(;jpt.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 Bpt(e,t){return typeof e!="string"?"":(t||(e=e.toLowerCase()),e.replace(Mpt,"").replace(/ /g,"-"))}function d2e(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 $pt={},mse=new Fpt;function Upt(e){const n=(e||$pt).prefix||"";return function(r){mse.reset(),Gs(r,"element",function(i){d2e(i)&&!i.properties.id&&(i.properties.id=n+mse.slug(Nv(i)))})}}const f2e=(function(e){if(e==null)return Vpt;if(typeof e=="string")return Hpt(e);if(typeof e=="object")return zpt(e);if(typeof e=="function")return _Y(e);throw new Error("Expected function, string, or array as `test`")});function zpt(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=f2e(e[n]);return _Y(r);function r(...i){let a=-1;for(;++a<t.length;)if(t[a].apply(this,i))return!0;return!1}}function Hpt(e){return _Y(t);function t(n){return n.tagName===e}}function _Y(e){return t;function t(n,r,i){return!!(Wpt(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function Vpt(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function Wpt(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}const gse={type:"element",tagName:"span",properties:{className:["icon","icon-link"]},children:[]},qpt={};function Gpt(e){const t=e||qpt;let n=t.properties;const r=t.headingProperties,i=t.behavior||"prepend",a=t.content,s=t.group,o=f2e(t.test);let l;return i==="after"||i==="before"?l=d:i==="wrap"?l=f:(l=u,n||(n={ariaHidden:"true",tabIndex:-1})),function(p){Gs(p,"element",function(m,b,y){if(d2e(m)&&m.properties.id&&o(m,b,y))return Object.assign(m.properties,dT(r,m)),l(m,b,y)})};function u(p){const m=bse(a||gse,p);return p.children[i==="prepend"?"unshift":"push"](aM(p,dT(n,p),m)),[DS]}function d(p,m,b){if(typeof m!="number"||!b)return;const y=bse(a||gse,p),v=aM(p,dT(n,p),y);let _=i==="before"?[v,p]:[p,v];if(s){const E=h2e(s,p);E&&!Array.isArray(E)&&E.type==="element"&&(E.children=_,_=[E])}return b.children.splice(m,1,..._),[DS,m+_.length]}function f(p){let m=p.children,b=[];return typeof a=="function"?(m=[],b=a(p)):a&&(b=SY(a)),p.children=[aM(p,dT(n,p),Array.isArray(b)?[...m,...b]:[...m,b])],[DS]}}function SY(e){return Db(e)}function aM(e,t,n){return{type:"element",tagName:"a",properties:{...t,href:"#"+e.properties.id},children:n}}function bse(e,t){const n=h2e(e,t);return Array.isArray(n)?n:[n]}function h2e(e,t){return typeof e=="function"?e(t):SY(e)}function dT(e,t){return typeof e=="function"?e(t):e?SY(e):{}}const Kpt=(e={})=>{const{openDelimiter:t="rehype:ignore:start",closeDelimiter:n="rehype:ignore:end"}=e;return r=>{Gs(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 Ypt={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 Xpt(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 Zpt=(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=ur({class:"anchor"},a.properties),a.children=[Ypt])}if(n.type==="element"&&n.tagName==="pre"&&!e){var s=Twe(n.children);n.children.push(Xpt(s))}t&&t(n,r===null?void 0:r,i===null?void 0:i)},Qpt=[Upt,Gpt,Kpt];const gh=Z.forwardRef((e,t)=>{var n,r=[Ppt,bCe,Lpt,...Qpt,[hat,{rewrite:Zpt((n=e.disableCopy)!=null?n:!1,e.rehypeRewrite)}],[gat,{properties:"attr"}],...e.rehypePlugins||[],[swe,{ignoreMissing:!0}]];return c.jsx(Dpt,ur({},e,{rehypePlugins:r,ref:t}))});function Jpt({role:e,content:t,isStreaming:n,onClick:r}){const i=e==="user",{resolvedTheme:a}=Sl(),s=a==="dark",o=!i&&t&&r,l=x.useMemo(()=>({a:({href:u,children:d,...f})=>c.jsx("a",{href:u,target:"_blank",rel:"noopener noreferrer",...f,children:d})}),[]);return c.jsxs("div",{className:`flex gap-3 py-3 animate-in fade-in-0 duration-200 ${i?"flex-row-reverse slide-in-from-right-2":"flex-row slide-in-from-left-2"}`,children:[c.jsx("div",{className:`w-8 h-8 flex-shrink-0 rounded-full flex items-center justify-center ${i?"bg-muted border border-border":"bg-gradient-to-br from-accent/30 to-accent/20 border border-accent/40"}`,style:i?void 0:{boxShadow:"0 0 10px color-mix(in oklch, var(--accent) 30%, transparent), 0 0 20px color-mix(in oklch, var(--accent) 15%, transparent)"},children:i?c.jsx(Hve,{className:"w-4 h-4 text-foreground"}):c.jsx(_m,{className:"w-4 h-4 text-accent"})}),c.jsx("div",{onClick:o?r:void 0,className:`flex-1 min-w-0 max-w-[85%] rounded-lg px-4 py-3 text-sm overflow-hidden text-foreground ${i?"bg-muted/50 border border-border/50 rounded-tr-sm":"bg-card/50 border border-border/50 rounded-tl-sm"} ${o?"cursor-pointer hover:ring-2 hover:ring-offset-1 transition-all hover:ring-accent/40 hover:ring-offset-background":""}`,title:o?"Click to expand":void 0,children:i?c.jsx("p",{className:"whitespace-pre-wrap leading-relaxed",children:t}):t?c.jsx("div",{"data-color-mode":s?"dark":"light",children:c.jsx(gh,{source:t,style:{backgroundColor:"transparent",fontSize:"13px",lineHeight:"1.6",color:"var(--foreground)",fontFamily:"var(--font-sans)"},components:l,className:"prose-sm max-w-none [&_table]:block [&_table]:overflow-x-auto [&_table]:max-w-full [&_pre]:overflow-x-auto [&_pre]:bg-muted/50 [&_pre]:border [&_pre]:border-border/50 [&_pre]:text-xs [&_code]:text-xs [&_code]:text-accent [&_a]:text-accent [&_a:hover]:text-accent/80 [&_strong]:text-foreground [&_h1]:text-foreground [&_h2]:text-foreground [&_h3]:text-foreground [&_h4]:text-foreground [&_li]:text-foreground [&_table]:border-border [&_th]:bg-muted [&_th]:border-border [&_td]:border-border"})}):n?c.jsxs("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[c.jsx("span",{className:"animate-pulse",children:"Thinking"}),c.jsxs("span",{className:"inline-flex gap-0.5",children:[c.jsx("span",{className:"w-1 h-1 rounded-full animate-bounce bg-accent",style:{animationDelay:"0ms"}}),c.jsx("span",{className:"w-1 h-1 rounded-full animate-bounce bg-accent",style:{animationDelay:"150ms"}}),c.jsx("span",{className:"w-1 h-1 rounded-full animate-bounce bg-accent",style:{animationDelay:"300ms"}})]})]}):null})]})}function emt({onSend:e,isLoading:t,placeholder:n}){const{t:r}=Mt("assistant"),i=n??r("input.placeholder"),[a,s]=x.useState(""),o=x.useRef(null),l=x.useCallback(()=>{const f=o.current;f&&(f.style.height="auto",f.style.height=`${Math.min(f.scrollHeight,150)}px`)},[]);x.useEffect(()=>{l()},[a,l]);const u=x.useCallback(()=>{const f=a.trim();f&&!t&&(e(f),s(""),o.current&&(o.current.style.height="auto"))},[a,t,e]),d=x.useCallback(f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),u())},[u]);return c.jsxs("div",{className:"relative",children:[c.jsx("div",{className:"relative overflow-hidden",children:c.jsx("textarea",{ref:o,value:a,onChange:f=>s(f.target.value),onKeyDown:d,rows:3,disabled:t,className:"w-full px-6 py-4 bg-transparent border-none outline-none resize-none text-base font-sans font-normal leading-relaxed min-h-[100px] disabled:opacity-50 text-foreground placeholder-muted-foreground caret-current",placeholder:i,style:{scrollbarWidth:"none"}})}),c.jsx("div",{className:"px-4 pb-4",children:c.jsx("div",{className:"flex items-center justify-end",children:c.jsxs("button",{onClick:u,disabled:!a.trim()||t,className:"group relative p-3 border-none rounded-lg cursor-pointer transition-all duration-300 shadow-lg hover:scale-105 hover:shadow-xl active:scale-95 transform disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:scale-100 disabled:hover:shadow-lg bg-accent text-accent-foreground hover:bg-accent/90",style:{boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 0 0 0 color-mix(in oklch, var(--accent) 30%, transparent)"},children:[t?c.jsx(Bve,{className:"w-5 h-5 animate-spin"}):c.jsx(Uve,{className:"w-5 h-5 transition-all duration-300 group-hover:-translate-y-0.5 group-hover:translate-x-0.5 group-hover:rotate-12"}),c.jsx("div",{className:"absolute inset-0 rounded-lg opacity-0 group-hover:opacity-50 transition-opacity duration-300 blur-lg transform scale-110 bg-accent"}),c.jsx("div",{className:"absolute inset-0 rounded-lg overflow-hidden",children:c.jsx("div",{className:"absolute inset-0 bg-white/20 transform scale-0 group-active:scale-100 transition-transform duration-200 rounded-lg"})})]})})})]})}function tmt(e){const t=e.replace(/\/$/,"")||"/";return t==="/"||t==="/tasks"?"tasks":t.startsWith("/tasks/")&&t.split("/").length===3?"task":t==="/projects"?"projects":t.startsWith("/projects/")&&t.split("/").length===3?"project":t==="/repositories"?"repositories":t.startsWith("/repositories/")&&t.split("/").length===3?"repository":t==="/monitoring"?"monitoring":t==="/terminals"?"terminals":t==="/apps"?"apps":t.startsWith("/apps/")&&t.split("/").length===3&&t.split("/")[2]!=="new"?"app":t==="/jobs"?"jobs":t.startsWith("/jobs/")&&t.split("/").length===3&&t.split("/")[2]!=="new"?"job":t==="/settings"?"settings":"unknown"}function O_(e,t){const n=e.replace(/\/$/,"");if(!n.startsWith(t))return;const r=n.slice(t.length).split("/")[0];if(!(!r||r==="new"))return r}function nmt(){const e=Sa({select:t=>t.location});return x.useMemo(()=>{const{pathname:t,search:n}=e,r=tmt(t),i={pageType:r,path:t};switch(r){case"task":i.taskId=O_(t,"/tasks/");break;case"project":i.projectId=O_(t,"/projects/");break;case"repository":i.repositoryId=O_(t,"/repositories/");break;case"app":i.appId=O_(t,"/apps/");break;case"job":i.jobId=O_(t,"/jobs/");break}const a=n;if(r==="tasks"){const s={};typeof a.project=="string"&&(s.project=a.project),typeof a.tags=="string"&&(s.tags=a.tags.split(",").filter(Boolean)),typeof a.view=="string"&&(s.view=a.view),Object.keys(s).length>0&&(i.filters=s)}return r==="monitoring"&&typeof a.tab=="string"&&(i.activeTab=a.tab),i},[e])}const rmt=Am("h-5 gap-1 rounded-full border border-transparent px-2 py-0.5 text-[0.625rem] font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-2.5! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-colors overflow-hidden group/badge",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground bg-input/20 dark:bg-input/30",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function Xr({className:e,variant:t="default",render:n,...r}){return Vze({defaultTagName:"span",props:Yc({className:je(rmt({className:e,variant:t}))},r),render:n,state:{slot:"badge",variant:t}})}function p2e({delay:e=0,...t}){return c.jsx(Hze,{"data-slot":"tooltip-provider",delay:e,...t})}function rh({...e}){return c.jsx(p2e,{children:c.jsx(Ize,{"data-slot":"tooltip",...e})})}function ih({...e}){return c.jsx(Mze,{"data-slot":"tooltip-trigger",...e})}function ah({className:e,side:t="top",sideOffset:n=4,align:r="center",alignOffset:i=0,children:a,...s}){return c.jsx(Fze,{children:c.jsx(Bze,{align:r,alignOffset:i,side:t,sideOffset:n,className:"isolate z-50",children:c.jsxs(Uze,{"data-slot":"tooltip-content",className:je("data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-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 rounded-md px-3 py-1.5 text-xs **:data-[slot=kbd]:rounded-md bg-foreground text-background z-50 w-fit max-w-xs origin-(--transform-origin)",e),...s,children:[a,c.jsx(zze,{className:"size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground z-50 data-[side=bottom]:top-1 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5"})]})})})}const imt=ty(function(){const{t}=Mt("assistant"),{isOpen:n,isStreaming:r,messages:i,hasMessages:a,error:s,provider:o,model:l,opencodeModel:u,toggle:d,close:f,sendMessage:p,clearMessages:m,setProvider:b,setModel:y,setOpencodeModel:v}=REe(),_=nmt(),E=gn(),{resolvedTheme:C}=Sl(),T=C==="dark",k=x.useRef(null),S=x.useRef(null),N=x.useRef(null),[R,D]=x.useState(!1),[I,P]=x.useState(null),[L,B]=x.useState(""),j=x.useRef(null),$=x.useRef(!1),{providers:F,installed:z}=AI(),{data:q}=O1();x.useEffect(()=>{o==="opencode"&&!u&&q&&v(q)},[o,u,q,v]);const Y=x.useMemo(()=>i.find(ae=>ae.id===I),[i,I]),K=x.useMemo(()=>({a:({href:ae,children:oe,...se})=>c.jsx("a",{href:ae,target:"_blank",rel:"noopener noreferrer",...se,children:oe})}),[]);x.useEffect(()=>{$.current&&!r&&(E.invalidateQueries({queryKey:["tasks"]}),E.invalidateQueries({queryKey:["task-dependencies"]}),E.invalidateQueries({queryKey:["projects"]}),E.invalidateQueries({queryKey:["repositories"]}),E.invalidateQueries({queryKey:["apps"]})),$.current=r},[r,E]);const W=i[i.length-1]?.content;x.useEffect(()=>{k.current&&(k.current.scrollTop=k.current.scrollHeight)},[i.length,W]),x.useEffect(()=>{const ae=oe=>{(oe.metaKey||oe.ctrlKey)&&oe.shiftKey&&oe.key.toLowerCase()==="c"&&(oe.preventDefault(),d()),oe.key==="Escape"&&n&&!I&&f()};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[d,f,n,I]),x.useEffect(()=>{const ae=oe=>{if(S.current&&!S.current.contains(oe.target)){const se=oe.target;!se.closest(".floating-ai-button")&&!se.closest('[data-slot="dialog-overlay"]')&&!se.closest('[data-slot="dialog-content"]')&&f()}};if(n)return document.addEventListener("mousedown",ae),()=>document.removeEventListener("mousedown",ae)},[n,f]),x.useEffect(()=>{const ae=oe=>{N.current&&!N.current.contains(oe.target)&&(D(!1),B(""))};if(R)return document.addEventListener("mousedown",ae),()=>document.removeEventListener("mousedown",ae)},[R]),x.useEffect(()=>{R&&o==="opencode"&&j.current&&setTimeout(()=>j.current?.focus(),50)},[R,o]);const X=x.useCallback(ae=>{p(ae,_)},[p,_]),U=Rie.find(ae=>ae.id===l),Q=()=>{if(o==="claude")return U?.label||t("models.opus");if(u){const ae=u.split("/");return ae.length>1?ae[1]:u}return t("models.selectModel")},J=x.useMemo(()=>{const ae=Object.entries(F).sort(([se],[ue])=>se.localeCompare(ue));if(!L.trim())return ae;const oe=L.toLowerCase();return ae.map(([se,ue])=>{const fe=ue.filter(ce=>ce.toLowerCase().includes(oe)||se.toLowerCase().includes(oe));return[se,fe]}).filter(([,se])=>se.length>0)},[F,L]),re=z&&J.length>0;return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"fixed bottom-6 right-6 z-50 hidden sm:block",children:c.jsxs("button",{className:`floating-ai-button relative w-16 h-16 rounded-full flex items-center justify-center transition-all duration-500 transform ${n?"rotate-90":"rotate-0"} hover:scale-110`,onClick:d,style:{cursor:"pointer",background:T?"linear-gradient(135deg, var(--destructive) 0%, color-mix(in oklch, var(--destructive) 80%, black) 100%)":"linear-gradient(135deg, var(--accent) 0%, color-mix(in oklch, var(--accent) 80%, black) 100%)",boxShadow:T?"0 0 20px color-mix(in oklch, var(--destructive) 50%, transparent), 0 0 40px color-mix(in oklch, var(--destructive) 30%, transparent)":"0 0 20px color-mix(in oklch, var(--accent) 50%, transparent), 0 0 40px color-mix(in oklch, var(--accent) 30%, transparent)",border:"2px solid rgba(255, 255, 255, 0.2)"},children:[c.jsx("div",{className:"absolute inset-0 rounded-full bg-gradient-to-b from-white/20 to-transparent opacity-30"}),c.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-white/10"}),c.jsx("div",{className:"relative z-10",children:n?c.jsx(aF,{className:"w-7 h-7 text-white"}):c.jsx(_m,{className:"w-8 h-8 text-white"})}),c.jsx("div",{className:`absolute inset-0 rounded-full animate-pulse opacity-30 ${T?"bg-destructive":"bg-accent"}`}),!n&&c.jsx("div",{className:`absolute -inset-1 rounded-full animate-ping opacity-15 ${T?"bg-destructive":"bg-accent"}`})]})}),n&&c.jsx("div",{ref:S,className:"fixed bottom-6 right-6 sm:bottom-24 z-50 w-[420px] max-w-[calc(100vw-48px)] transition-all duration-300 origin-bottom-right",style:{animation:"popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards"},children:c.jsxs("div",{className:"film-grain relative flex flex-col font-sans rounded-xl shadow-2xl overflow-hidden max-h-[min(600px,calc(100vh-140px))] bg-popover border border-border",style:{background:"var(--gradient-card)"},children:[c.jsxs("div",{className:"flex items-center justify-between px-3 sm:px-6 pt-3 sm:pt-4 pb-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),c.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:t("title")}),c.jsxs(rh,{children:[c.jsx(ih,{className:"flex items-center ml-1",children:c.jsx(Xr,{variant:"destructive",className:"text-[0.55rem] h-3.5 px-1 cursor-help leading-none border border-destructive/30",children:t("preview.badge")})}),c.jsx(ah,{side:"bottom",className:"max-w-[200px]",children:t("preview.tooltip")})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[re&&c.jsxs("div",{className:"hidden sm:flex items-center rounded-full p-0.5 bg-muted/60",children:[c.jsx("button",{onClick:()=>b("claude"),className:`px-2 py-1 text-[10px] font-medium rounded-full transition-all ${o==="claude"?"bg-accent/20 text-accent":"text-muted-foreground hover:text-foreground"}`,children:t("providers.claude")}),c.jsx("button",{onClick:()=>b("opencode"),className:`px-2 py-1 text-[10px] font-medium rounded-full transition-all ${o==="opencode"?"bg-accent/20 text-accent":"text-muted-foreground hover:text-foreground"}`,children:t("providers.opencode")})]}),c.jsxs("div",{ref:N,className:"relative",children:[c.jsxs("button",{onClick:()=>{const ae=!R;D(ae),ae||B("")},className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-lg transition-colors bg-muted/60 text-foreground hover:bg-muted",children:[c.jsx("span",{className:"max-w-[60px] sm:max-w-[80px] truncate",children:Q()}),c.jsx(Lz,{className:`w-3 h-3 transition-transform flex-shrink-0 ${R?"rotate-180":""}`})]}),R&&c.jsxs("div",{className:"absolute top-full right-0 mt-1 w-48 max-h-64 overflow-y-auto rounded-lg shadow-xl backdrop-blur-sm z-10 animate-in fade-in-0 slide-in-from-top-1 duration-150 scrollbar-thin bg-popover/95 border border-border scrollbar-thumb-muted",children:[o==="claude"&&c.jsx(c.Fragment,{children:Rie.map(ae=>c.jsxs("button",{onClick:()=>{y(ae.id),D(!1)},className:`w-full px-3 py-2 text-left transition-colors flex items-center justify-between hover:bg-muted/50 ${l===ae.id?"bg-accent/10 text-accent":"text-foreground"}`,children:[c.jsxs("div",{children:[c.jsx("div",{className:"font-medium text-xs",children:ae.label}),c.jsx("div",{className:"text-[10px] text-muted-foreground",children:ae.description})]}),l===ae.id&&c.jsx(o0,{className:"w-3.5 h-3.5 flex-shrink-0 text-accent"})]},ae.id))}),o==="opencode"&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"sticky top-0 p-2 bg-popover/95",children:c.jsx("input",{ref:j,type:"text",value:L,onChange:ae=>B(ae.target.value),placeholder:t("models.filterModels"),className:"w-full px-2.5 py-1.5 text-xs rounded-lg outline-none transition-colors bg-muted border border-border text-foreground placeholder:text-muted-foreground focus:border-ring",onKeyDown:ae=>ae.stopPropagation()})}),J.length===0&&L&&c.jsx("div",{className:"px-3 py-4 text-xs text-center text-muted-foreground",children:t("models.noModelsMatch",{filter:L})}),J.map(([ae,oe])=>c.jsxs("div",{children:[c.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground bg-muted/50",children:ae}),oe.map(se=>{const ue=`${ae}/${se}`,fe=u===ue;return c.jsxs("button",{onClick:()=>{v(ue),D(!1),B("")},className:`w-full px-3 py-1.5 text-left transition-colors flex items-center justify-between hover:bg-muted/50 ${fe?"bg-accent/10 text-accent":"text-foreground"}`,children:[c.jsx("span",{className:"text-xs truncate",children:se}),fe&&c.jsx(o0,{className:"w-3.5 h-3.5 flex-shrink-0 ml-2 text-accent"})]},ue)})]},ae))]})]})]}),a&&c.jsx("button",{onClick:m,className:"p-1.5 rounded-full transition-colors hover:bg-muted",title:t("header.clearConversation"),children:c.jsx(zve,{className:"w-4 h-4 text-muted-foreground"})}),c.jsx("button",{onClick:f,className:"p-1.5 rounded-full transition-colors hover:bg-muted",children:c.jsx(aF,{className:"w-4 h-4 text-muted-foreground"})})]})]}),i.length>0&&c.jsxs("div",{ref:k,className:"overflow-y-auto px-4 py-2 max-h-[350px] scrollbar-thin scrollbar-track-transparent scrollbar-thumb-muted",children:[i.map(ae=>c.jsx(Jpt,{role:ae.role,content:ae.content,isStreaming:ae.isStreaming,onClick:ae.role==="assistant"?()=>P(ae.id):void 0},ae.id)),s&&c.jsx("div",{className:"mt-2 p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-red-400 text-sm",children:s})]}),i.length===0&&s&&c.jsx("div",{className:"mx-4 my-2 p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-red-400 text-sm",children:s}),c.jsx(emt,{onSend:X,isLoading:r,placeholder:a?" ":void 0}),c.jsxs("div",{className:"hidden sm:flex items-center justify-between px-4 pb-3 pt-1 text-xs gap-4 text-muted-foreground",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(gje,{className:"w-3 h-3"}),c.jsx("span",{children:t("input.shiftEnterHint").split("<kbd>").map((ae,oe)=>{if(oe===0)return ae;const[se,ue]=ae.split("</kbd>");return c.jsxs("span",{children:[c.jsx("kbd",{className:"px-1.5 py-0.5 rounded font-mono text-xs shadow-sm bg-muted border border-border text-muted-foreground",children:se}),ue]},oe)})})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("div",{className:"w-1.5 h-1.5 bg-green-500 rounded-full"}),c.jsx("span",{children:t("header.connected")})]})]}),T&&c.jsx("div",{className:"absolute inset-0 rounded-xl pointer-events-none",style:{background:"linear-gradient(135deg, color-mix(in oklch, var(--destructive) 3%, transparent), transparent, color-mix(in oklch, var(--accent) 3%, transparent))"}})]})}),c.jsx("style",{children:`
83
83
  @keyframes popIn {
84
84
  0% {
85
85
  opacity: 0;
@@ -116,7 +116,7 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
116
116
  `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),jY&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Qse(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=MY(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-pM),pM),t/=pM,t/Math.abs(t)+Math.round(t*(Qbt-1)))}shouldForceSelection(e){return FN?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),Jbt)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(FN&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let r=n.lines.get(this._model.selectionEnd[1]);r&&r.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<eyt&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let n=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(n&&n[0]!==void 0&&n[1]!==void 0){let r=Vbt(n[0]-1,n[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(r,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!n){this._oldHasSelection&&this._fireOnSelectionChange(e,t,n);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let s=i.translateBufferLineToString(e[1],!1),o=this._convertViewportColToCharacterIndex(a,e[0]),l=o,u=e[0]-o,d=0,f=0,p=0,m=0;if(s.charAt(o)===" "){for(;o>0&&s.charAt(o-1)===" ";)o--;for(;l<s.length&&s.charAt(l+1)===" ";)l++}else{let v=e[0],_=e[0];a.getWidth(v)===0&&(d++,v--),a.getWidth(_)===2&&(f++,_++);let E=a.getString(_).length;for(E>1&&(m+=E-1,l+=E-1);v>0&&o>0&&!this._isCharWordSeparator(a.loadCell(v-1,this._workCell));){a.loadCell(v-1,this._workCell);let C=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,v--):C>1&&(p+=C-1,o-=C-1),o--,v--}for(;_<a.length&&l+1<s.length&&!this._isCharWordSeparator(a.loadCell(_+1,this._workCell));){a.loadCell(_+1,this._workCell);let C=this._workCell.getChars().length;this._workCell.getWidth()===2?(f++,_++):C>1&&(m+=C-1,l+=C-1),l++,_++}}l++;let b=o+u-d+p,y=Math.min(this._bufferService.cols,l-o+d+f-p-m);if(!(!t&&s.slice(o,l).trim()==="")){if(n&&b===0&&a.getCodePoint(0)!==32){let v=i.lines.get(e[1]-1);if(v&&a.isWrapped&&v.getCodePoint(this._bufferService.cols-1)!==32){let _=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(_){let E=this._bufferService.cols-_.start;b-=E,y+=E}}}if(r&&b+y===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let v=i.lines.get(e[1]+1);if(v?.isWrapped&&v.getCodePoint(0)!==32){let _=this._getWordAt([0,e[1]+1],!1,!1,!0);_&&(y+=_.length)}}return{start:b,length:y}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Qse(n,this._bufferService.cols)}};qB=fa([Kt(3,Uo),Kt(4,fy),Kt(5,NY),Kt(6,zo),Kt(7,Qh),Kt(8,Zh)],qB);var Jse=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},eoe=class{constructor(){this._color=new Jse,this._css=new Jse}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Va=Object.freeze((()=>{let e=[qi.toColor("#2e3436"),qi.toColor("#cc0000"),qi.toColor("#4e9a06"),qi.toColor("#c4a000"),qi.toColor("#3465a4"),qi.toColor("#75507b"),qi.toColor("#06989a"),qi.toColor("#d3d7cf"),qi.toColor("#555753"),qi.toColor("#ef2929"),qi.toColor("#8ae234"),qi.toColor("#fce94f"),qi.toColor("#729fcf"),qi.toColor("#ad7fa8"),qi.toColor("#34e2e2"),qi.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:Pa.toCss(r,i,a),rgba:Pa.toRgba(r,i,a)})}for(let n=0;n<24;n++){let r=8+n*10;e.push({css:Pa.toCss(r,r,r),rgba:Pa.toRgba(r,r,r)})}return e})()),Tg=qi.toColor("#ffffff"),uS=qi.toColor("#000000"),toe=qi.toColor("#ffffff"),noe=uS,D_={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},ryt=Tg,GB=class extends tr{constructor(e){super(),this._optionsService=e,this._contrastCache=new eoe,this._halfContrastCache=new eoe,this._onChangeColors=this._register(new Lt),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Tg,background:uS,cursor:toe,cursorAccent:noe,selectionForeground:void 0,selectionBackgroundTransparent:D_,selectionBackgroundOpaque:Oi.blend(uS,D_),selectionInactiveBackgroundTransparent:D_,selectionInactiveBackgroundOpaque:Oi.blend(uS,D_),scrollbarSliderBackground:Oi.opacity(Tg,.2),scrollbarSliderHoverBackground:Oi.opacity(Tg,.4),scrollbarSliderActiveBackground:Oi.opacity(Tg,.5),overviewRulerBorder:Tg,ansi:Va.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=ti(e.foreground,Tg),t.background=ti(e.background,uS),t.cursor=Oi.blend(t.background,ti(e.cursor,toe)),t.cursorAccent=Oi.blend(t.background,ti(e.cursorAccent,noe)),t.selectionBackgroundTransparent=ti(e.selectionBackground,D_),t.selectionBackgroundOpaque=Oi.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=ti(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Oi.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?ti(e.selectionForeground,Yse):void 0,t.selectionForeground===Yse&&(t.selectionForeground=void 0),Oi.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Oi.opacity(t.selectionBackgroundTransparent,.3)),Oi.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Oi.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=ti(e.scrollbarSliderBackground,Oi.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=ti(e.scrollbarSliderHoverBackground,Oi.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=ti(e.scrollbarSliderActiveBackground,Oi.opacity(t.foreground,.5)),t.overviewRulerBorder=ti(e.overviewRulerBorder,ryt),t.ansi=Va.slice(),t.ansi[0]=ti(e.black,Va[0]),t.ansi[1]=ti(e.red,Va[1]),t.ansi[2]=ti(e.green,Va[2]),t.ansi[3]=ti(e.yellow,Va[3]),t.ansi[4]=ti(e.blue,Va[4]),t.ansi[5]=ti(e.magenta,Va[5]),t.ansi[6]=ti(e.cyan,Va[6]),t.ansi[7]=ti(e.white,Va[7]),t.ansi[8]=ti(e.brightBlack,Va[8]),t.ansi[9]=ti(e.brightRed,Va[9]),t.ansi[10]=ti(e.brightGreen,Va[10]),t.ansi[11]=ti(e.brightYellow,Va[11]),t.ansi[12]=ti(e.brightBlue,Va[12]),t.ansi[13]=ti(e.brightMagenta,Va[13]),t.ansi[14]=ti(e.brightCyan,Va[14]),t.ansi[15]=ti(e.brightWhite,Va[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=ti(e.extendedAnsi[r],Va[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};GB=fa([Kt(0,zo)],GB);function ti(e,t){if(e!==void 0)try{return qi.toColor(e)}catch{}return t}var iyt=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},ayt=class{constructor(){this._services=new iyt,this._services.set(AY,this)}setService(t,n){this._services.set(t,n)}getService(t){return this._services.get(t)}createInstance(t,...n){let r=Qmt(t).sort((s,o)=>s.index-o.index),i=[];for(let s of r){let o=this._services.get(s.id);if(!o)throw new Error(`[createInstance] ${t.name} depends on UNKNOWN service ${s.id._id}.`);i.push(o)}let a=r.length>0?r[0].index:n.length;if(n.length!==a)throw new Error(`[createInstance] First service dependency of ${t.name} at position ${a+1} conflicts with ${n.length} static arguments`);return new t(...n,...i)}},syt={trace:0,debug:1,info:2,warn:3,error:4,off:5},oyt="xterm.js: ",KB=class extends tr{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=syt[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?"":oyt)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};KB=fa([Kt(0,zo)],KB);var roe=class extends tr{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Lt),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Lt),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Lt),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let r=e;r<this._length-t;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let r=this._length-1;r>=e;r--)this._array[this._getCyclicIndex(r+n.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<n.length;r++)this._array[this._getCyclicIndex(e+r)]=n[r];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let r=this._length+n.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+n<0)throw new Error("Cannot shift elements in list beyond index 0");if(n>0){for(let i=t-1;i>=0;i--)this.set(e+i+n,this.get(e+i));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Xn=3,Ia=Object.freeze(new XC),vT=0,mM=2,cS=class hke{constructor(t,n,r=!1){this.isWrapped=r,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*Xn);let i=n||tc.fromCharData([0,I2e,1,0]);for(let a=0;a<t;++a)this.setCell(a,i);this.length=t}get(t){let n=this._data[t*Xn+0],r=n&2097151;return[this._data[t*Xn+1],n&2097152?this._combined[t]:r?Bp(r):"",n>>22,n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):r]}set(t,n){this._data[t*Xn+1]=n[0],n[1].length>1?(this._combined[t]=n[1],this._data[t*Xn+0]=t|2097152|n[2]<<22):this._data[t*Xn+0]=n[1].charCodeAt(0)|n[2]<<22}getWidth(t){return this._data[t*Xn+0]>>22}hasWidth(t){return this._data[t*Xn+0]&12582912}getFg(t){return this._data[t*Xn+1]}getBg(t){return this._data[t*Xn+2]}hasContent(t){return this._data[t*Xn+0]&4194303}getCodePoint(t){let n=this._data[t*Xn+0];return n&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):n&2097151}isCombined(t){return this._data[t*Xn+0]&2097152}getString(t){let n=this._data[t*Xn+0];return n&2097152?this._combined[t]:n&2097151?Bp(n&2097151):""}isProtected(t){return this._data[t*Xn+2]&536870912}loadCell(t,n){return vT=t*Xn,n.content=this._data[vT+0],n.fg=this._data[vT+1],n.bg=this._data[vT+2],n.content&2097152&&(n.combinedData=this._combined[t]),n.bg&268435456&&(n.extended=this._extendedAttrs[t]),n}setCell(t,n){n.content&2097152&&(this._combined[t]=n.combinedData),n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*Xn+0]=n.content,this._data[t*Xn+1]=n.fg,this._data[t*Xn+2]=n.bg}setCellFromCodepoint(t,n,r,i){i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*Xn+0]=n|r<<22,this._data[t*Xn+1]=i.fg,this._data[t*Xn+2]=i.bg}addCodepointToCell(t,n,r){let i=this._data[t*Xn+0];i&2097152?this._combined[t]+=Bp(n):i&2097151?(this._combined[t]=Bp(i&2097151)+Bp(n),i&=-2097152,i|=2097152):i=n|1<<22,r&&(i&=-12582913,i|=r<<22),this._data[t*Xn+0]=i}insertCells(t,n,r){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length-t){let i=new tc;for(let a=this.length-t-n-1;a>=0;--a)this.setCell(t+n+a,this.loadCell(t+a,i));for(let a=0;a<n;++a)this.setCell(t+a,r)}else for(let i=t;i<this.length;++i)this.setCell(i,r);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,r)}deleteCells(t,n,r){if(t%=this.length,n<this.length-t){let i=new tc;for(let a=0;a<this.length-t-n;++a)this.setCell(t+a,this.loadCell(t+n+a,i));for(let a=this.length-n;a<this.length;++a)this.setCell(a,r)}else for(let i=t;i<this.length;++i)this.setCell(i,r);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,r)}replaceCells(t,n,r,i=!1){if(i){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&!this.isProtected(n)&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.isProtected(t)||this.setCell(t,r),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,r),n<this.length&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n,0,1,r);t<n&&t<this.length;)this.setCell(t++,r)}resize(t,n){if(t===this.length)return this._data.length*4*mM<this._data.buffer.byteLength;let r=t*Xn;if(t>this.length){if(this._data.buffer.byteLength>=r*4)this._data=new Uint32Array(this._data.buffer,0,r);else{let i=new Uint32Array(r);i.set(this._data),this._data=i}for(let i=this.length;i<t;++i)this.setCell(i,n)}else{this._data=this._data.subarray(0,r);let i=Object.keys(this._combined);for(let s=0;s<i.length;s++){let o=parseInt(i[s],10);o>=t&&delete this._combined[o]}let a=Object.keys(this._extendedAttrs);for(let s=0;s<a.length;s++){let o=parseInt(a[s],10);o>=t&&delete this._extendedAttrs[o]}}return this.length=t,r*4*mM<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*mM<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,n=!1){if(n){for(let r=0;r<this.length;++r)this.isProtected(r)||this.setCell(r,t);return}this._combined={},this._extendedAttrs={};for(let r=0;r<this.length;++r)this.setCell(r,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let n in t._combined)this._combined[n]=t._combined[n];this._extendedAttrs={};for(let n in t._extendedAttrs)this._extendedAttrs[n]=t._extendedAttrs[n];this.isWrapped=t.isWrapped}clone(){let t=new hke(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let n in this._combined)t._combined[n]=this._combined[n];for(let n in this._extendedAttrs)t._extendedAttrs[n]=this._extendedAttrs[n];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Xn+0]&4194303)return t+(this._data[t*Xn+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*Xn+0]&4194303||this._data[t*Xn+2]&50331648)return t+(this._data[t*Xn+0]>>22);return 0}copyCellsFrom(t,n,r,i,a){let s=t._data;if(a)for(let l=i-1;l>=0;l--){for(let u=0;u<Xn;u++)this._data[(r+l)*Xn+u]=s[(n+l)*Xn+u];s[(n+l)*Xn+2]&268435456&&(this._extendedAttrs[r+l]=t._extendedAttrs[n+l])}else for(let l=0;l<i;l++){for(let u=0;u<Xn;u++)this._data[(r+l)*Xn+u]=s[(n+l)*Xn+u];s[(n+l)*Xn+2]&268435456&&(this._extendedAttrs[r+l]=t._extendedAttrs[n+l])}let o=Object.keys(t._combined);for(let l=0;l<o.length;l++){let u=parseInt(o[l],10);u>=n&&(this._combined[u-n+r]=t._combined[u])}}translateToString(t,n,r,i){n=n??0,r=r??this.length,t&&(r=Math.min(r,this.getTrimmedLength())),i&&(i.length=0);let a="";for(;n<r;){let s=this._data[n*Xn+0],o=s&2097151,l=s&2097152?this._combined[n]:o?Bp(o):Jp;if(a+=l,i)for(let u=0;u<l.length;++u)i.push(n);n+=s>>22||1}return i&&i.push(n),a}};function lyt(e,t,n,r,i,a){let s=[];for(let o=0;o<e.length-1;o++){let l=o,u=e.get(++l);if(!u.isWrapped)continue;let d=[e.get(o)];for(;l<e.length&&u.isWrapped;)d.push(u),u=e.get(++l);if(!a&&r>=o&&r<l){o+=d.length-1;continue}let f=0,p=qE(d,f,t),m=1,b=0;for(;m<d.length;){let v=qE(d,m,t),_=v-b,E=n-p,C=Math.min(_,E);d[f].copyCellsFrom(d[m],b,p,C,!1),p+=C,p===n&&(f++,p=0),b+=C,b===v&&(m++,b=0),p===0&&f!==0&&d[f-1].getWidth(n-1)===2&&(d[f].copyCellsFrom(d[f-1],n-1,p++,1,!1),d[f-1].setCell(n-1,i))}d[f].replaceCells(p,n,i);let y=0;for(let v=d.length-1;v>0&&(v>f||d[v].getTrimmedLength()===0);v--)y++;y>0&&(s.push(o+d.length-y),s.push(y)),o+=d.length-1}return s}function uyt(e,t){let n=[],r=0,i=t[r],a=0;for(let s=0;s<e.length;s++)if(i===s){let o=t[++r];e.onDeleteEmitter.fire({index:s-a,amount:o}),s+=o-1,a+=o,i=t[++r]}else n.push(s);return{layout:n,countRemoved:a}}function cyt(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let r=0;r<n.length;r++)e.set(r,n[r]);e.length=t.length}function dyt(e,t,n){let r=[],i=e.map((l,u)=>qE(e,u,t)).reduce((l,u)=>l+u),a=0,s=0,o=0;for(;o<i;){if(i-o<n){r.push(i-o);break}a+=n;let l=qE(e,s,t);a>l&&(a-=l,s++);let u=e[s].getWidth(a-1)===2;u&&a--;let d=u?n-1:n;r.push(d),o+=d}return r}function qE(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var pke=class mke{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=mke._nextId++,this._onDispose=this.register(new Lt),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Lb(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};pke._nextId=1;var fyt=pke,ss={},Ag=ss.B;ss[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};ss.A={"#":"£"};ss.B=void 0;ss[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};ss.C=ss[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ss.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};ss.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};ss.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};ss.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};ss.E=ss[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};ss.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};ss.H=ss[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};ss["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var ioe=4294967295,aoe=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ia.clone(),this.savedCharset=Ag,this.markers=[],this._nullCell=tc.fromCharData([0,I2e,1,0]),this._whitespaceCell=tc.fromCharData([0,Jp,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new BN,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new roe(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new LN),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new LN),this._whitespaceCell}getBlankLine(e,t){return new cS(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>ioe?ioe:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ia);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new roe(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(Ia),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let s=0;s<this.lines.length;s++)r+=+this.lines.get(s).resize(e,n);let a=0;if(this._rows<t)for(let s=this._rows;s<t;s++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new cS(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new cS(e,n)));else for(let s=this._rows;s>t;s--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let s=this.lines.length-i;s>0&&(this.lines.trimStart(s),this.ybase=Math.max(this.ybase-s,0),this.ydisp=Math.max(this.ydisp-s,0),this.savedY=Math.max(this.savedY-s,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let a=0;a<this.lines.length;a++)r+=+this.lines.get(a).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=lyt(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ia),n);if(r.length>0){let i=uyt(this.lines,r);cyt(this.lines,i.layout),this._reflowLargerAdjustViewport(e,t,i.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(Ia),i=n;for(;i-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new cS(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(Ia),i=[],a=0;for(let s=this.lines.length-1;s>=0;s--){let o=this.lines.get(s);if(!o||!o.isWrapped&&o.getTrimmedLength()<=e)continue;let l=[o];for(;o.isWrapped&&s>0;)o=this.lines.get(--s),l.unshift(o);if(!n){let C=this.ybase+this.y;if(C>=s&&C<s+l.length)continue}let u=l[l.length-1].getTrimmedLength(),d=dyt(l,this._cols,e),f=d.length-l.length,p;this.ybase===0&&this.y!==this.lines.length-1?p=Math.max(0,this.y-this.lines.maxLength+f):p=Math.max(0,this.lines.length-this.lines.maxLength+f);let m=[];for(let C=0;C<f;C++){let T=this.getBlankLine(Ia,!0);m.push(T)}m.length>0&&(i.push({start:s+l.length+a,newLines:m}),a+=m.length),l.push(...m);let b=d.length-1,y=d[b];y===0&&(b--,y=d[b]);let v=l.length-f-1,_=u;for(;v>=0;){let C=Math.min(_,y);if(l[b]===void 0)break;if(l[b].copyCellsFrom(l[v],_-C,y-C,C,!0),y-=C,y===0&&(b--,y=d[b]),_-=C,_===0){v--;let T=Math.max(v,0);_=qE(l,T,this._cols)}}for(let C=0;C<l.length;C++)d[C]<e&&l[C].setCell(d[C],r);let E=f-p;for(;E-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+f,this.ybase+t-1)}if(i.length>0){let s=[],o=[];for(let y=0;y<this.lines.length;y++)o.push(this.lines.get(y));let l=this.lines.length,u=l-1,d=0,f=i[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let p=0;for(let y=Math.min(this.lines.maxLength-1,l+a-1);y>=0;y--)if(f&&f.start>u+p){for(let v=f.newLines.length-1;v>=0;v--)this.lines.set(y--,f.newLines[v]);y++,s.push({index:u+1,amount:f.newLines.length}),p+=f.newLines.length,f=i[++d]}else this.lines.set(y,o[u--]);let m=0;for(let y=s.length-1;y>=0;y--)s[y].index+=m,this.lines.onInsertEmitter.fire(s[y]),m+=s[y].amount;let b=Math.max(0,l+a-this.lines.maxLength);b>0&&this.lines.onTrimEmitter.fire(b)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):""}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new fyt(e);return this.markers.push(t),t.register(this.lines.onTrim(n=>{t.line-=n,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(n=>{t.line>=n.index&&(t.line+=n.amount)})),t.register(this.lines.onDelete(n=>{t.line>=n.index&&t.line<n.index+n.amount&&t.dispose(),t.line>n.index&&(t.line-=n.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},hyt=class extends tr{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Lt),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new aoe(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new aoe(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},gke=2,bke=1,YB=class extends tr{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Lt),this.onResize=this._onResize.event,this._onScroll=this._register(new Lt),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,gke),this.rows=Math.max(e.rawOptions.rows||0,bke),this.buffers=this._register(new hyt(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let s=n.lines.isFull;a===n.lines.length-1?s?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),s?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let s=a-i+1;n.lines.shiftElements(i+1,s-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};YB=fa([Kt(0,zo)],YB);var lv={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:FN,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},pyt=["normal","bold","100","200","300","400","500","600","700","800","900"],myt=class extends tr{constructor(e){super(),this._onOptionChange=this._register(new Lt),this.onOptionChange=this._onOptionChange.event;let t={...lv};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(r){console.error(r)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Ui(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=n=>{if(!(n in lv))throw new Error(`No option with key "${n}"`);return this.rawOptions[n]},t=(n,r)=>{if(!(n in lv))throw new Error(`No option with key "${n}"`);r=this._sanitizeAndValidateOption(n,r),this.rawOptions[n]!==r&&(this.rawOptions[n]=r,this._onOptionChange.fire(n))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=lv[e]),!gyt(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=lv[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=pyt.includes(t)?t:lv[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function gyt(e){return e==="block"||e==="underline"||e==="bar"}function dS(e,t=5){if(typeof e!="object")return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&dS(e[r],t-1);return n}var soe=Object.freeze({insertMode:!1}),ooe=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),XB=class extends tr{constructor(t,n,r){super(),this._bufferService=t,this._logService=n,this._optionsService=r,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Lt),this.onData=this._onData.event,this._onUserInput=this._register(new Lt),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Lt),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Lt),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=dS(soe),this.decPrivateModes=dS(ooe)}reset(){this.modes=dS(soe),this.decPrivateModes=dS(ooe)}triggerDataEvent(t,n=!1){if(this._optionsService.rawOptions.disableStdin)return;let r=this._bufferService.buffer;n&&this._optionsService.rawOptions.scrollOnUserInput&&r.ybase!==r.ydisp&&this._onRequestScrollToBottom.fire(),n&&this._onUserInput.fire(),this._logService.debug(`sending data "${t}"`),this._logService.trace("sending data (codes)",()=>t.split("").map(i=>i.charCodeAt(0))),this._onData.fire(t)}triggerBinaryEvent(t){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${t}"`),this._logService.trace("sending binary (codes)",()=>t.split("").map(n=>n.charCodeAt(0))),this._onBinary.fire(t))}};XB=fa([Kt(0,Uo),Kt(1,j2e),Kt(2,zo)],XB);var loe={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!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 gM(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var bM=String.fromCharCode,uoe={DEFAULT:e=>{let t=[gM(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${bM(t[0])}${bM(t[1])}${bM(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${gM(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${gM(e,!0)};${e.x};${e.y}${t}`}},ZB=class extends tr{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Lt),this.onProtocolChange=this._onProtocolChange.event;for(let r of Object.keys(loe))this.addProtocol(r,loe[r]);for(let r of Object.keys(uoe))this.addEncoding(r,uoe[r]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw 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,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};ZB=fa([Kt(0,Uo),Kt(1,fy),Kt(2,zo)],ZB);var yM=[[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]],byt=[[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]],Wa;function yyt(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var vyt=class{constructor(){if(this.version="6",!Wa){Wa=new Uint8Array(65536),Wa.fill(1),Wa[0]=0,Wa.fill(0,1,32),Wa.fill(0,127,160),Wa.fill(2,4352,4448),Wa[9001]=2,Wa[9002]=2,Wa.fill(2,11904,42192),Wa[12351]=1,Wa.fill(2,44032,55204),Wa.fill(2,63744,64256),Wa.fill(2,65040,65050),Wa.fill(2,65072,65136),Wa.fill(2,65280,65377),Wa.fill(2,65504,65511);for(let e=0;e<yM.length;++e)Wa.fill(0,yM[e][0],yM[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Wa[e]:yyt(e,byt)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let i=Gg.extractWidth(t);i===0?r=!1:i>n&&(n=i)}return Gg.createPropertyValue(0,n,r)}},Gg=class wA{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new Lt,this.onChange=this._onChange.event;let t=new vyt;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,n,r=!1){return(t&16777215)<<3|(n&3)<<1|(r?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let s=t.charCodeAt(a);if(55296<=s&&s<=56319){if(++a>=i)return n+this.wcwidth(s);let u=t.charCodeAt(a);56320<=u&&u<=57343?s=(s-55296)*1024+u-56320+65536:n+=this.wcwidth(u)}let o=this.charProperties(s,r),l=wA.extractWidth(o);wA.extractShouldJoin(o)&&(l-=wA.extractWidth(r)),n+=l,r=o}return n}charProperties(t,n){return this._activeProvider.charProperties(t,n)}},xyt=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function coe(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var P_=2147483647,_yt=256,yke=class QB{constructor(t=32,n=32){if(this.maxLength=t,this.maxSubParamsLength=n,n>_yt)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(n),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new QB;if(!t.length)return n;for(let r=Array.isArray(t[0])?1:0;r<t.length;++r){let i=t[r];if(Array.isArray(i))for(let a=0;a<i.length;++a)n.addSubParam(i[a]);else n.addParam(i)}return n}clone(){let t=new QB(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let n=0;n<this.length;++n){t.push(this.params[n]);let r=this._subParamsIdx[n]>>8,i=this._subParamsIdx[n]&255;i-r>0&&t.push(Array.prototype.slice.call(this._subParams,r,i))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>P_?P_:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>P_?P_:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;return r-n>0?this._subParams.subarray(n,r):null}getSubParamsAll(){let t={};for(let n=0;n<this.length;++n){let r=this._subParamsIdx[n]>>8,i=this._subParamsIdx[n]&255;i-r>0&&(t[n]=this._subParams.slice(r,i))}return t}addDigit(t){let n;if(this._rejectDigits||!(n=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let r=this._digitIsSub?this._subParams:this.params,i=r[n-1];r[n-1]=~i?Math.min(i*10+t,P_):t}},L_=[],Syt=class{constructor(){this._state=0,this._active=L_,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=L_}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=L_,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||L_,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,"PUT",yD(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let r=e[t++];if(r===59){this._state=2,this._start();break}if(r<48||57<r){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+r-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=L_,this._id=-1,this._state=0}}},Ul=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=yD(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(n=>(this._data="",this._hitLimit=!1,n));return this._data="",this._hitLimit=!1,t}},M_=[],Eyt=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(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=M_,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||M_,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let n=this._active.length-1;n>=0;n--)this._active[n].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,"PUT",yD(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=M_,this._ident=0}},fS=new yke;fS.addParam(0);var doe=class{constructor(e){this._handler=e,this._data="",this._params=fS,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():fS,this._data="",this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=yD(e,t,n),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(n=>(this._params=fS,this._data="",this._hitLimit=!1,n));return this._params=fS,this._data="",this._hitLimit=!1,t}},wyt=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},Lu=160,Cyt=(function(){let e=new wyt(4095),t=Array.apply(null,Array(256)).map((o,l)=>l),n=(o,l)=>t.slice(o,l),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),s;e.setDefault(1,0),e.addMany(r,0,2,0);for(s in a)e.addMany([24,26,153,154],s,3,0),e.addMany(n(128,144),s,3,0),e.addMany(n(144,152),s,3,0),e.add(156,s,0,0),e.add(27,s,11,1),e.add(157,s,4,8),e.addMany([152,158,159],s,0,7),e.add(155,s,11,3),e.add(144,s,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Lu,0,2,0),e.add(Lu,8,5,8),e.add(Lu,6,0,6),e.add(Lu,11,0,11),e.add(Lu,13,13,13),e})(),kyt=class extends tr{constructor(e=Cyt){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new yke,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,n,r)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,n)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Ui(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new Syt),this._dcsParser=this._register(new Eyt),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let i=0;i<e.intermediates.length;++i){let a=e.intermediates.charCodeAt(i);if(32>a||a>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");n<<=8,n|=a}}if(e.final.length!==1)throw new Error("final must be a single byte");let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let i=r.indexOf(t);i!==-1&&r.splice(i,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let i=r.indexOf(t);i!==-1&&r.splice(i,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,s;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let o=this._parseStack.handlers,l=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&l>-1){for(;l>=0&&(s=o[l](this._params),s!==!0);l--)if(s instanceof Promise)return this._parseStack.handlerPos=l,s}this._parseStack.handlers=[];break;case 4:if(n===!1&&l>-1){for(;l>=0&&(s=o[l](),s!==!0);l--)if(s instanceof Promise)return this._parseStack.handlerPos=l,s}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],s=this._dcsParser.unhook(r!==24&&r!==26,n),s)return s;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],s=this._oscParser.end(r!==24&&r!==26,n),s)return s;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let o=a;o<t;++o){switch(r=e[o],i=this._transitions.table[this.currentState<<8|(r<160?r:Lu)],i>>4){case 2:for(let p=o+1;;++p){if(p>=t||(r=e[p])<32||r>126&&r<Lu){this._printHandler(e,o,p),o=p-1;break}if(++p>=t||(r=e[p])<32||r>126&&r<Lu){this._printHandler(e,o,p),o=p-1;break}if(++p>=t||(r=e[p])<32||r>126&&r<Lu){this._printHandler(e,o,p),o=p-1;break}if(++p>=t||(r=e[p])<32||r>126&&r<Lu){this._printHandler(e,o,p),o=p-1;break}}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:o,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let l=this._csiHandlers[this._collect<<8|r],u=l?l.length-1:-1;for(;u>=0&&(s=l[u](this._params),s!==!0);u--)if(s instanceof Promise)return this._preserveStack(3,l,u,i,o),s;u<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++o<t&&(r=e[o])>47&&r<60);o--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let d=this._escHandlers[this._collect<<8|r],f=d?d.length-1:-1;for(;f>=0&&(s=d[f](),s!==!0);f--)if(s instanceof Promise)return this._preserveStack(4,d,f,i,o),s;f<0&&this._escHandlerFb(this._collect<<8|r),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|r,this._params);break;case 13:for(let p=o+1;;++p)if(p>=t||(r=e[p])===24||r===26||r===27||r>127&&r<Lu){this._dcsParser.put(e,o,p),o=p-1;break}break;case 14:if(s=this._dcsParser.unhook(r!==24&&r!==26),s)return this._preserveStack(6,[],0,i,o),s;r===27&&(i|=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>=t||(r=e[p])<32||r>127&&r<Lu){this._oscParser.put(e,o,p),o=p-1;break}break;case 6:if(s=this._oscParser.end(r!==24&&r!==26),s)return this._preserveStack(5,[],0,i,o),s;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=i&15}}},Tyt=/^([\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})$/,Ayt=/^[\da-f]+$/;function foe(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let n=Tyt.exec(t);if(n){let r=n[1]?15:n[4]?255:n[7]?4095:65535;return[Math.round(parseInt(n[1]||n[4]||n[7]||n[10],16)/r*255),Math.round(parseInt(n[2]||n[5]||n[8]||n[11],16)/r*255),Math.round(parseInt(n[3]||n[6]||n[9]||n[12],16)/r*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),Ayt.exec(t)&&[3,6,9,12].includes(t.length))){let n=t.length/3,r=[0,0,0];for(let i=0;i<3;++i){let a=parseInt(t.slice(n*i,n*i+n),16);r[i]=n===1?a<<4:n===2?a:n===3?a>>4:a>>8}return r}}function vM(e,t){let n=e.toString(16),r=n.length<2?"0"+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function Nyt(e,t=16){let[n,r,i]=e;return`rgb:${vM(n,t)}/${vM(r,t)}/${vM(i,t)}`}var Oyt={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ip=131072,hoe=10;function poe(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var moe=5e3,goe=0,Ryt=class extends tr{constructor(e,t,n,r,i,a,s,o,l=new kyt){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=s,this._unicodeService=o,this._parser=l,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Xmt,this._utf8Decoder=new Zmt,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ia.clone(),this._eraseAttrDataInternal=Ia.clone(),this._onRequestBell=this._register(new Lt),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Lt),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Lt),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Lt),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Lt),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Lt),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Lt),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Lt),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Lt),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Lt),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Lt),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Lt),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Lt),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new JB(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(u=>this._activeBuffer=u.activeBuffer)),this._parser.setCsiHandlerFallback((u,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(u),params:d.toArray()})}),this._parser.setEscHandlerFallback(u=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(u)})}),this._parser.setExecuteHandlerFallback(u=>{this._logService.debug("Unknown EXECUTE code: ",{code:u})}),this._parser.setOscHandlerFallback((u,d,f)=>{this._logService.debug("Unknown OSC code: ",{identifier:u,action:d,data:f})}),this._parser.setDcsHandlerFallback((u,d,f)=>{d==="HOOK"&&(f=f.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(u),action:d,payload:f})}),this._parser.setPrintHandler((u,d,f)=>this.print(u,d,f)),this._parser.registerCsiHandler({final:"@"},u=>this.insertChars(u)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},u=>this.scrollLeft(u)),this._parser.registerCsiHandler({final:"A"},u=>this.cursorUp(u)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},u=>this.scrollRight(u)),this._parser.registerCsiHandler({final:"B"},u=>this.cursorDown(u)),this._parser.registerCsiHandler({final:"C"},u=>this.cursorForward(u)),this._parser.registerCsiHandler({final:"D"},u=>this.cursorBackward(u)),this._parser.registerCsiHandler({final:"E"},u=>this.cursorNextLine(u)),this._parser.registerCsiHandler({final:"F"},u=>this.cursorPrecedingLine(u)),this._parser.registerCsiHandler({final:"G"},u=>this.cursorCharAbsolute(u)),this._parser.registerCsiHandler({final:"H"},u=>this.cursorPosition(u)),this._parser.registerCsiHandler({final:"I"},u=>this.cursorForwardTab(u)),this._parser.registerCsiHandler({final:"J"},u=>this.eraseInDisplay(u,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},u=>this.eraseInDisplay(u,!0)),this._parser.registerCsiHandler({final:"K"},u=>this.eraseInLine(u,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},u=>this.eraseInLine(u,!0)),this._parser.registerCsiHandler({final:"L"},u=>this.insertLines(u)),this._parser.registerCsiHandler({final:"M"},u=>this.deleteLines(u)),this._parser.registerCsiHandler({final:"P"},u=>this.deleteChars(u)),this._parser.registerCsiHandler({final:"S"},u=>this.scrollUp(u)),this._parser.registerCsiHandler({final:"T"},u=>this.scrollDown(u)),this._parser.registerCsiHandler({final:"X"},u=>this.eraseChars(u)),this._parser.registerCsiHandler({final:"Z"},u=>this.cursorBackwardTab(u)),this._parser.registerCsiHandler({final:"`"},u=>this.charPosAbsolute(u)),this._parser.registerCsiHandler({final:"a"},u=>this.hPositionRelative(u)),this._parser.registerCsiHandler({final:"b"},u=>this.repeatPrecedingCharacter(u)),this._parser.registerCsiHandler({final:"c"},u=>this.sendDeviceAttributesPrimary(u)),this._parser.registerCsiHandler({prefix:">",final:"c"},u=>this.sendDeviceAttributesSecondary(u)),this._parser.registerCsiHandler({final:"d"},u=>this.linePosAbsolute(u)),this._parser.registerCsiHandler({final:"e"},u=>this.vPositionRelative(u)),this._parser.registerCsiHandler({final:"f"},u=>this.hVPosition(u)),this._parser.registerCsiHandler({final:"g"},u=>this.tabClear(u)),this._parser.registerCsiHandler({final:"h"},u=>this.setMode(u)),this._parser.registerCsiHandler({prefix:"?",final:"h"},u=>this.setModePrivate(u)),this._parser.registerCsiHandler({final:"l"},u=>this.resetMode(u)),this._parser.registerCsiHandler({prefix:"?",final:"l"},u=>this.resetModePrivate(u)),this._parser.registerCsiHandler({final:"m"},u=>this.charAttributes(u)),this._parser.registerCsiHandler({final:"n"},u=>this.deviceStatus(u)),this._parser.registerCsiHandler({prefix:"?",final:"n"},u=>this.deviceStatusPrivate(u)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},u=>this.softReset(u)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},u=>this.setCursorStyle(u)),this._parser.registerCsiHandler({final:"r"},u=>this.setScrollRegion(u)),this._parser.registerCsiHandler({final:"s"},u=>this.saveCursor(u)),this._parser.registerCsiHandler({final:"t"},u=>this.windowOptions(u)),this._parser.registerCsiHandler({final:"u"},u=>this.restoreCursor(u)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},u=>this.insertColumns(u)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},u=>this.deleteColumns(u)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},u=>this.selectProtected(u)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},u=>this.requestMode(u,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},u=>this.requestMode(u,!1)),this._parser.setExecuteHandler(mt.BEL,()=>this.bell()),this._parser.setExecuteHandler(mt.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(mt.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(mt.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(mt.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(mt.BS,()=>this.backspace()),this._parser.setExecuteHandler(mt.HT,()=>this.tab()),this._parser.setExecuteHandler(mt.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(mt.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(SA.IND,()=>this.index()),this._parser.setExecuteHandler(SA.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(SA.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Ul(u=>(this.setTitle(u),this.setIconName(u),!0))),this._parser.registerOscHandler(1,new Ul(u=>this.setIconName(u))),this._parser.registerOscHandler(2,new Ul(u=>this.setTitle(u))),this._parser.registerOscHandler(4,new Ul(u=>this.setOrReportIndexedColor(u))),this._parser.registerOscHandler(8,new Ul(u=>this.setHyperlink(u))),this._parser.registerOscHandler(10,new Ul(u=>this.setOrReportFgColor(u))),this._parser.registerOscHandler(11,new Ul(u=>this.setOrReportBgColor(u))),this._parser.registerOscHandler(12,new Ul(u=>this.setOrReportCursorColor(u))),this._parser.registerOscHandler(104,new Ul(u=>this.restoreIndexedColor(u))),this._parser.registerOscHandler(110,new Ul(u=>this.restoreFgColor(u))),this._parser.registerOscHandler(111,new Ul(u=>this.restoreBgColor(u))),this._parser.registerOscHandler(112,new Ul(u=>this.restoreCursorColor(u))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let u in ss)this._parser.registerEscHandler({intermediates:"(",final:u},()=>this.selectCharset("("+u)),this._parser.registerEscHandler({intermediates:")",final:u},()=>this.selectCharset(")"+u)),this._parser.registerEscHandler({intermediates:"*",final:u},()=>this.selectCharset("*"+u)),this._parser.registerEscHandler({intermediates:"+",final:u},()=>this.selectCharset("+"+u)),this._parser.registerEscHandler({intermediates:"-",final:u},()=>this.selectCharset("-"+u)),this._parser.registerEscHandler({intermediates:".",final:u},()=>this.selectCharset("."+u)),this._parser.registerEscHandler({intermediates:"/",final:u},()=>this.selectCharset("/"+u));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(u=>(this._logService.error("Parsing error: ",u),u)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new doe((u,d)=>this.requestStatusString(u,d)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,n)=>setTimeout(()=>n("#SLOW_TIMEOUT"),moe))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${moe} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,s=this._parseStack.paused;if(s){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Ip&&(a=this._parseStack.position+Ip)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,u=>String.fromCharCode(u)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(u=>u.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Ip&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Ip))),s||this._dirtyRowTracker.clearRange(),e.length>Ip)for(let u=a;u<e.length;u+=Ip){let d=u+Ip<e.length?u+Ip:e.length,f=typeof e=="string"?this._stringDecoder.decode(e.substring(u,d),this._parseBuffer):this._utf8Decoder.decode(e.subarray(u,d),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,f))return this._preserveStack(r,i,f,u),this._logSlowResolvingAsync(n),n}else if(!s){let u=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,u))return this._preserveStack(r,i,u,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let o=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),l=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);l<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(l,this._bufferService.rows-1),end:Math.min(o,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,s=this._optionsService.rawOptions.screenReaderMode,o=this._bufferService.cols,l=this._coreService.decPrivateModes.wraparound,u=this._coreService.modes.insertMode,d=this._curAttrData,f=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&f.getWidth(this._activeBuffer.x-1)===2&&f.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let p=this._parser.precedingJoinState;for(let m=t;m<n;++m){if(r=e[m],r<127&&a){let _=a[String.fromCharCode(r)];_&&(r=_.charCodeAt(0))}let b=this._unicodeService.charProperties(r,p);i=Gg.extractWidth(b);let y=Gg.extractShouldJoin(b),v=y?Gg.extractWidth(p):0;if(p=b,s&&this._onA11yChar.fire(Bp(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-v>o){if(l){let _=f,E=this._activeBuffer.x-v;for(this._activeBuffer.x=v,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),f=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),v>0&&f instanceof cS&&f.copyCellsFrom(_,E,0,v,!1);E<o;)_.setCellFromCodepoint(E++,0,1,d)}else if(this._activeBuffer.x=o-1,i===2)continue}if(y&&this._activeBuffer.x){let _=f.getWidth(this._activeBuffer.x-1)?1:2;f.addCodepointToCell(this._activeBuffer.x-_,r,i);for(let E=i-v;--E>=0;)f.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(u&&(f.insertCells(this._activeBuffer.x,i-v,this._activeBuffer.getNullCell(d)),f.getWidth(o-1)===2&&f.setCellFromCodepoint(o-1,0,1,d)),f.setCellFromCodepoint(this._activeBuffer.x++,r,i,d),i>0)for(;--i;)f.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=p,this._activeBuffer.x<o&&n-t>0&&f.getWidth(this._activeBuffer.x)===0&&!f.hasContent(this._activeBuffer.x)&&f.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,n=>poe(n.params[0],this._optionsService.rawOptions.windowOptions)?t(n):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new doe(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Ul(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Ia));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let n=this._activeBuffer.scrollTop;n<=this._activeBuffer.scrollBottom;++n){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+n);r.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),r.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=Gg.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),s=new Uint32Array(a.length*n),o=0;for(let u=0;u<a.length;){let d=a.codePointAt(u)||0;s[o++]=d,u+=d>65535?2:1}let l=o;for(let u=1;u<n;++u)s.copyWithin(l,0,o),l+=o;return this.print(s,0,l),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(mt.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(mt.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(mt.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(mt.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(mt.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Ag),this._charsetService.setgCharset(1,Ag),this._charsetService.setgCharset(2,Ag),this._charsetService.setgCharset(3,Ag);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){let n;(y=>(y[y.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",y[y.SET=1]="SET",y[y.RESET=2]="RESET",y[y.PERMANENTLY_SET=3]="PERMANENTLY_SET",y[y.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,s=this._coreService,{buffers:o,cols:l}=this._bufferService,{active:u,alt:d}=o,f=this._optionsService.rawOptions,p=(y,v)=>(s.triggerDataEvent(`${mt.ESC}[${t?"":"?"}${y};${v}$y`),!0),m=y=>y?1:2,b=e.params[0];return t?b===2?p(b,4):b===4?p(b,m(s.modes.insertMode)):b===12?p(b,3):b===20?p(b,m(f.convertEol)):p(b,0):b===1?p(b,m(r.applicationCursorKeys)):b===3?p(b,f.windowOptions.setWinLines?l===80?2:l===132?1:0:0):b===6?p(b,m(r.origin)):b===7?p(b,m(r.wraparound)):b===8?p(b,3):b===9?p(b,m(i==="X10")):b===12?p(b,m(f.cursorBlink)):b===25?p(b,m(!s.isCursorHidden)):b===45?p(b,m(r.reverseWraparound)):b===66?p(b,m(r.applicationKeypad)):b===67?p(b,4):b===1e3?p(b,m(i==="VT200")):b===1002?p(b,m(i==="DRAG")):b===1003?p(b,m(i==="ANY")):b===1004?p(b,m(r.sendFocus)):b===1005?p(b,4):b===1006?p(b,m(a==="SGR")):b===1015?p(b,4):b===1016?p(b,m(a==="SGR_PIXELS")):b===1048?p(b,1):b===47||b===1047||b===1049?p(b,m(u===d)):b===2004?p(b,m(r.bracketedPasteMode)):b===2026?p(b,m(r.synchronizedOutput)):p(b,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=XC.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let s=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=s[o];while(++o<s.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let s=2;s<r.length;++s)r[s]===-1&&(r[s]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Ia.fg,e.bg=Ia.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=16777216|n-90|8):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=16777216|n-100|8):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=Ia.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=Ia.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=Ia.fg&16777215,r.bg&=-67108864,r.bg|=Ia.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${mt.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${mt.ESC}[${t};${n}R`);break}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let t=this._activeBuffer.y+1,n=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${mt.ESC}[?${t};${n}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Ia.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let n=t%2===1;this._coreService.decPrivateModes.cursorBlink=n}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!poe(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${mt.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>hoe&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>hoe&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(";");for(;n.length>1;){let r=n.shift(),i=n.shift();if(/^\d+$/.exec(r)){let a=parseInt(r);if(boe(a))if(i==="?")t.push({type:0,index:a});else{let s=foe(i);s&&t.push({type:1,index:a,color:s})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):n.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(":"),r,i=n.findIndex(a=>a.startsWith("id="));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(";");for(let r=0;r<n.length&&!(t>=this._specialColors.length);++r,++t)if(n[r]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let i=foe(n[r]);i&&this._onColor.fire([{type:1,index:this._specialColors[t],color:i}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(";");for(let r=0;r<n.length;++r)if(/^\d+$/.exec(n[r])){let i=parseInt(n[r]);boe(i)&&t.push({type:2,index:i})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Ag),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(Oyt[e[0]],ss[e[1]]||Ag),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Ia.clone(),this._eraseAttrDataInternal=Ia.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new tc;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=s=>(this._coreService.triggerDataEvent(`${mt.ESC}${s}${mt.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-(i.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},JB=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(goe=e,e=t,t=goe),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};JB=fa([Kt(0,Uo)],JB);function boe(e){return 0<=e&&e<256}var Iyt=5e7,yoe=12,Dyt=50,Pyt=class extends tr{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Lt),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>Iyt)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let r=this._writeBuffer[this._bufferOffset],i=this._action(r,t);if(i){let s=o=>performance.now()-n>=yoe?setTimeout(()=>this._innerWrite(0,o)):this._innerWrite(n,o);i.catch(o=>(queueMicrotask(()=>{throw o}),Promise.resolve(!1))).then(s);return}let a=this._callbacks[this._bufferOffset];if(a&&a(),this._bufferOffset++,this._pendingData-=r.length,performance.now()-n>=yoe)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Dyt&&(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()}},e$=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let o=t.addMarker(t.ybase+t.y),l={data:e,id:this._nextId++,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(l,o)),this._dataByLinkId.set(l.id,l),l.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),s={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(s,a)),this._entriesWithId.set(s.key,s),this._dataByLinkId.set(s.id,s),s.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(r=>r.line!==t)){let r=this._bufferService.buffer.addMarker(t);n.lines.push(r),r.onDispose(()=>this._removeMarkerFromLink(n,r))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};e$=fa([Kt(0,Uo)],e$);var voe=!1,Lyt=class extends tr{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new N0),this._onBinary=this._register(new Lt),this.onBinary=this._onBinary.event,this._onData=this._register(new Lt),this.onData=this._onData.event,this._onLineFeed=this._register(new Lt),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Lt),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Lt),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Lt),this._instantiationService=new ayt,this.optionsService=this._register(new myt(e)),this._instantiationService.setService(zo,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(YB)),this._instantiationService.setService(Uo,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(KB)),this._instantiationService.setService(j2e,this._logService),this.coreService=this._register(this._instantiationService.createInstance(XB)),this._instantiationService.setService(fy,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(ZB)),this._instantiationService.setService(M2e,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Gg)),this._instantiationService.setService(tgt,this.unicodeService),this._charsetService=this._instantiationService.createInstance(xyt),this._instantiationService.setService(egt,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(e$),this._instantiationService.setService(F2e,this._oscLinkService),this._inputHandler=this._register(new Ryt(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(zs.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(zs.forward(this._bufferService.onResize,this._onResize)),this._register(zs.forward(this.coreService.onData,this._onData)),this._register(zs.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new Pyt((t,n)=>this._inputHandler.parse(t,n))),this._register(zs.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Lt),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!voe&&(this._logService.warn("writeSync is unreliable and will be removed soon."),voe=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,gke),t=Math.max(t,bke),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(coe.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(coe(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Ui(()=>{for(let t of e)t.dispose()})}}},Myt={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:["'",'"']};function jyt(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?i.key=mt.ESC+"OA":i.key=mt.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?i.key=mt.ESC+"OD":i.key=mt.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?i.key=mt.ESC+"OC":i.key=mt.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?i.key=mt.ESC+"OB":i.key=mt.ESC+"[B");break;case 8:i.key=e.ctrlKey?"\b":mt.DEL,e.altKey&&(i.key=mt.ESC+i.key);break;case 9:if(e.shiftKey){i.key=mt.ESC+"[Z";break}i.key=mt.HT,i.cancel=!0;break;case 13:i.key=e.altKey?mt.ESC+mt.CR:mt.CR,i.cancel=!0;break;case 27:i.key=mt.ESC,e.altKey&&(i.key=mt.ESC+mt.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;a?i.key=mt.ESC+"[1;"+(a+1)+"D":t?i.key=mt.ESC+"OD":i.key=mt.ESC+"[D";break;case 39:if(e.metaKey)break;a?i.key=mt.ESC+"[1;"+(a+1)+"C":t?i.key=mt.ESC+"OC":i.key=mt.ESC+"[C";break;case 38:if(e.metaKey)break;a?i.key=mt.ESC+"[1;"+(a+1)+"A":t?i.key=mt.ESC+"OA":i.key=mt.ESC+"[A";break;case 40:if(e.metaKey)break;a?i.key=mt.ESC+"[1;"+(a+1)+"B":t?i.key=mt.ESC+"OB":i.key=mt.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=mt.ESC+"[2~");break;case 46:a?i.key=mt.ESC+"[3;"+(a+1)+"~":i.key=mt.ESC+"[3~";break;case 36:a?i.key=mt.ESC+"[1;"+(a+1)+"H":t?i.key=mt.ESC+"OH":i.key=mt.ESC+"[H";break;case 35:a?i.key=mt.ESC+"[1;"+(a+1)+"F":t?i.key=mt.ESC+"OF":i.key=mt.ESC+"[F";break;case 33:e.shiftKey?i.type=2:e.ctrlKey?i.key=mt.ESC+"[5;"+(a+1)+"~":i.key=mt.ESC+"[5~";break;case 34:e.shiftKey?i.type=3:e.ctrlKey?i.key=mt.ESC+"[6;"+(a+1)+"~":i.key=mt.ESC+"[6~";break;case 112:a?i.key=mt.ESC+"[1;"+(a+1)+"P":i.key=mt.ESC+"OP";break;case 113:a?i.key=mt.ESC+"[1;"+(a+1)+"Q":i.key=mt.ESC+"OQ";break;case 114:a?i.key=mt.ESC+"[1;"+(a+1)+"R":i.key=mt.ESC+"OR";break;case 115:a?i.key=mt.ESC+"[1;"+(a+1)+"S":i.key=mt.ESC+"OS";break;case 116:a?i.key=mt.ESC+"[15;"+(a+1)+"~":i.key=mt.ESC+"[15~";break;case 117:a?i.key=mt.ESC+"[17;"+(a+1)+"~":i.key=mt.ESC+"[17~";break;case 118:a?i.key=mt.ESC+"[18;"+(a+1)+"~":i.key=mt.ESC+"[18~";break;case 119:a?i.key=mt.ESC+"[19;"+(a+1)+"~":i.key=mt.ESC+"[19~";break;case 120:a?i.key=mt.ESC+"[20;"+(a+1)+"~":i.key=mt.ESC+"[20~";break;case 121:a?i.key=mt.ESC+"[21;"+(a+1)+"~":i.key=mt.ESC+"[21~";break;case 122:a?i.key=mt.ESC+"[23;"+(a+1)+"~":i.key=mt.ESC+"[23~";break;case 123:a?i.key=mt.ESC+"[24;"+(a+1)+"~":i.key=mt.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=mt.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=mt.DEL:e.keyCode===219?i.key=mt.ESC:e.keyCode===220?i.key=mt.FS:e.keyCode===221&&(i.key=mt.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let s=Myt[e.keyCode]?.[e.shiftKey?1:0];if(s)i.key=mt.ESC+s;else if(e.keyCode>=65&&e.keyCode<=90){let o=e.ctrlKey?e.keyCode-64:e.keyCode+32,l=String.fromCharCode(o);e.shiftKey&&(l=l.toUpperCase()),i.key=mt.ESC+l}else if(e.keyCode===32)i.key=mt.ESC+(e.ctrlKey?mt.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let o=e.code.slice(3,4);e.shiftKey||(o=o.toLowerCase()),i.key=mt.ESC+o,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(i.key=mt.US),e.key==="@"&&(i.key=mt.NUL));break}return i}var xa=0,Fyt=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new BN,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new BN,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((i,a)=>this._getKey(i)-this._getKey(a)),t=0,n=0,r=new Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(xa=this._search(t),xa===-1)||this._getKey(this._array[xa])!==t)return!1;do if(this._array[xa]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(xa),!0;while(++xa<this._array.length&&this._getKey(this._array[xa])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((i,a)=>i-a),t=0,n=new Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(xa=this._search(e),!(xa<0||xa>=this._array.length)&&this._getKey(this._array[xa])===e))do yield this._array[xa];while(++xa<this._array.length&&this._getKey(this._array[xa])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(xa=this._search(e),!(xa<0||xa>=this._array.length)&&this._getKey(this._array[xa])===e))do t(this._array[xa]);while(++xa<this._array.length&&this._getKey(this._array[xa])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},xM=0,xoe=0,Byt=class extends tr{constructor(){super(),this._decorations=new Fyt(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Lt),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Lt),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Ui(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new $yt(e);if(t){let n=t.marker.onDispose(()=>t.dispose()),r=t.onDispose(()=>{r.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),n.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??"bottom")===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,i=>{xM=i.options.x??0,xoe=xM+(i.options.width??1),e>=xM&&e<xoe&&(!n||(i.options.layer??"bottom")===n)&&r(i)})}},$yt=class extends pm{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Lt),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Lt),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=qi.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=qi.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Uyt=1e3,zyt=class{constructor(e,t=Uyt){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let i=r-this._lastRefreshMs,a=this._debounceThresholdMS-i;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},a)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},_oe=20,$N=class extends tr{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=i.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let a=0;a<this._terminal.rows;a++)this._rowElements[a]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[a]);if(this._topBoundaryFocusListener=a=>this._handleBoundaryFocus(a,0),this._bottomBoundaryFocusListener=a=>this._handleBoundaryFocus(a,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new zyt(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(a=>this._handleResize(a.rows))),this._register(this._terminal.onRender(a=>this._refreshRows(a.start,a.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(a=>this._handleChar(a))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
117
117
  `))),this._register(this._terminal.onA11yTab(a=>this._handleTab(a))),this._register(this._terminal.onKey(a=>this._handleKey(a.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Dn(i,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Ui(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<_oe+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
118
118
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===_oe+1&&(this._liveRegion.textContent+=xB.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let a=n.lines.get(n.ydisp+i),s=[],o=a?.translateToString(!0,void 0,void 0,s)||"",l=(n.ydisp+i+1).toString(),u=this._rowElements[i];u&&(o.length===0?(u.textContent=" ",this._rowColumns.set(u,[0,1])):(u.textContent=o,this._rowColumns.set(u,s)),u.setAttribute("aria-posinset",l),u.setAttribute("aria-setsize",r),this._alignRowWidth(u))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2],i=n.getAttribute("aria-posinset"),a=t===0?"1":`${this._terminal.buffer.lines.length}`;if(i===a||e.relatedTarget!==r)return;let s,o;if(t===0?(s=n,o=this._rowElements.pop(),this._rowContainer.removeChild(o)):(s=this._rowElements.shift(),o=n,this._rowContainer.removeChild(s)),s.removeEventListener("focus",this._topBoundaryFocusListener),o.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let l=this._createAccessibilityTreeNode();this._rowElements.unshift(l),this._rowContainer.insertAdjacentElement("afterbegin",l)}else{let l=this._createAccessibilityTreeNode();this._rowElements.push(l),this._rowContainer.appendChild(l)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:o,offset:l})=>{let u=o instanceof Text?o.parentNode:o,d=parseInt(u?.getAttribute("aria-posinset"),10)-1;if(isNaN(d))return console.warn("row is invalid. Race condition?"),null;let f=this._rowColumns.get(u);if(!f)return console.warn("columns is null. Race condition?"),null;let p=l<f.length?f[l]:f.slice(-1)[0]+1;return p>=this._terminal.cols&&(++d,p=0),{row:d,column:p}},a=i(t),s=i(n);if(!(!a||!s)){if(a.row>s.row||a.row===s.row&&a.column>=s.column)throw new Error("invalid range");this._terminal.select(a.column,a.row,(s.row-a.row)*this._terminal.cols-a.column+s.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};$N=fa([Kt(1,AY),Kt(2,Zh),Kt(3,Qh)],$N);var t$=class extends tr{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Lt),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Lt),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Ui(()=>{Lb(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Dn(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Dn(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Dn(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Dn(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let r=0;r<n.length;r++){let i=n[r];if(i.classList.contains("xterm"))break;if(i.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(r=>{r?.forEach(i=>{i.link.dispose&&i.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,a=>{if(this._isMouseOut)return;let s=a?.map(o=>({link:o}));this._activeProviderReplies?.set(r,s),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let a=0;a<i.length;a++){let s=i[a],o=s.link.range.start.y<e?0:s.link.range.start.x,l=s.link.range.end.y>e?this._bufferService.cols:s.link.range.end.x;for(let u=o;u<=l;u++){if(n.has(u)){i.splice(a--,1);break}n.add(u)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let a=0;a<e;a++)(!this._activeProviderReplies.has(a)||this._activeProviderReplies.get(a))&&(i=!0);if(!i&&r){let a=r.find(s=>this._linkAtPosition(s.link,t));a&&(n=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let a=0;a<this._activeProviderReplies.size;a++){let s=this._activeProviderReplies.get(a)?.find(o=>this._linkAtPosition(o.link,t));if(s){n=!0,this._handleNewLink(s);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Hyt(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Lb(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:n=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==n&&(this._currentLink.state.decorations.pointerCursor=n,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",n))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:n=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==n&&(this._currentLink.state.decorations.underline=n,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,n))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(n=>{if(!this._currentLink)return;let r=n.start===0?0:n.start+1+this._bufferService.buffer.ydisp,i=this._bufferService.buffer.ydisp+1+n.end;if(this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=i&&(this._clearCurrentLink(r,i),this._lastMouseEvent)){let a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._askForLink(a,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};t$=fa([Kt(1,NY),Kt(2,Qh),Kt(3,Uo),Kt(4,$2e)],t$);function Hyt(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var Vyt=class extends Lyt{constructor(e={}){super(e),this._linkifier=this._register(new N0),this.browser=ake,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new N0),this._onCursorMove=this._register(new Lt),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Lt),this.onKey=this._onKey.event,this._onRender=this._register(new Lt),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Lt),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Lt),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Lt),this.onBell=this._onBell.event,this._onFocus=this._register(new Lt),this._onBlur=this._register(new Lt),this._onA11yCharEmitter=this._register(new Lt),this._onA11yTabEmitter=this._register(new Lt),this._onWillOpen=this._register(new Lt),this._setup(),this._decorationService=this._instantiationService.createInstance(Byt),this._instantiationService.setService(ZC,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Dbt),this._instantiationService.setService($2e,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(SB)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh(t?.start??0,t?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(zs.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(zs.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(zs.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(zs.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(Ui(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let n,r="";switch(t.index){case 256:n="foreground",r="10";break;case 257:n="background",r="11";break;case 258:n="cursor",r="12";break;default:n="ansi",r="4;"+t.index}switch(t.type){case 0:let i=Oi.toColorRGB(n==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[n]);this.coreService.triggerDataEvent(`${mt.ESC}]${r};${Nyt(i)}${rke.ST}`);break;case 1:if(n==="ansi")this._themeService.modifyColors(a=>a.ansi[t.index]=Pa.toColor(...t.color));else{let a=n;this._themeService.modifyColors(s=>s[a]=Pa.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance($N,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(mt.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(mt.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,s=this.buffer.y*this._renderService.dimensions.css.cell.height,o=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=o+"px",this.textarea.style.top=s+"px",this.textarea.style.width=a+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Dn(this.element,"copy",t=>{this.hasSelection()&&Kmt(t,this._selectionService)}));let e=t=>Ymt(t,this.textarea,this.coreService,this.optionsService);this._register(Dn(this.textarea,"paste",e)),this._register(Dn(this.element,"paste",e)),ske?this._register(Dn(this.element,"mousedown",t=>{t.button===2&&Rse(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Dn(this.element,"contextmenu",t=>{Rse(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),jY&&this._register(Dn(this.element,"auxclick",t=>{t.button===1&&R2e(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Dn(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Dn(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Dn(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Dn(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Dn(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Dn(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Dn(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Dn(this.screenElement,"mousemove",i=>this.updateCursorStyle(i))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",vB.get()),uke||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Rbt,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Zh,this._coreBrowserService),this._register(Dn(this.textarea,"focus",i=>this._handleTextAreaFocus(i))),this._register(Dn(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(HB,this._document,this._helperContainer),this._instantiationService.setService(vD,this._charSizeService),this._themeService=this._instantiationService.createInstance(GB),this._instantiationService.setService(Z1,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(jN),this._instantiationService.setService(B2e,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(WB,this.rows,this.screenElement)),this._instantiationService.setService(Qh,this._renderService),this._register(this._renderService.onRenderedViewportChange(i=>this._onRender.fire(i))),this.onResize(i=>this._renderService.resize(i.cols,i.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance($B,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(VB),this._instantiationService.setService(NY,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(t$,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(FB,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(i=>{super.scrollLines(i,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(qB,this.element,this.screenElement,r)),this._instantiationService.setService(rgt,this._selectionService),this._register(this._selectionService.onRequestScrollLines(i=>this.scrollLines(i.amount,i.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(i=>this._renderService.handleSelectionChanged(i.start,i.end,i.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(i=>{this.textarea.value=i,this.textarea.focus(),this.textarea.select()})),this._register(zs.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(BB,this.screenElement)),this._register(Dn(this.element,"mousedown",i=>this._selectionService.handleMouseDown(i))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance($N,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",i=>this._handleScreenReaderModeOptionChange(i))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(MN,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",i=>{!this._overviewRulerRenderer&&i&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(MN,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(zB,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(a){let s=e._mouseService.getMouseReportCoords(a,e.screenElement);if(!s)return!1;let o,l;switch(a.overrideType||a.type){case"mousemove":l=32,a.buttons===void 0?(o=3,a.button!==void 0&&(o=a.button<3?a.button:3)):o=a.buttons&1?0:a.buttons&4?1:a.buttons&2?2:3;break;case"mouseup":l=0,o=a.button<3?a.button:3;break;case"mousedown":l=1,o=a.button<3?a.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(a)===!1)return!1;let u=a.deltaY;if(u===0||e.coreMouseService.consumeWheelEvent(a,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;l=u<0?0:1,o=4;break;default:return!1}return l===void 0||o===void 0||o>4?!1:e.coreMouseService.triggerMouseEvent({col:s.col,row:s.row,x:s.x,y:s.y,button:o,action:l,ctrl:a.ctrlKey,alt:a.altKey,shift:a.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:a=>(n(a),a.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(a)),wheel:a=>(n(a),this.cancel(a,!0)),mousedrag:a=>{a.buttons&&n(a)},mousemove:a=>{a.buttons||n(a)}};this._register(this.coreMouseService.onProtocolChange(a=>{a?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(a)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),a&8?r.mousemove||(t.addEventListener("mousemove",i.mousemove),r.mousemove=i.mousemove):(t.removeEventListener("mousemove",r.mousemove),r.mousemove=null),a&16?r.wheel||(t.addEventListener("wheel",i.wheel,{passive:!1}),r.wheel=i.wheel):(t.removeEventListener("wheel",r.wheel),r.wheel=null),a&2?r.mouseup||(r.mouseup=i.mouseup):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),a&4?r.mousedrag||(r.mousedrag=i.mousedrag):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Dn(t,"mousedown",a=>{if(a.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(a)))return n(a),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(a)})),this._register(Dn(t,"wheel",a=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(a)===!1)return!1;if(!this.buffer.hasScrollback){if(a.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(a,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(a,!0);let s=mt.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(a.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(s,!0),this.cancel(a,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){O2e(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let n=jyt(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let r=this.rows-1;return this.scrollLines(n.type===2?-r:r),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===mt.ETX||n.key===mt.CR)&&(this.textarea.value=""),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Wyt(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Ia));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(mt.ESC+"[I"):this.coreService.triggerDataEvent(mt.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),n=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${mt.ESC}[4;${n};${t}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),i=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${mt.ESC}[6;${i};${r}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function Wyt(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var qyt=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},Gyt=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new tc)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},Soe=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new Gyt(t)}getNullCell(){return new tc}},Kyt=class extends tr{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Lt),this.onBufferChange=this._onBufferChange.event,this._normal=new Soe(this._core.buffers.normal,"normal"),this._alternate=new Soe(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)}},Yyt=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,n=>t(n.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(n,r)=>t(n,r.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},Xyt=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Zyt=["cols","rows"],Cd=0,vke=class extends tr{constructor(e){super(),this._core=this._register(new Vyt(e)),this._addonManager=this._register(new qyt),this._publicOptions={...this._core.options};let t=r=>this._core.options[r],n=(r,i)=>{this._checkReadonlyOptions(r),this._core.options[r]=i};for(let r in this._core.options){let i={get:t.bind(this,r),set:n.bind(this,r)};Object.defineProperty(this._publicOptions,r,i)}}_checkReadonlyOptions(e){if(Zyt.includes(e))throw new Error(`Option "${e}" 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 Yyt(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Xyt(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 Kyt(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
119
- `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return vB.get()},set promptLabel(e){vB.set(e)},get tooMuchOutput(){return xB.get()},set tooMuchOutput(e){xB.set(e)}}}_verifyIntegers(...e){for(Cd of e)if(Cd===1/0||isNaN(Cd)||Cd%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Cd of e)if(Cd&&(Cd===1/0||isNaN(Cd)||Cd%1!==0||Cd<0))throw new Error("This API only accepts positive integers")}};var Qyt=2,Jyt=1,xke=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),i=Math.max(0,parseInt(n.getPropertyValue("width"))),a=window.getComputedStyle(this._terminal.element),s={top:parseInt(a.getPropertyValue("padding-top")),bottom:parseInt(a.getPropertyValue("padding-bottom")),right:parseInt(a.getPropertyValue("padding-right")),left:parseInt(a.getPropertyValue("padding-left"))},o=s.top+s.bottom,l=s.right+s.left,u=r-o,d=i-l-t;return{cols:Math.max(Qyt,Math.floor(d/e.css.cell.width)),rows:Math.max(Jyt,Math.floor(u/e.css.cell.height))}}};var evt=class{constructor(t,n,r,i={}){this._terminal=t,this._regex=n,this._handler=r,this._options=i}provideLinks(t,n){let r=nvt.computeLink(t,this._regex,this._terminal,this._handler);n(this._addCallbacks(r))}_addCallbacks(t){return t.map(n=>(n.leave=this._options.leave,n.hover=(r,i)=>{if(this._options.hover){let{range:a}=n;this._options.hover(r,i,a)}},n))}};function tvt(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var nvt=class CA{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||"")+"g"),[s,o]=CA._getWindowedLineStrings(t-1,r),l=s.join(""),u,d=[];for(;u=a.exec(l);){let f=u[0];if(!tvt(f))continue;let[p,m]=CA._mapStrIdx(r,o,0,u.index),[b,y]=CA._mapStrIdx(r,p,m,f.length);if(p===-1||m===-1||b===-1||y===-1)continue;let v={start:{x:m+1,y:p+1},end:{x:y,y:b+1}};d.push({range:v,text:f,activate:i})}return d}static _getWindowedLineStrings(t,n){let r,i=t,a=t,s=0,o="",l=[];if(r=n.buffer.active.getLine(t)){let u=r.translateToString(!0);if(r.isWrapped&&u[0]!==" "){for(s=0;(r=n.buffer.active.getLine(--i))&&s<2048&&(o=r.translateToString(!0),s+=o.length,l.push(o),!(!r.isWrapped||o.indexOf(" ")!==-1)););l.reverse()}for(l.push(u),s=0;(r=n.buffer.active.getLine(++a))&&r.isWrapped&&s<2048&&(o=r.translateToString(!0),s+=o.length,l.push(o),o.indexOf(" ")===-1););}return[l,i]}static _mapStrIdx(t,n,r,i){let a=t.buffer.active,s=a.getNullCell(),o=r;for(;i;){let l=a.getLine(n);if(!l)return[-1,-1];for(let u=o;u<l.length;++u){l.getCell(u,s);let d=s.getChars();if(s.getWidth()&&(i-=d.length||1,u===l.length-1&&d==="")){let f=a.getLine(n+1);f&&f.isWrapped&&(f.getCell(0,s),s.getWidth()===2&&(i+=1))}if(i<0)return[n,u]}n++,o=0}return[n,o]}},rvt=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function ivt(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var _ke=class{constructor(e=ivt,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||rvt;this._linkProvider=this._terminal.registerLinkProvider(new evt(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}};function Ske(e){const t=e.parser.registerOscHandler(52,n=>{const r=n.indexOf(";");if(r===-1)return!1;const i=n.slice(r+1);if(i==="?"||i==="")return!0;try{const a=atob(i);navigator.clipboard.writeText(a).catch(()=>{})}catch{}return!0});return()=>{t.dispose()}}function SD(){const[e,t]=x.useState(!1);return x.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 avt=[{label:"Esc",icon:er,data:"\x1B"},{label:"Up",icon:lC,data:"\x1B[A"},{label:"Down",icon:mc,data:"\x1B[B"},{label:"Tab",icon:null,data:" "},{label:"Enter",icon:null,data:"\r"}];function UN({onSend:e}){return SD()?c.jsx("div",{className:"flex shrink-0 items-center justify-center gap-2 border-t border-border bg-card px-3 py-2",children:avt.map(n=>c.jsxs(De,{variant:"outline",className:"h-11 min-w-11 touch-manipulation",onClick:()=>e(n.data),children:[n.icon?c.jsx(ie,{icon:n.icon,size:20,strokeWidth:2}):c.jsx("span",{className:"text-xs font-medium",children:n.label}),c.jsx("span",{className:"sr-only",children:n.label})]},n.label))}):null}function svt(e){const t=document.createElement("div");t.style.color=e,document.body.appendChild(t);const n=getComputedStyle(t).color;document.body.removeChild(t);const r=n.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(!r)return e;const i=parseInt(r[1]).toString(16).padStart(2,"0"),a=parseInt(r[2]).toString(16).padStart(2,"0"),s=parseInt(r[3]).toString(16).padStart(2,"0");return`#${i}${a}${s}`}function uv(e){const t=getComputedStyle(document.documentElement).getPropertyValue(e).trim();return t?svt(t):"#000000"}function Eke(e){const t=uv("--terminal-background"),n=uv("--foreground"),r=uv("--card"),i=uv("--muted-foreground"),a=uv("--accent"),s=uv("--destructive");return e?{background:t,foreground:n,cursor:n,cursorAccent:t,selectionBackground:r,black:"#18181b",red:s,green:"#22c55e",yellow:"#eab308",blue:a,magenta:"#a855f7",cyan:"#06b6d4",white:n,brightBlack:i,brightRed:"#f87171",brightGreen:"#4ade80",brightYellow:"#facc15",brightBlue:"#60a5fa",brightMagenta:"#c084fc",brightCyan:"#22d3ee",brightWhite:"#fafafa"}:{background:t,foreground:n,cursor:n,cursorAccent:t,selectionBackground:"#d1d5db",black:n,red:s,green:a,yellow:s,blue:a,magenta:i,cyan:a,white:i,brightBlack:i,brightRed:s,brightGreen:a,brightYellow:s,brightBlue:a,brightMagenta:i,brightCyan:a,brightWhite:i}}function n$({className:e,onReady:t,onResize:n,onContainerReady:r,terminalId:i,setupImagePaste:a,onSend:s,onFocus:o}){const l=x.useRef(null),u=x.useRef(null),d=x.useRef(null),f=x.useRef(n),p=x.useRef(o),m=x.useRef(t),b=x.useRef(r),{setTerminalFocused:y}=yH(),{resolvedTheme:v}=Sl(),_=v==="dark",E=Eke(_);x.useEffect(()=>{f.current=n},[n]),x.useEffect(()=>{p.current=o},[o]),x.useEffect(()=>{m.current=t},[t]),x.useEffect(()=>{b.current=r},[r]);const C=x.useCallback(()=>{if(!d.current||!u.current)return;d.current.fit();const{cols:k,rows:S}=u.current;f.current?.(k,S)},[]);x.useEffect(()=>{if(!l.current||u.current)return;const k=new vke({cursorBlink:!0,fontSize:14,fontFamily:"monospace",theme:E,scrollback:1e4,rightClickSelectsWord:!0,scrollOnUserInput:!1}),S=new xke,N=new _ke;k.loadAddon(S),k.loadAddon(N),k.open(l.current);const R=Ske(k);u.current=k,d.current=S,requestAnimationFrame(()=>{C(),m.current?.(k),l.current&&b.current?.(l.current)});const D=()=>{y(!0),p.current?.()},I=()=>y(!1);k.textarea&&(k.textarea.addEventListener("focus",D),k.textarea.addEventListener("blur",I));const P=setTimeout(()=>{C(),k.refresh(0,k.rows-1)},100),L=()=>{requestAnimationFrame(C)};window.addEventListener("resize",L);const B=()=>{document.visibilityState==="visible"&&requestAnimationFrame(()=>{C(),k.refresh(0,k.rows-1)})};document.addEventListener("visibilitychange",B);const j=new ResizeObserver(L);j.observe(l.current);const $=new IntersectionObserver(F=>{F[0]?.isIntersecting&&requestAnimationFrame(()=>{C(),k.refresh(0,k.rows-1)})},{threshold:.1});return $.observe(l.current),()=>{clearTimeout(P),window.removeEventListener("resize",L),document.removeEventListener("visibilitychange",B),j.disconnect(),$.disconnect(),R(),k.textarea&&(k.textarea.removeEventListener("focus",D),k.textarea.removeEventListener("blur",I)),y(!1),k.dispose(),u.current=null,d.current=null}},[C,y]),x.useEffect(()=>!l.current||!i||!a?void 0:a(l.current,i),[i,a]),x.useEffect(()=>{u.current&&(u.current.options.theme=E,u.current.refresh(0,u.current.rows-1))},[E]);const T=x.useCallback(()=>{u.current?.scrollToBottom()},[]);return c.jsxs("div",{className:"flex h-full w-full max-w-full flex-col",children:[c.jsxs("div",{className:"relative min-h-0 flex-1",children:[c.jsx("div",{ref:l,className:je("h-full w-full max-w-full overflow-hidden p-2 bg-terminal-background",e)}),c.jsx("button",{onClick:T,className:je("absolute top-2 right-5 p-1 transition-colors",_?"text-white/50 hover:text-white/80":"text-black/50 hover:text-black/80"),children:c.jsx(ie,{icon:g1e,size:20,strokeWidth:2})})]}),c.jsx("div",{className:"h-2 shrink-0 bg-terminal-background"}),s&&c.jsx(UN,{onSend:s})]})}function ovt({name:e,status:t,exitCode:n,className:r,onRename:i}){const[a,s]=x.useState(!1),[o,l]=x.useState(e),u=x.useRef(null);x.useEffect(()=>{a&&u.current&&(u.current.focus(),u.current.select())},[a]);const d=()=>{i&&(l(e),s(!0))},f=()=>{const m=o.trim();m&&m!==e&&i&&i(m),s(!1)},p=m=>{m.key==="Enter"?f():m.key==="Escape"&&s(!1)};return c.jsxs("div",{className:je("flex h-6 items-center gap-2 border-b border-border bg-card px-2 text-xs",r),children:[c.jsx("span",{className:je("h-2 w-2 shrink-0 rounded-full transition-colors duration-300",{"bg-accent animate-pulse":t==="running","bg-muted-foreground":t==="exited"&&n===0,"bg-destructive":t==="exited"&&n!==0||t==="error"})}),a?c.jsx("input",{ref:u,type:"text",value:o,onChange:m=>l(m.target.value),onBlur:f,onKeyDown:p,className:"h-4 w-24 rounded border border-border bg-background px-1 text-xs font-medium text-foreground outline-none focus:border-primary"}):c.jsx("span",{className:je("font-medium text-foreground",i&&"cursor-pointer hover:text-primary"),onDoubleClick:d,title:i?"Double-click to rename":void 0,children:e}),t==="exited"&&n!==void 0&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"ml-auto text-muted-foreground",children:"·"}),c.jsxs("span",{className:je({"text-muted-foreground":n===0,"text-destructive":n!==0}),children:["exit ",n]})]})]})}function Bd({...e}){return c.jsx($Ue,{"data-slot":"dropdown-menu",...e})}function $d({...e}){return c.jsx(zUe,{"data-slot":"dropdown-menu-trigger",...e})}function Ud({align:e="start",alignOffset:t=0,side:n="bottom",sideOffset:r=4,className:i,...a}){return c.jsx(AUe,{children:c.jsx(NUe,{className:"isolate z-50 outline-none",align:e,alignOffset:t,side:n,sideOffset:r,children:c.jsx(kUe,{"data-slot":"dropdown-menu-content",className:je("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 Fr({className:e,inset:t,variant:n="default",...r}){return c.jsx(wUe,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:je("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 r$({...e}){return c.jsx(RUe,{"data-slot":"dropdown-menu-radio-group",...e})}function i$({className:e,children:t,...n}){return c.jsxs(DUe,{"data-slot":"dropdown-menu-radio-item",className:je("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:[c.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:c.jsx(PUe,{children:c.jsx(ie,{icon:ni,strokeWidth:2})})}),t]})}function zN({className:e,...t}){return c.jsx(_H,{"data-slot":"dropdown-menu-separator",className:je("bg-border/50 -mx-1 my-1 h-px",e),...t})}const lvt="";function FY(){return Zt({mutationFn:async e=>{const t=await fetch(`${lvt}/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 uvt="";function BY(){return Zt({mutationFn:async e=>{const t=await fetch(`${uvt}/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 cvt="";function $Y(){return Zt({mutationFn:async e=>{const t=await fetch(`${cvt}/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 dvt="";function UY(){return Zt({mutationFn:async e=>{const t=await fetch(`${dvt}/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 fvt="";function zY(){return Zt({mutationFn:async e=>{const t=await fetch(`${fvt}/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 hvt="";function HY(){return Zt({mutationFn:async e=>{const t=await fetch(`${hvt}/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 pvt({repoPath:e,worktreePath:t,baseBranch:n,taskId:r,title:i,prUrl:a,isMobile:s,terminalId:o,sendInputToTerminal:l}){const{t:u}=Mt("common"),d=FY(),f=BY(),p=$Y(),m=UY(),b=zY(),y=A1(),v=HY(),_=D=>{o&&l?(l(o,D),Bt.info(u("git.sentToClaude"))):Bt.error(u("git.noTerminal"))},E=async()=>{try{await d.mutateAsync({repoPath:e,worktreePath:t,baseBranch:n}),Bt.success(u("git.syncedFromMain"))}catch(D){const I=D instanceof Error?D.message:"Sync failed",P=n||"main";Bt.error(I,{action:o&&l?{label:"Resolve with Claude",onClick:()=>_(`Rebase this worktree onto the parent repo's ${P} branch. Error: "${I}". Steps: 1) Check for uncommitted changes - stash or commit them first, 2) git fetch origin (in parent repo at ${e}) to ensure ${P} is current, 3) git rebase ${P} (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})}},C=async()=>{try{await f.mutateAsync({repoPath:e,worktreePath:t,baseBranch:n}),Bt.success(u("git.mergedToMain")),v.mutate(r),y.mutate({taskId:r,updates:{status:"DONE"}})}catch(D){const I=D instanceof Error?D.message:"Merge failed",P=n||"main";Bt.error(I,{action:o&&l?{label:"Resolve with Claude",onClick:()=>_(`Merge this worktree's branch into the parent repo's ${P}. Error: "${I}". Steps: 1) Ensure all changes in worktree are committed, 2) In parent repo at ${e}, checkout ${P} and pull latest from origin, 3) Squash merge the worktree branch into ${P} (use git merge --squash, then commit), 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) Push ${P} to origin. Worktree: ${t}, Parent repo: ${e}.`)}:void 0})}},T=async()=>{try{await p.mutateAsync({worktreePath:t}),Bt.success(u("git.pushedToOrigin"))}catch(D){const I=D instanceof Error?D.message:"Push failed";Bt.error(I,{action:o&&l?{label:"Resolve with Claude",onClick:()=>_(`Push this worktree's branch to origin. Error: "${I}". 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})}},k=async()=>{try{await m.mutateAsync({repoPath:e,baseBranch:n}),Bt.success(u("git.parentSynced"))}catch(D){const I=D instanceof Error?D.message:"Sync parent failed",P=n||"main";Bt.error(I,{action:o&&l?{label:"Resolve with Claude",onClick:()=>_(`Sync the parent repo's ${P} branch with origin. Error: "${I}". Steps: 1) git fetch origin, 2) git pull origin ${P} --ff-only, 3) If that fails, rebase with git rebase origin/${P}, 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) Once in sync, git push origin ${P}. Work in the parent repo at ${e}, not the worktree.`)}:void 0})}},S=()=>{o&&l&&l(o,"commit")},N=async()=>{try{const D=await b.mutateAsync({worktreePath:t,title:i,baseBranch:n});y.mutate({taskId:r,updates:{prUrl:D.prUrl}}),Bt.success(u("git.prCreated"),{action:{label:"View PR",onClick:()=>ul(D.prUrl)}})}catch(D){const I=D instanceof Error?D.message:"Failed to create PR",P=D&&typeof D=="object"&&"existingPrUrl"in D?D.existingPrUrl:void 0;if(P){y.mutate({taskId:r,updates:{prUrl:P}}),Bt.info(u("git.prExists"),{action:{label:"View PR",onClick:()=>ul(P)}});return}const L=I.split(`
119
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return vB.get()},set promptLabel(e){vB.set(e)},get tooMuchOutput(){return xB.get()},set tooMuchOutput(e){xB.set(e)}}}_verifyIntegers(...e){for(Cd of e)if(Cd===1/0||isNaN(Cd)||Cd%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Cd of e)if(Cd&&(Cd===1/0||isNaN(Cd)||Cd%1!==0||Cd<0))throw new Error("This API only accepts positive integers")}};var Qyt=2,Jyt=1,xke=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),i=Math.max(0,parseInt(n.getPropertyValue("width"))),a=window.getComputedStyle(this._terminal.element),s={top:parseInt(a.getPropertyValue("padding-top")),bottom:parseInt(a.getPropertyValue("padding-bottom")),right:parseInt(a.getPropertyValue("padding-right")),left:parseInt(a.getPropertyValue("padding-left"))},o=s.top+s.bottom,l=s.right+s.left,u=r-o,d=i-l-t;return{cols:Math.max(Qyt,Math.floor(d/e.css.cell.width)),rows:Math.max(Jyt,Math.floor(u/e.css.cell.height))}}};var evt=class{constructor(t,n,r,i={}){this._terminal=t,this._regex=n,this._handler=r,this._options=i}provideLinks(t,n){let r=nvt.computeLink(t,this._regex,this._terminal,this._handler);n(this._addCallbacks(r))}_addCallbacks(t){return t.map(n=>(n.leave=this._options.leave,n.hover=(r,i)=>{if(this._options.hover){let{range:a}=n;this._options.hover(r,i,a)}},n))}};function tvt(e){try{let t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var nvt=class CA{static computeLink(t,n,r,i){let a=new RegExp(n.source,(n.flags||"")+"g"),[s,o]=CA._getWindowedLineStrings(t-1,r),l=s.join(""),u,d=[];for(;u=a.exec(l);){let f=u[0];if(!tvt(f))continue;let[p,m]=CA._mapStrIdx(r,o,0,u.index),[b,y]=CA._mapStrIdx(r,p,m,f.length);if(p===-1||m===-1||b===-1||y===-1)continue;let v={start:{x:m+1,y:p+1},end:{x:y,y:b+1}};d.push({range:v,text:f,activate:i})}return d}static _getWindowedLineStrings(t,n){let r,i=t,a=t,s=0,o="",l=[];if(r=n.buffer.active.getLine(t)){let u=r.translateToString(!0);if(r.isWrapped&&u[0]!==" "){for(s=0;(r=n.buffer.active.getLine(--i))&&s<2048&&(o=r.translateToString(!0),s+=o.length,l.push(o),!(!r.isWrapped||o.indexOf(" ")!==-1)););l.reverse()}for(l.push(u),s=0;(r=n.buffer.active.getLine(++a))&&r.isWrapped&&s<2048&&(o=r.translateToString(!0),s+=o.length,l.push(o),o.indexOf(" ")===-1););}return[l,i]}static _mapStrIdx(t,n,r,i){let a=t.buffer.active,s=a.getNullCell(),o=r;for(;i;){let l=a.getLine(n);if(!l)return[-1,-1];for(let u=o;u<l.length;++u){l.getCell(u,s);let d=s.getChars();if(s.getWidth()&&(i-=d.length||1,u===l.length-1&&d==="")){let f=a.getLine(n+1);f&&f.isWrapped&&(f.getCell(0,s),s.getWidth()===2&&(i+=1))}if(i<0)return[n,u]}n++,o=0}return[n,o]}},rvt=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function ivt(e,t){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var _ke=class{constructor(e=ivt,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,n=t.urlRegex||rvt;this._linkProvider=this._terminal.registerLinkProvider(new evt(this._terminal,n,this._handler,t))}dispose(){this._linkProvider?.dispose()}};function Ske(e){const t=e.parser.registerOscHandler(52,n=>{const r=n.indexOf(";");if(r===-1)return!1;const i=n.slice(r+1);if(i==="?"||i==="")return!0;try{const a=atob(i);navigator.clipboard.writeText(a).catch(()=>{})}catch{}return!0});return()=>{t.dispose()}}function SD(){const[e,t]=x.useState(!1);return x.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 avt=[{label:"Esc",icon:er,data:"\x1B"},{label:"Up",icon:lC,data:"\x1B[A"},{label:"Down",icon:mc,data:"\x1B[B"},{label:"Tab",icon:null,data:" "},{label:"Enter",icon:null,data:"\r"}];function UN({onSend:e}){return SD()?c.jsx("div",{className:"flex shrink-0 items-center justify-center gap-2 border-t border-border bg-card px-3 py-2",children:avt.map(n=>c.jsxs(De,{variant:"outline",className:"h-11 min-w-11 touch-manipulation",onClick:()=>e(n.data),children:[n.icon?c.jsx(ie,{icon:n.icon,size:20,strokeWidth:2}):c.jsx("span",{className:"text-xs font-medium",children:n.label}),c.jsx("span",{className:"sr-only",children:n.label})]},n.label))}):null}function svt(e){const t=document.createElement("div");t.style.color=e,document.body.appendChild(t);const n=getComputedStyle(t).color;document.body.removeChild(t);const r=n.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(!r)return e;const i=parseInt(r[1]).toString(16).padStart(2,"0"),a=parseInt(r[2]).toString(16).padStart(2,"0"),s=parseInt(r[3]).toString(16).padStart(2,"0");return`#${i}${a}${s}`}function uv(e){const t=getComputedStyle(document.documentElement).getPropertyValue(e).trim();return t?svt(t):"#000000"}function Eke(e){const t=uv("--terminal-background"),n=uv("--foreground"),r=uv("--card"),i=uv("--muted-foreground"),a=uv("--accent"),s=uv("--destructive");return e?{background:t,foreground:n,cursor:n,cursorAccent:t,selectionBackground:r,black:t,red:s,green:a,yellow:s,blue:a,magenta:i,cyan:a,white:n,brightBlack:i,brightRed:s,brightGreen:a,brightYellow:s,brightBlue:a,brightMagenta:i,brightCyan:a,brightWhite:n}:{background:t,foreground:n,cursor:n,cursorAccent:t,selectionBackground:"#d1d5db",black:n,red:s,green:a,yellow:s,blue:a,magenta:i,cyan:a,white:i,brightBlack:i,brightRed:s,brightGreen:a,brightYellow:s,brightBlue:a,brightMagenta:i,brightCyan:a,brightWhite:i}}function n$({className:e,onReady:t,onResize:n,onContainerReady:r,terminalId:i,setupImagePaste:a,onSend:s,onFocus:o}){const l=x.useRef(null),u=x.useRef(null),d=x.useRef(null),f=x.useRef(n),p=x.useRef(o),m=x.useRef(t),b=x.useRef(r),{setTerminalFocused:y}=yH(),{resolvedTheme:v}=Sl(),_=v==="dark",E=Eke(_);x.useEffect(()=>{f.current=n},[n]),x.useEffect(()=>{p.current=o},[o]),x.useEffect(()=>{m.current=t},[t]),x.useEffect(()=>{b.current=r},[r]);const C=x.useCallback(()=>{if(!d.current||!u.current)return;d.current.fit();const{cols:k,rows:S}=u.current;f.current?.(k,S)},[]);x.useEffect(()=>{if(!l.current||u.current)return;const k=new vke({cursorBlink:!0,fontSize:14,fontFamily:"monospace",theme:E,scrollback:1e4,rightClickSelectsWord:!0,scrollOnUserInput:!1}),S=new xke,N=new _ke;k.loadAddon(S),k.loadAddon(N),k.open(l.current);const R=Ske(k);u.current=k,d.current=S,requestAnimationFrame(()=>{C(),m.current?.(k),l.current&&b.current?.(l.current)});const D=()=>{y(!0),p.current?.()},I=()=>y(!1);k.textarea&&(k.textarea.addEventListener("focus",D),k.textarea.addEventListener("blur",I));const P=setTimeout(()=>{C(),k.refresh(0,k.rows-1)},100),L=()=>{requestAnimationFrame(C)};window.addEventListener("resize",L);const B=()=>{document.visibilityState==="visible"&&requestAnimationFrame(()=>{C(),k.refresh(0,k.rows-1)})};document.addEventListener("visibilitychange",B);const j=new ResizeObserver(L);j.observe(l.current);const $=new IntersectionObserver(F=>{F[0]?.isIntersecting&&requestAnimationFrame(()=>{C(),k.refresh(0,k.rows-1)})},{threshold:.1});return $.observe(l.current),()=>{clearTimeout(P),window.removeEventListener("resize",L),document.removeEventListener("visibilitychange",B),j.disconnect(),$.disconnect(),R(),k.textarea&&(k.textarea.removeEventListener("focus",D),k.textarea.removeEventListener("blur",I)),y(!1),k.dispose(),u.current=null,d.current=null}},[C,y]),x.useEffect(()=>!l.current||!i||!a?void 0:a(l.current,i),[i,a]),x.useEffect(()=>{u.current&&(u.current.options.theme=E,u.current.refresh(0,u.current.rows-1))},[E]);const T=x.useCallback(()=>{u.current?.scrollToBottom()},[]);return c.jsxs("div",{className:"flex h-full w-full max-w-full flex-col",children:[c.jsxs("div",{className:"relative min-h-0 flex-1",children:[c.jsx("div",{ref:l,className:je("h-full w-full max-w-full overflow-hidden p-2 bg-terminal-background",e)}),c.jsx("button",{onClick:T,className:je("absolute top-2 right-5 p-1 transition-colors",_?"text-white/50 hover:text-white/80":"text-black/50 hover:text-black/80"),children:c.jsx(ie,{icon:g1e,size:20,strokeWidth:2})})]}),c.jsx("div",{className:"h-2 shrink-0 bg-terminal-background"}),s&&c.jsx(UN,{onSend:s})]})}function ovt({name:e,status:t,exitCode:n,className:r,onRename:i}){const[a,s]=x.useState(!1),[o,l]=x.useState(e),u=x.useRef(null);x.useEffect(()=>{a&&u.current&&(u.current.focus(),u.current.select())},[a]);const d=()=>{i&&(l(e),s(!0))},f=()=>{const m=o.trim();m&&m!==e&&i&&i(m),s(!1)},p=m=>{m.key==="Enter"?f():m.key==="Escape"&&s(!1)};return c.jsxs("div",{className:je("flex h-6 items-center gap-2 border-b border-border bg-card px-2 text-xs",r),children:[c.jsx("span",{className:je("h-2 w-2 shrink-0 rounded-full transition-colors duration-300",{"bg-accent animate-pulse":t==="running","bg-muted-foreground":t==="exited"&&n===0,"bg-destructive":t==="exited"&&n!==0||t==="error"})}),a?c.jsx("input",{ref:u,type:"text",value:o,onChange:m=>l(m.target.value),onBlur:f,onKeyDown:p,className:"h-4 w-24 rounded border border-border bg-background px-1 text-xs font-medium text-foreground outline-none focus:border-primary"}):c.jsx("span",{className:je("font-medium text-foreground",i&&"cursor-pointer hover:text-primary"),onDoubleClick:d,title:i?"Double-click to rename":void 0,children:e}),t==="exited"&&n!==void 0&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"ml-auto text-muted-foreground",children:"·"}),c.jsxs("span",{className:je({"text-muted-foreground":n===0,"text-destructive":n!==0}),children:["exit ",n]})]})]})}function Bd({...e}){return c.jsx($Ue,{"data-slot":"dropdown-menu",...e})}function $d({...e}){return c.jsx(zUe,{"data-slot":"dropdown-menu-trigger",...e})}function Ud({align:e="start",alignOffset:t=0,side:n="bottom",sideOffset:r=4,className:i,...a}){return c.jsx(AUe,{children:c.jsx(NUe,{className:"isolate z-50 outline-none",align:e,alignOffset:t,side:n,sideOffset:r,children:c.jsx(kUe,{"data-slot":"dropdown-menu-content",className:je("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 Fr({className:e,inset:t,variant:n="default",...r}){return c.jsx(wUe,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:je("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 r$({...e}){return c.jsx(RUe,{"data-slot":"dropdown-menu-radio-group",...e})}function i$({className:e,children:t,...n}){return c.jsxs(DUe,{"data-slot":"dropdown-menu-radio-item",className:je("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:[c.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:c.jsx(PUe,{children:c.jsx(ie,{icon:ni,strokeWidth:2})})}),t]})}function zN({className:e,...t}){return c.jsx(_H,{"data-slot":"dropdown-menu-separator",className:je("bg-border/50 -mx-1 my-1 h-px",e),...t})}const lvt="";function FY(){return Zt({mutationFn:async e=>{const t=await fetch(`${lvt}/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 uvt="";function BY(){return Zt({mutationFn:async e=>{const t=await fetch(`${uvt}/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 cvt="";function $Y(){return Zt({mutationFn:async e=>{const t=await fetch(`${cvt}/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 dvt="";function UY(){return Zt({mutationFn:async e=>{const t=await fetch(`${dvt}/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 fvt="";function zY(){return Zt({mutationFn:async e=>{const t=await fetch(`${fvt}/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 hvt="";function HY(){return Zt({mutationFn:async e=>{const t=await fetch(`${hvt}/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 pvt({repoPath:e,worktreePath:t,baseBranch:n,taskId:r,title:i,prUrl:a,isMobile:s,terminalId:o,sendInputToTerminal:l}){const{t:u}=Mt("common"),d=FY(),f=BY(),p=$Y(),m=UY(),b=zY(),y=A1(),v=HY(),_=D=>{o&&l?(l(o,D),Bt.info(u("git.sentToClaude"))):Bt.error(u("git.noTerminal"))},E=async()=>{try{await d.mutateAsync({repoPath:e,worktreePath:t,baseBranch:n}),Bt.success(u("git.syncedFromMain"))}catch(D){const I=D instanceof Error?D.message:"Sync failed",P=n||"main";Bt.error(I,{action:o&&l?{label:"Resolve with Claude",onClick:()=>_(`Rebase this worktree onto the parent repo's ${P} branch. Error: "${I}". Steps: 1) Check for uncommitted changes - stash or commit them first, 2) git fetch origin (in parent repo at ${e}) to ensure ${P} is current, 3) git rebase ${P} (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})}},C=async()=>{try{await f.mutateAsync({repoPath:e,worktreePath:t,baseBranch:n}),Bt.success(u("git.mergedToMain")),v.mutate(r),y.mutate({taskId:r,updates:{status:"DONE"}})}catch(D){const I=D instanceof Error?D.message:"Merge failed",P=n||"main";Bt.error(I,{action:o&&l?{label:"Resolve with Claude",onClick:()=>_(`Merge this worktree's branch into the parent repo's ${P}. Error: "${I}". Steps: 1) Ensure all changes in worktree are committed, 2) In parent repo at ${e}, checkout ${P} and pull latest from origin, 3) Squash merge the worktree branch into ${P} (use git merge --squash, then commit), 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) Push ${P} to origin. Worktree: ${t}, Parent repo: ${e}.`)}:void 0})}},T=async()=>{try{await p.mutateAsync({worktreePath:t}),Bt.success(u("git.pushedToOrigin"))}catch(D){const I=D instanceof Error?D.message:"Push failed";Bt.error(I,{action:o&&l?{label:"Resolve with Claude",onClick:()=>_(`Push this worktree's branch to origin. Error: "${I}". 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})}},k=async()=>{try{await m.mutateAsync({repoPath:e,baseBranch:n}),Bt.success(u("git.parentSynced"))}catch(D){const I=D instanceof Error?D.message:"Sync parent failed",P=n||"main";Bt.error(I,{action:o&&l?{label:"Resolve with Claude",onClick:()=>_(`Sync the parent repo's ${P} branch with origin. Error: "${I}". Steps: 1) git fetch origin, 2) git pull origin ${P} --ff-only, 3) If that fails, rebase with git rebase origin/${P}, 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) Once in sync, git push origin ${P}. Work in the parent repo at ${e}, not the worktree.`)}:void 0})}},S=()=>{o&&l&&l(o,"commit")},N=async()=>{try{const D=await b.mutateAsync({worktreePath:t,title:i,baseBranch:n});y.mutate({taskId:r,updates:{prUrl:D.prUrl}}),Bt.success(u("git.prCreated"),{action:{label:"View PR",onClick:()=>ul(D.prUrl)}})}catch(D){const I=D instanceof Error?D.message:"Failed to create PR",P=D&&typeof D=="object"&&"existingPrUrl"in D?D.existingPrUrl:void 0;if(P){y.mutate({taskId:r,updates:{prUrl:P}}),Bt.info(u("git.prExists"),{action:{label:"View PR",onClick:()=>ul(P)}});return}const L=I.split(`
120
120
  `).filter(Boolean).pop()||I;Bt.error(L,{action:{label:"Resolve with Claude",onClick:()=>_(`Create a PR for this task. Error: "${I}". After creating, link it using: fulcrum current-task pr <url>. Worktree: ${t}.`)}})}},R=d.isPending||f.isPending||p.isPending||m.isPending||b.isPending;return s?c.jsxs(Bd,{children:[c.jsx($d,{className:"flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:c.jsx(ie,{icon:bH,size:12,strokeWidth:2,className:R?"animate-pulse":""})}),c.jsxs(Ud,{align:"end",children:[c.jsxs(Fr,{onClick:E,disabled:d.isPending,children:[c.jsx(ie,{icon:mE,size:12,strokeWidth:2,className:d.isPending?"animate-spin":""}),"Pull from main"]}),c.jsxs(Fr,{onClick:C,disabled:f.isPending,children:[c.jsx(ie,{icon:pE,size:12,strokeWidth:2,className:f.isPending?"animate-pulse":""}),"Merge to main"]}),c.jsxs(Fr,{onClick:T,disabled:p.isPending,children:[c.jsx(ie,{icon:gE,size:12,strokeWidth:2,className:p.isPending?"animate-pulse":""}),"Push to origin"]}),c.jsxs(Fr,{onClick:k,disabled:m.isPending,children:[c.jsx(ie,{icon:yE,size:12,strokeWidth:2,className:m.isPending?"animate-spin":""}),"Sync parent with origin"]}),o&&l&&c.jsxs(Fr,{onClick:S,children:[c.jsx(ie,{icon:bE,size:12,strokeWidth:2}),"Commit"]}),!a&&c.jsxs(Fr,{onClick:N,disabled:b.isPending,children:[c.jsx(ie,{icon:Qu,size:12,strokeWidth:2,className:b.isPending?"animate-pulse":""}),"Create PR"]})]})]}):c.jsxs(c.Fragment,{children:[c.jsx(De,{variant:"ghost",size:"icon-xs",onClick:E,disabled:d.isPending,className:"h-5 w-5 text-muted-foreground hover:text-foreground",title:"Pull from main",children:c.jsx(ie,{icon:mE,size:12,strokeWidth:2,className:d.isPending?"animate-spin":""})}),c.jsx(De,{variant:"ghost",size:"icon-xs",onClick:C,disabled:f.isPending,className:"h-5 w-5 text-muted-foreground hover:text-foreground",title:"Merge to main",children:c.jsx(ie,{icon:pE,size:12,strokeWidth:2,className:f.isPending?"animate-pulse":""})}),c.jsx(De,{variant:"ghost",size:"icon-xs",onClick:T,disabled:p.isPending,className:"h-5 w-5 text-muted-foreground hover:text-foreground",title:"Push to origin",children:c.jsx(ie,{icon:gE,size:12,strokeWidth:2,className:p.isPending?"animate-pulse":""})}),c.jsx(De,{variant:"ghost",size:"icon-xs",onClick:k,disabled:m.isPending,className:"h-5 w-5 text-muted-foreground hover:text-foreground",title:"Sync parent with origin",children:c.jsx(ie,{icon:yE,size:12,strokeWidth:2,className:m.isPending?"animate-spin":""})}),o&&l&&c.jsx(De,{variant:"ghost",size:"icon-xs",onClick:S,className:"h-5 w-5 text-muted-foreground hover:text-foreground",title:"Commit",children:c.jsx(ie,{icon:bE,size:12,strokeWidth:2})}),!a&&c.jsx(De,{variant:"ghost",size:"icon-xs",onClick:N,disabled:b.isPending,className:"h-5 w-5 text-muted-foreground hover:text-foreground",title:"Create Pull Request",children:c.jsx(ie,{icon:Qu,size:12,strokeWidth:2,className:b.isPending?"animate-pulse":""})})]})}function ic({...e}){return c.jsx($$e,{"data-slot":"alert-dialog",...e})}function wke({...e}){return c.jsx(Y1e,{"data-slot":"alert-dialog-trigger",...e})}function mvt({...e}){return c.jsx(W1e,{"data-slot":"alert-dialog-portal",...e})}function gvt({className:e,...t}){return c.jsx(U1e,{"data-slot":"alert-dialog-overlay",className:je("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50",e),...t})}function ac({className:e,size:t="default",...n}){return c.jsxs(mvt,{children:[c.jsx(gvt,{}),c.jsx(V1e,{"data-slot":"alert-dialog-content","data-size":t,className:je("film-grain 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 ring-foreground/10 gap-3 rounded-xl p-4 ring-1 duration-100 data-[size=default]:max-w-xs data-[size=sm]:max-w-64 data-[size=default]:sm:max-w-sm group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 outline-none",e),style:{background:"var(--gradient-card)"},...n})]})}function sc({className:e,...t}){return c.jsx("div",{"data-slot":"alert-dialog-header",className:je("grid grid-rows-[auto_1fr] place-items-center gap-1 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function oc({className:e,...t}){return c.jsx("div",{"data-slot":"alert-dialog-footer",className:je("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function lc({className:e,...t}){return c.jsx(K1e,{"data-slot":"alert-dialog-title",className:je("text-sm font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function uc({className:e,...t}){return c.jsx(z1e,{"data-slot":"alert-dialog-description",className:je("text-muted-foreground *:[a]:hover:text-foreground text-xs/relaxed text-balance md:text-pretty *:[a]:underline *:[a]:underline-offset-3",e),...t})}function Hm({className:e,...t}){return c.jsx(De,{"data-slot":"alert-dialog-action",className:je(e),...t})}function cc({className:e,variant:t="outline",size:n="default",...r}){return c.jsx(gI,{"data-slot":"alert-dialog-cancel",className:je(e),render:c.jsx(De,{variant:t,size:n}),...r})}const Ei=x.forwardRef(({className:e,...t},n)=>c.jsx(yUe,{ref:n,className:je("peer size-4 shrink-0 rounded border border-input ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:cursor-not-allowed disabled:opacity-50","data-checked:bg-primary data-checked:border-primary data-checked:text-primary-foreground","flex items-center justify-center transition-colors",e),...t,children:c.jsx(vUe,{className:"flex items-center justify-center",children:c.jsx(ie,{icon:ni,size:12,strokeWidth:3})})}));Ei.displayName="Checkbox";function ED({task:e,open:t,onOpenChange:n,onDeleted:r}){const i=rHe(),[a,s]=x.useState(!0);x.useEffect(()=>{t&&s(!0)},[t]);const o=()=>{const u=e.pinned?!1:a;i.mutate({taskId:e.id,deleteLinkedWorktree:u},{onSuccess:()=>{n?.(!1),r?.()}})},l=e.worktreePath&&!e.pinned;return c.jsx(ic,{open:t,onOpenChange:n,children:c.jsxs(ac,{children:[c.jsxs(sc,{children:[c.jsx(lc,{children:"Delete Task"}),c.jsxs(uc,{children:['This will permanently delete "',e.title,'" and close its terminal.',a&&e.worktreePath&&!e.pinned&&" The linked worktree will also be removed."," ","This action cannot be undone."]}),e.pinned&&c.jsxs("p",{className:"flex items-center gap-1.5 text-sm text-primary",children:[c.jsx(ie,{icon:oN,size:14,strokeWidth:2}),"This worktree is pinned and will be preserved."]})]}),l&&c.jsxs("label",{className:"flex items-center gap-2 py-2 text-sm text-foreground cursor-pointer",children:[c.jsx(Ei,{checked:a,onCheckedChange:u=>s(u===!0),disabled:i.isPending}),"Also delete linked worktree"]}),c.jsxs(oc,{children:[c.jsx(cc,{disabled:i.isPending,children:"Cancel"}),c.jsx(Hm,{onClick:o,variant:"destructive",disabled:i.isPending,children:i.isPending?"Deleting...":"Delete"})]})]})})}function bvt({repoPath:e,worktreePath:t,baseBranch:n,taskId:r,title:i,prUrl:a,repoName:s,terminalId:o,sendInputToTerminal:l,pinned:u}){const{t:d}=Mt("common"),f=Ji(),p=FY(),m=BY(),b=$Y(),y=UY(),v=zY(),_=A1(),E=HY(),[C,T]=x.useState(!1),k={id:r,title:i,worktreePath:t,pinned:u??!1,description:null,status:"IN_PROGRESS",position:0,repoPath:e,repoName:s,baseBranch:n,branch:null,viewState:null,prUrl:a??null,startupScript:null,agent:"claude",aiMode:null,agentOptions:null,opencodeModel:null,projectId:null,repositoryId:null,tags:[],startedAt:null,dueDate:null,notes:null,createdAt:"",updatedAt:""},S=$=>{o&&l?(l(o,$),Bt.info(d("git.sentToClaude"))):Bt.error(d("git.noTerminal"))},N=async()=>{try{await p.mutateAsync({repoPath:e,worktreePath:t,baseBranch:n}),Bt.success(d("git.syncedFromMain"))}catch($){const F=$ instanceof Error?$.message:"Sync failed",z=n||"main";Bt.error(F,{action:o&&l?{label:"Resolve with Claude",onClick:()=>S(`Rebase this worktree onto the parent repo's ${z} branch. Error: "${F}". Steps: 1) Check for uncommitted changes - stash or commit them first, 2) git fetch origin (in parent repo at ${e}) to ensure ${z} is current, 3) git rebase ${z} (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})}},R=async()=>{try{await m.mutateAsync({repoPath:e,worktreePath:t,baseBranch:n}),Bt.success(d("git.mergedToMain")),E.mutate(r),_.mutate({taskId:r,updates:{status:"DONE"}})}catch($){const F=$ instanceof Error?$.message:"Merge failed",z=n||"main";Bt.error(F,{action:o&&l?{label:"Resolve with Claude",onClick:()=>S(`Merge this worktree's branch into the parent repo's ${z}. Error: "${F}". Steps: 1) Ensure all changes in worktree are committed, 2) In parent repo at ${e}, checkout ${z} and pull latest from origin, 3) Squash merge the worktree branch into ${z} (use git merge --squash, then commit), 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) Push ${z} to origin. Worktree: ${t}, Parent repo: ${e}.`)}:void 0})}},D=async()=>{try{await b.mutateAsync({worktreePath:t}),Bt.success(d("git.pushedToOrigin"))}catch($){const F=$ instanceof Error?$.message:"Push failed";Bt.error(F,{action:o&&l?{label:"Resolve with Claude",onClick:()=>S(`Push this worktree's branch to origin. Error: "${F}". 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})}},I=async()=>{try{await y.mutateAsync({repoPath:e,baseBranch:n}),Bt.success(d("git.parentSynced"))}catch($){const F=$ instanceof Error?$.message:"Sync parent failed",z=n||"main";Bt.error(F,{action:o&&l?{label:"Resolve with Claude",onClick:()=>S(`Sync the parent repo's ${z} branch with origin. Error: "${F}". Steps: 1) git fetch origin, 2) git pull origin ${z} --ff-only, 3) If that fails, rebase with git rebase origin/${z}, 4) Resolve any conflicts carefully - do not lose functionality or introduce regressions, 5) Once in sync, git push origin ${z}. Work in the parent repo at ${e}, not the worktree.`)}:void 0})}},P=()=>{o&&l&&l(o,"commit")},L=()=>{f({to:"/projects"})},B=async()=>{try{const $=await v.mutateAsync({worktreePath:t,title:i,baseBranch:n});_.mutate({taskId:r,updates:{prUrl:$.prUrl}}),Bt.success(d("git.prCreated"),{action:{label:"View PR",onClick:()=>ul($.prUrl)}})}catch($){const F=$ instanceof Error?$.message:"Failed to create PR",z=$&&typeof $=="object"&&"existingPrUrl"in $?$.existingPrUrl:void 0;if(z){_.mutate({taskId:r,updates:{prUrl:z}}),Bt.info(d("git.prExists"),{action:{label:"View PR",onClick:()=>ul(z)}});return}const q=F.split(`
121
121
  `).filter(Boolean).pop()||F;Bt.error(q,{action:{label:"Resolve with Claude",onClick:()=>S(`Create a PR for this task. Error: "${F}". After creating, link it using: fulcrum current-task pr <url>. Worktree: ${t}.`)}})}},j=p.isPending||m.isPending||b.isPending||y.isPending||v.isPending;return c.jsxs(c.Fragment,{children:[c.jsxs(Bd,{children:[c.jsx($d,{className:"flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:text-foreground",children:c.jsx(ie,{icon:bH,size:12,strokeWidth:2,className:j?"animate-pulse":""})}),c.jsxs(Ud,{align:"end",children:[c.jsxs(Fr,{onClick:N,disabled:p.isPending,children:[c.jsx(ie,{icon:mE,size:12,strokeWidth:2,className:p.isPending?"animate-spin":""}),"Pull from main"]}),c.jsxs(Fr,{onClick:R,disabled:m.isPending,children:[c.jsx(ie,{icon:pE,size:12,strokeWidth:2,className:m.isPending?"animate-pulse":""}),"Merge to main"]}),c.jsxs(Fr,{onClick:D,disabled:b.isPending,children:[c.jsx(ie,{icon:gE,size:12,strokeWidth:2,className:b.isPending?"animate-pulse":""}),"Push to origin"]}),c.jsxs(Fr,{onClick:I,disabled:y.isPending,children:[c.jsx(ie,{icon:yE,size:12,strokeWidth:2,className:y.isPending?"animate-spin":""}),"Sync parent with origin"]}),o&&l&&c.jsxs(Fr,{onClick:P,children:[c.jsx(ie,{icon:bE,size:12,strokeWidth:2}),"Commit"]}),!a&&c.jsxs(Fr,{onClick:B,disabled:v.isPending,children:[c.jsx(ie,{icon:Qu,size:12,strokeWidth:2,className:v.isPending?"animate-pulse":""}),"Create PR"]}),c.jsx(zN,{}),c.jsxs(Fr,{onClick:L,children:[c.jsx(ie,{icon:vE,size:12,strokeWidth:2}),s]}),c.jsx(zN,{}),c.jsxs(Fr,{onClick:()=>T(!0),className:"text-destructive focus:text-destructive",children:[c.jsx(ie,{icon:Fo,size:12,strokeWidth:2}),"Delete task"]})]})]}),c.jsx(ED,{task:k,open:C,onOpenChange:T})]})}function HS({worktreePath:e}){const{data:t,isLoading:n}=dHe(e);if(!e||n||!t)return null;if(t.clean)return c.jsxs(Xr,{className:"bg-green-500/20 text-green-600 dark:text-green-400 border-transparent",children:[c.jsx(ie,{icon:ni,size:12,strokeWidth:2}),"Clean"]});const r=t.files.length;return c.jsxs(Xr,{className:"bg-amber-500/20 text-amber-600 dark:text-amber-400 border-transparent",children:[c.jsx(ie,{icon:Yr,size:12,strokeWidth:2}),r," ",r===1?"change":"changes"]})}const yvt=600,vvt=450,xvt=250;function _vt({taskInfo:e,terminalId:t,terminalCwd:n,isMobile:r,sendInputToTerminal:i}){const a=x.useRef(null),[s,o]=x.useState(1/0),[l,u]=x.useState(!1);x.useEffect(()=>{const b=a.current;if(!b)return;const y=new ResizeObserver(v=>{for(const _ of v)o(_.contentRect.width)});return y.observe(b),()=>y.disconnect()},[]);const d=s>=yvt,f=s>=vvt&&!r,p=s>=xvt,m={id:e.taskId,title:e.title,worktreePath:e.worktreePath,pinned:e.pinned??!1,description:null,status:"IN_PROGRESS",position:0,repoPath:e.repoPath,repoName:e.repoName,baseBranch:e.baseBranch,branch:e.branch,viewState:null,prUrl:e.prUrl??null,startupScript:null,agent:"claude",aiMode:null,agentOptions:null,opencodeModel:null,projectId:null,repositoryId:null,tags:[],startedAt:null,dueDate:null,notes:null,createdAt:"",updatedAt:""};return c.jsx("div",{ref:a,className:"flex shrink-0 items-center justify-between border-b border-border bg-card",children:c.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2 py-1",children:[c.jsxs(bi,{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:[c.jsx(ie,{icon:mI,size:12,strokeWidth:2,className:"shrink-0"}),c.jsx("span",{className:"truncate",children:e.title})]}),d&&c.jsxs(c.Fragment,{children:[e.repoId?c.jsxs(bi,{to:"/repositories/$repoId",params:{repoId:e.repoId},className:"flex min-w-0 items-center gap-1 text-xs font-medium text-foreground hover:text-primary",children:[c.jsx(ie,{icon:Ld,size:12,strokeWidth:2,className:"shrink-0"}),c.jsx("span",{className:"truncate hover:underline",children:e.repoName})]}):c.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-xs font-medium text-foreground",children:[c.jsx(ie,{icon:Ld,size:12,strokeWidth:2,className:"shrink-0"}),c.jsx("span",{className:"truncate",children:e.repoName})]}),n&&c.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-xs text-muted-foreground",children:[c.jsx(ie,{icon:hI,size:12,strokeWidth:2,className:"shrink-0"}),c.jsx("span",{className:"truncate",children:n.split("/").pop()})]})]}),c.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[p&&c.jsx(HS,{worktreePath:e.worktreePath}),f?c.jsxs(c.Fragment,{children:[c.jsx(pvt,{repoPath:e.repoPath,worktreePath:e.worktreePath,baseBranch:e.baseBranch,taskId:e.taskId,title:e.title,prUrl:e.prUrl,isMobile:r,terminalId:t,sendInputToTerminal:i}),c.jsx(De,{variant:"ghost",size:"icon-xs",className:"h-5 w-5 text-muted-foreground hover:text-destructive",title:"Delete task",onClick:()=>u(!0),children:c.jsx(ie,{icon:Fo,size:12,strokeWidth:2})}),c.jsx(ED,{task:m,open:l,onOpenChange:u})]}):c.jsx(bvt,{repoPath:e.repoPath,worktreePath:e.worktreePath,baseBranch:e.baseBranch,taskId:e.taskId,title:e.title,prUrl:e.prUrl,repoName:e.repoName,terminalId:t,sendInputToTerminal:i,pinned:e.pinned})]})]})})}function Svt({repoInfo:e,isMaximized:t,onMaximize:n,onMinimize:r,canMaximize:i}){return c.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border bg-card",children:[c.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-2 py-1",children:[c.jsxs(bi,{to:"/repositories/$repoId",params:{repoId:e.repoId},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:[c.jsx(ie,{icon:Ld,size:12,strokeWidth:2,className:"shrink-0"}),c.jsx("span",{className:"truncate",children:e.repoName})]}),c.jsx("span",{className:"flex min-w-0 items-center gap-1 text-xs text-muted-foreground truncate",children:e.repoPath})]}),i&&c.jsx("div",{className:"flex items-center gap-1 mr-1",children:c.jsx(De,{variant:"ghost",size:"icon-xs",onClick:t?r:n,className:"h-5 w-5 text-muted-foreground hover:text-foreground",title:t?"Restore":"Maximize",children:c.jsx(ie,{icon:t?b1e:A1e,size:12,strokeWidth:2})})})]})}function Evt({terminals:e,activeIndex:t,onSelect:n,taskInfoByCwd:r}){const i=x.useRef(null),a=x.useRef(null);x.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 c.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,d=s(o,l);return c.jsx("button",{ref:u?a:null,onClick:()=>n(l),className:je("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:d},o.id)})})}const wvt=ty(function({terminal:t,taskInfo:n,repoInfo:r,isMobile:i,onClose:a,onReady:s,onResize:o,onRename:l,onContainerReady:u,setupImagePaste:d,onFocus:f,sendInputToTerminal:p,isMaximized:m,onMaximize:b,onMinimize:y,canMaximize:v}){const _=M1(),{resolvedTheme:E}=Sl(),C=E==="dark",T=n?_.terminals.get(t.id):null,k=T?.isStartingUp??!1;x.useEffect(()=>{n&&Vt.terminal.info("TerminalPane isStartingUp check",{terminalId:t.id,hasTaskInfo:!!n,hasTerminalModel:!!T,isStartingUp:T?.isStartingUp,isStartingClaude:k})},[t.id,n,T,k,T?.isStartingUp]);const S=()=>n?c.jsx(_vt,{taskInfo:n,terminalId:t.id,terminalCwd:t.cwd,isMobile:i,sendInputToTerminal:p}):r?c.jsx(Svt,{repoInfo:r,isMaximized:m,onMaximize:b,onMinimize:y,canMaximize:v}):c.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border bg-card",children:[c.jsx(ovt,{name:t.name,status:t.status,exitCode:t.exitCode,className:"flex-1 border-b-0",onRename:l}),c.jsxs("div",{className:"flex items-center gap-1 mr-1",children:[v&&c.jsx(De,{variant:"ghost",size:"icon-xs",onClick:m?y:b,className:"h-5 w-5 text-muted-foreground hover:text-foreground",title:m?"Restore":"Maximize",children:c.jsx(ie,{icon:m?b1e:A1e,size:12,strokeWidth:2})}),a&&c.jsx(De,{variant:"ghost",size:"icon-xs",onClick:a,className:"h-5 w-5 text-muted-foreground hover:text-foreground",children:c.jsx(ie,{icon:er,size:12,strokeWidth:2})})]})]});return c.jsxs("div",{className:"flex h-full min-w-0 flex-col overflow-hidden",children:[S(),c.jsxs("div",{className:"relative min-h-0 min-w-0 flex-1",children:[c.jsx(n$,{onReady:s,onResize:o,onContainerReady:u,terminalId:t.id,setupImagePaste:d,onFocus:f}),k&&c.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-terminal-background/90",children:c.jsxs("div",{className:"flex flex-col items-center gap-3",children:[c.jsx(ie,{icon:qt,size:24,strokeWidth:2,className:je("animate-spin",C?"text-white/60":"text-black/60")}),c.jsx("span",{className:je("font-mono text-sm",C?"text-white/60":"text-black/60"),children:"Starting Claude Code..."})]})})]})]})});function Cvt({onAdd:e,message:t}){return c.jsxs("div",{className:"relative flex h-full items-center justify-center bg-terminal-background overflow-hidden",children:[c.jsx("div",{className:"absolute inset-0 opacity-20 pointer-events-none",style:{background:`
122
122
  radial-gradient(ellipse 80% 50% at 20% 40%, var(--gradient-glow) 0%, transparent 50%),
@@ -297,7 +297,7 @@ Enter plan mode before starting.`)} --append-system-prompt ${a} --dangerously-sk
297
297
  ${e}`,d=im(u);return`opencode --agent ${zVt(o)} --prompt ${d}${l}`},notFoundPatterns:[/opencode: command not found/,/opencode: not found/,/'opencode' is not recognized/,/command not found: opencode/],processPattern:/\bopencode\b/i},lz={claude:HVt,opencode:VVt};function WVt(e,t){return lz[e].buildCommand(t)}function qVt(e,t){if(t)return lz[t].notFoundPatterns.some(r=>r.test(e))?t:null;for(const[n,r]of Object.entries(lz))if(r.notFoundPatterns.some(i=>i.test(e)))return n;return null}function mye({taskName:e,cwd:t,taskId:n,className:r,agent:i="claude",aiMode:a,description:s,startupScript:o,agentOptions:l,opencodeModel:u,serverPort:d=7777,autoFocus:f=!1}){const p=x.useRef(null),m=x.useRef(null),b=x.useRef(!1),y=x.useRef(f),v=x.useRef(null),_=x.useRef(!1),E=x.useRef(!1),[C,T]=x.useState(null),[k,S]=x.useState(!1),[N,R]=x.useState(!1),[D,I]=x.useState(!1),[P,L]=x.useState(null),{resolvedTheme:B}=Sl(),j=B==="dark",$=Eke(j),{data:F}=o_e(),{data:z}=l_e(),q=x.useRef(F),Y=x.useRef(z);x.useEffect(()=>{q.current=F},[F]),x.useEffect(()=>{Y.current=z},[z]),x.useEffect(()=>{Vt.taskTerminal.debug("cwd changed, resetting refs",{cwd:t}),_.current=!1,E.current=!1,b.current=!1,T(null),S(!1)},[t]);const{setTerminalFocused:K}=yH(),{terminals:W,terminalsLoaded:X,connected:U,createTerminal:Q,attachXterm:J,resizeTerminal:re,setupImagePaste:ae,writeToTerminal:oe,consumePendingStartup:se,clearStartingUp:ue}=HZ(),fe=x.useRef(J),ce=x.useRef(ae),ge=x.useRef(oe),we=x.useRef(se),de=x.useRef(ue);x.useEffect(()=>{fe.current=J},[J]),x.useEffect(()=>{ce.current=ae},[ae]),x.useEffect(()=>{ge.current=oe},[oe]),x.useEffect(()=>{we.current=se},[se]),x.useEffect(()=>{de.current=ue},[ue]),x.useEffect(()=>{y.current=f},[f]);const Ie=C?W.find(He=>He.id===C):null,ve=Ie?.status;x.useEffect(()=>{if(!p.current||m.current)return;const He=()=>K(!0),Ne=()=>K(!1),Oe=new vke({cursorBlink:!0,fontSize:14,fontFamily:"monospace",theme:$,scrollback:1e4,rightClickSelectsWord:!0,scrollOnUserInput:!1}),_e=new xke,Be=new _ke;Oe.loadAddon(_e),Oe.loadAddon(Be),Oe.open(p.current);const Ve=Ske(Oe);m.current=Oe,v.current=_e,I(!0),requestAnimationFrame(()=>{_e.fit()});const Ae=setTimeout(()=>{_e.fit(),Oe.refresh(0,Oe.rows-1)},100);return Oe.textarea&&(Oe.textarea.addEventListener("focus",He),Oe.textarea.addEventListener("blur",Ne)),()=>{clearTimeout(Ae),Ve(),Oe.textarea&&(Oe.textarea.removeEventListener("focus",He),Oe.textarea.removeEventListener("blur",Ne)),K(!1),Oe.dispose(),m.current=null,v.current=null,I(!1)}},[K,t]);const Fe=x.useCallback(()=>{if(!v.current||!m.current)return;v.current.fit();const{cols:He,rows:Ne}=m.current;C&&re(C,He,Ne)},[C,re]);x.useEffect(()=>{if(!p.current)return;const He=()=>{requestAnimationFrame(Fe)};window.addEventListener("resize",He);const Ne=()=>{document.visibilityState==="visible"&&requestAnimationFrame(()=>{Fe(),m.current?.refresh(0,m.current.rows-1)})};document.addEventListener("visibilitychange",Ne);const Oe=new ResizeObserver(He);Oe.observe(p.current);const _e=new IntersectionObserver(Be=>{Be[0]?.isIntersecting&&requestAnimationFrame(()=>{Fe(),m.current?.refresh(0,m.current.rows-1)})},{threshold:.1});return _e.observe(p.current),()=>{window.removeEventListener("resize",He),document.removeEventListener("visibilitychange",Ne),Oe.disconnect(),_e.disconnect()}},[Fe]),x.useEffect(()=>{if(!U||!t||!D||!X){Vt.taskTerminal.debug("Terminal effect: waiting for conditions",{connected:U,cwd:t,xtermOpened:D,terminalsLoaded:X});return}Vt.taskTerminal.info("Looking for terminal",{cwd:t,terminalCount:W.length,availableTerminals:W.map(Ne=>({id:Ne.id,name:Ne.name,cwd:Ne.cwd,tabId:Ne.tabId}))});const He=W.find(Ne=>Ne.cwd===t);if(He){Vt.taskTerminal.info("Found existing terminal",{terminalId:He.id,name:He.name,cwd:t}),T(He.id);return}if(!_.current&&m.current){Vt.taskTerminal.info("Creating new terminal",{reason:"no_existing_terminal_for_cwd",cwd:t,taskName:e,taskId:n,agent:i}),_.current=!0,S(!0);const{cols:Ne,rows:Oe}=m.current;Q({name:e,cols:Ne,rows:Oe,cwd:t,taskId:n,startup:{startupScript:o,agent:i,agentOptions:l,opencodeModel:u,aiMode:a,description:s,taskName:e,serverPort:d}})}else _.current&&Vt.taskTerminal.debug("Terminal creation already in progress",{cwd:t,createdTerminalRef:_.current})},[U,t,D,X,W,e,Q]),x.useEffect(()=>{if(!t)return;const He=W.find(Oe=>Oe.cwd===t);if(!He)return;const Ne=C&&W.some(Oe=>Oe.id===C);(!C||!Ne)&&(Vt.taskTerminal.debug("setting terminalId",{newId:He.id,prevId:C,reason:C?"tempId replaced":"initial",cwd:t,terminalCount:W.length}),T(He.id),S(!1),C&&!Ne&&(E.current=!1))},[W,t,C]),x.useEffect(()=>{if(Vt.taskTerminal.debug("attach effect",{terminalId:C,hasTermRef:!!m.current,hasContainerRef:!!p.current,attachedRef:E.current}),!C||!m.current||!p.current||E.current)return;Vt.taskTerminal.debug("attach effect passed guards, calling attachXterm",{terminalId:C});const He=_e=>{requestAnimationFrame(Fe);const Be=we.current(_e);if(Vt.taskTerminal.debug("onAttached checking pending startup",{terminalId:_e,hasPendingStartup:!!Be}),!Be){if(y.current&&!b.current&&m.current){const nt=()=>{const rt=m.current;!b.current&&rt&&(rt.focus(),rt.textarea===document.activeElement&&(b.current=!0))};setTimeout(nt,50),setTimeout(nt,200),setTimeout(nt,500)}return}Vt.taskTerminal.info("onAttached: running startup commands",{terminalId:_e}),R(!0);const{startupScript:Ve,agent:Ae="claude",agentOptions:Me,opencodeModel:ne,aiMode:qe,description:st,taskName:vt,serverPort:Je}=Be;Ve&&setTimeout(()=>{const nt="FULCRUM_STARTUP_"+Date.now(),rt=`source /dev/stdin <<'${nt}'
298
298
  ${Ve}
299
299
  ${nt}`;ge.current(_e,rt+"\r")},100);const dt=Je??7777,Ge=dt!==7777?` --port=${dt}`:"",Tt=`You are working in a Fulcrum task worktree. Reference the fulcrum skill for complete CLI documentation (attachments, dependencies, notifications, etc.). Commit after completing each logical unit of work (feature, fix, refactor) to preserve progress. When you finish working and need user input, run: fulcrum current-task review${Ge}. When linking a PR: fulcrum current-task pr <url>${Ge}. When linking a URL: fulcrum current-task link <url>${Ge}. For notifications: fulcrum notify "Title" "Message"${Ge}.`,Ce=st?`${vt}: ${st}`:vt,ze=WVt(Ae,{prompt:Ce,systemPrompt:Tt,mode:qe==="plan"?"plan":"default",additionalOptions:Me??{},opencodeModel:ne,opencodeDefaultAgent:q.current,opencodePlanAgent:Y.current});setTimeout(()=>{if(ge.current(_e,ze+"\r"),R(!1),de.current(_e),y.current&&!b.current&&m.current){const nt=()=>{const rt=m.current;!b.current&&rt&&(rt.focus(),rt.textarea===document.activeElement&&(b.current=!0))};setTimeout(nt,50),setTimeout(nt,200),setTimeout(nt,500)}},Ve?5e3:100)},Ne=fe.current(C,m.current,{onAttached:He}),Oe=ce.current(p.current,C);return E.current=!0,Vt.taskTerminal.debug("attachedRef set to true",{terminalId:C}),()=>{Vt.taskTerminal.debug("cleanup running, setting attachedRef to false",{terminalId:C}),Ne(),Oe(),E.current=!1}},[C,Fe]),x.useEffect(()=>{if(!m.current)return;const He=m.current;He.options.theme=$,He.refresh(0,He.rows-1)},[$]),x.useEffect(()=>{if(!f||b.current||!m.current||!C||k||N)return;const He=[0,50,150,300,500],Ne=[];return He.forEach(Oe=>{const _e=setTimeout(()=>{const Be=m.current;!b.current&&Be&&(Be.focus(),Be.textarea===document.activeElement&&(b.current=!0))},Oe);Ne.push(_e)}),()=>{Ne.forEach(clearTimeout)}},[f,k,N,C]),x.useEffect(()=>{if(!m.current||P)return;const He=m.current,Ne=()=>{const _e=He.buffer.active;for(let Be=Math.max(0,_e.cursorY-3);Be<=_e.cursorY;Be++){const Ve=_e.getLine(Be);if(Ve){const Ae=Ve.translateToString(),Me=qVt(Ae,i);if(Me){L(Me);return}}}},Oe=He.onLineFeed(Ne);return()=>{Oe.dispose()}},[P,i]);const Ue=x.useCallback(He=>{C&&ge.current(C,He)},[C]);return t?c.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[!U&&c.jsx("div",{className:"shrink-0 px-2 py-1 bg-muted-foreground/20 text-muted-foreground text-xs",children:"Connecting to terminal server..."}),ve==="error"&&c.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."}),ve==="exited"&&c.jsxs("div",{className:"shrink-0 px-2 py-1 bg-muted text-muted-foreground text-xs",children:["Terminal exited (code: ",Ie?.exitCode,")"]}),c.jsxs("div",{className:"relative min-h-0 min-w-0 flex-1",children:[c.jsx("div",{ref:p,className:je("h-full w-full overflow-hidden p-2 bg-terminal-background",r)}),k&&!C&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-terminal-background",children:c.jsxs("div",{className:"flex flex-col items-center gap-3",children:[c.jsx(ie,{icon:qt,size:24,strokeWidth:2,className:je("animate-spin",j?"text-white/50":"text-black/50")}),c.jsx("span",{className:je("font-mono text-sm",j?"text-white/50":"text-black/50"),children:"Initializing terminal..."})]})}),N&&c.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-terminal-background/90",children:c.jsxs("div",{className:"flex flex-col items-center gap-3",children:[c.jsx(ie,{icon:qt,size:24,strokeWidth:2,className:je("animate-spin",j?"text-white/60":"text-black/60")}),c.jsxs("span",{className:je("font-mono text-sm",j?"text-white/60":"text-black/60"),children:["Starting ",As[i],"..."]})]})}),P&&c.jsx("div",{className:"pointer-events-none absolute bottom-4 left-4 right-4 z-10",children:c.jsxs("div",{className:je("pointer-events-auto flex items-start gap-3 rounded-lg border p-4","bg-amber-500/10 border-amber-500/30"),children:[c.jsx(ie,{icon:Yr,size:18,strokeWidth:2,className:"shrink-0 mt-0.5 text-amber-600 dark:text-amber-400"}),c.jsxs("div",{className:"flex-1 space-y-2",children:[c.jsxs("p",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:[As[P]," CLI not found"]}),c.jsxs("p",{className:"text-xs text-amber-600/80 dark:text-amber-400/80",children:["Install it with:"," ",c.jsx("code",{className:"rounded bg-amber-500/20 px-1.5 py-0.5 font-mono",children:m_e[P]})]}),c.jsx("a",{href:g_e[P],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"})]}),c.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:c.jsx(ie,{icon:er,size:14,strokeWidth:2})})]})}),c.jsx("button",{onClick:()=>m.current?.scrollToBottom(),className:je("absolute top-2 right-5 p-1 transition-colors",j?"text-white/50 hover:text-white/80":"text-black/50 hover:text-black/80"),children:c.jsx(ie,{icon:g1e,size:20,strokeWidth:2})})]}),c.jsx("div",{className:"h-2 shrink-0 bg-terminal-background"}),c.jsx(UN,{onSend:Ue})]}):c.jsx("div",{className:je("flex h-full items-center justify-center text-muted-foreground text-sm bg-terminal-background",r),children:"No worktree path configured for this task"})}function GVt(e){const{viewState:t,setDiffOptions:n}=zZ(e),{collapsedFiles:r}=t.diffOptions,i=x.useCallback(l=>{const u=r.includes(l);n({collapsedFiles:u?r.filter(d=>d!==l):[...r,l]})},[r,n]),a=x.useCallback(l=>{n({collapsedFiles:l})},[n]),s=x.useCallback(()=>{n({collapsedFiles:[]})},[n]),o=x.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 KVt(e){const t=[];let n=null,r=0,i=0;for(const a of e.split(`
300
- `))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 YVt({file:e,wrap:t,isCollapsed:n,onToggle:r}){return c.jsxs(PD,{open:!n,onOpenChange:()=>r(),children:[c.jsx(LD,{asChild:!0,children:c.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:[c.jsx(ie,{icon:n?Hc:mc,size:12,strokeWidth:2,className:"text-muted-foreground shrink-0"}),c.jsx("span",{className:"font-mono text-xs text-foreground truncate flex-1",children:e.path}),c.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[e.additions>0&&c.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions]}),e.additions>0&&e.deletions>0&&" ",e.deletions>0&&c.jsxs("span",{className:"text-destructive",children:["-",e.deletions]})]})]})}),c.jsx(MD,{children:c.jsx("div",{className:"font-mono text-xs",children:e.lines.slice(1).map((i,a)=>c.jsxs("div",{className:je("flex px-2 py-0.5",i.type==="added"&&"bg-green-500/10",i.type==="removed"&&"bg-destructive/10",i.type==="header"&&"bg-muted/50 text-muted-foreground",i.type==="hunk"&&"bg-green-500/10 text-green-600 dark:text-green-400"),children:[(i.type==="added"||i.type==="removed"||i.type==="context")&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"w-10 shrink-0 select-none pr-2 text-right text-muted-foreground",children:i.oldLineNumber??""}),c.jsx("span",{className:"w-10 shrink-0 select-none pr-2 text-right text-muted-foreground",children:i.newLineNumber??""})]}),c.jsxs("span",{className:je("w-4 shrink-0 select-none text-center",i.type==="added"&&"text-green-600 dark:text-green-400",i.type==="removed"&&"text-destructive"),children:[i.type==="added"&&"+",i.type==="removed"&&"-"]}),c.jsx("span",{className:je("flex-1",t?"whitespace-pre-wrap break-all":"whitespace-pre",i.type==="added"&&"text-green-600 dark:text-green-400",i.type==="removed"&&"text-destructive"),children:i.content})]},a))})})]})}function gye({taskId:e,worktreePath:t,baseBranch:n}){const{options:r,setOption:i,toggleFileCollapse:a,collapseAll:s,expandAll:o,isFileCollapsed:l}=GVt(e),{wrap:u,ignoreWhitespace:d,includeUntracked:f,collapsedFiles:p}=r,{data:m,isLoading:b,error:y}=cHe(t,{ignoreWhitespace:d,includeUntracked:f,baseBranch:n}),v=x.useMemo(()=>m?.diff?KVt(m.diff):[],[m?.diff]),_=x.useMemo(()=>v.map(S=>S.path),[v]),E=v.length>0&&p.length===v.length,C=x.useMemo(()=>v.reduce((S,N)=>S+N.additions,0),[v]),T=x.useMemo(()=>v.reduce((S,N)=>S+N.deletions,0),[v]);if(x.useEffect(()=>{const S=N=>{if(N.shiftKey&&N.key==="C"&&!N.ctrlKey&&!N.metaKey&&!N.altKey){const R=N.target;if(R.tagName==="INPUT"||R.tagName==="TEXTAREA"||R.isContentEditable)return;N.preventDefault(),E?o():s(_)}};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[E,_,s,o]),!t)return c.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"No worktree selected"});if(b)return c.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"Loading diff..."});if(y)return c.jsx("div",{className:"flex h-full items-center justify-center text-destructive text-sm",children:y.message});const k=m?.files?.some(S=>S.status==="untracked")??!1;return v.length===0?c.jsxs("div",{className:"flex h-full flex-col items-center justify-center text-muted-foreground text-sm gap-2",children:[c.jsx("p",{children:"No changes detected"}),m?.files&&m.files.length>0&&c.jsxs("div",{className:"text-xs",children:[c.jsx("p",{className:"text-center mb-2",children:"Modified files:"}),c.jsxs("div",{className:"flex flex-col gap-1",children:[m.files.map(S=>c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("span",{className:je("w-4 text-center",S.status==="added"&&"text-green-600 dark:text-green-400",S.status==="deleted"&&"text-destructive",S.status==="modified"&&"text-muted-foreground",S.status==="untracked"&&"text-muted-foreground"),children:[S.status==="added"&&"A",S.status==="deleted"&&"D",S.status==="modified"&&"M",S.status==="untracked"&&"?"]}),c.jsx("span",{children:S.path})]},S.path)),k&&c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-muted-foreground hover:text-foreground mt-1",children:[c.jsx("input",{type:"checkbox",checked:f,onChange:S=>i("includeUntracked",S.target.checked),className:"w-4 h-3"}),c.jsx("span",{children:"Show untracked files"})]})]})]})]}):c.jsxs("div",{className:"flex flex-col h-full bg-background",children:[c.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-card border-b border-border text-xs",children:[m?.branch&&c.jsxs("span",{className:"text-muted-foreground",children:[m.branch,m.isBranchDiff&&m.baseBranch&&c.jsxs("span",{className:"opacity-70",children:[" (vs ",m.baseBranch,")"]})]}),(C>0||T>0)&&c.jsxs("span",{className:"text-muted-foreground",children:[c.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",C]})," ",c.jsxs("span",{className:"text-destructive",children:["-",T]})]}),c.jsx("div",{className:"flex-1"}),c.jsxs("button",{onClick:()=>E?o():s(_),className:"flex items-center gap-1 px-1.5 py-0.5 text-muted-foreground hover:text-foreground rounded hover:bg-muted/50",title:E?"Expand all (Shift+C)":"Collapse all (Shift+C)",children:[c.jsx(ie,{icon:E?P1e:N1e,size:12,strokeWidth:2}),c.jsx("span",{className:"hidden sm:inline",children:E?"Expand":"Collapse"})]}),c.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-muted-foreground hover:text-foreground",children:[c.jsx("input",{type:"checkbox",checked:u,onChange:S=>i("wrap",S.target.checked),className:"w-3 h-3"}),"Wrap"]}),c.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-muted-foreground hover:text-foreground",children:[c.jsx("input",{type:"checkbox",checked:d,onChange:S=>i("ignoreWhitespace",S.target.checked),className:"w-3 h-3"}),"Ignore whitespace"]}),c.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-muted-foreground hover:text-foreground",children:[c.jsx("input",{type:"checkbox",checked:f,onChange:S=>i("includeUntracked",S.target.checked),className:"w-3 h-3"}),"Untracked"]})]}),c.jsx(Kh,{className:"flex-1 min-h-0",children:v.map(S=>c.jsx(YVt,{file:S,wrap:u,isCollapsed:l(S.path),onToggle:()=>a(S.path)},S.path))})]})}function XVt(e){const{viewState:t,setBrowserUrl:n}=zZ(e);return{url:t.browserUrl,setUrl:n}}function bye({taskId:e}){const{url:t,setUrl:n}=XVt(e),[r,i]=x.useState(t),[a,s]=x.useState(0);x.useEffect(()=>{i(t)},[t]);const o=x.useCallback(()=>{s(u=>u+1)},[]),l=x.useCallback(u=>{u.preventDefault();let d=r.trim();!d.startsWith("http://")&&!d.startsWith("https://")&&(d=`http://${d}`),n(d),s(f=>f+1)},[r,n]);return c.jsxs("div",{className:"flex h-full flex-col bg-background",children:[c.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border bg-card px-2 py-1.5",children:[c.jsx(De,{variant:"ghost",size:"icon-xs",disabled:!0,children:c.jsx(ie,{icon:Th,size:14,strokeWidth:2})}),c.jsx(De,{variant:"ghost",size:"icon-xs",disabled:!0,children:c.jsx(ie,{icon:Hc,size:14,strokeWidth:2})}),c.jsx(De,{variant:"ghost",size:"icon-xs",onClick:o,children:c.jsx(ie,{icon:uC,size:14,strokeWidth:2})}),c.jsx("form",{onSubmit:l,className:"flex-1",children:c.jsx(Wt,{value:r,onChange:u=>i(u.target.value),className:"h-7 bg-background text-xs",placeholder:"Enter URL..."})})]}),c.jsx("div",{className:"flex-1 overflow-hidden bg-card",children:c.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)})]})}const ZVt="";function yye(e){const t=[];function n(r){for(const i of r)t.push(`${i.type}:${i.path}`),i.children&&n(i.children)}return n(e),t.sort().join("|")}function QVt({worktreePath:e,currentTree:t,onTreeChanged:n,pollInterval:r=5e3,enabled:i=!0}){const a=x.useRef(null),s=x.useRef(null),o=x.useRef(n);x.useEffect(()=>{o.current=n},[n]),x.useEffect(()=>{t&&(s.current=yye(t))},[t]);const l=x.useCallback(async()=>{if(e)try{const u=await St(`${ZVt}/api/fs/tree?root=${encodeURIComponent(e)}`),d=yye(u.entries);s.current!==null&&d!==s.current&&(s.current=d,o.current(u.entries))}catch{}},[e]);x.useEffect(()=>{if(!i||!e||!t){a.current&&(clearInterval(a.current),a.current=null);return}return a.current=setInterval(l,r),()=>{a.current&&(clearInterval(a.current),a.current=null)}},[i,e,t,r,l]),x.useEffect(()=>{s.current=null},[e])}function JVt(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 o3e(e){const t=e.split(".").pop()?.toLowerCase()||"";return["png","jpg","jpeg","gif","svg","webp","ico"].includes(t)?RFe:["ts","tsx","js","jsx","json","css","html","md","yaml","yml","toml","sh","py","rs","go","sql"].includes(t)?SFe:E1e}function l3e({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=x.useCallback(()=>{l?a(e.path):i(e.path)},[l,e.path,i,a]);return c.jsxs("div",{children:[c.jsxs("div",{className:je("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:[c.jsx(ie,{icon:l?s?TF:Hs:o3e(e.name),size:14,strokeWidth:2,className:je("shrink-0",l?"text-accent":"text-muted-foreground")}),c.jsx("span",{className:"break-all",children:e.name})]}),l&&s&&e.children&&c.jsx("div",{children:e.children.map(d=>c.jsx(l3e,{entry:d,depth:t+1,selectedFile:n,expandedDirs:r,onSelectFile:i,onToggleDir:a},d.path))})]})}function eWt({entries:e,selectedFile:t,expandedDirs:n,onSelectFile:r,onToggleDir:i,onCollapseAll:a}){const{t:s}=Mt("repositories"),[o,l]=x.useState(""),u=x.useMemo(()=>JVt(e),[e]),d=x.useMemo(()=>{if(!o.trim())return null;const p=o.trim();return u.map(m=>({...m,score:Math.max(al(m.name,p),al(m.path,p))})).filter(m=>m.score>0).sort((m,b)=>b.score-m.score)},[u,o]),f=x.useCallback(()=>{l("")},[]);return e.length===0?c.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:s("detailView.fileTree.noFiles")}):c.jsxs("div",{className:"flex flex-col h-full",style:{background:"var(--gradient-card)"},children:[c.jsxs("div",{className:"flex shrink-0 items-center justify-between px-2 py-1 border-b border-border bg-card",children:[c.jsx("span",{className:"text-xs text-muted-foreground",children:s("detailView.fileTree.title")}),c.jsx("button",{onClick:a,className:"p-1 text-muted-foreground hover:text-foreground rounded hover:bg-muted/50",title:s("detailView.fileTree.collapseAll"),children:c.jsx(ie,{icon:N1e,size:14,strokeWidth:2})})]}),c.jsx("div",{className:"shrink-0 px-2 py-1.5 border-b border-border bg-card",children:c.jsxs("div",{className:"relative",children:[c.jsx("input",{type:"text",value:o,onChange:p=>l(p.target.value),placeholder:s("detailView.fileTree.searchPlaceholder"),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"}),o&&c.jsx("button",{onClick:f,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:c.jsx(ie,{icon:er,size:12,strokeWidth:2})})]})}),c.jsx("div",{className:"py-1 flex-1 overflow-auto",children:d?d.length>0?d.map(p=>c.jsxs("div",{className:je("flex items-center gap-1.5 px-2 py-0.5 cursor-pointer text-sm hover:bg-muted/50",t===p.path&&"bg-primary/10 text-primary"),onClick:()=>r(p.path),children:[c.jsx(ie,{icon:o3e(p.name),size:14,strokeWidth:2,className:"shrink-0 text-muted-foreground"}),c.jsx("span",{className:"truncate",title:p.path,children:p.name}),c.jsx("span",{className:"text-xs text-muted-foreground truncate ml-auto",children:p.path.split("/").slice(0,-1).join("/")})]},p.path)):c.jsx("div",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No matching files"}):e.map(p=>c.jsx(l3e,{entry:p,depth:0,selectedFile:t,expandedDirs:n,onSelectFile:r,onToggleDir:i},p.path))})]})}const tWt="";function nWt({worktreePath:e,filePath:t,currentMtime:n,isDirty:r,pollInterval:i=3e3,enabled:a=!0}){const[s,o]=x.useState(!1),l=x.useRef(null),u=x.useRef(null),d=x.useCallback(async()=>{if(!(!e||!t||!n))try{const p=new URLSearchParams({path:t,root:e}),m=await St(`${tWt}/api/fs/file-stat?${p}`);m.exists&&m.mtime!==n&&u.current!==m.mtime&&(u.current=m.mtime,o(!0))}catch{}},[e,t,n]);x.useEffect(()=>{if(!a||!t||!n){l.current&&(clearInterval(l.current),l.current=null);return}u.current=null;const p=setTimeout(d,500);return l.current=setInterval(d,i),()=>{clearTimeout(p),l.current&&(clearInterval(l.current),l.current=null)}},[a,t,n,i,d]),x.useEffect(()=>{o(!1),u.current=null},[t]);const f=x.useCallback(()=>{o(!1)},[]);return{hasExternalChange:s,isConflict:s&&r,resetExternalChange:f}}function vye(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 rWt(e){if(Array.isArray(e))return e}function iWt(e,t,n){return(t=dWt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function aWt(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(d){u=!0,i=d}finally{try{if(!l&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw i}}return o}}function sWt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
300
+ `))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 YVt({file:e,wrap:t,isCollapsed:n,onToggle:r}){return c.jsxs(PD,{open:!n,onOpenChange:()=>r(),children:[c.jsx(LD,{asChild:!0,children:c.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:[c.jsx(ie,{icon:n?Hc:mc,size:12,strokeWidth:2,className:"text-muted-foreground shrink-0"}),c.jsx("span",{className:"font-mono text-xs text-foreground truncate flex-1",children:e.path}),c.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[e.additions>0&&c.jsxs("span",{className:"text-diff-add-fg",children:["+",e.additions]}),e.additions>0&&e.deletions>0&&" ",e.deletions>0&&c.jsxs("span",{className:"text-diff-remove-fg",children:["-",e.deletions]})]})]})}),c.jsx(MD,{children:c.jsx("div",{className:"font-mono text-xs",children:e.lines.slice(1).map((i,a)=>c.jsxs("div",{className:je("flex px-2 py-0.5",i.type==="added"&&"bg-diff-add-bg",i.type==="removed"&&"bg-diff-remove-bg",i.type==="header"&&"bg-muted/50 text-muted-foreground",i.type==="hunk"&&"bg-diff-add-bg/50 text-diff-add-fg"),children:[(i.type==="added"||i.type==="removed"||i.type==="context")&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"w-10 shrink-0 select-none pr-2 text-right text-muted-foreground",children:i.oldLineNumber??""}),c.jsx("span",{className:"w-10 shrink-0 select-none pr-2 text-right text-muted-foreground",children:i.newLineNumber??""})]}),c.jsxs("span",{className:je("w-4 shrink-0 select-none text-center",i.type==="added"&&"text-diff-add-fg",i.type==="removed"&&"text-diff-remove-fg"),children:[i.type==="added"&&"+",i.type==="removed"&&"-"]}),c.jsx("span",{className:je("flex-1",t?"whitespace-pre-wrap break-all":"whitespace-pre",i.type==="added"&&"text-diff-add-fg",i.type==="removed"&&"text-diff-remove-fg"),children:i.content})]},a))})})]})}function gye({taskId:e,worktreePath:t,baseBranch:n}){const{options:r,setOption:i,toggleFileCollapse:a,collapseAll:s,expandAll:o,isFileCollapsed:l}=GVt(e),{wrap:u,ignoreWhitespace:d,includeUntracked:f,collapsedFiles:p}=r,{data:m,isLoading:b,error:y}=cHe(t,{ignoreWhitespace:d,includeUntracked:f,baseBranch:n}),v=x.useMemo(()=>m?.diff?KVt(m.diff):[],[m?.diff]),_=x.useMemo(()=>v.map(S=>S.path),[v]),E=v.length>0&&p.length===v.length,C=x.useMemo(()=>v.reduce((S,N)=>S+N.additions,0),[v]),T=x.useMemo(()=>v.reduce((S,N)=>S+N.deletions,0),[v]);if(x.useEffect(()=>{const S=N=>{if(N.shiftKey&&N.key==="C"&&!N.ctrlKey&&!N.metaKey&&!N.altKey){const R=N.target;if(R.tagName==="INPUT"||R.tagName==="TEXTAREA"||R.isContentEditable)return;N.preventDefault(),E?o():s(_)}};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[E,_,s,o]),!t)return c.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"No worktree selected"});if(b)return c.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground text-sm",children:"Loading diff..."});if(y)return c.jsx("div",{className:"flex h-full items-center justify-center text-destructive text-sm",children:y.message});const k=m?.files?.some(S=>S.status==="untracked")??!1;return v.length===0?c.jsxs("div",{className:"flex h-full flex-col items-center justify-center text-muted-foreground text-sm gap-2",children:[c.jsx("p",{children:"No changes detected"}),m?.files&&m.files.length>0&&c.jsxs("div",{className:"text-xs",children:[c.jsx("p",{className:"text-center mb-2",children:"Modified files:"}),c.jsxs("div",{className:"flex flex-col gap-1",children:[m.files.map(S=>c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("span",{className:je("w-4 text-center",S.status==="added"&&"text-diff-add-fg",S.status==="deleted"&&"text-diff-remove-fg",S.status==="modified"&&"text-muted-foreground",S.status==="untracked"&&"text-muted-foreground"),children:[S.status==="added"&&"A",S.status==="deleted"&&"D",S.status==="modified"&&"M",S.status==="untracked"&&"?"]}),c.jsx("span",{children:S.path})]},S.path)),k&&c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-muted-foreground hover:text-foreground mt-1",children:[c.jsx("input",{type:"checkbox",checked:f,onChange:S=>i("includeUntracked",S.target.checked),className:"w-4 h-3"}),c.jsx("span",{children:"Show untracked files"})]})]})]})]}):c.jsxs("div",{className:"flex flex-col h-full bg-background",children:[c.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-card border-b border-border text-xs",children:[m?.branch&&c.jsxs("span",{className:"text-muted-foreground",children:[m.branch,m.isBranchDiff&&m.baseBranch&&c.jsxs("span",{className:"opacity-70",children:[" (vs ",m.baseBranch,")"]})]}),(C>0||T>0)&&c.jsxs("span",{className:"text-muted-foreground",children:[c.jsxs("span",{className:"text-diff-add-fg",children:["+",C]})," ",c.jsxs("span",{className:"text-diff-remove-fg",children:["-",T]})]}),c.jsx("div",{className:"flex-1"}),c.jsxs("button",{onClick:()=>E?o():s(_),className:"flex items-center gap-1 px-1.5 py-0.5 text-muted-foreground hover:text-foreground rounded hover:bg-muted/50",title:E?"Expand all (Shift+C)":"Collapse all (Shift+C)",children:[c.jsx(ie,{icon:E?P1e:N1e,size:12,strokeWidth:2}),c.jsx("span",{className:"hidden sm:inline",children:E?"Expand":"Collapse"})]}),c.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-muted-foreground hover:text-foreground",children:[c.jsx("input",{type:"checkbox",checked:u,onChange:S=>i("wrap",S.target.checked),className:"w-3 h-3"}),"Wrap"]}),c.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-muted-foreground hover:text-foreground",children:[c.jsx("input",{type:"checkbox",checked:d,onChange:S=>i("ignoreWhitespace",S.target.checked),className:"w-3 h-3"}),"Ignore whitespace"]}),c.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer text-muted-foreground hover:text-foreground",children:[c.jsx("input",{type:"checkbox",checked:f,onChange:S=>i("includeUntracked",S.target.checked),className:"w-3 h-3"}),"Untracked"]})]}),c.jsx(Kh,{className:"flex-1 min-h-0",children:v.map(S=>c.jsx(YVt,{file:S,wrap:u,isCollapsed:l(S.path),onToggle:()=>a(S.path)},S.path))})]})}function XVt(e){const{viewState:t,setBrowserUrl:n}=zZ(e);return{url:t.browserUrl,setUrl:n}}function bye({taskId:e}){const{url:t,setUrl:n}=XVt(e),[r,i]=x.useState(t),[a,s]=x.useState(0);x.useEffect(()=>{i(t)},[t]);const o=x.useCallback(()=>{s(u=>u+1)},[]),l=x.useCallback(u=>{u.preventDefault();let d=r.trim();!d.startsWith("http://")&&!d.startsWith("https://")&&(d=`http://${d}`),n(d),s(f=>f+1)},[r,n]);return c.jsxs("div",{className:"flex h-full flex-col bg-background",children:[c.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border bg-card px-2 py-1.5",children:[c.jsx(De,{variant:"ghost",size:"icon-xs",disabled:!0,children:c.jsx(ie,{icon:Th,size:14,strokeWidth:2})}),c.jsx(De,{variant:"ghost",size:"icon-xs",disabled:!0,children:c.jsx(ie,{icon:Hc,size:14,strokeWidth:2})}),c.jsx(De,{variant:"ghost",size:"icon-xs",onClick:o,children:c.jsx(ie,{icon:uC,size:14,strokeWidth:2})}),c.jsx("form",{onSubmit:l,className:"flex-1",children:c.jsx(Wt,{value:r,onChange:u=>i(u.target.value),className:"h-7 bg-background text-xs",placeholder:"Enter URL..."})})]}),c.jsx("div",{className:"flex-1 overflow-hidden bg-card",children:c.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)})]})}const ZVt="";function yye(e){const t=[];function n(r){for(const i of r)t.push(`${i.type}:${i.path}`),i.children&&n(i.children)}return n(e),t.sort().join("|")}function QVt({worktreePath:e,currentTree:t,onTreeChanged:n,pollInterval:r=5e3,enabled:i=!0}){const a=x.useRef(null),s=x.useRef(null),o=x.useRef(n);x.useEffect(()=>{o.current=n},[n]),x.useEffect(()=>{t&&(s.current=yye(t))},[t]);const l=x.useCallback(async()=>{if(e)try{const u=await St(`${ZVt}/api/fs/tree?root=${encodeURIComponent(e)}`),d=yye(u.entries);s.current!==null&&d!==s.current&&(s.current=d,o.current(u.entries))}catch{}},[e]);x.useEffect(()=>{if(!i||!e||!t){a.current&&(clearInterval(a.current),a.current=null);return}return a.current=setInterval(l,r),()=>{a.current&&(clearInterval(a.current),a.current=null)}},[i,e,t,r,l]),x.useEffect(()=>{s.current=null},[e])}function JVt(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 o3e(e){const t=e.split(".").pop()?.toLowerCase()||"";return["png","jpg","jpeg","gif","svg","webp","ico"].includes(t)?RFe:["ts","tsx","js","jsx","json","css","html","md","yaml","yml","toml","sh","py","rs","go","sql"].includes(t)?SFe:E1e}function l3e({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=x.useCallback(()=>{l?a(e.path):i(e.path)},[l,e.path,i,a]);return c.jsxs("div",{children:[c.jsxs("div",{className:je("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:[c.jsx(ie,{icon:l?s?TF:Hs:o3e(e.name),size:14,strokeWidth:2,className:je("shrink-0",l?"text-accent":"text-muted-foreground")}),c.jsx("span",{className:"break-all",children:e.name})]}),l&&s&&e.children&&c.jsx("div",{children:e.children.map(d=>c.jsx(l3e,{entry:d,depth:t+1,selectedFile:n,expandedDirs:r,onSelectFile:i,onToggleDir:a},d.path))})]})}function eWt({entries:e,selectedFile:t,expandedDirs:n,onSelectFile:r,onToggleDir:i,onCollapseAll:a}){const{t:s}=Mt("repositories"),[o,l]=x.useState(""),u=x.useMemo(()=>JVt(e),[e]),d=x.useMemo(()=>{if(!o.trim())return null;const p=o.trim();return u.map(m=>({...m,score:Math.max(al(m.name,p),al(m.path,p))})).filter(m=>m.score>0).sort((m,b)=>b.score-m.score)},[u,o]),f=x.useCallback(()=>{l("")},[]);return e.length===0?c.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:s("detailView.fileTree.noFiles")}):c.jsxs("div",{className:"flex flex-col h-full",style:{background:"var(--gradient-card)"},children:[c.jsxs("div",{className:"flex shrink-0 items-center justify-between px-2 py-1 border-b border-border bg-card",children:[c.jsx("span",{className:"text-xs text-muted-foreground",children:s("detailView.fileTree.title")}),c.jsx("button",{onClick:a,className:"p-1 text-muted-foreground hover:text-foreground rounded hover:bg-muted/50",title:s("detailView.fileTree.collapseAll"),children:c.jsx(ie,{icon:N1e,size:14,strokeWidth:2})})]}),c.jsx("div",{className:"shrink-0 px-2 py-1.5 border-b border-border bg-card",children:c.jsxs("div",{className:"relative",children:[c.jsx("input",{type:"text",value:o,onChange:p=>l(p.target.value),placeholder:s("detailView.fileTree.searchPlaceholder"),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"}),o&&c.jsx("button",{onClick:f,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:c.jsx(ie,{icon:er,size:12,strokeWidth:2})})]})}),c.jsx("div",{className:"py-1 flex-1 overflow-auto",children:d?d.length>0?d.map(p=>c.jsxs("div",{className:je("flex items-center gap-1.5 px-2 py-0.5 cursor-pointer text-sm hover:bg-muted/50",t===p.path&&"bg-primary/10 text-primary"),onClick:()=>r(p.path),children:[c.jsx(ie,{icon:o3e(p.name),size:14,strokeWidth:2,className:"shrink-0 text-muted-foreground"}),c.jsx("span",{className:"truncate",title:p.path,children:p.name}),c.jsx("span",{className:"text-xs text-muted-foreground truncate ml-auto",children:p.path.split("/").slice(0,-1).join("/")})]},p.path)):c.jsx("div",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No matching files"}):e.map(p=>c.jsx(l3e,{entry:p,depth:0,selectedFile:t,expandedDirs:n,onSelectFile:r,onToggleDir:i},p.path))})]})}const tWt="";function nWt({worktreePath:e,filePath:t,currentMtime:n,isDirty:r,pollInterval:i=3e3,enabled:a=!0}){const[s,o]=x.useState(!1),l=x.useRef(null),u=x.useRef(null),d=x.useCallback(async()=>{if(!(!e||!t||!n))try{const p=new URLSearchParams({path:t,root:e}),m=await St(`${tWt}/api/fs/file-stat?${p}`);m.exists&&m.mtime!==n&&u.current!==m.mtime&&(u.current=m.mtime,o(!0))}catch{}},[e,t,n]);x.useEffect(()=>{if(!a||!t||!n){l.current&&(clearInterval(l.current),l.current=null);return}u.current=null;const p=setTimeout(d,500);return l.current=setInterval(d,i),()=>{clearTimeout(p),l.current&&(clearInterval(l.current),l.current=null)}},[a,t,n,i,d]),x.useEffect(()=>{o(!1),u.current=null},[t]);const f=x.useCallback(()=>{o(!1)},[]);return{hasExternalChange:s,isConflict:s&&r,resetExternalChange:f}}function vye(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 rWt(e){if(Array.isArray(e))return e}function iWt(e,t,n){return(t=dWt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function aWt(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(d){u=!0,i=d}finally{try{if(!l&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw i}}return o}}function sWt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
301
301
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xye(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 _ye(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?xye(Object(n),!0).forEach(function(r){iWt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xye(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function oWt(e,t){if(e==null)return{};var n,r,i=lWt(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 lWt(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 uWt(e,t){return rWt(e)||aWt(e,t)||fWt(e,t)||sWt()}function cWt(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 dWt(e){var t=cWt(e,"string");return typeof t=="symbol"?t:t+""}function fWt(e,t){if(e){if(typeof e=="string")return vye(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)?vye(e,t):void 0}}function hWt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Sye(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 Eye(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Sye(Object(n),!0).forEach(function(r){hWt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Sye(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function pWt(){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 _S(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 xR(e){return{}.toString.call(e).includes("Object")}function mWt(e){return!Object.keys(e).length}function Ww(e){return typeof e=="function"}function gWt(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function bWt(e,t){return xR(t)||ym("changeType"),Object.keys(t).some(function(n){return!gWt(e,n)})&&ym("changeField"),t}function yWt(e){Ww(e)||ym("selectorType")}function vWt(e){Ww(e)||xR(e)||ym("handlerType"),xR(e)&&Object.values(e).some(function(t){return!Ww(t)})&&ym("handlersType")}function xWt(e){e||ym("initialIsRequired"),xR(e)||ym("initialType"),mWt(e)&&ym("initialContent")}function _Wt(e,t){throw new Error(e[t]||e.default)}var SWt={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"},ym=_S(_Wt)(SWt),KT={changes:bWt,selector:yWt,handler:vWt,initial:xWt};function EWt(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};KT.initial(e),KT.handler(t);var n={current:e},r=_S(kWt)(n,t),i=_S(CWt)(n),a=_S(KT.changes)(e),s=_S(wWt)(n);function o(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(d){return d};return KT.selector(u),u(n.current)}function l(u){pWt(r,i,a,s)(u)}return[o,l]}function wWt(e,t){return Ww(t)?t(e.current):t}function CWt(e,t){return e.current=Eye(Eye({},e.current),t),t}function kWt(e,t,n){return Ww(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 TWt={create:EWt},AWt={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function NWt(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 OWt(e){return{}.toString.call(e).includes("Object")}function RWt(e){return e||wye("configIsRequired"),OWt(e)||wye("configType"),e.urls?(IWt(),{paths:{vs:e.urls.monacoBase}}):e}function IWt(){console.warn(u3e.deprecation)}function DWt(e,t){throw new Error(e[t]||e.default)}var u3e={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!
302
302
  You are using deprecated way of configuration.
303
303