phirepass-widgets 0.0.33 → 0.0.35

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.
@@ -476,7 +476,7 @@ const ErrorType = Object.freeze({
476
476
  function __wbg_get_imports() {
477
477
  const import0 = {
478
478
  __proto__: null,
479
- __wbg_Error_55538483de6e3abe: function(arg0, arg1) {
479
+ __wbg_Error_2e59b1b37a9a34c3: function(arg0, arg1) {
480
480
  const ret = Error(getStringFromWasm0(arg0, arg1));
481
481
  return addHeapObject(ret);
482
482
  },
@@ -487,14 +487,14 @@ function __wbg_get_imports() {
487
487
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
488
488
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
489
489
  },
490
- __wbg___wbindgen_debug_string_d89627202d0155b7: function(arg0, arg1) {
490
+ __wbg___wbindgen_debug_string_dd5d2d07ce9e6c57: function(arg0, arg1) {
491
491
  const ret = debugString(getObject(arg1));
492
492
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
493
493
  const len1 = WASM_VECTOR_LEN;
494
494
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
495
495
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
496
496
  },
497
- __wbg___wbindgen_string_get_f1161390414f9b59: function(arg0, arg1) {
497
+ __wbg___wbindgen_string_get_914df97fcfa788f2: function(arg0, arg1) {
498
498
  const obj = getObject(arg1);
499
499
  const ret = typeof(obj) === 'string' ? obj : undefined;
500
500
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
@@ -502,17 +502,17 @@ function __wbg_get_imports() {
502
502
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
503
503
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
504
504
  },
505
- __wbg___wbindgen_throw_5549492daedad139: function(arg0, arg1) {
505
+ __wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
506
506
  throw new Error(getStringFromWasm0(arg0, arg1));
507
507
  },
508
- __wbg__wbg_cb_unref_fbe69bb076c16bad: function(arg0) {
508
+ __wbg__wbg_cb_unref_3c3b4f651835fbcb: function(arg0) {
509
509
  getObject(arg0)._wbg_cb_unref();
510
510
  },
511
- __wbg_call_6ae20895a60069a2: function() { return handleError(function (arg0, arg1) {
511
+ __wbg_call_7f2987183bb62793: function() { return handleError(function (arg0, arg1) {
512
512
  const ret = getObject(arg0).call(getObject(arg1));
513
513
  return addHeapObject(ret);
514
514
  }, arguments); },
515
- __wbg_call_8f5d7bb070283508: function() { return handleError(function (arg0, arg1, arg2) {
515
+ __wbg_call_d578befcc3145dee: function() { return handleError(function (arg0, arg1, arg2) {
516
516
  const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
517
517
  return addHeapObject(ret);
518
518
  }, arguments); },
@@ -520,18 +520,18 @@ function __wbg_get_imports() {
520
520
  const ret = clearInterval(takeObject(arg0));
521
521
  return addHeapObject(ret);
522
522
  },
523
- __wbg_close_1bf0654059764e94: function() { return handleError(function (arg0) {
523
+ __wbg_close_f181fdc02ee236e6: function() { return handleError(function (arg0) {
524
524
  getObject(arg0).close();
525
525
  }, arguments); },
526
- __wbg_data_7de671a92a650aba: function(arg0) {
526
+ __wbg_data_60b50110c5bd9349: function(arg0) {
527
527
  const ret = getObject(arg0).data;
528
528
  return addHeapObject(ret);
529
529
  },
530
- __wbg_from_45cebbf5e49a6ac6: function(arg0) {
530
+ __wbg_from_741da0f916ab74aa: function(arg0) {
531
531
  const ret = Array.from(getObject(arg0));
532
532
  return addHeapObject(ret);
533
533
  },
534
- __wbg_instanceof_ArrayBuffer_8d855993947fc3a2: function(arg0) {
534
+ __wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a: function(arg0) {
535
535
  let result;
536
536
  try {
537
537
  result = getObject(arg0) instanceof ArrayBuffer;
@@ -541,62 +541,62 @@ function __wbg_get_imports() {
541
541
  const ret = result;
542
542
  return ret;
543
543
  },
544
- __wbg_length_e6e1633fbea6cfa9: function(arg0) {
544
+ __wbg_length_0c32cb8543c8e4c8: function(arg0) {
545
545
  const ret = getObject(arg0).length;
546
546
  return ret;
547
547
  },
548
- __wbg_new_1d96678aaacca32e: function(arg0) {
549
- const ret = new Uint8Array(getObject(arg0));
548
+ __wbg_new_4f9fafbb3909af72: function() {
549
+ const ret = new Object();
550
550
  return addHeapObject(ret);
551
551
  },
552
- __wbg_new_4370be21fa2b2f80: function() {
553
- const ret = new Array();
552
+ __wbg_new_a560378ea1240b14: function(arg0) {
553
+ const ret = new Uint8Array(getObject(arg0));
554
554
  return addHeapObject(ret);
555
555
  },
556
- __wbg_new_48e1d86cfd30c8e7: function() {
557
- const ret = new Object();
556
+ __wbg_new_f3c9df4f38f3f798: function() {
557
+ const ret = new Array();
558
558
  return addHeapObject(ret);
559
559
  },
560
- __wbg_new_with_str_53b505a6bb7f12f6: function() { return handleError(function (arg0, arg1, arg2, arg3) {
560
+ __wbg_new_with_str_7cf464e6e0f54ec2: function() { return handleError(function (arg0, arg1, arg2, arg3) {
561
561
  const ret = new WebSocket(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
562
562
  return addHeapObject(ret);
563
563
  }, arguments); },
564
- __wbg_prototypesetcall_3875d54d12ef2eec: function(arg0, arg1, arg2) {
564
+ __wbg_prototypesetcall_3e05eb9545565046: function(arg0, arg1, arg2) {
565
565
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
566
566
  },
567
- __wbg_readyState_a08d25cc57214030: function(arg0) {
567
+ __wbg_readyState_631d9f7c37e595d7: function(arg0) {
568
568
  const ret = getObject(arg0).readyState;
569
569
  return ret;
570
570
  },
571
- __wbg_send_da543a379e952bc6: function() { return handleError(function (arg0, arg1, arg2) {
571
+ __wbg_send_64dd480ad0d86a31: function() { return handleError(function (arg0, arg1, arg2) {
572
572
  getObject(arg0).send(getArrayU8FromWasm0(arg1, arg2));
573
573
  }, arguments); },
574
574
  __wbg_setInterval_cbf1c35c6a692d37: function() { return handleError(function (arg0, arg1) {
575
575
  const ret = setInterval(getObject(arg0), arg1);
576
576
  return addHeapObject(ret);
577
577
  }, arguments); },
578
- __wbg_set_4702dfa37c77f492: function(arg0, arg1, arg2) {
579
- getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
580
- },
581
578
  __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
582
579
  getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
583
580
  },
584
- __wbg_set_binaryType_0675f0e51c055ca8: function(arg0, arg1) {
581
+ __wbg_set_6c60b2e8ad0e9383: function(arg0, arg1, arg2) {
582
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
583
+ },
584
+ __wbg_set_binaryType_95c0a0f7586a3903: function(arg0, arg1) {
585
585
  getObject(arg0).binaryType = __wbindgen_enum_BinaryType[arg1];
586
586
  },
587
- __wbg_set_onclose_f791ef701be808a0: function(arg0, arg1) {
587
+ __wbg_set_onclose_47cce56c686db4fb: function(arg0, arg1) {
588
588
  getObject(arg0).onclose = getObject(arg1);
589
589
  },
590
- __wbg_set_onerror_e23002e9224d353b: function(arg0, arg1) {
590
+ __wbg_set_onerror_3db8bc3e52b2b10b: function(arg0, arg1) {
591
591
  getObject(arg0).onerror = getObject(arg1);
592
592
  },
593
- __wbg_set_onmessage_d2fe701a9ce80846: function(arg0, arg1) {
593
+ __wbg_set_onmessage_45bd33b110c54f5b: function(arg0, arg1) {
594
594
  getObject(arg0).onmessage = getObject(arg1);
595
595
  },
596
- __wbg_set_onopen_0556381d0db30cbb: function(arg0, arg1) {
596
+ __wbg_set_onopen_7ffeb01f8a628209: function(arg0, arg1) {
597
597
  getObject(arg0).onopen = getObject(arg1);
598
598
  },
599
- __wbg_warn_7e545c047609d0b6: function(arg0, arg1) {
599
+ __wbg_warn_97be992ef0100a92: function(arg0, arg1) {
600
600
  console.warn(getStringFromWasm0(arg0, arg1));
601
601
  },
602
602
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
@@ -1245,8 +1245,8 @@ const PhirepassTerminal = class {
1245
1245
  const rows = this.terminal?.rows ?? 0;
1246
1246
  const px_width = this.containerEl.clientWidth ?? 0;
1247
1247
  const px_height = this.containerEl.clientHeight ?? 0;
1248
- if (cols <= 0 || rows <= 0) {
1249
- console.warn('Cannot send terminal resize: invalid terminal dimensions (cols:', cols, 'rows:', rows, ') ');
1248
+ if (cols <= 0 || rows <= 0 || px_width <= 0 || px_height <= 0) {
1249
+ console.warn(`Cannot send terminal resize: invalid terminal dimensions cols=${cols}, rows=${rows}, px_width=${px_width}, px_height=${px_height}`);
1250
1250
  return;
1251
1251
  }
1252
1252
  try {
@@ -1450,7 +1450,7 @@ const PhirepassTerminal = class {
1450
1450
  this.usernameBuffer = "";
1451
1451
  }
1452
1452
  render() {
1453
- return (index.h(index.Host, { key: '71243a4c9c9468091e5ab830857f91b9b57812b0' }, index.h("div", { key: '0dd9ae1e44cbf78f8a6ede6604c35d7d441cea93', id: "ccc", ref: el => (this.containerEl = el) })));
1453
+ return (index.h(index.Host, { key: '6c6080f3b370c76871ab48695046557c64d173b6' }, index.h("div", { key: '17c80b9c99de88dc53e61e0bf8725dafcf96d3b6', id: "ccc", ref: el => (this.containerEl = el) })));
1454
1454
  }
1455
1455
  static get watchers() { return {
1456
1456
  "nodeId": [{
@@ -267,8 +267,8 @@ export class PhirepassTerminal {
267
267
  const rows = this.terminal?.rows ?? 0;
268
268
  const px_width = this.containerEl.clientWidth ?? 0;
269
269
  const px_height = this.containerEl.clientHeight ?? 0;
270
- if (cols <= 0 || rows <= 0) {
271
- console.warn('Cannot send terminal resize: invalid terminal dimensions (cols:', cols, 'rows:', rows, ') ');
270
+ if (cols <= 0 || rows <= 0 || px_width <= 0 || px_height <= 0) {
271
+ console.warn(`Cannot send terminal resize: invalid terminal dimensions cols=${cols}, rows=${rows}, px_width=${px_width}, px_height=${px_height}`);
272
272
  return;
273
273
  }
274
274
  try {
@@ -472,7 +472,7 @@ export class PhirepassTerminal {
472
472
  this.usernameBuffer = "";
473
473
  }
474
474
  render() {
475
- return (h(Host, { key: '71243a4c9c9468091e5ab830857f91b9b57812b0' }, h("div", { key: '0dd9ae1e44cbf78f8a6ede6604c35d7d441cea93', id: "ccc", ref: el => (this.containerEl = el) })));
475
+ return (h(Host, { key: '6c6080f3b370c76871ab48695046557c64d173b6' }, h("div", { key: '17c80b9c99de88dc53e61e0bf8725dafcf96d3b6', id: "ccc", ref: el => (this.containerEl = el) })));
476
476
  }
477
477
  static get is() { return "phirepass-terminal"; }
478
478
  static get encapsulation() { return "shadow"; }
@@ -46,4 +46,4 @@ import{t,p as i,H as s,c as e,h,a as r}from"./index.js";
46
46
  * Fabrice Bellard's javascript vt100 for jslinux:
47
47
  * http://bellard.org/jslinux/
48
48
  * Copyright (c) 2011 Fabrice Bellard
49
- */function Ol(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}(t=>{t.isLessThan=function(t){return t<0},t.isLessThanOrEqual=function(t){return t<=0},t.isGreaterThan=function(t){return t>0},t.isNeitherLessOrGreaterThan=function(t){return 0===t},t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(yl||={}),(t=>{function i(t){return t&&"object"==typeof t&&"function"==typeof t[Symbol.iterator]}t.is=i;let s=Object.freeze([]);function*e(t){yield t}t.empty=function(){return s},t.single=e,t.wrap=function(t){return i(t)?t:e(t)},t.from=function(t){return t||s},t.reverse=function*(t){for(let i=t.length-1;i>=0;i--)yield t[i]},t.isEmpty=function(t){return!t||!0===t[Symbol.iterator]().next().done},t.first=function(t){return t[Symbol.iterator]().next().value},t.some=function(t,i){let s=0;for(let e of t)if(i(e,s++))return!0;return!1},t.find=function(t,i){for(let s of t)if(i(s))return s},t.filter=function*(t,i){for(let s of t)i(s)&&(yield s)},t.map=function*(t,i){let s=0;for(let e of t)yield i(e,s++)},t.flatMap=function*(t,i){let s=0;for(let e of t)yield*i(e,s++)},t.concat=function*(...t){for(let i of t)yield*i},t.reduce=function(t,i,s){let e=s;for(let s of t)e=i(e,s);return e},t.slice=function*(t,i,s=t.length){for(i<0&&(i+=t.length),s<0?s+=t.length:s>t.length&&(s=t.length);i<s;i++)yield t[i]},t.consume=function(i,s=1/0){let e=[];if(0===s)return[e,i];let h=i[Symbol.iterator]();for(let i=0;i<s;i++){let i=h.next();if(i.done)return[e,t.empty()];e.push(i.value)}return[e,{[Symbol.iterator]:()=>h}]},t.asyncToArray=async function(t){let i=[];for await(let s of t)i.push(s);return Promise.resolve(i)}})(El||={});var Wl=class t{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{!function(t){if(El.is(t)){let i=[];for(let s of t)if(s)try{s.dispose()}catch(t){i.push(t)}if(1===i.length)throw i[0];if(i.length>1)throw new AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}t&&t.dispose()}(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(i),i}delete(t){if(t){if(t===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};Wl.DISABLE_DISPOSED_WARNING=!1;var zl=Wl,ql=class{constructor(){this._store=new zl}dispose(){this._store.dispose()}_register(t){if(t===this)throw Error("Cannot register a disposable on itself!");return this._store.add(t)}};ql.None=Object.freeze({dispose(){}});var Kl=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},jl=class t extends ql{constructor(t){super(),this._terminal=t,this._optionsRefresh=this._register(new Kl),this._oldOpen=this._terminal._core.open,this._terminal._core.open=t=>{this._oldOpen?.call(this._terminal._core,t),this._open()},this._terminal._core.screenElement&&this._open(),this._optionsRefresh.value=this._terminal._core.optionsService.onOptionChange((t=>{"fontSize"===t&&(this.rescaleCanvas(),this._renderService?.refreshRows(0,this._terminal.rows))})),this._register(function(t){return{dispose:Ol((()=>{t()}))}}((()=>{this.removeLayerFromDom(),this._terminal._core&&this._oldOpen&&(this._terminal._core.open=this._oldOpen,this._oldOpen=void 0),this._renderService&&this._oldSetRenderer&&(this._renderService.setRenderer=this._oldSetRenderer,this._oldSetRenderer=void 0),this._renderService=void 0,this.canvas=void 0,this._ctx=void 0,this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0})))}static createCanvas(t,i,s){let e=(t||document).createElement("canvas");return e.width=0|i,e.height=0|s,e}static createImageData(t,i,s,e){if("function"!=typeof ImageData){let h=t.createImageData(i,s);return e&&h.data.set(new Uint8ClampedArray(e,0,i*s*4)),h}return e?new ImageData(new Uint8ClampedArray(e,0,i*s*4),i,s):new ImageData(i,s)}static createImageBitmap(t){return"function"!=typeof createImageBitmap?Promise.resolve(void 0):createImageBitmap(t)}showPlaceholder(t){t?!this._placeholder&&-1!==this.cellSize.height&&this._createPlaceHolder(Math.max(this.cellSize.height+1,24)):(this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0),this._renderService?.refreshRows(0,this._terminal.rows)}get dimensions(){return this._renderService?.dimensions}get cellSize(){return{width:this.dimensions?.css.cell.width||-1,height:this.dimensions?.css.cell.height||-1}}clearLines(t,i){this._ctx?.clearRect(0,t*(this.dimensions?.css.cell.height||0),this.dimensions?.css.canvas.width||0,(++i-t)*(this.dimensions?.css.cell.height||0))}clearAll(){this._ctx?.clearRect(0,0,this.canvas?.width||0,this.canvas?.height||0)}draw(t,i,s,e,h=1){if(!this._ctx)return;let{width:r,height:n}=this.cellSize;if(-1===r||-1===n)return;this._rescaleImage(t,r,n);let o=t.actual,a=Math.ceil(o.width/r),l=i%a*r,c=Math.floor(i/a)*n,u=s*r,A=e*n,f=h*r+l>o.width?o.width-l:h*r,d=c+n>o.height?o.height-c:n;this._ctx.drawImage(o,Math.floor(l),Math.floor(c),Math.ceil(f),Math.ceil(d),Math.floor(u),Math.floor(A),Math.ceil(f),Math.ceil(d))}extractTile(i,s){let{width:e,height:h}=this.cellSize;if(-1===e||-1===h)return;this._rescaleImage(i,e,h);let r=i.actual,n=Math.ceil(r.width/e),o=s%n*e,a=Math.floor(s/n)*h,l=e+o>r.width?r.width-o:e,c=a+h>r.height?r.height-a:h,u=t.createCanvas(this.document,l,c),A=u.getContext("2d");return A?(A.drawImage(r,Math.floor(o),Math.floor(a),Math.floor(l),Math.floor(c),0,0,Math.floor(l),Math.floor(c)),u):void 0}drawPlaceholder(t,i,s=1){if(this._ctx){let{width:e,height:h}=this.cellSize;if(-1===e||-1===h||(this._placeholder?h>=this._placeholder.height&&this._createPlaceHolder(h+1):this._createPlaceHolder(Math.max(h+1,24)),!this._placeholder))return;this._ctx.drawImage(this._placeholderBitmap||this._placeholder,t*e,i*h%2?0:1,e*s,h,t*e,i*h,e*s,h)}}rescaleCanvas(){this.canvas&&(this.canvas.width!==this.dimensions.css.canvas.width||this.canvas.height!==this.dimensions.css.canvas.height)&&(this.canvas.width=this.dimensions.css.canvas.width||0,this.canvas.height=this.dimensions.css.canvas.height||0)}_rescaleImage(i,s,e){if(s===i.actualCellSize.width&&e===i.actualCellSize.height)return;let{width:h,height:r}=i.origCellSize;if(s===h&&e===r)return i.actual=i.orig,i.actualCellSize.width=h,void(i.actualCellSize.height=r);let n=t.createCanvas(this.document,Math.ceil(i.orig.width*s/h),Math.ceil(i.orig.height*e/r)),o=n.getContext("2d");o&&(o.drawImage(i.orig,0,0,n.width,n.height),i.actual=n,i.actualCellSize.width=s,i.actualCellSize.height=e)}_open(){this._renderService=this._terminal._core._renderService,this._oldSetRenderer=this._renderService.setRenderer.bind(this._renderService),this._renderService.setRenderer=t=>{this.removeLayerFromDom(),this._oldSetRenderer?.call(this._renderService,t)}}insertLayerToDom(){this.document&&this._terminal._core.screenElement?this.canvas||(this.canvas=t.createCanvas(this.document,this.dimensions?.css.canvas.width||0,this.dimensions?.css.canvas.height||0),this.canvas.classList.add("xterm-image-layer"),this._terminal._core.screenElement.appendChild(this.canvas),this._ctx=this.canvas.getContext("2d",{alpha:!0,desynchronized:!0}),this.clearAll()):console.warn("image addon: cannot insert output canvas to DOM, missing document or screenElement")}removeLayerFromDom(){this.canvas&&(this._ctx=void 0,this.canvas.remove(),this.canvas=void 0)}_createPlaceHolder(i=24){this._placeholderBitmap?.close(),this._placeholderBitmap=void 0;let s=32,e=t.createCanvas(this.document,s,i),h=e.getContext("2d",{alpha:!1});if(!h)return;let r=t.createImageData(h,s,i),n=new Uint32Array(r.data.buffer),o=(0,Jl.toRGBA8888)(0,0,0),a=(0,Jl.toRGBA8888)(255,255,255);n.fill(o);for(let t=0;t<i;++t){let i=t%2,e=t*s;for(let t=0;t<s;t+=2)n[e+t+i]=a}h.putImageData(r,0,0);let l=screen.width+s-1&-32||4096;this._placeholder=t.createCanvas(this.document,l,i);let c=this._placeholder.getContext("2d",{alpha:!1});if(c){for(let t=0;t<l;t+=s)c.drawImage(e,t,0);t.createImageBitmap(this._placeholder).then((t=>this._placeholderBitmap=t))}else this._placeholder=void 0}get document(){return this._terminal._core._coreBrowserService?.window.document}},Yl={width:7,height:14},Zl=class t{constructor(t=0,i=0,s=-1,e=-1){this.imageId=s,this.tileId=e,this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(t){this._ext&=-67108864,this._ext|=67108863&t}get underlineVariantOffset(){let t=(3758096384&this._ext)>>29;return t<0?4294967288^t:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}get urlId(){return this._urlId}set urlId(t){this._urlId=t}clone(){return new t(this._ext,this._urlId,this.imageId,this.tileId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId&&-1===this.imageId}},Xl=new Zl,Vl=class{constructor(t,i,s){this._terminal=t,this._renderer=i,this._opts=s,this._images=new Map,this._lastId=0,this._lowestId=0,this._fullyCleared=!1,this._needsFullClear=!1,this._pixelLimit=25e5;try{this.setLimit(this._opts.storageLimit)}catch(t){console.error(t.message),console.warn(`storageLimit is set to ${this.getLimit()} MB`)}this._viewportMetrics={cols:this._terminal.cols,rows:this._terminal.rows}}dispose(){this.reset()}reset(){for(let t of this._images.values())t.marker?.dispose();this._images.clear(),this._renderer.clearAll()}getLimit(){return 4*this._pixelLimit/1e6}setLimit(t){if(t<.5||t>1e3)throw RangeError("invalid storageLimit, should be at least 0.5 MB and not exceed 1G");this._pixelLimit=t/4*1e6>>>0,this._evictOldest(0)}getUsage(){return 4*this._getStoredPixels()/1e6}_getStoredPixels(){let t=0;for(let i of this._images.values())i.orig&&(t+=i.orig.width*i.orig.height,i.actual&&i.actual!==i.orig&&(t+=i.actual.width*i.actual.height));return t}_delImg(t){let i=this._images.get(t);this._images.delete(t),i&&window.ImageBitmap&&i.orig instanceof ImageBitmap&&i.orig.close()}wipeAlternate(){let t=[];for(let[i,s]of this._images.entries())"alternate"===s.bufferType&&(s.marker?.dispose(),t.push(i));for(let i of t)this._delImg(i);this._needsFullClear=!0,this._fullyCleared=!1}advanceCursor(t){if(this._opts.sixelScrolling){let i=this._renderer.cellSize;(-1===i.width||-1===i.height)&&(i=Yl);let s=Math.ceil(t/i.height);for(let t=1;t<s;++t)this._terminal._core._inputHandler.lineFeed()}}addImage(t){this._evictOldest(t.width*t.height);let i=this._renderer.cellSize;(-1===i.width||-1===i.height)&&(i=Yl);let s=Math.ceil(t.width/i.width),e=Math.ceil(t.height/i.height),h=++this._lastId,r=this._terminal._core.buffer,n=this._terminal.cols,o=this._terminal.rows,a=r.x,l=r.y,c=a,u=0;this._opts.sixelScrolling||(r.x=0,r.y=0,c=0),this._terminal._core._inputHandler._dirtyRowTracker.markDirty(r.y);for(let t=0;t<e;++t){let i=r.lines.get(r.y+r.ybase);for(let e=0;e<s&&!(c+e>=n);++e)this._writeToCell(i,c+e,h,t*s+e),u++;if(this._opts.sixelScrolling)t<e-1&&this._terminal._core._inputHandler.lineFeed();else if(++r.y>=o)break;r.x=c}this._terminal._core._inputHandler._dirtyRowTracker.markDirty(r.y),this._opts.sixelScrolling?r.x=c:(r.x=a,r.y=l);let A=[];for(let[t,i]of this._images.entries())i.tileCount<1&&(i.marker?.dispose(),A.push(t));for(let t of A)this._delImg(t);let f=this._terminal.registerMarker(0);f?.onDispose((()=>{this._images.get(h)&&this._delImg(h)})),"alternate"===this._terminal.buffer.active.type&&this._evictOnAlternate();let d={orig:t,origCellSize:i,actual:t,actualCellSize:{...i},marker:f||void 0,tileCount:u,bufferType:this._terminal.buffer.active.type};this._images.set(h,d)}render(t){if(!this._renderer.canvas&&this._images.size&&(this._renderer.insertLayerToDom(),!this._renderer.canvas))return;if(this._renderer.rescaleCanvas(),!this._images.size)return this._fullyCleared||(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1),void(this._renderer.canvas&&this._renderer.removeLayerFromDom());this._needsFullClear&&(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1);let{start:i,end:s}=t,e=this._terminal._core.buffer,h=this._terminal._core.cols;this._renderer.clearLines(i,s);for(let t=i;t<=s;++t){let i=e.lines.get(t+e.ydisp);if(!i)return;for(let s=0;s<h;++s)if(268435456&i.getBg(s)){let e=i._extendedAttrs[s]||Xl,r=e.imageId;if(void 0===r||-1===r)continue;let n=this._images.get(r);if(-1!==e.tileId){let o=e.tileId,a=s,l=1;for(;++s<h&&268435456&i.getBg(s)&&(e=i._extendedAttrs[s]||Xl)&&e.imageId===r&&e.tileId===o+l;)l++;s--,n?n.actual&&this._renderer.draw(n,o,a,t,l):this._opts.showPlaceholder&&this._renderer.drawPlaceholder(a,t,l),this._fullyCleared=!1}}}}viewportResize(t){if(!this._images.size)return void(this._viewportMetrics=t);if(this._viewportMetrics.cols>=t.cols)return void(this._viewportMetrics=t);let i=this._terminal._core.buffer,s=i.lines.length,e=this._viewportMetrics.cols-1;for(let h=0;h<s;++h){let s=i.lines.get(h);if(268435456&s.getBg(e)){let i=s._extendedAttrs[e]||Xl,h=i.imageId;if(void 0===h||-1===h)continue;let r=this._images.get(h);if(!r)continue;let n=Math.ceil((r.actual?.width||0)/r.actualCellSize.width);if(i.tileId%n+1>=n)continue;let o=!1;for(let i=e+1;i>t.cols;++i)if(4194303&s._data[3*i+0]){o=!0;break}if(o)continue;let a=Math.min(t.cols,n-i.tileId%n+e),l=i.tileId;for(let t=e+1;t<a;++t)this._writeToCell(s,t,h,++l),r.tileCount++}}this._viewportMetrics=t}getImageAtBufferCell(t,i){let s=this._terminal._core.buffer.lines.get(i);if(s&&268435456&s.getBg(t)){let i=s._extendedAttrs[t]||Xl;if(i.imageId&&-1!==i.imageId){let t=this._images.get(i.imageId)?.orig;if(window.ImageBitmap&&t instanceof ImageBitmap){let i=jl.createCanvas(window.document,t.width,t.height);return i.getContext("2d")?.drawImage(t,0,0,t.width,t.height),i}return t}}}extractTileAtBufferCell(t,i){let s=this._terminal._core.buffer.lines.get(i);if(s&&268435456&s.getBg(t)){let i=s._extendedAttrs[t]||Xl;if(i.imageId&&-1!==i.imageId&&-1!==i.tileId){let t=this._images.get(i.imageId);if(t)return this._renderer.extractTile(t,i.tileId)}}}_evictOldest(t){let i=this._getStoredPixels(),s=i;for(;this._pixelLimit<s+t&&this._images.size;){let t=this._images.get(++this._lowestId);t&&t.orig&&(s-=t.orig.width*t.orig.height,t.actual&&t.orig!==t.actual&&(s-=t.actual.width*t.actual.height),t.marker?.dispose(),this._delImg(this._lowestId))}return i-s}_writeToCell(t,i,s,e){if(268435456&t._data[3*i+2]){let h=t._extendedAttrs[i];if(h){if(void 0!==h.imageId){let t=this._images.get(h.imageId);return t&&t.tileCount--,h.imageId=s,void(h.tileId=e)}return void(t._extendedAttrs[i]=new Zl(h.ext,h.urlId,s,e))}}t._data[3*i+2]|=268435456,t._extendedAttrs[i]=new Zl(0,0,s,e)}_evictOnAlternate(){for(let t of this._images.values())"alternate"===t.bufferType&&(t.tileCount=0);let t=this._terminal._core.buffer;for(let i=0;i<this._terminal.rows;++i){let s=t.lines.get(i);if(s)for(let t=0;t<this._terminal.cols;++t)if(268435456&s._data[3*t+2]){let i=s._extendedAttrs[t]?.imageId;if(i){let t=this._images.get(i);t&&t.tileCount++}}}let i=[];for(let[t,s]of this._images.entries())"alternate"===s.bufferType&&!s.tileCount&&(s.marker?.dispose(),i.push(t));for(let t of i)this._delImg(t)}},tc=Fl(Tl());function ic(t){let i="";for(let s=0;s<t.length;++s)i+=String.fromCharCode(t[s]);return i}function sc(t){let i=0;for(let s=0;s<t.length;++s){if(t[s]<48||t[s]>57)throw Error("illegal char");i=10*i+t[s]-48}return i}function ec(t){let i=ic(t);if(!i.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw Error("illegal size");return i}var hc={inline:sc,size:sc,name:function(t){if(typeof Buffer<"u")return""+Buffer.from(ic(t),"base64");let i=atob(ic(t)),s=new Uint8Array(i.length);for(let t=0;t<s.length;++t)s[t]=i.charCodeAt(t);return(new TextDecoder).decode(s)},width:ec,height:ec,preserveAspectRatio:sc},rc=[70,105,108,101],nc=1024,oc=class{constructor(){this.state=0,this._buffer=new Uint32Array(nc),this._position=0,this._key="",this.fields={}}reset(){this._buffer.fill(0),this.state=0,this._position=0,this.fields={},this._key=""}parse(t,i,s){let e=this.state,h=this._position,r=this._buffer;if(1===e||4===e||0===e&&h>6)return-1;for(let n=i;n<s;++n){let i=t[n];switch(i){case 59:if(!this._storeValue(h))return this._a();e=2,h=0;break;case 61:if(0===e){for(let t=0;t<4;++t)if(r[t]!==rc[t])return this._a();e=2,h=0}else if(2===e){if(!this._storeKey(h))return this._a();e=3,h=0}else if(3===e){if(h>=nc)return this._a();r[h++]=i}break;case 58:return 3!==e||this._storeValue(h)?(this.state=4,n+1):this._a();default:if(h>=nc)return this._a();r[h++]=i}}return this.state=e,this._position=h,-2}_a(){return this.state=1,-1}_storeKey(t){let i=ic(this._buffer.subarray(0,t));return!!i&&(this._key=i,this.fields[i]=null,!0)}_storeValue(t){if(this._key){try{let i=this._buffer.slice(0,t);this.fields[this._key]=hc[this._key]?hc[this._key](i):i}catch{return!1}return!0}return!1}},ac={mime:"unsupported",width:0,height:0},lc={name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},cc=class{constructor(t,i,s,e){this._opts=t,this._renderer=i,this._storage=s,this._coreTerminal=e,this._aborted=!1,this._hp=new oc,this._header=lc,this._dec=new tc.default(4194304),this._metrics=ac}reset(){}start(){this._aborted=!1,this._header=lc,this._metrics=ac,this._hp.reset()}put(t,i,s){if(!this._aborted)if(4===this._hp.state)this._dec.put(t,i,s)&&(this._dec.release(),this._aborted=!0);else{let e=this._hp.parse(t,i,s);if(-1===e)return void(this._aborted=!0);if(e>0){if(this._header=Object.assign({},lc,this._hp.fields),!this._header.inline||!this._header.size||this._header.size>this._opts.iipSizeLimit)return void(this._aborted=!0);this._dec.init(this._header.size),this._dec.put(t,e,s)&&(this._dec.release(),this._aborted=!0)}}}end(t){if(this._aborted)return!0;let i=0,s=0,e=!0;if((e=t)&&(e=!this._dec.end())&&(this._metrics=function(t){if(t.length<24)return ac;let i=new Uint32Array(t.buffer,t.byteOffset,6);if(1196314761===i[0]&&169478669===i[1]&&1380206665===i[3])return{mime:"image/png",width:t[16]<<24|t[17]<<16|t[18]<<8|t[19],height:t[20]<<24|t[21]<<16|t[22]<<8|t[23]};if(255===t[0]&&216===t[1]&&255===t[2]){let[i,s]=function(t){let i=t.length,s=4,e=t[s]<<8|t[s+1];for(;;){if(s+=e,s>=i)return[0,0];if(255!==t[s])return[0,0];if(192===t[s+1]||194===t[s+1])return s+8<i?[t[s+7]<<8|t[s+8],t[s+5]<<8|t[s+6]]:[0,0];s+=2,e=t[s]<<8|t[s+1]}}(t);return{mime:"image/jpeg",width:i,height:s}}return 944130375!==i[0]||55!==t[4]&&57!==t[4]||97!==t[5]?ac:{mime:"image/gif",width:t[7]<<8|t[6],height:t[9]<<8|t[8]}}(this._dec.data8),(e="unsupported"!==this._metrics.mime)&&(i=this._metrics.width,s=this._metrics.height,(e=i&&s&&i*s<this._opts.pixelLimit)&&([i,s]=this._resize(i,s).map(Math.floor),e=i&&s&&i*s<this._opts.pixelLimit))),!e)return this._dec.release(),!0;let h=new Blob([this._dec.data8],{type:this._metrics.mime});if(this._dec.release(),!window.createImageBitmap){let t=URL.createObjectURL(h),e=new Image;return new Promise((h=>{e.addEventListener("load",(()=>{URL.revokeObjectURL(t);let r=jl.createCanvas(window.document,i,s);r.getContext("2d")?.drawImage(e,0,0,i,s),this._storage.addImage(r),h(!0)})),e.src=t,setTimeout((()=>h(!0)),1e3)}))}return createImageBitmap(h,{resizeWidth:i,resizeHeight:s}).then((t=>(this._storage.addImage(t),!0)))}_resize(t,i){let s=this._renderer.dimensions?.css.cell.width||Yl.width,e=this._renderer.dimensions?.css.cell.height||Yl.height,h=this._renderer.dimensions?.css.canvas.width||s*this._coreTerminal.cols,r=this._renderer.dimensions?.css.canvas.height||e*this._coreTerminal.rows,n=this._dim(this._header.width,h,s),o=this._dim(this._header.height,r,e);if(!n&&!o){let s=Math.min(h/t,(r-e)/i);return s<1?[t*s,i*s]:[t,i]}return n?!this._header.preserveAspectRatio&&n&&o?[n,o]:[n,i*n/t]:[t*o/i,o]}_dim(t,i,s){return"auto"===t?0:t.endsWith("%")?parseInt(t.slice(0,-1))*i/100:t.endsWith("px")?parseInt(t.slice(0,-2)):parseInt(t)*s}},uc=Fl(Hl()),Ac=Fl(Pl()),fc=uc.PALETTE_ANSI_256;fc.set(uc.PALETTE_VT340_COLOR);var dc=class{constructor(t,i,s){this._opts=t,this._storage=i,this._coreTerminal=s,this._size=0,this._aborted=!1,(0,Ac.DecoderAsync)({memoryLimit:4*this._opts.pixelLimit,palette:fc,paletteLimit:this._opts.sixelPaletteLimit}).then((t=>this._dec=t))}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,fc,this._opts.sixelPaletteLimit))}hook(t){if(this._size=0,this._aborted=!1,this._dec){let i=1===t.params[1]?0:function(t,i){let s=0;if(!i)return s;if(t.isInverse())if(t.isFgDefault())s=gc(i.foreground.rgba);else if(t.isFgRGB()){let i=t.constructor.toColorRGB(t.getFgColor());s=(0,uc.toRGBA8888)(...i)}else s=gc(i.ansi[t.getFgColor()].rgba);else if(t.isBgDefault())s=gc(i.background.rgba);else if(t.isBgRGB()){let i=t.constructor.toColorRGB(t.getBgColor());s=(0,uc.toRGBA8888)(...i)}else s=gc(i.ansi[t.getBgColor()].rgba);return s}(this._coreTerminal._core._inputHandler._curAttrData,this._coreTerminal._core._themeService?.colors);this._dec.init(i,null,this._opts.sixelPaletteLimit)}}put(t,i,s){if(!this._aborted&&this._dec){if(this._size+=s-i,this._size>this._opts.sixelSizeLimit)return console.warn("SIXEL: too much data, aborting"),this._aborted=!0,void this._dec.release();try{this._dec.decode(t,i,s)}catch(t){console.warn("SIXEL: error while decoding image - "+t),this._aborted=!0,this._dec.release()}}}unhook(t){if(this._aborted||!t||!this._dec)return!0;let i=this._dec.width,s=this._dec.height;if(!i||!s)return s&&this._storage.advanceCursor(s),!0;let e=jl.createCanvas(void 0,i,s);return e.getContext("2d")?.putImageData(new ImageData(this._dec.data8,i,s),0,0),this._dec.memoryUsage>4194304&&this._dec.release(),this._storage.addImage(e),!0}};function gc(t){return uc.BIG_ENDIAN?t:(255&t)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255}var wc={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7},pc=class{constructor(t){this._disposables=[],this._handlers=new Map,this._opts=Object.assign({},wc,t),this._defaultOpts=Object.assign({},wc,t)}dispose(){for(let t of this._disposables)t.dispose();this._disposables.length=0,this._handlers.clear()}_disposeLater(...t){for(let i of t)this._disposables.push(i)}activate(t){if(this._terminal=t,this._renderer=new jl(t),this._storage=new Vl(t,this._renderer,this._opts),this._opts.enableSizeReports){let i=t.options.windowOptions||{};i.getWinSizePixels=!0,i.getCellSizePixels=!0,i.getWinSizeChars=!0,t.options.windowOptions=i}if(this._disposeLater(this._renderer,this._storage,t.parser.registerCsiHandler({prefix:"?",final:"h"},(t=>this._decset(t))),t.parser.registerCsiHandler({prefix:"?",final:"l"},(t=>this._decrst(t))),t.parser.registerCsiHandler({final:"c"},(t=>this._da1(t))),t.parser.registerCsiHandler({prefix:"?",final:"S"},(t=>this._xtermGraphicsAttributes(t))),t.onRender((t=>this._storage?.render(t))),t.parser.registerCsiHandler({intermediates:"!",final:"p"},(()=>this.reset())),t.parser.registerEscHandler({final:"c"},(()=>this.reset())),t._core._inputHandler.onRequestReset((()=>this.reset())),t.buffer.onBufferChange((()=>this._storage?.wipeAlternate())),t.onResize((t=>this._storage?.viewportResize(t)))),this._opts.sixelSupport){let i=new dc(this._opts,this._storage,t);this._handlers.set("sixel",i),this._disposeLater(t._core._inputHandler._parser.registerDcsHandler({final:"q"},i))}if(this._opts.iipSupport){let i=new cc(this._opts,this._renderer,this._storage,t);this._handlers.set("iip",i),this._disposeLater(t._core._inputHandler._parser.registerOscHandler(1337,i))}}reset(){this._opts.sixelScrolling=this._defaultOpts.sixelScrolling,this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._storage?.reset();for(let t of this._handlers.values())t.reset();return!1}get storageLimit(){return this._storage?.getLimit()||-1}set storageLimit(t){this._storage?.setLimit(t),this._opts.storageLimit=t}get storageUsage(){return this._storage?this._storage.getUsage():-1}get showPlaceholder(){return this._opts.showPlaceholder}set showPlaceholder(t){this._opts.showPlaceholder=t,this._renderer?.showPlaceholder(t)}getImageAtBufferCell(t,i){return this._storage?.getImageAtBufferCell(t,i)}extractTileAtBufferCell(t,i){return this._storage?.extractTileAtBufferCell(t,i)}_report(t){this._terminal?._core.coreService.triggerDataEvent(t)}_decset(t){for(let i=0;i<t.length;++i)80===t[i]&&(this._opts.sixelScrolling=!1);return!1}_decrst(t){for(let i=0;i<t.length;++i)80===t[i]&&(this._opts.sixelScrolling=!0);return!1}_da1(t){return!!t[0]||!!this._opts.sixelSupport&&(this._report("[?62;4;9;22c"),!0)}_xtermGraphicsAttributes(t){if(t.length<2)return!0;if(1===t[0])switch(t[1]){case 1:return this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`),!0;case 2:this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`);for(let t of this._handlers.values())t.reset();return!0;case 3:return t.length>2&&!(t[2]instanceof Array)&&t[2]<=4096?(this._opts.sixelPaletteLimit=t[2],this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`)):this._report(`[?${t[0]};2S`),!0;case 4:return this._report(`[?${t[0]};0;4096S`),!0;default:return this._report(`[?${t[0]};2S`),!0}if(2===t[0])switch(t[1]){case 1:let i=this._renderer?.dimensions?.css.canvas.width,s=this._renderer?.dimensions?.css.canvas.height;if(!i||!s){let t=Yl;i=(this._terminal?.cols||80)*t.width,s=(this._terminal?.rows||24)*t.height}if(i*s<this._opts.pixelLimit)this._report(`[?${t[0]};0;${i.toFixed(0)};${s.toFixed(0)}S`);else{let i=Math.floor(Math.sqrt(this._opts.pixelLimit));this._report(`[?${t[0]};0;${i};${i}S`)}return!0;case 4:let e=Math.floor(Math.sqrt(this._opts.pixelLimit));return this._report(`[?${t[0]};0;${e};${e}S`),!0;default:return this._report(`[?${t[0]};2S`),!0}return this._report(`[?${t[0]};1S`),!0}};class Cc{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,Ec.unregister(this),t}free(){const t=this.__destroy_into_raw();Kc.__wbg_channel_free(t,0)}authenticate(t,i,s){const e=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),h=jc,r=Pc(i,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_authenticate(this.__wbg_ptr,e,h,r,jc,Tc(s)?4294967297:s>>>0)}connect(){Kc.channel_connect(this.__wbg_ptr)}disconnect(){Kc.channel_disconnect(this.__wbg_ptr)}is_connected(){return 0!==Kc.channel_is_connected(this.__wbg_ptr)}is_disconnected(){return 0!==Kc.channel_is_disconnected(this.__wbg_ptr)}constructor(t,i,s){const e=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),h=jc,r=Pc(i,Kc.__wbindgen_export,Kc.__wbindgen_export2),n=jc;var o=Tc(s)?0:Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2);const a=Kc.channel_new(e,h,r,n,o,jc);return this.__wbg_ptr=a>>>0,Ec.register(this,this.__wbg_ptr,this),this}on_connection_close(t){Kc.channel_on_connection_close(this.__wbg_ptr,Tc(t)?0:Qc(t))}on_connection_error(t){Kc.channel_on_connection_error(this.__wbg_ptr,Tc(t)?0:Qc(t))}on_connection_message(t){Kc.channel_on_connection_message(this.__wbg_ptr,Tc(t)?0:Qc(t))}on_connection_open(t){Kc.channel_on_connection_open(this.__wbg_ptr,Tc(t)?0:Qc(t))}on_protocol_message(t){Kc.channel_on_protocol_message(this.__wbg_ptr,Tc(t)?0:Qc(t))}open_sftp_tunnel(t,i,s,e){const h=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),r=jc;var n=Tc(i)?0:Pc(i,Kc.__wbindgen_export,Kc.__wbindgen_export2),o=jc,a=Tc(s)?0:Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_open_sftp_tunnel(this.__wbg_ptr,h,r,n,o,a,jc,Tc(e)?4294967297:e>>>0)}open_ssh_tunnel(t,i,s,e){const h=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),r=jc;var n=Tc(i)?0:Pc(i,Kc.__wbindgen_export,Kc.__wbindgen_export2),o=jc,a=Tc(s)?0:Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_open_ssh_tunnel(this.__wbg_ptr,h,r,n,o,a,jc,Tc(e)?4294967297:e>>>0)}send_sftp_delete(t,i,s,e,h){const r=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),n=jc,o=Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2),a=jc,l=Pc(e,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_sftp_delete(this.__wbg_ptr,r,n,i,o,a,l,jc,Tc(h)?4294967297:h>>>0)}send_sftp_download_chunk(t,i,s,e,h){const r=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_sftp_download_chunk(this.__wbg_ptr,r,jc,i,s,e,Tc(h)?4294967297:h>>>0)}send_sftp_download_start(t,i,s,e,h){const r=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),n=jc,o=Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2),a=jc,l=Pc(e,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_sftp_download_start(this.__wbg_ptr,r,n,i,o,a,l,jc,Tc(h)?4294967297:h>>>0)}send_sftp_list_data(t,i,s,e){const h=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),r=jc,n=Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_sftp_list_data(this.__wbg_ptr,h,r,i,n,jc,Tc(e)?4294967297:e>>>0)}send_sftp_upload_chunk(t,i,s,e,h,r,n){const o=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),a=jc,l=function(t){const i=(0,Kc.__wbindgen_export)(1*t.length,1)>>>0;return Rc().set(t,i/1),jc=t.length,i}(r);Kc.channel_send_sftp_upload_chunk(this.__wbg_ptr,o,a,i,s,e,h,l,jc,Tc(n)?4294967297:n>>>0)}send_sftp_upload_start(t,i,s,e,h,r,n){const o=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),a=jc,l=Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2),c=jc,u=Pc(e,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_sftp_upload_start(this.__wbg_ptr,o,a,i,l,c,u,jc,h,r,Tc(n)?4294967297:n>>>0)}send_ssh_terminal_resize(t,i,s,e,h,r){const n=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_ssh_terminal_resize(this.__wbg_ptr,n,jc,i,s,e,h,r)}send_ssh_tunnel_data(t,i,s){const e=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),h=jc,r=Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_ssh_tunnel_data(this.__wbg_ptr,e,h,i,r,jc)}start_heartbeat(t){Kc.channel_start_heartbeat(this.__wbg_ptr,t)}stop_heartbeat(){Kc.channel_stop_heartbeat(this.__wbg_ptr)}}Symbol.dispose&&(Cc.prototype[Symbol.dispose]=Cc.prototype.free);const mc=Object.freeze({Generic:0,0:"Generic",RequiresUsername:100,100:"RequiresUsername",RequiresPassword:110,110:"RequiresPassword"});function Ic(){const t={__proto__:null,__wbg_Error_55538483de6e3abe:function(t,i){return Qc(Error(Sc(t,i)))},__wbg_String_8564e559799eccda:function(t,i){const s=Pc(Nc(i)+"",Kc.__wbindgen_export,Kc.__wbindgen_export2),e=jc;_c().setInt32(t+4,e,!0),_c().setInt32(t+0,s,!0)},__wbg___wbindgen_debug_string_d89627202d0155b7:function(t,i){const s=Pc(xc(Nc(i)),Kc.__wbindgen_export,Kc.__wbindgen_export2),e=jc;_c().setInt32(t+4,e,!0),_c().setInt32(t+0,s,!0)},__wbg___wbindgen_string_get_f1161390414f9b59:function(t,i){const s=Nc(i),e="string"==typeof s?s:void 0;var h=Tc(e)?0:Pc(e,Kc.__wbindgen_export,Kc.__wbindgen_export2),r=jc;_c().setInt32(t+4,r,!0),_c().setInt32(t+0,h,!0)},__wbg___wbindgen_throw_5549492daedad139:function(t,i){throw Error(Sc(t,i))},__wbg__wbg_cb_unref_fbe69bb076c16bad:function(t){Nc(t)._wbg_cb_unref()},__wbg_call_6ae20895a60069a2:function(){return Fc((function(t,i){return Qc(Nc(t).call(Nc(i)))}),arguments)},__wbg_call_8f5d7bb070283508:function(){return Fc((function(t,i,s){return Qc(Nc(t).call(Nc(i),Nc(s)))}),arguments)},__wbg_clearInterval_26ba580547547579:function(t){return Qc(clearInterval(Jc(t)))},__wbg_close_1bf0654059764e94:function(){return Fc((function(t){Nc(t).close()}),arguments)},__wbg_data_7de671a92a650aba:function(t){return Qc(Nc(t).data)},__wbg_from_45cebbf5e49a6ac6:function(t){return Qc(Array.from(Nc(t)))},__wbg_instanceof_ArrayBuffer_8d855993947fc3a2:function(t){let i;try{i=Nc(t)instanceof ArrayBuffer}catch(t){i=!1}return i},__wbg_length_e6e1633fbea6cfa9:function(t){return Nc(t).length},__wbg_new_1d96678aaacca32e:function(t){return Qc(new Uint8Array(Nc(t)))},__wbg_new_4370be21fa2b2f80:function(){return Qc([])},__wbg_new_48e1d86cfd30c8e7:function(){return Qc({})},__wbg_new_with_str_53b505a6bb7f12f6:function(){return Fc((function(t,i,s,e){return Qc(new WebSocket(Sc(t,i),Sc(s,e)))}),arguments)},__wbg_prototypesetcall_3875d54d12ef2eec:function(t,i,s){Uint8Array.prototype.set.call(Dc(t,i),Nc(s))},__wbg_readyState_a08d25cc57214030:function(t){return Nc(t).readyState},__wbg_send_da543a379e952bc6:function(){return Fc((function(t,i,s){Nc(t).send(Dc(i,s))}),arguments)},__wbg_setInterval_cbf1c35c6a692d37:function(){return Fc((function(t,i){return Qc(setInterval(Nc(t),i))}),arguments)},__wbg_set_4702dfa37c77f492:function(t,i,s){Nc(t)[i>>>0]=Jc(s)},__wbg_set_6be42768c690e380:function(t,i,s){Nc(t)[Jc(i)]=Jc(s)},__wbg_set_binaryType_0675f0e51c055ca8:function(t,i){Nc(t).binaryType=yc[i]},__wbg_set_onclose_f791ef701be808a0:function(t,i){Nc(t).onclose=Nc(i)},__wbg_set_onerror_e23002e9224d353b:function(t,i){Nc(t).onerror=Nc(i)},__wbg_set_onmessage_d2fe701a9ce80846:function(t,i){Nc(t).onmessage=Nc(i)},__wbg_set_onopen_0556381d0db30cbb:function(t,i){Nc(t).onopen=Nc(i)},__wbg_warn_7e545c047609d0b6:function(t,i){console.warn(Sc(t,i))},__wbindgen_cast_0000000000000001:function(t,i){return Qc(Gc(t,i,Bc))},__wbindgen_cast_0000000000000002:function(t,i){return Qc(Gc(t,i,bc))},__wbindgen_cast_0000000000000003:function(t,i){return Qc(Gc(t,i,Mc))},__wbindgen_cast_0000000000000004:function(t,i){return Qc(Gc(t,i,vc))},__wbindgen_cast_0000000000000005:function(t){return Qc(t)},__wbindgen_cast_0000000000000006:function(t,i){return Qc(Dc(t,i))},__wbindgen_cast_0000000000000007:function(t,i){return Qc(Sc(t,i))},__wbindgen_cast_0000000000000008:function(t){return Qc(BigInt.asUintN(64,t))},__wbindgen_object_clone_ref:function(t){return Qc(Nc(t))},__wbindgen_object_drop_ref:function(t){Jc(t)}};return{__proto__:null,"./phirepass-channel_bg.js":t}}function vc(t,i){Kc.__wasm_bindgen_func_elem_41(t,i)}function Bc(t,i,s){Kc.__wasm_bindgen_func_elem_37(t,i,Qc(s))}function bc(t,i,s){Kc.__wasm_bindgen_func_elem_37_1(t,i,Qc(s))}function Mc(t,i,s){Kc.__wasm_bindgen_func_elem_37_2(t,i,Qc(s))}const yc=["blob","arraybuffer"],Ec="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>Kc.__wbg_channel_free(t>>>0,1)));function Qc(t){Uc===Hc.length&&Hc.push(Hc.length+1);const i=Uc;return Uc=Hc[i],Hc[i]=t,i}const kc="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>Kc.__wbindgen_export4(t.a,t.b)));function xc(t){const i=typeof t;if("number"==i||"boolean"==i||null==t)return""+t;if("string"==i)return`"${t}"`;if("symbol"==i){const i=t.description;return null==i?"Symbol":`Symbol(${i})`}if("function"==i){const i=t.name;return"string"==typeof i&&i.length>0?`Function(${i})`:"Function"}if(Array.isArray(t)){const i=t.length;let s="[";i>0&&(s+=xc(t[0]));for(let e=1;e<i;e++)s+=", "+xc(t[e]);return s+="]",s}const s=/\[object ([^\]]+)\]/.exec(toString.call(t));let e;if(!(s&&s.length>1))return toString.call(t);if(e=s[1],"Object"==e)try{return"Object("+JSON.stringify(t)+")"}catch(t){return"Object"}return t instanceof Error?`${t.name}: ${t.message}\n${t.stack}`:e}function Dc(t,i){return t>>>=0,Rc().subarray(t/1,t/1+i)}let Lc=null;function _c(){return(null===Lc||!0===Lc.buffer.detached||void 0===Lc.buffer.detached&&Lc.buffer!==Kc.memory.buffer)&&(Lc=new DataView(Kc.memory.buffer)),Lc}function Sc(t,i){return function(t,i){return zc+=i,zc>=Wc&&(Oc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Oc.decode(),zc=i),Oc.decode(Rc().subarray(t,t+i))}(t>>>=0,i)}let $c=null;function Rc(){return null!==$c&&0!==$c.byteLength||($c=new Uint8Array(Kc.memory.buffer)),$c}function Nc(t){return Hc[t]}function Fc(t,i){try{return t.apply(this,i)}catch(t){Kc.__wbindgen_export3(Qc(t))}}let Hc=Array(1024).fill(void 0);Hc.push(void 0,null,!0,!1);let Uc=Hc.length;function Tc(t){return null==t}function Gc(t,i,s){const e={a:t,b:i,cnt:1},h=(...t)=>{e.cnt++;const i=e.a;e.a=0;try{return s(i,e.b,...t)}finally{e.a=i,h._wbg_cb_unref()}};return h._wbg_cb_unref=()=>{0==--e.cnt&&(Kc.__wbindgen_export4(e.a,e.b),e.a=0,kc.unregister(e))},kc.register(h,e,e),h}function Pc(t,i,s){if(void 0===s){const s=qc.encode(t),e=i(s.length,1)>>>0;return Rc().subarray(e,e+s.length).set(s),jc=s.length,e}let e=t.length,h=i(e,1)>>>0;const r=Rc();let n=0;for(;n<e;n++){const i=t.charCodeAt(n);if(i>127)break;r[h+n]=i}if(n!==e){0!==n&&(t=t.slice(n)),h=s(h,e,e=n+3*t.length,1)>>>0;const i=Rc().subarray(h+n,h+e);n+=qc.encodeInto(t,i).written,h=s(h,e,n,1)>>>0}return jc=n,h}function Jc(t){const i=Nc(t);return function(t){t<1028||(Hc[t]=Uc,Uc=t)}(t),i}let Oc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Oc.decode();const Wc=2146435072;let zc=0;const qc=new TextEncoder;"encodeInto"in qc||(qc.encodeInto=function(t,i){const s=qc.encode(t);return i.set(s),{read:t.length,written:s.length}});let Kc,jc=0;var Yc,Zc;!function(t){t[t.Username=0]="Username",t[t.Password=1]="Password",t[t.Default=2]="Default"}(Yc||(Yc={})),function(t){t.Disconnected="disconnected",t.Connected="connected",t.Error="error"}(Zc||(Zc={}));const Xc=i(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.connectionStateChanged=e(this,"connectionStateChanged")}terminal;fitAddon;webLinksAddon;searchAddon;webglAddon;serializeAddon;imageAddon;channel;containerEl;domReady=!1;runtimeReady=!1;connected=!1;inputMode=Yc.Default;resizeObserver;resizeDebounceHandle;session_id;usernameBuffer="";passwordBuffer="";xtermImageSettings={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7};get el(){return this}terminalOptions={termName:"xterm-256color",rendererType:"canvas",allowTransparency:!1,fontFamily:'"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace',fontSize:12,letterSpacing:0,lineHeight:1,allowProposedApi:!0,cursorBlink:!0,cursorWidth:1,theme:{background:"#0b1021",foreground:"#e2e8f0",cursor:"#67e8f9"},scrollback:1e4,fastScrollModifier:"shift",fastScrollSensitivity:5,bellStyle:"sound",convertEol:!1,disableStdin:!1,rightClickSelectsWord:!0,drawBoldTextInBrightColors:!0,minimumContrastRatio:1,windowsMode:!1,macOptionIsMeta:!1,altClickMovesCursor:!0};serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;token;onNodeIdChange(t,i){this.reset_session_state(),this.terminal.reset(),this.channel&&this.channel.is_connected()&&this.close_comms(),t&&(this.open_comms(),this.channel.connect())}serverId;onServerIdChange(t,i){this.onNodeIdChange(this.nodeId,this.nodeId)}connectionStateChanged;create_web_socket_endpoint(){const t=this.allowInsecure?"ws":"wss";return this.allowInsecure||443!==this.serverPort?this.allowInsecure&&80===this.serverPort?`${t}://${this.serverHost}`:`${t}://${this.serverHost}:${this.serverPort}`:`${t}://${this.serverHost}`}async connectedCallback(){await async function(t){if(void 0!==Kc)return Kc;void 0!==t&&(Object.getPrototypeOf(t)===Object.prototype?({module_or_path:t}=t):console.warn("using deprecated parameters for the initialization function; pass a single object instead")),void 0===t&&(t=new URL("phirepass-channel_bg.wasm",import.meta.url));const i=Ic();("string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL)&&(t=fetch(t));const{instance:s}=await async function(t,i){if("function"==typeof Response&&t instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(t,i)}catch(i){if(!t.ok||!function(t){switch(t){case"basic":case"cors":case"default":return!0}return!1}(t.type)||"application/wasm"===t.headers.get("Content-Type"))throw i;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",i)}const s=await t.arrayBuffer();return await WebAssembly.instantiate(s,i)}{const s=await WebAssembly.instantiate(t,i);return s instanceof WebAssembly.Instance?{instance:s,module:t}:s}}(await t,i);return function(t){return Kc=t.exports,Lc=null,$c=null,Kc}(s)}(),this.setup_terminal(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to terminal.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){this.resizeObserver&&this.resizeObserver.disconnect(),this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.close_comms(),this.destroy_terminal()}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.containerEl&&this.terminal&&this.channel&&this.connect()}setup_terminal(){this.terminal=new dr(this.terminalOptions),this.fitAddon=new gr,this.terminal.loadAddon(this.fitAddon),this.webLinksAddon=new vr,this.terminal.loadAddon(this.webLinksAddon),this.searchAddon=new In,this.terminal.loadAddon(this.searchAddon),this.serializeAddon=new kl,this.terminal.loadAddon(this.serializeAddon),this.imageAddon=new pc(this.xtermImageSettings),this.terminal.loadAddon(this.imageAddon);try{this.webglAddon=new Al,this.terminal.loadAddon(this.webglAddon)}catch(t){console.warn("WebGL addon not available or failed to load:",t)}"function"==typeof this.terminal.onResize&&this.terminal.onResize((()=>{this.send_ssh_terminal_resize()}))}destroy_terminal(){this.terminal&&(this.terminal.reset(),"function"==typeof this.terminal.dispose&&this.terminal.dispose())}open_comms(){this.channel=this.serverId?new Cc(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId,this.serverId):new Cc(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([Zc.Connected]),this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([Zc.Disconnected]),this.terminal.reset()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([Zc.Error,t])})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((t=>{const{web:i}=t.data;switch(i.type){case"Error":this.handle_error(i);break;case"AuthSuccess":this.handle_auth_success(i);break;case"TunnelOpened":this.handle_tunnel_opened(i);break;case"TunnelClosed":this.handle_tunnel_closed(i);break;case"TunnelData":this.handle_tunnel_data(i);break;default:console.warn("Unknown protocol message type:",i)}}))}send_ssh_terminal_resize(){if(!this.containerEl)return void console.warn("Cannot send terminal resize: container element not available");if(!this.nodeId)return void console.warn("Cannot send terminal resize: node_id is missing");if(!this.channel)return void console.warn("Cannot send terminal resize: channel is not initialized");if(!this.channel.is_connected())return void console.warn("Cannot send terminal resize: channel not connected");if(!this.session_id)return void console.warn("Cannot send terminal resize: session_id is missing");this.fitAddon.fit();const t=this.terminal?.cols??0,i=this.terminal?.rows??0,s=this.containerEl.clientWidth??0,e=this.containerEl.clientHeight??0;if(t<=0||i<=0)console.warn("Cannot send terminal resize: invalid terminal dimensions (cols:",t,"rows:",i,") ");else try{console.log(`Sending terminal resize: cols=${t}, rows=${i}, px_width=${s}, px_height=${e}`),this.channel.send_ssh_terminal_resize(this.nodeId,this.session_id,t,i,s,e)}catch(t){console.error("Failed to send terminal resize:",t)}}send_ssh_data(t){this.channel.is_connected()&&this.session_id&&this.channel.send_ssh_tunnel_data(this.nodeId,this.session_id,t)}handle_error(t){switch(t.kind){case mc.Generic:this.terminal.reset(),this.terminal.write(t.message+"\r\n"),this.terminal.focus();break;case mc.RequiresUsername:this.terminal.reset(),this.inputMode=Yc.Username,this.usernameBuffer="",this.terminal.write("Enter your username: "),this.terminal.focus();break;case mc.RequiresPassword:this.terminal.reset(),this.inputMode=Yc.Password,this.passwordBuffer="",this.terminal.write("Enter your password: "),this.terminal.focus();break;default:console.warn("Unknown error kind:",t)}}close_comms(){this.channel.stop_heartbeat(),this.channel.disconnect()}cancel_credential_entry(){this.inputMode=Yc.Default,this.clear_creds_buffer(),this.terminal.writeln("Authentication cancelled."),this.terminal.reset(),this.close_comms()}clear_creds_buffer(){this.usernameBuffer="",this.passwordBuffer=""}reset_session_state(){this.session_id=void 0,this.inputMode=Yc.Default,this.clear_creds_buffer()}handle_auth_success(t){this.clear_creds_buffer(),this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.channel.open_ssh_tunnel(this.nodeId)}handle_tunnel_opened(t){this.session_id=t.sid,this.terminal.reset(),this.fitAddon.fit(),this.send_ssh_terminal_resize()}handle_tunnel_data(t){this.terminal.write(new Uint8Array(t.data))}handle_tunnel_closed(t){this.session_id=void 0,this.inputMode=Yc.Default,this.clear_creds_buffer(),this.terminal.reset(),this.terminal.writeln("Connection closed."),this.close_comms()}connect(){const t=this.containerEl;console.log("Attempting to connect terminal to container:",t),t&&(this.terminal.open(t),console.log("Terminal opened in container"),this.fitAddon.fit(),this.terminal.focus(),this.terminal.onData(this.handle_terminal_data.bind(this)),this.channel.connect(),this.setup_resize_observer(),this.connected=!0,console.log("Terminal connected and ready"))}setup_resize_observer(){this.resizeObserver=new ResizeObserver((()=>{console.log("Container resized, fitting terminal"),this.resizeDebounceHandle&&clearTimeout(this.resizeDebounceHandle),this.resizeDebounceHandle=setTimeout((()=>{this.fitAddon.fit(),this.send_ssh_terminal_resize()}),100)})),this.resizeObserver.observe(this.containerEl??this.el)}handle_terminal_data(t){switch(this.inputMode){case Yc.Username:this.handle_username_input(t);break;case Yc.Password:this.handle_password_input(t);break;case Yc.Default:this.send_ssh_data(t)}}handle_username_input(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submit_username()):""===t?(this.terminal.write("^C\r\n"),void this.cancel_credential_entry()):void(""!==t?t>=" "&&t<="~"&&(this.usernameBuffer+=t,this.terminal.write(t)):this.usernameBuffer.length&&(this.usernameBuffer=this.usernameBuffer.slice(0,-1),this.terminal.write("\b \b")))}submit_username(){if(!this.channel.is_connected())return;const t=this.usernameBuffer.trim();if(!t)return this.terminal.writeln(""),this.terminal.write("Enter your username: "),void(this.usernameBuffer="");this.inputMode=Yc.Default,this.channel.open_ssh_tunnel(this.nodeId,t)}handle_password_input(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submit_password()):""===t?(this.terminal.write("^C\r\n"),void this.cancel_credential_entry()):void(""!==t?t>=" "&&t<="~"&&(this.passwordBuffer+=t,this.terminal.write("*")):this.passwordBuffer.length&&(this.passwordBuffer=this.passwordBuffer.slice(0,-1),this.terminal.write("\b \b")))}submit_password(){if(!this.channel.is_connected())return;const t=this.passwordBuffer;if(!t)return this.terminal.writeln(""),this.terminal.write("Enter your password: "),void(this.passwordBuffer="");this.inputMode=Yc.Default,this.channel.open_ssh_tunnel(this.nodeId,this.usernameBuffer.trim(),t),this.passwordBuffer="",this.usernameBuffer=""}render(){return h(r,{key:"71243a4c9c9468091e5ab830857f91b9b57812b0"},h("div",{key:"0dd9ae1e44cbf78f8a6ede6604c35d7d441cea93",id:"ccc",ref:t=>this.containerEl=t}))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}static get style(){return".xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#FFF;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1 !important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px !important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:rgba(0,0,0,0);transition:opacity 100ms linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity 800ms linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}:host{display:block;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}:host #ccc{width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}"}},[513,"phirepass-terminal",{terminalOptions:[16],serverHost:[1,"server-host"],serverPort:[2,"server-port"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],nodeId:[1,"node-id"],token:[1],serverId:[1,"server-id"]},void 0,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]);function Vc(){"undefined"!=typeof customElements&&["phirepass-terminal"].forEach((i=>{"phirepass-terminal"===i&&(customElements.get(t(i))||customElements.define(t(i),Xc))}))}Vc();const tu=Xc,iu=Vc;export{tu as PhirepassTerminal,iu as defineCustomElement}
49
+ */function Ol(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}(t=>{t.isLessThan=function(t){return t<0},t.isLessThanOrEqual=function(t){return t<=0},t.isGreaterThan=function(t){return t>0},t.isNeitherLessOrGreaterThan=function(t){return 0===t},t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(yl||={}),(t=>{function i(t){return t&&"object"==typeof t&&"function"==typeof t[Symbol.iterator]}t.is=i;let s=Object.freeze([]);function*e(t){yield t}t.empty=function(){return s},t.single=e,t.wrap=function(t){return i(t)?t:e(t)},t.from=function(t){return t||s},t.reverse=function*(t){for(let i=t.length-1;i>=0;i--)yield t[i]},t.isEmpty=function(t){return!t||!0===t[Symbol.iterator]().next().done},t.first=function(t){return t[Symbol.iterator]().next().value},t.some=function(t,i){let s=0;for(let e of t)if(i(e,s++))return!0;return!1},t.find=function(t,i){for(let s of t)if(i(s))return s},t.filter=function*(t,i){for(let s of t)i(s)&&(yield s)},t.map=function*(t,i){let s=0;for(let e of t)yield i(e,s++)},t.flatMap=function*(t,i){let s=0;for(let e of t)yield*i(e,s++)},t.concat=function*(...t){for(let i of t)yield*i},t.reduce=function(t,i,s){let e=s;for(let s of t)e=i(e,s);return e},t.slice=function*(t,i,s=t.length){for(i<0&&(i+=t.length),s<0?s+=t.length:s>t.length&&(s=t.length);i<s;i++)yield t[i]},t.consume=function(i,s=1/0){let e=[];if(0===s)return[e,i];let h=i[Symbol.iterator]();for(let i=0;i<s;i++){let i=h.next();if(i.done)return[e,t.empty()];e.push(i.value)}return[e,{[Symbol.iterator]:()=>h}]},t.asyncToArray=async function(t){let i=[];for await(let s of t)i.push(s);return Promise.resolve(i)}})(El||={});var Wl=class t{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{!function(t){if(El.is(t)){let i=[];for(let s of t)if(s)try{s.dispose()}catch(t){i.push(t)}if(1===i.length)throw i[0];if(i.length>1)throw new AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}t&&t.dispose()}(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(i),i}delete(t){if(t){if(t===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};Wl.DISABLE_DISPOSED_WARNING=!1;var zl=Wl,ql=class{constructor(){this._store=new zl}dispose(){this._store.dispose()}_register(t){if(t===this)throw Error("Cannot register a disposable on itself!");return this._store.add(t)}};ql.None=Object.freeze({dispose(){}});var Kl=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},jl=class t extends ql{constructor(t){super(),this._terminal=t,this._optionsRefresh=this._register(new Kl),this._oldOpen=this._terminal._core.open,this._terminal._core.open=t=>{this._oldOpen?.call(this._terminal._core,t),this._open()},this._terminal._core.screenElement&&this._open(),this._optionsRefresh.value=this._terminal._core.optionsService.onOptionChange((t=>{"fontSize"===t&&(this.rescaleCanvas(),this._renderService?.refreshRows(0,this._terminal.rows))})),this._register(function(t){return{dispose:Ol((()=>{t()}))}}((()=>{this.removeLayerFromDom(),this._terminal._core&&this._oldOpen&&(this._terminal._core.open=this._oldOpen,this._oldOpen=void 0),this._renderService&&this._oldSetRenderer&&(this._renderService.setRenderer=this._oldSetRenderer,this._oldSetRenderer=void 0),this._renderService=void 0,this.canvas=void 0,this._ctx=void 0,this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0})))}static createCanvas(t,i,s){let e=(t||document).createElement("canvas");return e.width=0|i,e.height=0|s,e}static createImageData(t,i,s,e){if("function"!=typeof ImageData){let h=t.createImageData(i,s);return e&&h.data.set(new Uint8ClampedArray(e,0,i*s*4)),h}return e?new ImageData(new Uint8ClampedArray(e,0,i*s*4),i,s):new ImageData(i,s)}static createImageBitmap(t){return"function"!=typeof createImageBitmap?Promise.resolve(void 0):createImageBitmap(t)}showPlaceholder(t){t?!this._placeholder&&-1!==this.cellSize.height&&this._createPlaceHolder(Math.max(this.cellSize.height+1,24)):(this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0),this._renderService?.refreshRows(0,this._terminal.rows)}get dimensions(){return this._renderService?.dimensions}get cellSize(){return{width:this.dimensions?.css.cell.width||-1,height:this.dimensions?.css.cell.height||-1}}clearLines(t,i){this._ctx?.clearRect(0,t*(this.dimensions?.css.cell.height||0),this.dimensions?.css.canvas.width||0,(++i-t)*(this.dimensions?.css.cell.height||0))}clearAll(){this._ctx?.clearRect(0,0,this.canvas?.width||0,this.canvas?.height||0)}draw(t,i,s,e,h=1){if(!this._ctx)return;let{width:r,height:n}=this.cellSize;if(-1===r||-1===n)return;this._rescaleImage(t,r,n);let o=t.actual,a=Math.ceil(o.width/r),l=i%a*r,c=Math.floor(i/a)*n,u=s*r,A=e*n,f=h*r+l>o.width?o.width-l:h*r,d=c+n>o.height?o.height-c:n;this._ctx.drawImage(o,Math.floor(l),Math.floor(c),Math.ceil(f),Math.ceil(d),Math.floor(u),Math.floor(A),Math.ceil(f),Math.ceil(d))}extractTile(i,s){let{width:e,height:h}=this.cellSize;if(-1===e||-1===h)return;this._rescaleImage(i,e,h);let r=i.actual,n=Math.ceil(r.width/e),o=s%n*e,a=Math.floor(s/n)*h,l=e+o>r.width?r.width-o:e,c=a+h>r.height?r.height-a:h,u=t.createCanvas(this.document,l,c),A=u.getContext("2d");return A?(A.drawImage(r,Math.floor(o),Math.floor(a),Math.floor(l),Math.floor(c),0,0,Math.floor(l),Math.floor(c)),u):void 0}drawPlaceholder(t,i,s=1){if(this._ctx){let{width:e,height:h}=this.cellSize;if(-1===e||-1===h||(this._placeholder?h>=this._placeholder.height&&this._createPlaceHolder(h+1):this._createPlaceHolder(Math.max(h+1,24)),!this._placeholder))return;this._ctx.drawImage(this._placeholderBitmap||this._placeholder,t*e,i*h%2?0:1,e*s,h,t*e,i*h,e*s,h)}}rescaleCanvas(){this.canvas&&(this.canvas.width!==this.dimensions.css.canvas.width||this.canvas.height!==this.dimensions.css.canvas.height)&&(this.canvas.width=this.dimensions.css.canvas.width||0,this.canvas.height=this.dimensions.css.canvas.height||0)}_rescaleImage(i,s,e){if(s===i.actualCellSize.width&&e===i.actualCellSize.height)return;let{width:h,height:r}=i.origCellSize;if(s===h&&e===r)return i.actual=i.orig,i.actualCellSize.width=h,void(i.actualCellSize.height=r);let n=t.createCanvas(this.document,Math.ceil(i.orig.width*s/h),Math.ceil(i.orig.height*e/r)),o=n.getContext("2d");o&&(o.drawImage(i.orig,0,0,n.width,n.height),i.actual=n,i.actualCellSize.width=s,i.actualCellSize.height=e)}_open(){this._renderService=this._terminal._core._renderService,this._oldSetRenderer=this._renderService.setRenderer.bind(this._renderService),this._renderService.setRenderer=t=>{this.removeLayerFromDom(),this._oldSetRenderer?.call(this._renderService,t)}}insertLayerToDom(){this.document&&this._terminal._core.screenElement?this.canvas||(this.canvas=t.createCanvas(this.document,this.dimensions?.css.canvas.width||0,this.dimensions?.css.canvas.height||0),this.canvas.classList.add("xterm-image-layer"),this._terminal._core.screenElement.appendChild(this.canvas),this._ctx=this.canvas.getContext("2d",{alpha:!0,desynchronized:!0}),this.clearAll()):console.warn("image addon: cannot insert output canvas to DOM, missing document or screenElement")}removeLayerFromDom(){this.canvas&&(this._ctx=void 0,this.canvas.remove(),this.canvas=void 0)}_createPlaceHolder(i=24){this._placeholderBitmap?.close(),this._placeholderBitmap=void 0;let s=32,e=t.createCanvas(this.document,s,i),h=e.getContext("2d",{alpha:!1});if(!h)return;let r=t.createImageData(h,s,i),n=new Uint32Array(r.data.buffer),o=(0,Jl.toRGBA8888)(0,0,0),a=(0,Jl.toRGBA8888)(255,255,255);n.fill(o);for(let t=0;t<i;++t){let i=t%2,e=t*s;for(let t=0;t<s;t+=2)n[e+t+i]=a}h.putImageData(r,0,0);let l=screen.width+s-1&-32||4096;this._placeholder=t.createCanvas(this.document,l,i);let c=this._placeholder.getContext("2d",{alpha:!1});if(c){for(let t=0;t<l;t+=s)c.drawImage(e,t,0);t.createImageBitmap(this._placeholder).then((t=>this._placeholderBitmap=t))}else this._placeholder=void 0}get document(){return this._terminal._core._coreBrowserService?.window.document}},Yl={width:7,height:14},Zl=class t{constructor(t=0,i=0,s=-1,e=-1){this.imageId=s,this.tileId=e,this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(t){this._ext&=-67108864,this._ext|=67108863&t}get underlineVariantOffset(){let t=(3758096384&this._ext)>>29;return t<0?4294967288^t:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}get urlId(){return this._urlId}set urlId(t){this._urlId=t}clone(){return new t(this._ext,this._urlId,this.imageId,this.tileId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId&&-1===this.imageId}},Xl=new Zl,Vl=class{constructor(t,i,s){this._terminal=t,this._renderer=i,this._opts=s,this._images=new Map,this._lastId=0,this._lowestId=0,this._fullyCleared=!1,this._needsFullClear=!1,this._pixelLimit=25e5;try{this.setLimit(this._opts.storageLimit)}catch(t){console.error(t.message),console.warn(`storageLimit is set to ${this.getLimit()} MB`)}this._viewportMetrics={cols:this._terminal.cols,rows:this._terminal.rows}}dispose(){this.reset()}reset(){for(let t of this._images.values())t.marker?.dispose();this._images.clear(),this._renderer.clearAll()}getLimit(){return 4*this._pixelLimit/1e6}setLimit(t){if(t<.5||t>1e3)throw RangeError("invalid storageLimit, should be at least 0.5 MB and not exceed 1G");this._pixelLimit=t/4*1e6>>>0,this._evictOldest(0)}getUsage(){return 4*this._getStoredPixels()/1e6}_getStoredPixels(){let t=0;for(let i of this._images.values())i.orig&&(t+=i.orig.width*i.orig.height,i.actual&&i.actual!==i.orig&&(t+=i.actual.width*i.actual.height));return t}_delImg(t){let i=this._images.get(t);this._images.delete(t),i&&window.ImageBitmap&&i.orig instanceof ImageBitmap&&i.orig.close()}wipeAlternate(){let t=[];for(let[i,s]of this._images.entries())"alternate"===s.bufferType&&(s.marker?.dispose(),t.push(i));for(let i of t)this._delImg(i);this._needsFullClear=!0,this._fullyCleared=!1}advanceCursor(t){if(this._opts.sixelScrolling){let i=this._renderer.cellSize;(-1===i.width||-1===i.height)&&(i=Yl);let s=Math.ceil(t/i.height);for(let t=1;t<s;++t)this._terminal._core._inputHandler.lineFeed()}}addImage(t){this._evictOldest(t.width*t.height);let i=this._renderer.cellSize;(-1===i.width||-1===i.height)&&(i=Yl);let s=Math.ceil(t.width/i.width),e=Math.ceil(t.height/i.height),h=++this._lastId,r=this._terminal._core.buffer,n=this._terminal.cols,o=this._terminal.rows,a=r.x,l=r.y,c=a,u=0;this._opts.sixelScrolling||(r.x=0,r.y=0,c=0),this._terminal._core._inputHandler._dirtyRowTracker.markDirty(r.y);for(let t=0;t<e;++t){let i=r.lines.get(r.y+r.ybase);for(let e=0;e<s&&!(c+e>=n);++e)this._writeToCell(i,c+e,h,t*s+e),u++;if(this._opts.sixelScrolling)t<e-1&&this._terminal._core._inputHandler.lineFeed();else if(++r.y>=o)break;r.x=c}this._terminal._core._inputHandler._dirtyRowTracker.markDirty(r.y),this._opts.sixelScrolling?r.x=c:(r.x=a,r.y=l);let A=[];for(let[t,i]of this._images.entries())i.tileCount<1&&(i.marker?.dispose(),A.push(t));for(let t of A)this._delImg(t);let f=this._terminal.registerMarker(0);f?.onDispose((()=>{this._images.get(h)&&this._delImg(h)})),"alternate"===this._terminal.buffer.active.type&&this._evictOnAlternate();let d={orig:t,origCellSize:i,actual:t,actualCellSize:{...i},marker:f||void 0,tileCount:u,bufferType:this._terminal.buffer.active.type};this._images.set(h,d)}render(t){if(!this._renderer.canvas&&this._images.size&&(this._renderer.insertLayerToDom(),!this._renderer.canvas))return;if(this._renderer.rescaleCanvas(),!this._images.size)return this._fullyCleared||(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1),void(this._renderer.canvas&&this._renderer.removeLayerFromDom());this._needsFullClear&&(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1);let{start:i,end:s}=t,e=this._terminal._core.buffer,h=this._terminal._core.cols;this._renderer.clearLines(i,s);for(let t=i;t<=s;++t){let i=e.lines.get(t+e.ydisp);if(!i)return;for(let s=0;s<h;++s)if(268435456&i.getBg(s)){let e=i._extendedAttrs[s]||Xl,r=e.imageId;if(void 0===r||-1===r)continue;let n=this._images.get(r);if(-1!==e.tileId){let o=e.tileId,a=s,l=1;for(;++s<h&&268435456&i.getBg(s)&&(e=i._extendedAttrs[s]||Xl)&&e.imageId===r&&e.tileId===o+l;)l++;s--,n?n.actual&&this._renderer.draw(n,o,a,t,l):this._opts.showPlaceholder&&this._renderer.drawPlaceholder(a,t,l),this._fullyCleared=!1}}}}viewportResize(t){if(!this._images.size)return void(this._viewportMetrics=t);if(this._viewportMetrics.cols>=t.cols)return void(this._viewportMetrics=t);let i=this._terminal._core.buffer,s=i.lines.length,e=this._viewportMetrics.cols-1;for(let h=0;h<s;++h){let s=i.lines.get(h);if(268435456&s.getBg(e)){let i=s._extendedAttrs[e]||Xl,h=i.imageId;if(void 0===h||-1===h)continue;let r=this._images.get(h);if(!r)continue;let n=Math.ceil((r.actual?.width||0)/r.actualCellSize.width);if(i.tileId%n+1>=n)continue;let o=!1;for(let i=e+1;i>t.cols;++i)if(4194303&s._data[3*i+0]){o=!0;break}if(o)continue;let a=Math.min(t.cols,n-i.tileId%n+e),l=i.tileId;for(let t=e+1;t<a;++t)this._writeToCell(s,t,h,++l),r.tileCount++}}this._viewportMetrics=t}getImageAtBufferCell(t,i){let s=this._terminal._core.buffer.lines.get(i);if(s&&268435456&s.getBg(t)){let i=s._extendedAttrs[t]||Xl;if(i.imageId&&-1!==i.imageId){let t=this._images.get(i.imageId)?.orig;if(window.ImageBitmap&&t instanceof ImageBitmap){let i=jl.createCanvas(window.document,t.width,t.height);return i.getContext("2d")?.drawImage(t,0,0,t.width,t.height),i}return t}}}extractTileAtBufferCell(t,i){let s=this._terminal._core.buffer.lines.get(i);if(s&&268435456&s.getBg(t)){let i=s._extendedAttrs[t]||Xl;if(i.imageId&&-1!==i.imageId&&-1!==i.tileId){let t=this._images.get(i.imageId);if(t)return this._renderer.extractTile(t,i.tileId)}}}_evictOldest(t){let i=this._getStoredPixels(),s=i;for(;this._pixelLimit<s+t&&this._images.size;){let t=this._images.get(++this._lowestId);t&&t.orig&&(s-=t.orig.width*t.orig.height,t.actual&&t.orig!==t.actual&&(s-=t.actual.width*t.actual.height),t.marker?.dispose(),this._delImg(this._lowestId))}return i-s}_writeToCell(t,i,s,e){if(268435456&t._data[3*i+2]){let h=t._extendedAttrs[i];if(h){if(void 0!==h.imageId){let t=this._images.get(h.imageId);return t&&t.tileCount--,h.imageId=s,void(h.tileId=e)}return void(t._extendedAttrs[i]=new Zl(h.ext,h.urlId,s,e))}}t._data[3*i+2]|=268435456,t._extendedAttrs[i]=new Zl(0,0,s,e)}_evictOnAlternate(){for(let t of this._images.values())"alternate"===t.bufferType&&(t.tileCount=0);let t=this._terminal._core.buffer;for(let i=0;i<this._terminal.rows;++i){let s=t.lines.get(i);if(s)for(let t=0;t<this._terminal.cols;++t)if(268435456&s._data[3*t+2]){let i=s._extendedAttrs[t]?.imageId;if(i){let t=this._images.get(i);t&&t.tileCount++}}}let i=[];for(let[t,s]of this._images.entries())"alternate"===s.bufferType&&!s.tileCount&&(s.marker?.dispose(),i.push(t));for(let t of i)this._delImg(t)}},tc=Fl(Tl());function ic(t){let i="";for(let s=0;s<t.length;++s)i+=String.fromCharCode(t[s]);return i}function sc(t){let i=0;for(let s=0;s<t.length;++s){if(t[s]<48||t[s]>57)throw Error("illegal char");i=10*i+t[s]-48}return i}function ec(t){let i=ic(t);if(!i.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw Error("illegal size");return i}var hc={inline:sc,size:sc,name:function(t){if(typeof Buffer<"u")return""+Buffer.from(ic(t),"base64");let i=atob(ic(t)),s=new Uint8Array(i.length);for(let t=0;t<s.length;++t)s[t]=i.charCodeAt(t);return(new TextDecoder).decode(s)},width:ec,height:ec,preserveAspectRatio:sc},rc=[70,105,108,101],nc=1024,oc=class{constructor(){this.state=0,this._buffer=new Uint32Array(nc),this._position=0,this._key="",this.fields={}}reset(){this._buffer.fill(0),this.state=0,this._position=0,this.fields={},this._key=""}parse(t,i,s){let e=this.state,h=this._position,r=this._buffer;if(1===e||4===e||0===e&&h>6)return-1;for(let n=i;n<s;++n){let i=t[n];switch(i){case 59:if(!this._storeValue(h))return this._a();e=2,h=0;break;case 61:if(0===e){for(let t=0;t<4;++t)if(r[t]!==rc[t])return this._a();e=2,h=0}else if(2===e){if(!this._storeKey(h))return this._a();e=3,h=0}else if(3===e){if(h>=nc)return this._a();r[h++]=i}break;case 58:return 3!==e||this._storeValue(h)?(this.state=4,n+1):this._a();default:if(h>=nc)return this._a();r[h++]=i}}return this.state=e,this._position=h,-2}_a(){return this.state=1,-1}_storeKey(t){let i=ic(this._buffer.subarray(0,t));return!!i&&(this._key=i,this.fields[i]=null,!0)}_storeValue(t){if(this._key){try{let i=this._buffer.slice(0,t);this.fields[this._key]=hc[this._key]?hc[this._key](i):i}catch{return!1}return!0}return!1}},ac={mime:"unsupported",width:0,height:0},lc={name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},cc=class{constructor(t,i,s,e){this._opts=t,this._renderer=i,this._storage=s,this._coreTerminal=e,this._aborted=!1,this._hp=new oc,this._header=lc,this._dec=new tc.default(4194304),this._metrics=ac}reset(){}start(){this._aborted=!1,this._header=lc,this._metrics=ac,this._hp.reset()}put(t,i,s){if(!this._aborted)if(4===this._hp.state)this._dec.put(t,i,s)&&(this._dec.release(),this._aborted=!0);else{let e=this._hp.parse(t,i,s);if(-1===e)return void(this._aborted=!0);if(e>0){if(this._header=Object.assign({},lc,this._hp.fields),!this._header.inline||!this._header.size||this._header.size>this._opts.iipSizeLimit)return void(this._aborted=!0);this._dec.init(this._header.size),this._dec.put(t,e,s)&&(this._dec.release(),this._aborted=!0)}}}end(t){if(this._aborted)return!0;let i=0,s=0,e=!0;if((e=t)&&(e=!this._dec.end())&&(this._metrics=function(t){if(t.length<24)return ac;let i=new Uint32Array(t.buffer,t.byteOffset,6);if(1196314761===i[0]&&169478669===i[1]&&1380206665===i[3])return{mime:"image/png",width:t[16]<<24|t[17]<<16|t[18]<<8|t[19],height:t[20]<<24|t[21]<<16|t[22]<<8|t[23]};if(255===t[0]&&216===t[1]&&255===t[2]){let[i,s]=function(t){let i=t.length,s=4,e=t[s]<<8|t[s+1];for(;;){if(s+=e,s>=i)return[0,0];if(255!==t[s])return[0,0];if(192===t[s+1]||194===t[s+1])return s+8<i?[t[s+7]<<8|t[s+8],t[s+5]<<8|t[s+6]]:[0,0];s+=2,e=t[s]<<8|t[s+1]}}(t);return{mime:"image/jpeg",width:i,height:s}}return 944130375!==i[0]||55!==t[4]&&57!==t[4]||97!==t[5]?ac:{mime:"image/gif",width:t[7]<<8|t[6],height:t[9]<<8|t[8]}}(this._dec.data8),(e="unsupported"!==this._metrics.mime)&&(i=this._metrics.width,s=this._metrics.height,(e=i&&s&&i*s<this._opts.pixelLimit)&&([i,s]=this._resize(i,s).map(Math.floor),e=i&&s&&i*s<this._opts.pixelLimit))),!e)return this._dec.release(),!0;let h=new Blob([this._dec.data8],{type:this._metrics.mime});if(this._dec.release(),!window.createImageBitmap){let t=URL.createObjectURL(h),e=new Image;return new Promise((h=>{e.addEventListener("load",(()=>{URL.revokeObjectURL(t);let r=jl.createCanvas(window.document,i,s);r.getContext("2d")?.drawImage(e,0,0,i,s),this._storage.addImage(r),h(!0)})),e.src=t,setTimeout((()=>h(!0)),1e3)}))}return createImageBitmap(h,{resizeWidth:i,resizeHeight:s}).then((t=>(this._storage.addImage(t),!0)))}_resize(t,i){let s=this._renderer.dimensions?.css.cell.width||Yl.width,e=this._renderer.dimensions?.css.cell.height||Yl.height,h=this._renderer.dimensions?.css.canvas.width||s*this._coreTerminal.cols,r=this._renderer.dimensions?.css.canvas.height||e*this._coreTerminal.rows,n=this._dim(this._header.width,h,s),o=this._dim(this._header.height,r,e);if(!n&&!o){let s=Math.min(h/t,(r-e)/i);return s<1?[t*s,i*s]:[t,i]}return n?!this._header.preserveAspectRatio&&n&&o?[n,o]:[n,i*n/t]:[t*o/i,o]}_dim(t,i,s){return"auto"===t?0:t.endsWith("%")?parseInt(t.slice(0,-1))*i/100:t.endsWith("px")?parseInt(t.slice(0,-2)):parseInt(t)*s}},uc=Fl(Hl()),Ac=Fl(Pl()),fc=uc.PALETTE_ANSI_256;fc.set(uc.PALETTE_VT340_COLOR);var dc=class{constructor(t,i,s){this._opts=t,this._storage=i,this._coreTerminal=s,this._size=0,this._aborted=!1,(0,Ac.DecoderAsync)({memoryLimit:4*this._opts.pixelLimit,palette:fc,paletteLimit:this._opts.sixelPaletteLimit}).then((t=>this._dec=t))}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,fc,this._opts.sixelPaletteLimit))}hook(t){if(this._size=0,this._aborted=!1,this._dec){let i=1===t.params[1]?0:function(t,i){let s=0;if(!i)return s;if(t.isInverse())if(t.isFgDefault())s=gc(i.foreground.rgba);else if(t.isFgRGB()){let i=t.constructor.toColorRGB(t.getFgColor());s=(0,uc.toRGBA8888)(...i)}else s=gc(i.ansi[t.getFgColor()].rgba);else if(t.isBgDefault())s=gc(i.background.rgba);else if(t.isBgRGB()){let i=t.constructor.toColorRGB(t.getBgColor());s=(0,uc.toRGBA8888)(...i)}else s=gc(i.ansi[t.getBgColor()].rgba);return s}(this._coreTerminal._core._inputHandler._curAttrData,this._coreTerminal._core._themeService?.colors);this._dec.init(i,null,this._opts.sixelPaletteLimit)}}put(t,i,s){if(!this._aborted&&this._dec){if(this._size+=s-i,this._size>this._opts.sixelSizeLimit)return console.warn("SIXEL: too much data, aborting"),this._aborted=!0,void this._dec.release();try{this._dec.decode(t,i,s)}catch(t){console.warn("SIXEL: error while decoding image - "+t),this._aborted=!0,this._dec.release()}}}unhook(t){if(this._aborted||!t||!this._dec)return!0;let i=this._dec.width,s=this._dec.height;if(!i||!s)return s&&this._storage.advanceCursor(s),!0;let e=jl.createCanvas(void 0,i,s);return e.getContext("2d")?.putImageData(new ImageData(this._dec.data8,i,s),0,0),this._dec.memoryUsage>4194304&&this._dec.release(),this._storage.addImage(e),!0}};function gc(t){return uc.BIG_ENDIAN?t:(255&t)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255}var wc={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7},pc=class{constructor(t){this._disposables=[],this._handlers=new Map,this._opts=Object.assign({},wc,t),this._defaultOpts=Object.assign({},wc,t)}dispose(){for(let t of this._disposables)t.dispose();this._disposables.length=0,this._handlers.clear()}_disposeLater(...t){for(let i of t)this._disposables.push(i)}activate(t){if(this._terminal=t,this._renderer=new jl(t),this._storage=new Vl(t,this._renderer,this._opts),this._opts.enableSizeReports){let i=t.options.windowOptions||{};i.getWinSizePixels=!0,i.getCellSizePixels=!0,i.getWinSizeChars=!0,t.options.windowOptions=i}if(this._disposeLater(this._renderer,this._storage,t.parser.registerCsiHandler({prefix:"?",final:"h"},(t=>this._decset(t))),t.parser.registerCsiHandler({prefix:"?",final:"l"},(t=>this._decrst(t))),t.parser.registerCsiHandler({final:"c"},(t=>this._da1(t))),t.parser.registerCsiHandler({prefix:"?",final:"S"},(t=>this._xtermGraphicsAttributes(t))),t.onRender((t=>this._storage?.render(t))),t.parser.registerCsiHandler({intermediates:"!",final:"p"},(()=>this.reset())),t.parser.registerEscHandler({final:"c"},(()=>this.reset())),t._core._inputHandler.onRequestReset((()=>this.reset())),t.buffer.onBufferChange((()=>this._storage?.wipeAlternate())),t.onResize((t=>this._storage?.viewportResize(t)))),this._opts.sixelSupport){let i=new dc(this._opts,this._storage,t);this._handlers.set("sixel",i),this._disposeLater(t._core._inputHandler._parser.registerDcsHandler({final:"q"},i))}if(this._opts.iipSupport){let i=new cc(this._opts,this._renderer,this._storage,t);this._handlers.set("iip",i),this._disposeLater(t._core._inputHandler._parser.registerOscHandler(1337,i))}}reset(){this._opts.sixelScrolling=this._defaultOpts.sixelScrolling,this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._storage?.reset();for(let t of this._handlers.values())t.reset();return!1}get storageLimit(){return this._storage?.getLimit()||-1}set storageLimit(t){this._storage?.setLimit(t),this._opts.storageLimit=t}get storageUsage(){return this._storage?this._storage.getUsage():-1}get showPlaceholder(){return this._opts.showPlaceholder}set showPlaceholder(t){this._opts.showPlaceholder=t,this._renderer?.showPlaceholder(t)}getImageAtBufferCell(t,i){return this._storage?.getImageAtBufferCell(t,i)}extractTileAtBufferCell(t,i){return this._storage?.extractTileAtBufferCell(t,i)}_report(t){this._terminal?._core.coreService.triggerDataEvent(t)}_decset(t){for(let i=0;i<t.length;++i)80===t[i]&&(this._opts.sixelScrolling=!1);return!1}_decrst(t){for(let i=0;i<t.length;++i)80===t[i]&&(this._opts.sixelScrolling=!0);return!1}_da1(t){return!!t[0]||!!this._opts.sixelSupport&&(this._report("[?62;4;9;22c"),!0)}_xtermGraphicsAttributes(t){if(t.length<2)return!0;if(1===t[0])switch(t[1]){case 1:return this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`),!0;case 2:this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`);for(let t of this._handlers.values())t.reset();return!0;case 3:return t.length>2&&!(t[2]instanceof Array)&&t[2]<=4096?(this._opts.sixelPaletteLimit=t[2],this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`)):this._report(`[?${t[0]};2S`),!0;case 4:return this._report(`[?${t[0]};0;4096S`),!0;default:return this._report(`[?${t[0]};2S`),!0}if(2===t[0])switch(t[1]){case 1:let i=this._renderer?.dimensions?.css.canvas.width,s=this._renderer?.dimensions?.css.canvas.height;if(!i||!s){let t=Yl;i=(this._terminal?.cols||80)*t.width,s=(this._terminal?.rows||24)*t.height}if(i*s<this._opts.pixelLimit)this._report(`[?${t[0]};0;${i.toFixed(0)};${s.toFixed(0)}S`);else{let i=Math.floor(Math.sqrt(this._opts.pixelLimit));this._report(`[?${t[0]};0;${i};${i}S`)}return!0;case 4:let e=Math.floor(Math.sqrt(this._opts.pixelLimit));return this._report(`[?${t[0]};0;${e};${e}S`),!0;default:return this._report(`[?${t[0]};2S`),!0}return this._report(`[?${t[0]};1S`),!0}};class Cc{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,Ec.unregister(this),t}free(){const t=this.__destroy_into_raw();Kc.__wbg_channel_free(t,0)}authenticate(t,i,s){const e=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),h=jc,r=Pc(i,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_authenticate(this.__wbg_ptr,e,h,r,jc,Tc(s)?4294967297:s>>>0)}connect(){Kc.channel_connect(this.__wbg_ptr)}disconnect(){Kc.channel_disconnect(this.__wbg_ptr)}is_connected(){return 0!==Kc.channel_is_connected(this.__wbg_ptr)}is_disconnected(){return 0!==Kc.channel_is_disconnected(this.__wbg_ptr)}constructor(t,i,s){const e=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),h=jc,r=Pc(i,Kc.__wbindgen_export,Kc.__wbindgen_export2),n=jc;var o=Tc(s)?0:Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2);const a=Kc.channel_new(e,h,r,n,o,jc);return this.__wbg_ptr=a>>>0,Ec.register(this,this.__wbg_ptr,this),this}on_connection_close(t){Kc.channel_on_connection_close(this.__wbg_ptr,Tc(t)?0:Qc(t))}on_connection_error(t){Kc.channel_on_connection_error(this.__wbg_ptr,Tc(t)?0:Qc(t))}on_connection_message(t){Kc.channel_on_connection_message(this.__wbg_ptr,Tc(t)?0:Qc(t))}on_connection_open(t){Kc.channel_on_connection_open(this.__wbg_ptr,Tc(t)?0:Qc(t))}on_protocol_message(t){Kc.channel_on_protocol_message(this.__wbg_ptr,Tc(t)?0:Qc(t))}open_sftp_tunnel(t,i,s,e){const h=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),r=jc;var n=Tc(i)?0:Pc(i,Kc.__wbindgen_export,Kc.__wbindgen_export2),o=jc,a=Tc(s)?0:Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_open_sftp_tunnel(this.__wbg_ptr,h,r,n,o,a,jc,Tc(e)?4294967297:e>>>0)}open_ssh_tunnel(t,i,s,e){const h=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),r=jc;var n=Tc(i)?0:Pc(i,Kc.__wbindgen_export,Kc.__wbindgen_export2),o=jc,a=Tc(s)?0:Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_open_ssh_tunnel(this.__wbg_ptr,h,r,n,o,a,jc,Tc(e)?4294967297:e>>>0)}send_sftp_delete(t,i,s,e,h){const r=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),n=jc,o=Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2),a=jc,l=Pc(e,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_sftp_delete(this.__wbg_ptr,r,n,i,o,a,l,jc,Tc(h)?4294967297:h>>>0)}send_sftp_download_chunk(t,i,s,e,h){const r=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_sftp_download_chunk(this.__wbg_ptr,r,jc,i,s,e,Tc(h)?4294967297:h>>>0)}send_sftp_download_start(t,i,s,e,h){const r=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),n=jc,o=Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2),a=jc,l=Pc(e,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_sftp_download_start(this.__wbg_ptr,r,n,i,o,a,l,jc,Tc(h)?4294967297:h>>>0)}send_sftp_list_data(t,i,s,e){const h=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),r=jc,n=Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_sftp_list_data(this.__wbg_ptr,h,r,i,n,jc,Tc(e)?4294967297:e>>>0)}send_sftp_upload_chunk(t,i,s,e,h,r,n){const o=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),a=jc,l=function(t){const i=(0,Kc.__wbindgen_export)(1*t.length,1)>>>0;return Rc().set(t,i/1),jc=t.length,i}(r);Kc.channel_send_sftp_upload_chunk(this.__wbg_ptr,o,a,i,s,e,h,l,jc,Tc(n)?4294967297:n>>>0)}send_sftp_upload_start(t,i,s,e,h,r,n){const o=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),a=jc,l=Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2),c=jc,u=Pc(e,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_sftp_upload_start(this.__wbg_ptr,o,a,i,l,c,u,jc,h,r,Tc(n)?4294967297:n>>>0)}send_ssh_terminal_resize(t,i,s,e,h,r){const n=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_ssh_terminal_resize(this.__wbg_ptr,n,jc,i,s,e,h,r)}send_ssh_tunnel_data(t,i,s){const e=Pc(t,Kc.__wbindgen_export,Kc.__wbindgen_export2),h=jc,r=Pc(s,Kc.__wbindgen_export,Kc.__wbindgen_export2);Kc.channel_send_ssh_tunnel_data(this.__wbg_ptr,e,h,i,r,jc)}start_heartbeat(t){Kc.channel_start_heartbeat(this.__wbg_ptr,t)}stop_heartbeat(){Kc.channel_stop_heartbeat(this.__wbg_ptr)}}Symbol.dispose&&(Cc.prototype[Symbol.dispose]=Cc.prototype.free);const mc=Object.freeze({Generic:0,0:"Generic",RequiresUsername:100,100:"RequiresUsername",RequiresPassword:110,110:"RequiresPassword"});function Ic(){const t={__proto__:null,__wbg_Error_2e59b1b37a9a34c3:function(t,i){return Qc(Error(Sc(t,i)))},__wbg_String_8564e559799eccda:function(t,i){const s=Pc(Nc(i)+"",Kc.__wbindgen_export,Kc.__wbindgen_export2),e=jc;_c().setInt32(t+4,e,!0),_c().setInt32(t+0,s,!0)},__wbg___wbindgen_debug_string_dd5d2d07ce9e6c57:function(t,i){const s=Pc(xc(Nc(i)),Kc.__wbindgen_export,Kc.__wbindgen_export2),e=jc;_c().setInt32(t+4,e,!0),_c().setInt32(t+0,s,!0)},__wbg___wbindgen_string_get_914df97fcfa788f2:function(t,i){const s=Nc(i),e="string"==typeof s?s:void 0;var h=Tc(e)?0:Pc(e,Kc.__wbindgen_export,Kc.__wbindgen_export2),r=jc;_c().setInt32(t+4,r,!0),_c().setInt32(t+0,h,!0)},__wbg___wbindgen_throw_81fc77679af83bc6:function(t,i){throw Error(Sc(t,i))},__wbg__wbg_cb_unref_3c3b4f651835fbcb:function(t){Nc(t)._wbg_cb_unref()},__wbg_call_7f2987183bb62793:function(){return Fc((function(t,i){return Qc(Nc(t).call(Nc(i)))}),arguments)},__wbg_call_d578befcc3145dee:function(){return Fc((function(t,i,s){return Qc(Nc(t).call(Nc(i),Nc(s)))}),arguments)},__wbg_clearInterval_26ba580547547579:function(t){return Qc(clearInterval(Jc(t)))},__wbg_close_f181fdc02ee236e6:function(){return Fc((function(t){Nc(t).close()}),arguments)},__wbg_data_60b50110c5bd9349:function(t){return Qc(Nc(t).data)},__wbg_from_741da0f916ab74aa:function(t){return Qc(Array.from(Nc(t)))},__wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a:function(t){let i;try{i=Nc(t)instanceof ArrayBuffer}catch(t){i=!1}return i},__wbg_length_0c32cb8543c8e4c8:function(t){return Nc(t).length},__wbg_new_4f9fafbb3909af72:function(){return Qc({})},__wbg_new_a560378ea1240b14:function(t){return Qc(new Uint8Array(Nc(t)))},__wbg_new_f3c9df4f38f3f798:function(){return Qc([])},__wbg_new_with_str_7cf464e6e0f54ec2:function(){return Fc((function(t,i,s,e){return Qc(new WebSocket(Sc(t,i),Sc(s,e)))}),arguments)},__wbg_prototypesetcall_3e05eb9545565046:function(t,i,s){Uint8Array.prototype.set.call(Dc(t,i),Nc(s))},__wbg_readyState_631d9f7c37e595d7:function(t){return Nc(t).readyState},__wbg_send_64dd480ad0d86a31:function(){return Fc((function(t,i,s){Nc(t).send(Dc(i,s))}),arguments)},__wbg_setInterval_cbf1c35c6a692d37:function(){return Fc((function(t,i){return Qc(setInterval(Nc(t),i))}),arguments)},__wbg_set_6be42768c690e380:function(t,i,s){Nc(t)[Jc(i)]=Jc(s)},__wbg_set_6c60b2e8ad0e9383:function(t,i,s){Nc(t)[i>>>0]=Jc(s)},__wbg_set_binaryType_95c0a0f7586a3903:function(t,i){Nc(t).binaryType=yc[i]},__wbg_set_onclose_47cce56c686db4fb:function(t,i){Nc(t).onclose=Nc(i)},__wbg_set_onerror_3db8bc3e52b2b10b:function(t,i){Nc(t).onerror=Nc(i)},__wbg_set_onmessage_45bd33b110c54f5b:function(t,i){Nc(t).onmessage=Nc(i)},__wbg_set_onopen_7ffeb01f8a628209:function(t,i){Nc(t).onopen=Nc(i)},__wbg_warn_97be992ef0100a92:function(t,i){console.warn(Sc(t,i))},__wbindgen_cast_0000000000000001:function(t,i){return Qc(Gc(t,i,Bc))},__wbindgen_cast_0000000000000002:function(t,i){return Qc(Gc(t,i,bc))},__wbindgen_cast_0000000000000003:function(t,i){return Qc(Gc(t,i,Mc))},__wbindgen_cast_0000000000000004:function(t,i){return Qc(Gc(t,i,vc))},__wbindgen_cast_0000000000000005:function(t){return Qc(t)},__wbindgen_cast_0000000000000006:function(t,i){return Qc(Dc(t,i))},__wbindgen_cast_0000000000000007:function(t,i){return Qc(Sc(t,i))},__wbindgen_cast_0000000000000008:function(t){return Qc(BigInt.asUintN(64,t))},__wbindgen_object_clone_ref:function(t){return Qc(Nc(t))},__wbindgen_object_drop_ref:function(t){Jc(t)}};return{__proto__:null,"./phirepass-channel_bg.js":t}}function vc(t,i){Kc.__wasm_bindgen_func_elem_41(t,i)}function Bc(t,i,s){Kc.__wasm_bindgen_func_elem_37(t,i,Qc(s))}function bc(t,i,s){Kc.__wasm_bindgen_func_elem_37_1(t,i,Qc(s))}function Mc(t,i,s){Kc.__wasm_bindgen_func_elem_37_2(t,i,Qc(s))}const yc=["blob","arraybuffer"],Ec="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>Kc.__wbg_channel_free(t>>>0,1)));function Qc(t){Uc===Hc.length&&Hc.push(Hc.length+1);const i=Uc;return Uc=Hc[i],Hc[i]=t,i}const kc="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>Kc.__wbindgen_export4(t.a,t.b)));function xc(t){const i=typeof t;if("number"==i||"boolean"==i||null==t)return""+t;if("string"==i)return`"${t}"`;if("symbol"==i){const i=t.description;return null==i?"Symbol":`Symbol(${i})`}if("function"==i){const i=t.name;return"string"==typeof i&&i.length>0?`Function(${i})`:"Function"}if(Array.isArray(t)){const i=t.length;let s="[";i>0&&(s+=xc(t[0]));for(let e=1;e<i;e++)s+=", "+xc(t[e]);return s+="]",s}const s=/\[object ([^\]]+)\]/.exec(toString.call(t));let e;if(!(s&&s.length>1))return toString.call(t);if(e=s[1],"Object"==e)try{return"Object("+JSON.stringify(t)+")"}catch(t){return"Object"}return t instanceof Error?`${t.name}: ${t.message}\n${t.stack}`:e}function Dc(t,i){return t>>>=0,Rc().subarray(t/1,t/1+i)}let Lc=null;function _c(){return(null===Lc||!0===Lc.buffer.detached||void 0===Lc.buffer.detached&&Lc.buffer!==Kc.memory.buffer)&&(Lc=new DataView(Kc.memory.buffer)),Lc}function Sc(t,i){return function(t,i){return zc+=i,zc>=Wc&&(Oc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Oc.decode(),zc=i),Oc.decode(Rc().subarray(t,t+i))}(t>>>=0,i)}let $c=null;function Rc(){return null!==$c&&0!==$c.byteLength||($c=new Uint8Array(Kc.memory.buffer)),$c}function Nc(t){return Hc[t]}function Fc(t,i){try{return t.apply(this,i)}catch(t){Kc.__wbindgen_export3(Qc(t))}}let Hc=Array(1024).fill(void 0);Hc.push(void 0,null,!0,!1);let Uc=Hc.length;function Tc(t){return null==t}function Gc(t,i,s){const e={a:t,b:i,cnt:1},h=(...t)=>{e.cnt++;const i=e.a;e.a=0;try{return s(i,e.b,...t)}finally{e.a=i,h._wbg_cb_unref()}};return h._wbg_cb_unref=()=>{0==--e.cnt&&(Kc.__wbindgen_export4(e.a,e.b),e.a=0,kc.unregister(e))},kc.register(h,e,e),h}function Pc(t,i,s){if(void 0===s){const s=qc.encode(t),e=i(s.length,1)>>>0;return Rc().subarray(e,e+s.length).set(s),jc=s.length,e}let e=t.length,h=i(e,1)>>>0;const r=Rc();let n=0;for(;n<e;n++){const i=t.charCodeAt(n);if(i>127)break;r[h+n]=i}if(n!==e){0!==n&&(t=t.slice(n)),h=s(h,e,e=n+3*t.length,1)>>>0;const i=Rc().subarray(h+n,h+e);n+=qc.encodeInto(t,i).written,h=s(h,e,n,1)>>>0}return jc=n,h}function Jc(t){const i=Nc(t);return function(t){t<1028||(Hc[t]=Uc,Uc=t)}(t),i}let Oc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Oc.decode();const Wc=2146435072;let zc=0;const qc=new TextEncoder;"encodeInto"in qc||(qc.encodeInto=function(t,i){const s=qc.encode(t);return i.set(s),{read:t.length,written:s.length}});let Kc,jc=0;var Yc,Zc;!function(t){t[t.Username=0]="Username",t[t.Password=1]="Password",t[t.Default=2]="Default"}(Yc||(Yc={})),function(t){t.Disconnected="disconnected",t.Connected="connected",t.Error="error"}(Zc||(Zc={}));const Xc=i(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.connectionStateChanged=e(this,"connectionStateChanged")}terminal;fitAddon;webLinksAddon;searchAddon;webglAddon;serializeAddon;imageAddon;channel;containerEl;domReady=!1;runtimeReady=!1;connected=!1;inputMode=Yc.Default;resizeObserver;resizeDebounceHandle;session_id;usernameBuffer="";passwordBuffer="";xtermImageSettings={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7};get el(){return this}terminalOptions={termName:"xterm-256color",rendererType:"canvas",allowTransparency:!1,fontFamily:'"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace',fontSize:12,letterSpacing:0,lineHeight:1,allowProposedApi:!0,cursorBlink:!0,cursorWidth:1,theme:{background:"#0b1021",foreground:"#e2e8f0",cursor:"#67e8f9"},scrollback:1e4,fastScrollModifier:"shift",fastScrollSensitivity:5,bellStyle:"sound",convertEol:!1,disableStdin:!1,rightClickSelectsWord:!0,drawBoldTextInBrightColors:!0,minimumContrastRatio:1,windowsMode:!1,macOptionIsMeta:!1,altClickMovesCursor:!0};serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;token;onNodeIdChange(t,i){this.reset_session_state(),this.terminal.reset(),this.channel&&this.channel.is_connected()&&this.close_comms(),t&&(this.open_comms(),this.channel.connect())}serverId;onServerIdChange(t,i){this.onNodeIdChange(this.nodeId,this.nodeId)}connectionStateChanged;create_web_socket_endpoint(){const t=this.allowInsecure?"ws":"wss";return this.allowInsecure||443!==this.serverPort?this.allowInsecure&&80===this.serverPort?`${t}://${this.serverHost}`:`${t}://${this.serverHost}:${this.serverPort}`:`${t}://${this.serverHost}`}async connectedCallback(){await async function(t){if(void 0!==Kc)return Kc;void 0!==t&&(Object.getPrototypeOf(t)===Object.prototype?({module_or_path:t}=t):console.warn("using deprecated parameters for the initialization function; pass a single object instead")),void 0===t&&(t=new URL("phirepass-channel_bg.wasm",import.meta.url));const i=Ic();("string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL)&&(t=fetch(t));const{instance:s}=await async function(t,i){if("function"==typeof Response&&t instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(t,i)}catch(i){if(!t.ok||!function(t){switch(t){case"basic":case"cors":case"default":return!0}return!1}(t.type)||"application/wasm"===t.headers.get("Content-Type"))throw i;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",i)}const s=await t.arrayBuffer();return await WebAssembly.instantiate(s,i)}{const s=await WebAssembly.instantiate(t,i);return s instanceof WebAssembly.Instance?{instance:s,module:t}:s}}(await t,i);return function(t){return Kc=t.exports,Lc=null,$c=null,Kc}(s)}(),this.setup_terminal(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to terminal.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){this.resizeObserver&&this.resizeObserver.disconnect(),this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.close_comms(),this.destroy_terminal()}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.containerEl&&this.terminal&&this.channel&&this.connect()}setup_terminal(){this.terminal=new dr(this.terminalOptions),this.fitAddon=new gr,this.terminal.loadAddon(this.fitAddon),this.webLinksAddon=new vr,this.terminal.loadAddon(this.webLinksAddon),this.searchAddon=new In,this.terminal.loadAddon(this.searchAddon),this.serializeAddon=new kl,this.terminal.loadAddon(this.serializeAddon),this.imageAddon=new pc(this.xtermImageSettings),this.terminal.loadAddon(this.imageAddon);try{this.webglAddon=new Al,this.terminal.loadAddon(this.webglAddon)}catch(t){console.warn("WebGL addon not available or failed to load:",t)}"function"==typeof this.terminal.onResize&&this.terminal.onResize((()=>{this.send_ssh_terminal_resize()}))}destroy_terminal(){this.terminal&&(this.terminal.reset(),"function"==typeof this.terminal.dispose&&this.terminal.dispose())}open_comms(){this.channel=this.serverId?new Cc(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId,this.serverId):new Cc(this.create_web_socket_endpoint()+"/api/web/ws",this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([Zc.Connected]),this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([Zc.Disconnected]),this.terminal.reset()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([Zc.Error,t])})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((t=>{const{web:i}=t.data;switch(i.type){case"Error":this.handle_error(i);break;case"AuthSuccess":this.handle_auth_success(i);break;case"TunnelOpened":this.handle_tunnel_opened(i);break;case"TunnelClosed":this.handle_tunnel_closed(i);break;case"TunnelData":this.handle_tunnel_data(i);break;default:console.warn("Unknown protocol message type:",i)}}))}send_ssh_terminal_resize(){if(!this.containerEl)return void console.warn("Cannot send terminal resize: container element not available");if(!this.nodeId)return void console.warn("Cannot send terminal resize: node_id is missing");if(!this.channel)return void console.warn("Cannot send terminal resize: channel is not initialized");if(!this.channel.is_connected())return void console.warn("Cannot send terminal resize: channel not connected");if(!this.session_id)return void console.warn("Cannot send terminal resize: session_id is missing");this.fitAddon.fit();const t=this.terminal?.cols??0,i=this.terminal?.rows??0,s=this.containerEl.clientWidth??0,e=this.containerEl.clientHeight??0;if(t<=0||i<=0||s<=0||e<=0)console.warn(`Cannot send terminal resize: invalid terminal dimensions cols=${t}, rows=${i}, px_width=${s}, px_height=${e}`);else try{console.log(`Sending terminal resize: cols=${t}, rows=${i}, px_width=${s}, px_height=${e}`),this.channel.send_ssh_terminal_resize(this.nodeId,this.session_id,t,i,s,e)}catch(t){console.error("Failed to send terminal resize:",t)}}send_ssh_data(t){this.channel.is_connected()&&this.session_id&&this.channel.send_ssh_tunnel_data(this.nodeId,this.session_id,t)}handle_error(t){switch(t.kind){case mc.Generic:this.terminal.reset(),this.terminal.write(t.message+"\r\n"),this.terminal.focus();break;case mc.RequiresUsername:this.terminal.reset(),this.inputMode=Yc.Username,this.usernameBuffer="",this.terminal.write("Enter your username: "),this.terminal.focus();break;case mc.RequiresPassword:this.terminal.reset(),this.inputMode=Yc.Password,this.passwordBuffer="",this.terminal.write("Enter your password: "),this.terminal.focus();break;default:console.warn("Unknown error kind:",t)}}close_comms(){this.channel.stop_heartbeat(),this.channel.disconnect()}cancel_credential_entry(){this.inputMode=Yc.Default,this.clear_creds_buffer(),this.terminal.writeln("Authentication cancelled."),this.terminal.reset(),this.close_comms()}clear_creds_buffer(){this.usernameBuffer="",this.passwordBuffer=""}reset_session_state(){this.session_id=void 0,this.inputMode=Yc.Default,this.clear_creds_buffer()}handle_auth_success(t){this.clear_creds_buffer(),this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.channel.open_ssh_tunnel(this.nodeId)}handle_tunnel_opened(t){this.session_id=t.sid,this.terminal.reset(),this.fitAddon.fit(),this.send_ssh_terminal_resize()}handle_tunnel_data(t){this.terminal.write(new Uint8Array(t.data))}handle_tunnel_closed(t){this.session_id=void 0,this.inputMode=Yc.Default,this.clear_creds_buffer(),this.terminal.reset(),this.terminal.writeln("Connection closed."),this.close_comms()}connect(){const t=this.containerEl;console.log("Attempting to connect terminal to container:",t),t&&(this.terminal.open(t),console.log("Terminal opened in container"),this.fitAddon.fit(),this.terminal.focus(),this.terminal.onData(this.handle_terminal_data.bind(this)),this.channel.connect(),this.setup_resize_observer(),this.connected=!0,console.log("Terminal connected and ready"))}setup_resize_observer(){this.resizeObserver=new ResizeObserver((()=>{console.log("Container resized, fitting terminal"),this.resizeDebounceHandle&&clearTimeout(this.resizeDebounceHandle),this.resizeDebounceHandle=setTimeout((()=>{this.fitAddon.fit(),this.send_ssh_terminal_resize()}),100)})),this.resizeObserver.observe(this.containerEl??this.el)}handle_terminal_data(t){switch(this.inputMode){case Yc.Username:this.handle_username_input(t);break;case Yc.Password:this.handle_password_input(t);break;case Yc.Default:this.send_ssh_data(t)}}handle_username_input(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submit_username()):""===t?(this.terminal.write("^C\r\n"),void this.cancel_credential_entry()):void(""!==t?t>=" "&&t<="~"&&(this.usernameBuffer+=t,this.terminal.write(t)):this.usernameBuffer.length&&(this.usernameBuffer=this.usernameBuffer.slice(0,-1),this.terminal.write("\b \b")))}submit_username(){if(!this.channel.is_connected())return;const t=this.usernameBuffer.trim();if(!t)return this.terminal.writeln(""),this.terminal.write("Enter your username: "),void(this.usernameBuffer="");this.inputMode=Yc.Default,this.channel.open_ssh_tunnel(this.nodeId,t)}handle_password_input(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submit_password()):""===t?(this.terminal.write("^C\r\n"),void this.cancel_credential_entry()):void(""!==t?t>=" "&&t<="~"&&(this.passwordBuffer+=t,this.terminal.write("*")):this.passwordBuffer.length&&(this.passwordBuffer=this.passwordBuffer.slice(0,-1),this.terminal.write("\b \b")))}submit_password(){if(!this.channel.is_connected())return;const t=this.passwordBuffer;if(!t)return this.terminal.writeln(""),this.terminal.write("Enter your password: "),void(this.passwordBuffer="");this.inputMode=Yc.Default,this.channel.open_ssh_tunnel(this.nodeId,this.usernameBuffer.trim(),t),this.passwordBuffer="",this.usernameBuffer=""}render(){return h(r,{key:"6c6080f3b370c76871ab48695046557c64d173b6"},h("div",{key:"17c80b9c99de88dc53e61e0bf8725dafcf96d3b6",id:"ccc",ref:t=>this.containerEl=t}))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}static get style(){return".xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#FFF;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1 !important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px !important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:rgba(0,0,0,0);transition:opacity 100ms linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity 800ms linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}:host{display:block;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}:host #ccc{width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}"}},[513,"phirepass-terminal",{terminalOptions:[16],serverHost:[1,"server-host"],serverPort:[2,"server-port"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],nodeId:[1,"node-id"],token:[1],serverId:[1,"server-id"]},void 0,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]);function Vc(){"undefined"!=typeof customElements&&["phirepass-terminal"].forEach((i=>{"phirepass-terminal"===i&&(customElements.get(t(i))||customElements.define(t(i),Xc))}))}Vc();const tu=Xc,iu=Vc;export{tu as PhirepassTerminal,iu as defineCustomElement}
@@ -473,7 +473,7 @@ const ErrorType = Object.freeze({
473
473
  function __wbg_get_imports() {
474
474
  const import0 = {
475
475
  __proto__: null,
476
- __wbg_Error_55538483de6e3abe: function(arg0, arg1) {
476
+ __wbg_Error_2e59b1b37a9a34c3: function(arg0, arg1) {
477
477
  const ret = Error(getStringFromWasm0(arg0, arg1));
478
478
  return addHeapObject(ret);
479
479
  },
@@ -484,14 +484,14 @@ function __wbg_get_imports() {
484
484
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
485
485
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
486
486
  },
487
- __wbg___wbindgen_debug_string_d89627202d0155b7: function(arg0, arg1) {
487
+ __wbg___wbindgen_debug_string_dd5d2d07ce9e6c57: function(arg0, arg1) {
488
488
  const ret = debugString(getObject(arg1));
489
489
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
490
490
  const len1 = WASM_VECTOR_LEN;
491
491
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
492
492
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
493
493
  },
494
- __wbg___wbindgen_string_get_f1161390414f9b59: function(arg0, arg1) {
494
+ __wbg___wbindgen_string_get_914df97fcfa788f2: function(arg0, arg1) {
495
495
  const obj = getObject(arg1);
496
496
  const ret = typeof(obj) === 'string' ? obj : undefined;
497
497
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
@@ -499,17 +499,17 @@ function __wbg_get_imports() {
499
499
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
500
500
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
501
501
  },
502
- __wbg___wbindgen_throw_5549492daedad139: function(arg0, arg1) {
502
+ __wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
503
503
  throw new Error(getStringFromWasm0(arg0, arg1));
504
504
  },
505
- __wbg__wbg_cb_unref_fbe69bb076c16bad: function(arg0) {
505
+ __wbg__wbg_cb_unref_3c3b4f651835fbcb: function(arg0) {
506
506
  getObject(arg0)._wbg_cb_unref();
507
507
  },
508
- __wbg_call_6ae20895a60069a2: function() { return handleError(function (arg0, arg1) {
508
+ __wbg_call_7f2987183bb62793: function() { return handleError(function (arg0, arg1) {
509
509
  const ret = getObject(arg0).call(getObject(arg1));
510
510
  return addHeapObject(ret);
511
511
  }, arguments); },
512
- __wbg_call_8f5d7bb070283508: function() { return handleError(function (arg0, arg1, arg2) {
512
+ __wbg_call_d578befcc3145dee: function() { return handleError(function (arg0, arg1, arg2) {
513
513
  const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
514
514
  return addHeapObject(ret);
515
515
  }, arguments); },
@@ -517,18 +517,18 @@ function __wbg_get_imports() {
517
517
  const ret = clearInterval(takeObject(arg0));
518
518
  return addHeapObject(ret);
519
519
  },
520
- __wbg_close_1bf0654059764e94: function() { return handleError(function (arg0) {
520
+ __wbg_close_f181fdc02ee236e6: function() { return handleError(function (arg0) {
521
521
  getObject(arg0).close();
522
522
  }, arguments); },
523
- __wbg_data_7de671a92a650aba: function(arg0) {
523
+ __wbg_data_60b50110c5bd9349: function(arg0) {
524
524
  const ret = getObject(arg0).data;
525
525
  return addHeapObject(ret);
526
526
  },
527
- __wbg_from_45cebbf5e49a6ac6: function(arg0) {
527
+ __wbg_from_741da0f916ab74aa: function(arg0) {
528
528
  const ret = Array.from(getObject(arg0));
529
529
  return addHeapObject(ret);
530
530
  },
531
- __wbg_instanceof_ArrayBuffer_8d855993947fc3a2: function(arg0) {
531
+ __wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a: function(arg0) {
532
532
  let result;
533
533
  try {
534
534
  result = getObject(arg0) instanceof ArrayBuffer;
@@ -538,62 +538,62 @@ function __wbg_get_imports() {
538
538
  const ret = result;
539
539
  return ret;
540
540
  },
541
- __wbg_length_e6e1633fbea6cfa9: function(arg0) {
541
+ __wbg_length_0c32cb8543c8e4c8: function(arg0) {
542
542
  const ret = getObject(arg0).length;
543
543
  return ret;
544
544
  },
545
- __wbg_new_1d96678aaacca32e: function(arg0) {
546
- const ret = new Uint8Array(getObject(arg0));
545
+ __wbg_new_4f9fafbb3909af72: function() {
546
+ const ret = new Object();
547
547
  return addHeapObject(ret);
548
548
  },
549
- __wbg_new_4370be21fa2b2f80: function() {
550
- const ret = new Array();
549
+ __wbg_new_a560378ea1240b14: function(arg0) {
550
+ const ret = new Uint8Array(getObject(arg0));
551
551
  return addHeapObject(ret);
552
552
  },
553
- __wbg_new_48e1d86cfd30c8e7: function() {
554
- const ret = new Object();
553
+ __wbg_new_f3c9df4f38f3f798: function() {
554
+ const ret = new Array();
555
555
  return addHeapObject(ret);
556
556
  },
557
- __wbg_new_with_str_53b505a6bb7f12f6: function() { return handleError(function (arg0, arg1, arg2, arg3) {
557
+ __wbg_new_with_str_7cf464e6e0f54ec2: function() { return handleError(function (arg0, arg1, arg2, arg3) {
558
558
  const ret = new WebSocket(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
559
559
  return addHeapObject(ret);
560
560
  }, arguments); },
561
- __wbg_prototypesetcall_3875d54d12ef2eec: function(arg0, arg1, arg2) {
561
+ __wbg_prototypesetcall_3e05eb9545565046: function(arg0, arg1, arg2) {
562
562
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
563
563
  },
564
- __wbg_readyState_a08d25cc57214030: function(arg0) {
564
+ __wbg_readyState_631d9f7c37e595d7: function(arg0) {
565
565
  const ret = getObject(arg0).readyState;
566
566
  return ret;
567
567
  },
568
- __wbg_send_da543a379e952bc6: function() { return handleError(function (arg0, arg1, arg2) {
568
+ __wbg_send_64dd480ad0d86a31: function() { return handleError(function (arg0, arg1, arg2) {
569
569
  getObject(arg0).send(getArrayU8FromWasm0(arg1, arg2));
570
570
  }, arguments); },
571
571
  __wbg_setInterval_cbf1c35c6a692d37: function() { return handleError(function (arg0, arg1) {
572
572
  const ret = setInterval(getObject(arg0), arg1);
573
573
  return addHeapObject(ret);
574
574
  }, arguments); },
575
- __wbg_set_4702dfa37c77f492: function(arg0, arg1, arg2) {
576
- getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
577
- },
578
575
  __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
579
576
  getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
580
577
  },
581
- __wbg_set_binaryType_0675f0e51c055ca8: function(arg0, arg1) {
578
+ __wbg_set_6c60b2e8ad0e9383: function(arg0, arg1, arg2) {
579
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
580
+ },
581
+ __wbg_set_binaryType_95c0a0f7586a3903: function(arg0, arg1) {
582
582
  getObject(arg0).binaryType = __wbindgen_enum_BinaryType[arg1];
583
583
  },
584
- __wbg_set_onclose_f791ef701be808a0: function(arg0, arg1) {
584
+ __wbg_set_onclose_47cce56c686db4fb: function(arg0, arg1) {
585
585
  getObject(arg0).onclose = getObject(arg1);
586
586
  },
587
- __wbg_set_onerror_e23002e9224d353b: function(arg0, arg1) {
587
+ __wbg_set_onerror_3db8bc3e52b2b10b: function(arg0, arg1) {
588
588
  getObject(arg0).onerror = getObject(arg1);
589
589
  },
590
- __wbg_set_onmessage_d2fe701a9ce80846: function(arg0, arg1) {
590
+ __wbg_set_onmessage_45bd33b110c54f5b: function(arg0, arg1) {
591
591
  getObject(arg0).onmessage = getObject(arg1);
592
592
  },
593
- __wbg_set_onopen_0556381d0db30cbb: function(arg0, arg1) {
593
+ __wbg_set_onopen_7ffeb01f8a628209: function(arg0, arg1) {
594
594
  getObject(arg0).onopen = getObject(arg1);
595
595
  },
596
- __wbg_warn_7e545c047609d0b6: function(arg0, arg1) {
596
+ __wbg_warn_97be992ef0100a92: function(arg0, arg1) {
597
597
  console.warn(getStringFromWasm0(arg0, arg1));
598
598
  },
599
599
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
@@ -1242,8 +1242,8 @@ const PhirepassTerminal = class {
1242
1242
  const rows = this.terminal?.rows ?? 0;
1243
1243
  const px_width = this.containerEl.clientWidth ?? 0;
1244
1244
  const px_height = this.containerEl.clientHeight ?? 0;
1245
- if (cols <= 0 || rows <= 0) {
1246
- console.warn('Cannot send terminal resize: invalid terminal dimensions (cols:', cols, 'rows:', rows, ') ');
1245
+ if (cols <= 0 || rows <= 0 || px_width <= 0 || px_height <= 0) {
1246
+ console.warn(`Cannot send terminal resize: invalid terminal dimensions cols=${cols}, rows=${rows}, px_width=${px_width}, px_height=${px_height}`);
1247
1247
  return;
1248
1248
  }
1249
1249
  try {
@@ -1447,7 +1447,7 @@ const PhirepassTerminal = class {
1447
1447
  this.usernameBuffer = "";
1448
1448
  }
1449
1449
  render() {
1450
- return (h$1(Host, { key: '71243a4c9c9468091e5ab830857f91b9b57812b0' }, h$1("div", { key: '0dd9ae1e44cbf78f8a6ede6604c35d7d441cea93', id: "ccc", ref: el => (this.containerEl = el) })));
1450
+ return (h$1(Host, { key: '6c6080f3b370c76871ab48695046557c64d173b6' }, h$1("div", { key: '17c80b9c99de88dc53e61e0bf8725dafcf96d3b6', id: "ccc", ref: el => (this.containerEl = el) })));
1451
1451
  }
1452
1452
  static get watchers() { return {
1453
1453
  "nodeId": [{
@@ -46,4 +46,4 @@ import{r as t,c as i,g as s,h as e,H as h}from"./p-C8ZFkLEv.js";
46
46
  * Fabrice Bellard's javascript vt100 for jslinux:
47
47
  * http://bellard.org/jslinux/
48
48
  * Copyright (c) 2011 Fabrice Bellard
49
- */function Zl(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}(t=>{t.isLessThan=function(t){return t<0},t.isLessThanOrEqual=function(t){return t<=0},t.isGreaterThan=function(t){return t>0},t.isNeitherLessOrGreaterThan=function(t){return 0===t},t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(_l||={}),(t=>{function i(t){return t&&"object"==typeof t&&"function"==typeof t[Symbol.iterator]}t.is=i;let s=Object.freeze([]);function*e(t){yield t}t.empty=function(){return s},t.single=e,t.wrap=function(t){return i(t)?t:e(t)},t.from=function(t){return t||s},t.reverse=function*(t){for(let i=t.length-1;i>=0;i--)yield t[i]},t.isEmpty=function(t){return!t||!0===t[Symbol.iterator]().next().done},t.first=function(t){return t[Symbol.iterator]().next().value},t.some=function(t,i){let s=0;for(let e of t)if(i(e,s++))return!0;return!1},t.find=function(t,i){for(let s of t)if(i(s))return s},t.filter=function*(t,i){for(let s of t)i(s)&&(yield s)},t.map=function*(t,i){let s=0;for(let e of t)yield i(e,s++)},t.flatMap=function*(t,i){let s=0;for(let e of t)yield*i(e,s++)},t.concat=function*(...t){for(let i of t)yield*i},t.reduce=function(t,i,s){let e=s;for(let s of t)e=i(e,s);return e},t.slice=function*(t,i,s=t.length){for(i<0&&(i+=t.length),s<0?s+=t.length:s>t.length&&(s=t.length);i<s;i++)yield t[i]},t.consume=function(i,s=Number.POSITIVE_INFINITY){let e=[];if(0===s)return[e,i];let h=i[Symbol.iterator]();for(let i=0;i<s;i++){let i=h.next();if(i.done)return[e,t.empty()];e.push(i.value)}return[e,{[Symbol.iterator]:()=>h}]},t.asyncToArray=async function(t){let i=[];for await(let s of t)i.push(s);return Promise.resolve(i)}})(Sl||={});var Xl=class t{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{!function(t){if(Sl.is(t)){let i=[];for(let s of t)if(s)try{s.dispose()}catch(t){i.push(t)}if(1===i.length)throw i[0];if(i.length>1)throw new AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}t&&t.dispose()}(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(i),i}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};Xl.DISABLE_DISPOSED_WARNING=!1;var Vl=Xl,tc=class{constructor(){this._store=new Vl}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};tc.None=Object.freeze({dispose(){}});var ic=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},sc=class t extends tc{constructor(t){super(),this._terminal=t,this._optionsRefresh=this._register(new ic),this._oldOpen=this._terminal._core.open,this._terminal._core.open=t=>{this._oldOpen?.call(this._terminal._core,t),this._open()},this._terminal._core.screenElement&&this._open(),this._optionsRefresh.value=this._terminal._core.optionsService.onOptionChange((t=>{"fontSize"===t&&(this.rescaleCanvas(),this._renderService?.refreshRows(0,this._terminal.rows))})),this._register(function(t){return{dispose:Zl((()=>{t()}))}}((()=>{this.removeLayerFromDom(),this._terminal._core&&this._oldOpen&&(this._terminal._core.open=this._oldOpen,this._oldOpen=void 0),this._renderService&&this._oldSetRenderer&&(this._renderService.setRenderer=this._oldSetRenderer,this._oldSetRenderer=void 0),this._renderService=void 0,this.canvas=void 0,this._ctx=void 0,this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0})))}static createCanvas(t,i,s){let e=(t||document).createElement("canvas");return e.width=0|i,e.height=0|s,e}static createImageData(t,i,s,e){if("function"!=typeof ImageData){let h=t.createImageData(i,s);return e&&h.data.set(new Uint8ClampedArray(e,0,i*s*4)),h}return e?new ImageData(new Uint8ClampedArray(e,0,i*s*4),i,s):new ImageData(i,s)}static createImageBitmap(t){return"function"!=typeof createImageBitmap?Promise.resolve(void 0):createImageBitmap(t)}showPlaceholder(t){t?!this._placeholder&&-1!==this.cellSize.height&&this._createPlaceHolder(Math.max(this.cellSize.height+1,24)):(this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0),this._renderService?.refreshRows(0,this._terminal.rows)}get dimensions(){return this._renderService?.dimensions}get cellSize(){return{width:this.dimensions?.css.cell.width||-1,height:this.dimensions?.css.cell.height||-1}}clearLines(t,i){this._ctx?.clearRect(0,t*(this.dimensions?.css.cell.height||0),this.dimensions?.css.canvas.width||0,(++i-t)*(this.dimensions?.css.cell.height||0))}clearAll(){this._ctx?.clearRect(0,0,this.canvas?.width||0,this.canvas?.height||0)}draw(t,i,s,e,h=1){if(!this._ctx)return;let{width:r,height:n}=this.cellSize;if(-1===r||-1===n)return;this._rescaleImage(t,r,n);let o=t.actual,a=Math.ceil(o.width/r),l=i%a*r,c=Math.floor(i/a)*n,u=s*r,A=e*n,f=h*r+l>o.width?o.width-l:h*r,d=c+n>o.height?o.height-c:n;this._ctx.drawImage(o,Math.floor(l),Math.floor(c),Math.ceil(f),Math.ceil(d),Math.floor(u),Math.floor(A),Math.ceil(f),Math.ceil(d))}extractTile(i,s){let{width:e,height:h}=this.cellSize;if(-1===e||-1===h)return;this._rescaleImage(i,e,h);let r=i.actual,n=Math.ceil(r.width/e),o=s%n*e,a=Math.floor(s/n)*h,l=e+o>r.width?r.width-o:e,c=a+h>r.height?r.height-a:h,u=t.createCanvas(this.document,l,c),A=u.getContext("2d");return A?(A.drawImage(r,Math.floor(o),Math.floor(a),Math.floor(l),Math.floor(c),0,0,Math.floor(l),Math.floor(c)),u):void 0}drawPlaceholder(t,i,s=1){if(this._ctx){let{width:e,height:h}=this.cellSize;if(-1===e||-1===h||(this._placeholder?h>=this._placeholder.height&&this._createPlaceHolder(h+1):this._createPlaceHolder(Math.max(h+1,24)),!this._placeholder))return;this._ctx.drawImage(this._placeholderBitmap||this._placeholder,t*e,i*h%2?0:1,e*s,h,t*e,i*h,e*s,h)}}rescaleCanvas(){this.canvas&&(this.canvas.width!==this.dimensions.css.canvas.width||this.canvas.height!==this.dimensions.css.canvas.height)&&(this.canvas.width=this.dimensions.css.canvas.width||0,this.canvas.height=this.dimensions.css.canvas.height||0)}_rescaleImage(i,s,e){if(s===i.actualCellSize.width&&e===i.actualCellSize.height)return;let{width:h,height:r}=i.origCellSize;if(s===h&&e===r)return i.actual=i.orig,i.actualCellSize.width=h,void(i.actualCellSize.height=r);let n=t.createCanvas(this.document,Math.ceil(i.orig.width*s/h),Math.ceil(i.orig.height*e/r)),o=n.getContext("2d");o&&(o.drawImage(i.orig,0,0,n.width,n.height),i.actual=n,i.actualCellSize.width=s,i.actualCellSize.height=e)}_open(){this._renderService=this._terminal._core._renderService,this._oldSetRenderer=this._renderService.setRenderer.bind(this._renderService),this._renderService.setRenderer=t=>{this.removeLayerFromDom(),this._oldSetRenderer?.call(this._renderService,t)}}insertLayerToDom(){this.document&&this._terminal._core.screenElement?this.canvas||(this.canvas=t.createCanvas(this.document,this.dimensions?.css.canvas.width||0,this.dimensions?.css.canvas.height||0),this.canvas.classList.add("xterm-image-layer"),this._terminal._core.screenElement.appendChild(this.canvas),this._ctx=this.canvas.getContext("2d",{alpha:!0,desynchronized:!0}),this.clearAll()):console.warn("image addon: cannot insert output canvas to DOM, missing document or screenElement")}removeLayerFromDom(){this.canvas&&(this._ctx=void 0,this.canvas.remove(),this.canvas=void 0)}_createPlaceHolder(i=24){this._placeholderBitmap?.close(),this._placeholderBitmap=void 0;let s=32,e=t.createCanvas(this.document,s,i),h=e.getContext("2d",{alpha:!1});if(!h)return;let r=t.createImageData(h,s,i),n=new Uint32Array(r.data.buffer),o=(0,Yl.toRGBA8888)(0,0,0),a=(0,Yl.toRGBA8888)(255,255,255);n.fill(o);for(let t=0;t<i;++t){let i=t%2,e=t*s;for(let t=0;t<s;t+=2)n[e+t+i]=a}h.putImageData(r,0,0);let l=screen.width+s-1&-32||4096;this._placeholder=t.createCanvas(this.document,l,i);let c=this._placeholder.getContext("2d",{alpha:!1});if(c){for(let t=0;t<l;t+=s)c.drawImage(e,t,0);t.createImageBitmap(this._placeholder).then((t=>this._placeholderBitmap=t))}else this._placeholder=void 0}get document(){return this._terminal._core._coreBrowserService?.window.document}},ec={width:7,height:14},hc=class t{constructor(t=0,i=0,s=-1,e=-1){this.imageId=s,this.tileId=e,this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(t){this._ext&=-67108864,this._ext|=67108863&t}get underlineVariantOffset(){let t=(3758096384&this._ext)>>29;return t<0?4294967288^t:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}get urlId(){return this._urlId}set urlId(t){this._urlId=t}clone(){return new t(this._ext,this._urlId,this.imageId,this.tileId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId&&-1===this.imageId}},rc=new hc,nc=class{constructor(t,i,s){this._terminal=t,this._renderer=i,this._opts=s,this._images=new Map,this._lastId=0,this._lowestId=0,this._fullyCleared=!1,this._needsFullClear=!1,this._pixelLimit=25e5;try{this.setLimit(this._opts.storageLimit)}catch(t){console.error(t.message),console.warn(`storageLimit is set to ${this.getLimit()} MB`)}this._viewportMetrics={cols:this._terminal.cols,rows:this._terminal.rows}}dispose(){this.reset()}reset(){for(let t of this._images.values())t.marker?.dispose();this._images.clear(),this._renderer.clearAll()}getLimit(){return 4*this._pixelLimit/1e6}setLimit(t){if(t<.5||t>1e3)throw RangeError("invalid storageLimit, should be at least 0.5 MB and not exceed 1G");this._pixelLimit=t/4*1e6>>>0,this._evictOldest(0)}getUsage(){return 4*this._getStoredPixels()/1e6}_getStoredPixels(){let t=0;for(let i of this._images.values())i.orig&&(t+=i.orig.width*i.orig.height,i.actual&&i.actual!==i.orig&&(t+=i.actual.width*i.actual.height));return t}_delImg(t){let i=this._images.get(t);this._images.delete(t),i&&window.ImageBitmap&&i.orig instanceof ImageBitmap&&i.orig.close()}wipeAlternate(){let t=[];for(let[i,s]of this._images.entries())"alternate"===s.bufferType&&(s.marker?.dispose(),t.push(i));for(let i of t)this._delImg(i);this._needsFullClear=!0,this._fullyCleared=!1}advanceCursor(t){if(this._opts.sixelScrolling){let i=this._renderer.cellSize;(-1===i.width||-1===i.height)&&(i=ec);let s=Math.ceil(t/i.height);for(let t=1;t<s;++t)this._terminal._core._inputHandler.lineFeed()}}addImage(t){this._evictOldest(t.width*t.height);let i=this._renderer.cellSize;(-1===i.width||-1===i.height)&&(i=ec);let s=Math.ceil(t.width/i.width),e=Math.ceil(t.height/i.height),h=++this._lastId,r=this._terminal._core.buffer,n=this._terminal.cols,o=this._terminal.rows,a=r.x,l=r.y,c=a,u=0;this._opts.sixelScrolling||(r.x=0,r.y=0,c=0),this._terminal._core._inputHandler._dirtyRowTracker.markDirty(r.y);for(let t=0;t<e;++t){let i=r.lines.get(r.y+r.ybase);for(let e=0;e<s&&!(c+e>=n);++e)this._writeToCell(i,c+e,h,t*s+e),u++;if(this._opts.sixelScrolling)t<e-1&&this._terminal._core._inputHandler.lineFeed();else if(++r.y>=o)break;r.x=c}this._terminal._core._inputHandler._dirtyRowTracker.markDirty(r.y),this._opts.sixelScrolling?r.x=c:(r.x=a,r.y=l);let A=[];for(let[t,i]of this._images.entries())i.tileCount<1&&(i.marker?.dispose(),A.push(t));for(let t of A)this._delImg(t);let f=this._terminal.registerMarker(0);f?.onDispose((()=>{this._images.get(h)&&this._delImg(h)})),"alternate"===this._terminal.buffer.active.type&&this._evictOnAlternate();let d={orig:t,origCellSize:i,actual:t,actualCellSize:{...i},marker:f||void 0,tileCount:u,bufferType:this._terminal.buffer.active.type};this._images.set(h,d)}render(t){if(!this._renderer.canvas&&this._images.size&&(this._renderer.insertLayerToDom(),!this._renderer.canvas))return;if(this._renderer.rescaleCanvas(),!this._images.size)return this._fullyCleared||(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1),void(this._renderer.canvas&&this._renderer.removeLayerFromDom());this._needsFullClear&&(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1);let{start:i,end:s}=t,e=this._terminal._core.buffer,h=this._terminal._core.cols;this._renderer.clearLines(i,s);for(let t=i;t<=s;++t){let i=e.lines.get(t+e.ydisp);if(!i)return;for(let s=0;s<h;++s)if(268435456&i.getBg(s)){let e=i._extendedAttrs[s]||rc,r=e.imageId;if(void 0===r||-1===r)continue;let n=this._images.get(r);if(-1!==e.tileId){let o=e.tileId,a=s,l=1;for(;++s<h&&268435456&i.getBg(s)&&(e=i._extendedAttrs[s]||rc)&&e.imageId===r&&e.tileId===o+l;)l++;s--,n?n.actual&&this._renderer.draw(n,o,a,t,l):this._opts.showPlaceholder&&this._renderer.drawPlaceholder(a,t,l),this._fullyCleared=!1}}}}viewportResize(t){if(!this._images.size)return void(this._viewportMetrics=t);if(this._viewportMetrics.cols>=t.cols)return void(this._viewportMetrics=t);let i=this._terminal._core.buffer,s=i.lines.length,e=this._viewportMetrics.cols-1;for(let h=0;h<s;++h){let s=i.lines.get(h);if(268435456&s.getBg(e)){let i=s._extendedAttrs[e]||rc,h=i.imageId;if(void 0===h||-1===h)continue;let r=this._images.get(h);if(!r)continue;let n=Math.ceil((r.actual?.width||0)/r.actualCellSize.width);if(i.tileId%n+1>=n)continue;let o=!1;for(let i=e+1;i>t.cols;++i)if(4194303&s._data[3*i+0]){o=!0;break}if(o)continue;let a=Math.min(t.cols,n-i.tileId%n+e),l=i.tileId;for(let t=e+1;t<a;++t)this._writeToCell(s,t,h,++l),r.tileCount++}}this._viewportMetrics=t}getImageAtBufferCell(t,i){let s=this._terminal._core.buffer.lines.get(i);if(s&&268435456&s.getBg(t)){let i=s._extendedAttrs[t]||rc;if(i.imageId&&-1!==i.imageId){let t=this._images.get(i.imageId)?.orig;if(window.ImageBitmap&&t instanceof ImageBitmap){let i=sc.createCanvas(window.document,t.width,t.height);return i.getContext("2d")?.drawImage(t,0,0,t.width,t.height),i}return t}}}extractTileAtBufferCell(t,i){let s=this._terminal._core.buffer.lines.get(i);if(s&&268435456&s.getBg(t)){let i=s._extendedAttrs[t]||rc;if(i.imageId&&-1!==i.imageId&&-1!==i.tileId){let t=this._images.get(i.imageId);if(t)return this._renderer.extractTile(t,i.tileId)}}}_evictOldest(t){let i=this._getStoredPixels(),s=i;for(;this._pixelLimit<s+t&&this._images.size;){let t=this._images.get(++this._lowestId);t&&t.orig&&(s-=t.orig.width*t.orig.height,t.actual&&t.orig!==t.actual&&(s-=t.actual.width*t.actual.height),t.marker?.dispose(),this._delImg(this._lowestId))}return i-s}_writeToCell(t,i,s,e){if(268435456&t._data[3*i+2]){let h=t._extendedAttrs[i];if(h){if(void 0!==h.imageId){let t=this._images.get(h.imageId);return t&&t.tileCount--,h.imageId=s,void(h.tileId=e)}return void(t._extendedAttrs[i]=new hc(h.ext,h.urlId,s,e))}}t._data[3*i+2]|=268435456,t._extendedAttrs[i]=new hc(0,0,s,e)}_evictOnAlternate(){for(let t of this._images.values())"alternate"===t.bufferType&&(t.tileCount=0);let t=this._terminal._core.buffer;for(let i=0;i<this._terminal.rows;++i){let s=t.lines.get(i);if(s)for(let t=0;t<this._terminal.cols;++t)if(268435456&s._data[3*t+2]){let i=s._extendedAttrs[t]?.imageId;if(i){let t=this._images.get(i);t&&t.tileCount++}}}let i=[];for(let[t,s]of this._images.entries())"alternate"===s.bufferType&&!s.tileCount&&(s.marker?.dispose(),i.push(t));for(let t of i)this._delImg(t)}},oc=Ol(ql());function ac(t){let i="";for(let s=0;s<t.length;++s)i+=String.fromCharCode(t[s]);return i}function lc(t){let i=0;for(let s=0;s<t.length;++s){if(t[s]<48||t[s]>57)throw new Error("illegal char");i=10*i+t[s]-48}return i}function cc(t){let i=ac(t);if(!i.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw new Error("illegal size");return i}var uc={inline:lc,size:lc,name:function(t){if(typeof Buffer<"u")return Buffer.from(ac(t),"base64").toString();let i=atob(ac(t)),s=new Uint8Array(i.length);for(let t=0;t<s.length;++t)s[t]=i.charCodeAt(t);return(new TextDecoder).decode(s)},width:cc,height:cc,preserveAspectRatio:lc},Ac=[70,105,108,101],fc=1024,dc=class{constructor(){this.state=0,this._buffer=new Uint32Array(fc),this._position=0,this._key="",this.fields={}}reset(){this._buffer.fill(0),this.state=0,this._position=0,this.fields={},this._key=""}parse(t,i,s){let e=this.state,h=this._position,r=this._buffer;if(1===e||4===e||0===e&&h>6)return-1;for(let n=i;n<s;++n){let i=t[n];switch(i){case 59:if(!this._storeValue(h))return this._a();e=2,h=0;break;case 61:if(0===e){for(let t=0;t<Ac.length;++t)if(r[t]!==Ac[t])return this._a();e=2,h=0}else if(2===e){if(!this._storeKey(h))return this._a();e=3,h=0}else if(3===e){if(h>=fc)return this._a();r[h++]=i}break;case 58:return 3!==e||this._storeValue(h)?(this.state=4,n+1):this._a();default:if(h>=fc)return this._a();r[h++]=i}}return this.state=e,this._position=h,-2}_a(){return this.state=1,-1}_storeKey(t){let i=ac(this._buffer.subarray(0,t));return!!i&&(this._key=i,this.fields[i]=null,!0)}_storeValue(t){if(this._key){try{let i=this._buffer.slice(0,t);this.fields[this._key]=uc[this._key]?uc[this._key](i):i}catch{return!1}return!0}return!1}},gc={mime:"unsupported",width:0,height:0},wc={name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},pc=class{constructor(t,i,s,e){this._opts=t,this._renderer=i,this._storage=s,this._coreTerminal=e,this._aborted=!1,this._hp=new dc,this._header=wc,this._dec=new oc.default(4194304),this._metrics=gc}reset(){}start(){this._aborted=!1,this._header=wc,this._metrics=gc,this._hp.reset()}put(t,i,s){if(!this._aborted)if(4===this._hp.state)this._dec.put(t,i,s)&&(this._dec.release(),this._aborted=!0);else{let e=this._hp.parse(t,i,s);if(-1===e)return void(this._aborted=!0);if(e>0){if(this._header=Object.assign({},wc,this._hp.fields),!this._header.inline||!this._header.size||this._header.size>this._opts.iipSizeLimit)return void(this._aborted=!0);this._dec.init(this._header.size),this._dec.put(t,e,s)&&(this._dec.release(),this._aborted=!0)}}}end(t){if(this._aborted)return!0;let i=0,s=0,e=!0;if((e=t)&&(e=!this._dec.end())&&(this._metrics=function(t){if(t.length<24)return gc;let i=new Uint32Array(t.buffer,t.byteOffset,6);if(1196314761===i[0]&&169478669===i[1]&&1380206665===i[3])return{mime:"image/png",width:t[16]<<24|t[17]<<16|t[18]<<8|t[19],height:t[20]<<24|t[21]<<16|t[22]<<8|t[23]};if(255===t[0]&&216===t[1]&&255===t[2]){let[i,s]=function(t){let i=t.length,s=4,e=t[s]<<8|t[s+1];for(;;){if(s+=e,s>=i)return[0,0];if(255!==t[s])return[0,0];if(192===t[s+1]||194===t[s+1])return s+8<i?[t[s+7]<<8|t[s+8],t[s+5]<<8|t[s+6]]:[0,0];s+=2,e=t[s]<<8|t[s+1]}}(t);return{mime:"image/jpeg",width:i,height:s}}return 944130375!==i[0]||55!==t[4]&&57!==t[4]||97!==t[5]?gc:{mime:"image/gif",width:t[7]<<8|t[6],height:t[9]<<8|t[8]}}(this._dec.data8),(e="unsupported"!==this._metrics.mime)&&(i=this._metrics.width,s=this._metrics.height,(e=i&&s&&i*s<this._opts.pixelLimit)&&([i,s]=this._resize(i,s).map(Math.floor),e=i&&s&&i*s<this._opts.pixelLimit))),!e)return this._dec.release(),!0;let h=new Blob([this._dec.data8],{type:this._metrics.mime});if(this._dec.release(),!window.createImageBitmap){let t=URL.createObjectURL(h),e=new Image;return new Promise((h=>{e.addEventListener("load",(()=>{URL.revokeObjectURL(t);let r=sc.createCanvas(window.document,i,s);r.getContext("2d")?.drawImage(e,0,0,i,s),this._storage.addImage(r),h(!0)})),e.src=t,setTimeout((()=>h(!0)),1e3)}))}return createImageBitmap(h,{resizeWidth:i,resizeHeight:s}).then((t=>(this._storage.addImage(t),!0)))}_resize(t,i){let s=this._renderer.dimensions?.css.cell.width||ec.width,e=this._renderer.dimensions?.css.cell.height||ec.height,h=this._renderer.dimensions?.css.canvas.width||s*this._coreTerminal.cols,r=this._renderer.dimensions?.css.canvas.height||e*this._coreTerminal.rows,n=this._dim(this._header.width,h,s),o=this._dim(this._header.height,r,e);if(!n&&!o){let s=Math.min(h/t,(r-e)/i);return s<1?[t*s,i*s]:[t,i]}return n?!this._header.preserveAspectRatio&&n&&o?[n,o]:[n,i*n/t]:[t*o/i,o]}_dim(t,i,s){return"auto"===t?0:t.endsWith("%")?parseInt(t.slice(0,-1))*i/100:t.endsWith("px")?parseInt(t.slice(0,-2)):parseInt(t)*s}},Cc=Ol(Wl()),mc=Ol(jl()),Ic=Cc.PALETTE_ANSI_256;Ic.set(Cc.PALETTE_VT340_COLOR);var vc=class{constructor(t,i,s){this._opts=t,this._storage=i,this._coreTerminal=s,this._size=0,this._aborted=!1,(0,mc.DecoderAsync)({memoryLimit:4*this._opts.pixelLimit,palette:Ic,paletteLimit:this._opts.sixelPaletteLimit}).then((t=>this._dec=t))}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,Ic,this._opts.sixelPaletteLimit))}hook(t){if(this._size=0,this._aborted=!1,this._dec){let i=1===t.params[1]?0:function(t,i){let s=0;if(!i)return s;if(t.isInverse())if(t.isFgDefault())s=Bc(i.foreground.rgba);else if(t.isFgRGB()){let i=t.constructor.toColorRGB(t.getFgColor());s=(0,Cc.toRGBA8888)(...i)}else s=Bc(i.ansi[t.getFgColor()].rgba);else if(t.isBgDefault())s=Bc(i.background.rgba);else if(t.isBgRGB()){let i=t.constructor.toColorRGB(t.getBgColor());s=(0,Cc.toRGBA8888)(...i)}else s=Bc(i.ansi[t.getBgColor()].rgba);return s}(this._coreTerminal._core._inputHandler._curAttrData,this._coreTerminal._core._themeService?.colors);this._dec.init(i,null,this._opts.sixelPaletteLimit)}}put(t,i,s){if(!this._aborted&&this._dec){if(this._size+=s-i,this._size>this._opts.sixelSizeLimit)return console.warn("SIXEL: too much data, aborting"),this._aborted=!0,void this._dec.release();try{this._dec.decode(t,i,s)}catch(t){console.warn(`SIXEL: error while decoding image - ${t}`),this._aborted=!0,this._dec.release()}}}unhook(t){if(this._aborted||!t||!this._dec)return!0;let i=this._dec.width,s=this._dec.height;if(!i||!s)return s&&this._storage.advanceCursor(s),!0;let e=sc.createCanvas(void 0,i,s);return e.getContext("2d")?.putImageData(new ImageData(this._dec.data8,i,s),0,0),this._dec.memoryUsage>4194304&&this._dec.release(),this._storage.addImage(e),!0}};function Bc(t){return Cc.BIG_ENDIAN?t:(255&t)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255}var bc={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7},Mc=class{constructor(t){this._disposables=[],this._handlers=new Map,this._opts=Object.assign({},bc,t),this._defaultOpts=Object.assign({},bc,t)}dispose(){for(let t of this._disposables)t.dispose();this._disposables.length=0,this._handlers.clear()}_disposeLater(...t){for(let i of t)this._disposables.push(i)}activate(t){if(this._terminal=t,this._renderer=new sc(t),this._storage=new nc(t,this._renderer,this._opts),this._opts.enableSizeReports){let i=t.options.windowOptions||{};i.getWinSizePixels=!0,i.getCellSizePixels=!0,i.getWinSizeChars=!0,t.options.windowOptions=i}if(this._disposeLater(this._renderer,this._storage,t.parser.registerCsiHandler({prefix:"?",final:"h"},(t=>this._decset(t))),t.parser.registerCsiHandler({prefix:"?",final:"l"},(t=>this._decrst(t))),t.parser.registerCsiHandler({final:"c"},(t=>this._da1(t))),t.parser.registerCsiHandler({prefix:"?",final:"S"},(t=>this._xtermGraphicsAttributes(t))),t.onRender((t=>this._storage?.render(t))),t.parser.registerCsiHandler({intermediates:"!",final:"p"},(()=>this.reset())),t.parser.registerEscHandler({final:"c"},(()=>this.reset())),t._core._inputHandler.onRequestReset((()=>this.reset())),t.buffer.onBufferChange((()=>this._storage?.wipeAlternate())),t.onResize((t=>this._storage?.viewportResize(t)))),this._opts.sixelSupport){let i=new vc(this._opts,this._storage,t);this._handlers.set("sixel",i),this._disposeLater(t._core._inputHandler._parser.registerDcsHandler({final:"q"},i))}if(this._opts.iipSupport){let i=new pc(this._opts,this._renderer,this._storage,t);this._handlers.set("iip",i),this._disposeLater(t._core._inputHandler._parser.registerOscHandler(1337,i))}}reset(){this._opts.sixelScrolling=this._defaultOpts.sixelScrolling,this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._storage?.reset();for(let t of this._handlers.values())t.reset();return!1}get storageLimit(){return this._storage?.getLimit()||-1}set storageLimit(t){this._storage?.setLimit(t),this._opts.storageLimit=t}get storageUsage(){return this._storage?this._storage.getUsage():-1}get showPlaceholder(){return this._opts.showPlaceholder}set showPlaceholder(t){this._opts.showPlaceholder=t,this._renderer?.showPlaceholder(t)}getImageAtBufferCell(t,i){return this._storage?.getImageAtBufferCell(t,i)}extractTileAtBufferCell(t,i){return this._storage?.extractTileAtBufferCell(t,i)}_report(t){this._terminal?._core.coreService.triggerDataEvent(t)}_decset(t){for(let i=0;i<t.length;++i)80===t[i]&&(this._opts.sixelScrolling=!1);return!1}_decrst(t){for(let i=0;i<t.length;++i)80===t[i]&&(this._opts.sixelScrolling=!0);return!1}_da1(t){return!!t[0]||!!this._opts.sixelSupport&&(this._report("[?62;4;9;22c"),!0)}_xtermGraphicsAttributes(t){if(t.length<2)return!0;if(1===t[0])switch(t[1]){case 1:return this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`),!0;case 2:this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`);for(let t of this._handlers.values())t.reset();return!0;case 3:return t.length>2&&!(t[2]instanceof Array)&&t[2]<=4096?(this._opts.sixelPaletteLimit=t[2],this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`)):this._report(`[?${t[0]};2S`),!0;case 4:return this._report(`[?${t[0]};0;4096S`),!0;default:return this._report(`[?${t[0]};2S`),!0}if(2===t[0])switch(t[1]){case 1:let i=this._renderer?.dimensions?.css.canvas.width,s=this._renderer?.dimensions?.css.canvas.height;if(!i||!s){let t=ec;i=(this._terminal?.cols||80)*t.width,s=(this._terminal?.rows||24)*t.height}if(i*s<this._opts.pixelLimit)this._report(`[?${t[0]};0;${i.toFixed(0)};${s.toFixed(0)}S`);else{let i=Math.floor(Math.sqrt(this._opts.pixelLimit));this._report(`[?${t[0]};0;${i};${i}S`)}return!0;case 4:let e=Math.floor(Math.sqrt(this._opts.pixelLimit));return this._report(`[?${t[0]};0;${e};${e}S`),!0;default:return this._report(`[?${t[0]};2S`),!0}return this._report(`[?${t[0]};1S`),!0}};class yc{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,Sc.unregister(this),t}free(){const t=this.__destroy_into_raw();iu.__wbg_channel_free(t,0)}authenticate(t,i,s){const e=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),h=su,r=jc(i,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_authenticate(this.__wbg_ptr,e,h,r,su,qc(s)?4294967297:s>>>0)}connect(){iu.channel_connect(this.__wbg_ptr)}disconnect(){iu.channel_disconnect(this.__wbg_ptr)}is_connected(){return 0!==iu.channel_is_connected(this.__wbg_ptr)}is_disconnected(){return 0!==iu.channel_is_disconnected(this.__wbg_ptr)}constructor(t,i,s){const e=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),h=su,r=jc(i,iu.__wbindgen_export,iu.__wbindgen_export2),n=su;var o=qc(s)?0:jc(s,iu.__wbindgen_export,iu.__wbindgen_export2);const a=iu.channel_new(e,h,r,n,o,su);return this.__wbg_ptr=a>>>0,Sc.register(this,this.__wbg_ptr,this),this}on_connection_close(t){iu.channel_on_connection_close(this.__wbg_ptr,qc(t)?0:$c(t))}on_connection_error(t){iu.channel_on_connection_error(this.__wbg_ptr,qc(t)?0:$c(t))}on_connection_message(t){iu.channel_on_connection_message(this.__wbg_ptr,qc(t)?0:$c(t))}on_connection_open(t){iu.channel_on_connection_open(this.__wbg_ptr,qc(t)?0:$c(t))}on_protocol_message(t){iu.channel_on_protocol_message(this.__wbg_ptr,qc(t)?0:$c(t))}open_sftp_tunnel(t,i,s,e){const h=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),r=su;var n=qc(i)?0:jc(i,iu.__wbindgen_export,iu.__wbindgen_export2),o=su,a=qc(s)?0:jc(s,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_open_sftp_tunnel(this.__wbg_ptr,h,r,n,o,a,su,qc(e)?4294967297:e>>>0)}open_ssh_tunnel(t,i,s,e){const h=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),r=su;var n=qc(i)?0:jc(i,iu.__wbindgen_export,iu.__wbindgen_export2),o=su,a=qc(s)?0:jc(s,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_open_ssh_tunnel(this.__wbg_ptr,h,r,n,o,a,su,qc(e)?4294967297:e>>>0)}send_sftp_delete(t,i,s,e,h){const r=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),n=su,o=jc(s,iu.__wbindgen_export,iu.__wbindgen_export2),a=su,l=jc(e,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_send_sftp_delete(this.__wbg_ptr,r,n,i,o,a,l,su,qc(h)?4294967297:h>>>0)}send_sftp_download_chunk(t,i,s,e,h){const r=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_send_sftp_download_chunk(this.__wbg_ptr,r,su,i,s,e,qc(h)?4294967297:h>>>0)}send_sftp_download_start(t,i,s,e,h){const r=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),n=su,o=jc(s,iu.__wbindgen_export,iu.__wbindgen_export2),a=su,l=jc(e,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_send_sftp_download_start(this.__wbg_ptr,r,n,i,o,a,l,su,qc(h)?4294967297:h>>>0)}send_sftp_list_data(t,i,s,e){const h=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),r=su,n=jc(s,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_send_sftp_list_data(this.__wbg_ptr,h,r,i,n,su,qc(e)?4294967297:e>>>0)}send_sftp_upload_chunk(t,i,s,e,h,r,n){const o=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),a=su,l=function(t){const i=(0,iu.__wbindgen_export)(1*t.length,1)>>>0;return Pc().set(t,i/1),su=t.length,i}(r);iu.channel_send_sftp_upload_chunk(this.__wbg_ptr,o,a,i,s,e,h,l,su,qc(n)?4294967297:n>>>0)}send_sftp_upload_start(t,i,s,e,h,r,n){const o=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),a=su,l=jc(s,iu.__wbindgen_export,iu.__wbindgen_export2),c=su,u=jc(e,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_send_sftp_upload_start(this.__wbg_ptr,o,a,i,l,c,u,su,h,r,qc(n)?4294967297:n>>>0)}send_ssh_terminal_resize(t,i,s,e,h,r){const n=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_send_ssh_terminal_resize(this.__wbg_ptr,n,su,i,s,e,h,r)}send_ssh_tunnel_data(t,i,s){const e=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),h=su,r=jc(s,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_send_ssh_tunnel_data(this.__wbg_ptr,e,h,i,r,su)}start_heartbeat(t){iu.channel_start_heartbeat(this.__wbg_ptr,t)}stop_heartbeat(){iu.channel_stop_heartbeat(this.__wbg_ptr)}}Symbol.dispose&&(yc.prototype[Symbol.dispose]=yc.prototype.free);const Ec=Object.freeze({Generic:0,0:"Generic",RequiresUsername:100,100:"RequiresUsername",RequiresPassword:110,110:"RequiresPassword"});function Qc(){const t={__proto__:null,__wbg_Error_55538483de6e3abe:function(t,i){return $c(Error(Tc(t,i)))},__wbg_String_8564e559799eccda:function(t,i){const s=jc(String(Jc(i)),iu.__wbindgen_export,iu.__wbindgen_export2),e=su;Uc().setInt32(t+4,e,!0),Uc().setInt32(t+0,s,!0)},__wbg___wbindgen_debug_string_d89627202d0155b7:function(t,i){const s=jc(Nc(Jc(i)),iu.__wbindgen_export,iu.__wbindgen_export2),e=su;Uc().setInt32(t+4,e,!0),Uc().setInt32(t+0,s,!0)},__wbg___wbindgen_string_get_f1161390414f9b59:function(t,i){const s=Jc(i),e="string"==typeof s?s:void 0;var h=qc(e)?0:jc(e,iu.__wbindgen_export,iu.__wbindgen_export2),r=su;Uc().setInt32(t+4,r,!0),Uc().setInt32(t+0,h,!0)},__wbg___wbindgen_throw_5549492daedad139:function(t,i){throw new Error(Tc(t,i))},__wbg__wbg_cb_unref_fbe69bb076c16bad:function(t){Jc(t)._wbg_cb_unref()},__wbg_call_6ae20895a60069a2:function(){return Oc((function(t,i){return $c(Jc(t).call(Jc(i)))}),arguments)},__wbg_call_8f5d7bb070283508:function(){return Oc((function(t,i,s){return $c(Jc(t).call(Jc(i),Jc(s)))}),arguments)},__wbg_clearInterval_26ba580547547579:function(t){return $c(clearInterval(Yc(t)))},__wbg_close_1bf0654059764e94:function(){return Oc((function(t){Jc(t).close()}),arguments)},__wbg_data_7de671a92a650aba:function(t){return $c(Jc(t).data)},__wbg_from_45cebbf5e49a6ac6:function(t){return $c(Array.from(Jc(t)))},__wbg_instanceof_ArrayBuffer_8d855993947fc3a2:function(t){let i;try{i=Jc(t)instanceof ArrayBuffer}catch(t){i=!1}return i},__wbg_length_e6e1633fbea6cfa9:function(t){return Jc(t).length},__wbg_new_1d96678aaacca32e:function(t){return $c(new Uint8Array(Jc(t)))},__wbg_new_4370be21fa2b2f80:function(){return $c(new Array)},__wbg_new_48e1d86cfd30c8e7:function(){return $c(new Object)},__wbg_new_with_str_53b505a6bb7f12f6:function(){return Oc((function(t,i,s,e){return $c(new WebSocket(Tc(t,i),Tc(s,e)))}),arguments)},__wbg_prototypesetcall_3875d54d12ef2eec:function(t,i,s){Uint8Array.prototype.set.call(Fc(t,i),Jc(s))},__wbg_readyState_a08d25cc57214030:function(t){return Jc(t).readyState},__wbg_send_da543a379e952bc6:function(){return Oc((function(t,i,s){Jc(t).send(Fc(i,s))}),arguments)},__wbg_setInterval_cbf1c35c6a692d37:function(){return Oc((function(t,i){return $c(setInterval(Jc(t),i))}),arguments)},__wbg_set_4702dfa37c77f492:function(t,i,s){Jc(t)[i>>>0]=Yc(s)},__wbg_set_6be42768c690e380:function(t,i,s){Jc(t)[Yc(i)]=Yc(s)},__wbg_set_binaryType_0675f0e51c055ca8:function(t,i){Jc(t).binaryType=_c[i]},__wbg_set_onclose_f791ef701be808a0:function(t,i){Jc(t).onclose=Jc(i)},__wbg_set_onerror_e23002e9224d353b:function(t,i){Jc(t).onerror=Jc(i)},__wbg_set_onmessage_d2fe701a9ce80846:function(t,i){Jc(t).onmessage=Jc(i)},__wbg_set_onopen_0556381d0db30cbb:function(t,i){Jc(t).onopen=Jc(i)},__wbg_warn_7e545c047609d0b6:function(t,i){console.warn(Tc(t,i))},__wbindgen_cast_0000000000000001:function(t,i){return $c(Kc(t,i,xc))},__wbindgen_cast_0000000000000002:function(t,i){return $c(Kc(t,i,Dc))},__wbindgen_cast_0000000000000003:function(t,i){return $c(Kc(t,i,Lc))},__wbindgen_cast_0000000000000004:function(t,i){return $c(Kc(t,i,kc))},__wbindgen_cast_0000000000000005:function(t){return $c(t)},__wbindgen_cast_0000000000000006:function(t,i){return $c(Fc(t,i))},__wbindgen_cast_0000000000000007:function(t,i){return $c(Tc(t,i))},__wbindgen_cast_0000000000000008:function(t){return $c(BigInt.asUintN(64,t))},__wbindgen_object_clone_ref:function(t){return $c(Jc(t))},__wbindgen_object_drop_ref:function(t){Yc(t)}};return{__proto__:null,"./phirepass-channel_bg.js":t}}function kc(t,i){iu.__wasm_bindgen_func_elem_41(t,i)}function xc(t,i,s){iu.__wasm_bindgen_func_elem_37(t,i,$c(s))}function Dc(t,i,s){iu.__wasm_bindgen_func_elem_37_1(t,i,$c(s))}function Lc(t,i,s){iu.__wasm_bindgen_func_elem_37_2(t,i,$c(s))}const _c=["blob","arraybuffer"],Sc="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>iu.__wbg_channel_free(t>>>0,1)));function $c(t){zc===Wc.length&&Wc.push(Wc.length+1);const i=zc;return zc=Wc[i],Wc[i]=t,i}const Rc="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>iu.__wbindgen_export4(t.a,t.b)));function Nc(t){const i=typeof t;if("number"==i||"boolean"==i||null==t)return`${t}`;if("string"==i)return`"${t}"`;if("symbol"==i){const i=t.description;return null==i?"Symbol":`Symbol(${i})`}if("function"==i){const i=t.name;return"string"==typeof i&&i.length>0?`Function(${i})`:"Function"}if(Array.isArray(t)){const i=t.length;let s="[";i>0&&(s+=Nc(t[0]));for(let e=1;e<i;e++)s+=", "+Nc(t[e]);return s+="]",s}const s=/\[object ([^\]]+)\]/.exec(toString.call(t));let e;if(!(s&&s.length>1))return toString.call(t);if(e=s[1],"Object"==e)try{return"Object("+JSON.stringify(t)+")"}catch(t){return"Object"}return t instanceof Error?`${t.name}: ${t.message}\n${t.stack}`:e}function Fc(t,i){return t>>>=0,Pc().subarray(t/1,t/1+i)}let Hc=null;function Uc(){return(null===Hc||!0===Hc.buffer.detached||void 0===Hc.buffer.detached&&Hc.buffer!==iu.memory.buffer)&&(Hc=new DataView(iu.memory.buffer)),Hc}function Tc(t,i){return function(t,i){return Vc+=i,Vc>=Xc&&(Zc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Zc.decode(),Vc=i),Zc.decode(Pc().subarray(t,t+i))}(t>>>=0,i)}let Gc=null;function Pc(){return null!==Gc&&0!==Gc.byteLength||(Gc=new Uint8Array(iu.memory.buffer)),Gc}function Jc(t){return Wc[t]}function Oc(t,i){try{return t.apply(this,i)}catch(t){iu.__wbindgen_export3($c(t))}}let Wc=new Array(1024).fill(void 0);Wc.push(void 0,null,!0,!1);let zc=Wc.length;function qc(t){return null==t}function Kc(t,i,s){const e={a:t,b:i,cnt:1},h=(...t)=>{e.cnt++;const i=e.a;e.a=0;try{return s(i,e.b,...t)}finally{e.a=i,h._wbg_cb_unref()}};return h._wbg_cb_unref=()=>{0==--e.cnt&&(iu.__wbindgen_export4(e.a,e.b),e.a=0,Rc.unregister(e))},Rc.register(h,e,e),h}function jc(t,i,s){if(void 0===s){const s=tu.encode(t),e=i(s.length,1)>>>0;return Pc().subarray(e,e+s.length).set(s),su=s.length,e}let e=t.length,h=i(e,1)>>>0;const r=Pc();let n=0;for(;n<e;n++){const i=t.charCodeAt(n);if(i>127)break;r[h+n]=i}if(n!==e){0!==n&&(t=t.slice(n)),h=s(h,e,e=n+3*t.length,1)>>>0;const i=Pc().subarray(h+n,h+e);n+=tu.encodeInto(t,i).written,h=s(h,e,n,1)>>>0}return su=n,h}function Yc(t){const i=Jc(t);return function(t){t<1028||(Wc[t]=zc,zc=t)}(t),i}let Zc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Zc.decode();const Xc=2146435072;let Vc=0;const tu=new TextEncoder;"encodeInto"in tu||(tu.encodeInto=function(t,i){const s=tu.encode(t);return i.set(s),{read:t.length,written:s.length}});let iu,su=0;var eu,hu;!function(t){t[t.Username=0]="Username",t[t.Password=1]="Password",t[t.Default=2]="Default"}(eu||(eu={})),function(t){t.Disconnected="disconnected",t.Connected="connected",t.Error="error"}(hu||(hu={}));const ru=class{constructor(s){t(this,s),this.connectionStateChanged=i(this,"connectionStateChanged")}terminal;fitAddon;webLinksAddon;searchAddon;webglAddon;serializeAddon;imageAddon;channel;containerEl;domReady=!1;runtimeReady=!1;connected=!1;inputMode=eu.Default;resizeObserver;resizeDebounceHandle;session_id;usernameBuffer="";passwordBuffer="";xtermImageSettings={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7};get el(){return s(this)}terminalOptions={termName:"xterm-256color",rendererType:"canvas",allowTransparency:!1,fontFamily:'"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace',fontSize:12,letterSpacing:0,lineHeight:1,allowProposedApi:!0,cursorBlink:!0,cursorWidth:1,theme:{background:"#0b1021",foreground:"#e2e8f0",cursor:"#67e8f9"},scrollback:1e4,fastScrollModifier:"shift",fastScrollSensitivity:5,bellStyle:"sound",convertEol:!1,disableStdin:!1,rightClickSelectsWord:!0,drawBoldTextInBrightColors:!0,minimumContrastRatio:1,windowsMode:!1,macOptionIsMeta:!1,altClickMovesCursor:!0};serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;token;onNodeIdChange(t,i){this.reset_session_state(),this.terminal.reset(),this.channel&&this.channel.is_connected()&&this.close_comms(),t&&(this.open_comms(),this.channel.connect())}serverId;onServerIdChange(t,i){this.onNodeIdChange(this.nodeId,this.nodeId)}connectionStateChanged;create_web_socket_endpoint(){const t=this.allowInsecure?"ws":"wss";return this.allowInsecure||443!==this.serverPort?this.allowInsecure&&80===this.serverPort?`${t}://${this.serverHost}`:`${t}://${this.serverHost}:${this.serverPort}`:`${t}://${this.serverHost}`}async connectedCallback(){await async function(t){if(void 0!==iu)return iu;void 0!==t&&(Object.getPrototypeOf(t)===Object.prototype?({module_or_path:t}=t):console.warn("using deprecated parameters for the initialization function; pass a single object instead")),void 0===t&&(t=new URL("phirepass-channel_bg.wasm",import.meta.url));const i=Qc();("string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL)&&(t=fetch(t));const{instance:s}=await async function(t,i){if("function"==typeof Response&&t instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(t,i)}catch(i){if(!t.ok||!function(t){switch(t){case"basic":case"cors":case"default":return!0}return!1}(t.type)||"application/wasm"===t.headers.get("Content-Type"))throw i;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",i)}const s=await t.arrayBuffer();return await WebAssembly.instantiate(s,i)}{const s=await WebAssembly.instantiate(t,i);return s instanceof WebAssembly.Instance?{instance:s,module:t}:s}}(await t,i);return function(t){return iu=t.exports,Hc=null,Gc=null,iu}(s)}(),this.setup_terminal(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to terminal.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){this.resizeObserver&&this.resizeObserver.disconnect(),this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.close_comms(),this.destroy_terminal()}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.containerEl&&this.terminal&&this.channel&&this.connect()}setup_terminal(){this.terminal=new pr(this.terminalOptions),this.fitAddon=new Cr,this.terminal.loadAddon(this.fitAddon),this.webLinksAddon=new Mr,this.terminal.loadAddon(this.webLinksAddon),this.searchAddon=new yn,this.terminal.loadAddon(this.searchAddon),this.serializeAddon=new Rl,this.terminal.loadAddon(this.serializeAddon),this.imageAddon=new Mc(this.xtermImageSettings),this.terminal.loadAddon(this.imageAddon);try{this.webglAddon=new ml,this.terminal.loadAddon(this.webglAddon)}catch(t){console.warn("WebGL addon not available or failed to load:",t)}"function"==typeof this.terminal.onResize&&this.terminal.onResize((()=>{this.send_ssh_terminal_resize()}))}destroy_terminal(){this.terminal&&(this.terminal.reset(),"function"==typeof this.terminal.dispose&&this.terminal.dispose())}open_comms(){this.channel=this.serverId?new yc(`${this.create_web_socket_endpoint()}/api/web/ws`,this.nodeId,this.serverId):new yc(`${this.create_web_socket_endpoint()}/api/web/ws`,this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([hu.Connected]),this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([hu.Disconnected]),this.terminal.reset()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([hu.Error,t])})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((t=>{const{web:i}=t.data;switch(i.type){case"Error":this.handle_error(i);break;case"AuthSuccess":this.handle_auth_success(i);break;case"TunnelOpened":this.handle_tunnel_opened(i);break;case"TunnelClosed":this.handle_tunnel_closed(i);break;case"TunnelData":this.handle_tunnel_data(i);break;default:console.warn("Unknown protocol message type:",i)}}))}send_ssh_terminal_resize(){if(!this.containerEl)return void console.warn("Cannot send terminal resize: container element not available");if(!this.nodeId)return void console.warn("Cannot send terminal resize: node_id is missing");if(!this.channel)return void console.warn("Cannot send terminal resize: channel is not initialized");if(!this.channel.is_connected())return void console.warn("Cannot send terminal resize: channel not connected");if(!this.session_id)return void console.warn("Cannot send terminal resize: session_id is missing");this.fitAddon.fit();const t=this.terminal?.cols??0,i=this.terminal?.rows??0,s=this.containerEl.clientWidth??0,e=this.containerEl.clientHeight??0;if(t<=0||i<=0)console.warn("Cannot send terminal resize: invalid terminal dimensions (cols:",t,"rows:",i,") ");else try{console.log(`Sending terminal resize: cols=${t}, rows=${i}, px_width=${s}, px_height=${e}`),this.channel.send_ssh_terminal_resize(this.nodeId,this.session_id,t,i,s,e)}catch(t){console.error("Failed to send terminal resize:",t)}}send_ssh_data(t){this.channel.is_connected()&&this.session_id&&this.channel.send_ssh_tunnel_data(this.nodeId,this.session_id,t)}handle_error(t){switch(t.kind){case Ec.Generic:this.terminal.reset(),this.terminal.write(t.message+"\r\n"),this.terminal.focus();break;case Ec.RequiresUsername:this.terminal.reset(),this.inputMode=eu.Username,this.usernameBuffer="",this.terminal.write("Enter your username: "),this.terminal.focus();break;case Ec.RequiresPassword:this.terminal.reset(),this.inputMode=eu.Password,this.passwordBuffer="",this.terminal.write("Enter your password: "),this.terminal.focus();break;default:console.warn("Unknown error kind:",t)}}close_comms(){this.channel.stop_heartbeat(),this.channel.disconnect()}cancel_credential_entry(){this.inputMode=eu.Default,this.clear_creds_buffer(),this.terminal.writeln("Authentication cancelled."),this.terminal.reset(),this.close_comms()}clear_creds_buffer(){this.usernameBuffer="",this.passwordBuffer=""}reset_session_state(){this.session_id=void 0,this.inputMode=eu.Default,this.clear_creds_buffer()}handle_auth_success(t){this.clear_creds_buffer(),this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.channel.open_ssh_tunnel(this.nodeId)}handle_tunnel_opened(t){this.session_id=t.sid,this.terminal.reset(),this.fitAddon.fit(),this.send_ssh_terminal_resize()}handle_tunnel_data(t){this.terminal.write(new Uint8Array(t.data))}handle_tunnel_closed(t){this.session_id=void 0,this.inputMode=eu.Default,this.clear_creds_buffer(),this.terminal.reset(),this.terminal.writeln("Connection closed."),this.close_comms()}connect(){const t=this.containerEl;console.log("Attempting to connect terminal to container:",t),t&&(this.terminal.open(t),console.log("Terminal opened in container"),this.fitAddon.fit(),this.terminal.focus(),this.terminal.onData(this.handle_terminal_data.bind(this)),this.channel.connect(),this.setup_resize_observer(),this.connected=!0,console.log("Terminal connected and ready"))}setup_resize_observer(){this.resizeObserver=new ResizeObserver((()=>{console.log("Container resized, fitting terminal"),this.resizeDebounceHandle&&clearTimeout(this.resizeDebounceHandle),this.resizeDebounceHandle=setTimeout((()=>{this.fitAddon.fit(),this.send_ssh_terminal_resize()}),100)})),this.resizeObserver.observe(this.containerEl??this.el)}handle_terminal_data(t){switch(this.inputMode){case eu.Username:this.handle_username_input(t);break;case eu.Password:this.handle_password_input(t);break;case eu.Default:this.send_ssh_data(t)}}handle_username_input(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submit_username()):""===t?(this.terminal.write("^C\r\n"),void this.cancel_credential_entry()):void(""!==t?t>=" "&&t<="~"&&(this.usernameBuffer+=t,this.terminal.write(t)):this.usernameBuffer.length&&(this.usernameBuffer=this.usernameBuffer.slice(0,-1),this.terminal.write("\b \b")))}submit_username(){if(!this.channel.is_connected())return;const t=this.usernameBuffer.trim();if(!t)return this.terminal.writeln(""),this.terminal.write("Enter your username: "),void(this.usernameBuffer="");this.inputMode=eu.Default,this.channel.open_ssh_tunnel(this.nodeId,t)}handle_password_input(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submit_password()):""===t?(this.terminal.write("^C\r\n"),void this.cancel_credential_entry()):void(""!==t?t>=" "&&t<="~"&&(this.passwordBuffer+=t,this.terminal.write("*")):this.passwordBuffer.length&&(this.passwordBuffer=this.passwordBuffer.slice(0,-1),this.terminal.write("\b \b")))}submit_password(){if(!this.channel.is_connected())return;const t=this.passwordBuffer;if(!t)return this.terminal.writeln(""),this.terminal.write("Enter your password: "),void(this.passwordBuffer="");this.inputMode=eu.Default,this.channel.open_ssh_tunnel(this.nodeId,this.usernameBuffer.trim(),t),this.passwordBuffer="",this.usernameBuffer=""}render(){return e(h,{key:"71243a4c9c9468091e5ab830857f91b9b57812b0"},e("div",{key:"0dd9ae1e44cbf78f8a6ede6604c35d7d441cea93",id:"ccc",ref:t=>this.containerEl=t}))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}};ru.style=".xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#FFF;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1 !important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px !important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:rgba(0,0,0,0);transition:opacity 100ms linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity 800ms linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}:host{display:block;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}:host #ccc{width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}";export{ru as phirepass_terminal}
49
+ */function Zl(t,i){let s,e=this,h=!1;return function(){return h||(h=!0,i||(s=t.apply(e,arguments))),s}}(t=>{t.isLessThan=function(t){return t<0},t.isLessThanOrEqual=function(t){return t<=0},t.isGreaterThan=function(t){return t>0},t.isNeitherLessOrGreaterThan=function(t){return 0===t},t.greaterThan=1,t.lessThan=-1,t.neitherLessOrGreaterThan=0})(_l||={}),(t=>{function i(t){return t&&"object"==typeof t&&"function"==typeof t[Symbol.iterator]}t.is=i;let s=Object.freeze([]);function*e(t){yield t}t.empty=function(){return s},t.single=e,t.wrap=function(t){return i(t)?t:e(t)},t.from=function(t){return t||s},t.reverse=function*(t){for(let i=t.length-1;i>=0;i--)yield t[i]},t.isEmpty=function(t){return!t||!0===t[Symbol.iterator]().next().done},t.first=function(t){return t[Symbol.iterator]().next().value},t.some=function(t,i){let s=0;for(let e of t)if(i(e,s++))return!0;return!1},t.find=function(t,i){for(let s of t)if(i(s))return s},t.filter=function*(t,i){for(let s of t)i(s)&&(yield s)},t.map=function*(t,i){let s=0;for(let e of t)yield i(e,s++)},t.flatMap=function*(t,i){let s=0;for(let e of t)yield*i(e,s++)},t.concat=function*(...t){for(let i of t)yield*i},t.reduce=function(t,i,s){let e=s;for(let s of t)e=i(e,s);return e},t.slice=function*(t,i,s=t.length){for(i<0&&(i+=t.length),s<0?s+=t.length:s>t.length&&(s=t.length);i<s;i++)yield t[i]},t.consume=function(i,s=Number.POSITIVE_INFINITY){let e=[];if(0===s)return[e,i];let h=i[Symbol.iterator]();for(let i=0;i<s;i++){let i=h.next();if(i.done)return[e,t.empty()];e.push(i.value)}return[e,{[Symbol.iterator]:()=>h}]},t.asyncToArray=async function(t){let i=[];for await(let s of t)i.push(s);return Promise.resolve(i)}})(Sl||={});var Xl=class t{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{!function(t){if(Sl.is(t)){let i=[];for(let s of t)if(s)try{s.dispose()}catch(t){i.push(t)}if(1===i.length)throw i[0];if(i.length>1)throw new AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(t)?[]:t}t&&t.dispose()}(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?t.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(i),i}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&this._toDispose.delete(t)}};Xl.DISABLE_DISPOSED_WARNING=!1;var Vl=Xl,tc=class{constructor(){this._store=new Vl}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};tc.None=Object.freeze({dispose(){}});var ic=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(t){this._isDisposed||t===this._value||(this._value?.dispose(),this._value=t)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}clearAndLeak(){let t=this._value;return this._value=void 0,t}},sc=class t extends tc{constructor(t){super(),this._terminal=t,this._optionsRefresh=this._register(new ic),this._oldOpen=this._terminal._core.open,this._terminal._core.open=t=>{this._oldOpen?.call(this._terminal._core,t),this._open()},this._terminal._core.screenElement&&this._open(),this._optionsRefresh.value=this._terminal._core.optionsService.onOptionChange((t=>{"fontSize"===t&&(this.rescaleCanvas(),this._renderService?.refreshRows(0,this._terminal.rows))})),this._register(function(t){return{dispose:Zl((()=>{t()}))}}((()=>{this.removeLayerFromDom(),this._terminal._core&&this._oldOpen&&(this._terminal._core.open=this._oldOpen,this._oldOpen=void 0),this._renderService&&this._oldSetRenderer&&(this._renderService.setRenderer=this._oldSetRenderer,this._oldSetRenderer=void 0),this._renderService=void 0,this.canvas=void 0,this._ctx=void 0,this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0})))}static createCanvas(t,i,s){let e=(t||document).createElement("canvas");return e.width=0|i,e.height=0|s,e}static createImageData(t,i,s,e){if("function"!=typeof ImageData){let h=t.createImageData(i,s);return e&&h.data.set(new Uint8ClampedArray(e,0,i*s*4)),h}return e?new ImageData(new Uint8ClampedArray(e,0,i*s*4),i,s):new ImageData(i,s)}static createImageBitmap(t){return"function"!=typeof createImageBitmap?Promise.resolve(void 0):createImageBitmap(t)}showPlaceholder(t){t?!this._placeholder&&-1!==this.cellSize.height&&this._createPlaceHolder(Math.max(this.cellSize.height+1,24)):(this._placeholderBitmap?.close(),this._placeholderBitmap=void 0,this._placeholder=void 0),this._renderService?.refreshRows(0,this._terminal.rows)}get dimensions(){return this._renderService?.dimensions}get cellSize(){return{width:this.dimensions?.css.cell.width||-1,height:this.dimensions?.css.cell.height||-1}}clearLines(t,i){this._ctx?.clearRect(0,t*(this.dimensions?.css.cell.height||0),this.dimensions?.css.canvas.width||0,(++i-t)*(this.dimensions?.css.cell.height||0))}clearAll(){this._ctx?.clearRect(0,0,this.canvas?.width||0,this.canvas?.height||0)}draw(t,i,s,e,h=1){if(!this._ctx)return;let{width:r,height:n}=this.cellSize;if(-1===r||-1===n)return;this._rescaleImage(t,r,n);let o=t.actual,a=Math.ceil(o.width/r),l=i%a*r,c=Math.floor(i/a)*n,u=s*r,A=e*n,f=h*r+l>o.width?o.width-l:h*r,d=c+n>o.height?o.height-c:n;this._ctx.drawImage(o,Math.floor(l),Math.floor(c),Math.ceil(f),Math.ceil(d),Math.floor(u),Math.floor(A),Math.ceil(f),Math.ceil(d))}extractTile(i,s){let{width:e,height:h}=this.cellSize;if(-1===e||-1===h)return;this._rescaleImage(i,e,h);let r=i.actual,n=Math.ceil(r.width/e),o=s%n*e,a=Math.floor(s/n)*h,l=e+o>r.width?r.width-o:e,c=a+h>r.height?r.height-a:h,u=t.createCanvas(this.document,l,c),A=u.getContext("2d");return A?(A.drawImage(r,Math.floor(o),Math.floor(a),Math.floor(l),Math.floor(c),0,0,Math.floor(l),Math.floor(c)),u):void 0}drawPlaceholder(t,i,s=1){if(this._ctx){let{width:e,height:h}=this.cellSize;if(-1===e||-1===h||(this._placeholder?h>=this._placeholder.height&&this._createPlaceHolder(h+1):this._createPlaceHolder(Math.max(h+1,24)),!this._placeholder))return;this._ctx.drawImage(this._placeholderBitmap||this._placeholder,t*e,i*h%2?0:1,e*s,h,t*e,i*h,e*s,h)}}rescaleCanvas(){this.canvas&&(this.canvas.width!==this.dimensions.css.canvas.width||this.canvas.height!==this.dimensions.css.canvas.height)&&(this.canvas.width=this.dimensions.css.canvas.width||0,this.canvas.height=this.dimensions.css.canvas.height||0)}_rescaleImage(i,s,e){if(s===i.actualCellSize.width&&e===i.actualCellSize.height)return;let{width:h,height:r}=i.origCellSize;if(s===h&&e===r)return i.actual=i.orig,i.actualCellSize.width=h,void(i.actualCellSize.height=r);let n=t.createCanvas(this.document,Math.ceil(i.orig.width*s/h),Math.ceil(i.orig.height*e/r)),o=n.getContext("2d");o&&(o.drawImage(i.orig,0,0,n.width,n.height),i.actual=n,i.actualCellSize.width=s,i.actualCellSize.height=e)}_open(){this._renderService=this._terminal._core._renderService,this._oldSetRenderer=this._renderService.setRenderer.bind(this._renderService),this._renderService.setRenderer=t=>{this.removeLayerFromDom(),this._oldSetRenderer?.call(this._renderService,t)}}insertLayerToDom(){this.document&&this._terminal._core.screenElement?this.canvas||(this.canvas=t.createCanvas(this.document,this.dimensions?.css.canvas.width||0,this.dimensions?.css.canvas.height||0),this.canvas.classList.add("xterm-image-layer"),this._terminal._core.screenElement.appendChild(this.canvas),this._ctx=this.canvas.getContext("2d",{alpha:!0,desynchronized:!0}),this.clearAll()):console.warn("image addon: cannot insert output canvas to DOM, missing document or screenElement")}removeLayerFromDom(){this.canvas&&(this._ctx=void 0,this.canvas.remove(),this.canvas=void 0)}_createPlaceHolder(i=24){this._placeholderBitmap?.close(),this._placeholderBitmap=void 0;let s=32,e=t.createCanvas(this.document,s,i),h=e.getContext("2d",{alpha:!1});if(!h)return;let r=t.createImageData(h,s,i),n=new Uint32Array(r.data.buffer),o=(0,Yl.toRGBA8888)(0,0,0),a=(0,Yl.toRGBA8888)(255,255,255);n.fill(o);for(let t=0;t<i;++t){let i=t%2,e=t*s;for(let t=0;t<s;t+=2)n[e+t+i]=a}h.putImageData(r,0,0);let l=screen.width+s-1&-32||4096;this._placeholder=t.createCanvas(this.document,l,i);let c=this._placeholder.getContext("2d",{alpha:!1});if(c){for(let t=0;t<l;t+=s)c.drawImage(e,t,0);t.createImageBitmap(this._placeholder).then((t=>this._placeholderBitmap=t))}else this._placeholder=void 0}get document(){return this._terminal._core._coreBrowserService?.window.document}},ec={width:7,height:14},hc=class t{constructor(t=0,i=0,s=-1,e=-1){this.imageId=s,this.tileId=e,this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(t){this._ext&=-67108864,this._ext|=67108863&t}get underlineVariantOffset(){let t=(3758096384&this._ext)>>29;return t<0?4294967288^t:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}get urlId(){return this._urlId}set urlId(t){this._urlId=t}clone(){return new t(this._ext,this._urlId,this.imageId,this.tileId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId&&-1===this.imageId}},rc=new hc,nc=class{constructor(t,i,s){this._terminal=t,this._renderer=i,this._opts=s,this._images=new Map,this._lastId=0,this._lowestId=0,this._fullyCleared=!1,this._needsFullClear=!1,this._pixelLimit=25e5;try{this.setLimit(this._opts.storageLimit)}catch(t){console.error(t.message),console.warn(`storageLimit is set to ${this.getLimit()} MB`)}this._viewportMetrics={cols:this._terminal.cols,rows:this._terminal.rows}}dispose(){this.reset()}reset(){for(let t of this._images.values())t.marker?.dispose();this._images.clear(),this._renderer.clearAll()}getLimit(){return 4*this._pixelLimit/1e6}setLimit(t){if(t<.5||t>1e3)throw RangeError("invalid storageLimit, should be at least 0.5 MB and not exceed 1G");this._pixelLimit=t/4*1e6>>>0,this._evictOldest(0)}getUsage(){return 4*this._getStoredPixels()/1e6}_getStoredPixels(){let t=0;for(let i of this._images.values())i.orig&&(t+=i.orig.width*i.orig.height,i.actual&&i.actual!==i.orig&&(t+=i.actual.width*i.actual.height));return t}_delImg(t){let i=this._images.get(t);this._images.delete(t),i&&window.ImageBitmap&&i.orig instanceof ImageBitmap&&i.orig.close()}wipeAlternate(){let t=[];for(let[i,s]of this._images.entries())"alternate"===s.bufferType&&(s.marker?.dispose(),t.push(i));for(let i of t)this._delImg(i);this._needsFullClear=!0,this._fullyCleared=!1}advanceCursor(t){if(this._opts.sixelScrolling){let i=this._renderer.cellSize;(-1===i.width||-1===i.height)&&(i=ec);let s=Math.ceil(t/i.height);for(let t=1;t<s;++t)this._terminal._core._inputHandler.lineFeed()}}addImage(t){this._evictOldest(t.width*t.height);let i=this._renderer.cellSize;(-1===i.width||-1===i.height)&&(i=ec);let s=Math.ceil(t.width/i.width),e=Math.ceil(t.height/i.height),h=++this._lastId,r=this._terminal._core.buffer,n=this._terminal.cols,o=this._terminal.rows,a=r.x,l=r.y,c=a,u=0;this._opts.sixelScrolling||(r.x=0,r.y=0,c=0),this._terminal._core._inputHandler._dirtyRowTracker.markDirty(r.y);for(let t=0;t<e;++t){let i=r.lines.get(r.y+r.ybase);for(let e=0;e<s&&!(c+e>=n);++e)this._writeToCell(i,c+e,h,t*s+e),u++;if(this._opts.sixelScrolling)t<e-1&&this._terminal._core._inputHandler.lineFeed();else if(++r.y>=o)break;r.x=c}this._terminal._core._inputHandler._dirtyRowTracker.markDirty(r.y),this._opts.sixelScrolling?r.x=c:(r.x=a,r.y=l);let A=[];for(let[t,i]of this._images.entries())i.tileCount<1&&(i.marker?.dispose(),A.push(t));for(let t of A)this._delImg(t);let f=this._terminal.registerMarker(0);f?.onDispose((()=>{this._images.get(h)&&this._delImg(h)})),"alternate"===this._terminal.buffer.active.type&&this._evictOnAlternate();let d={orig:t,origCellSize:i,actual:t,actualCellSize:{...i},marker:f||void 0,tileCount:u,bufferType:this._terminal.buffer.active.type};this._images.set(h,d)}render(t){if(!this._renderer.canvas&&this._images.size&&(this._renderer.insertLayerToDom(),!this._renderer.canvas))return;if(this._renderer.rescaleCanvas(),!this._images.size)return this._fullyCleared||(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1),void(this._renderer.canvas&&this._renderer.removeLayerFromDom());this._needsFullClear&&(this._renderer.clearAll(),this._fullyCleared=!0,this._needsFullClear=!1);let{start:i,end:s}=t,e=this._terminal._core.buffer,h=this._terminal._core.cols;this._renderer.clearLines(i,s);for(let t=i;t<=s;++t){let i=e.lines.get(t+e.ydisp);if(!i)return;for(let s=0;s<h;++s)if(268435456&i.getBg(s)){let e=i._extendedAttrs[s]||rc,r=e.imageId;if(void 0===r||-1===r)continue;let n=this._images.get(r);if(-1!==e.tileId){let o=e.tileId,a=s,l=1;for(;++s<h&&268435456&i.getBg(s)&&(e=i._extendedAttrs[s]||rc)&&e.imageId===r&&e.tileId===o+l;)l++;s--,n?n.actual&&this._renderer.draw(n,o,a,t,l):this._opts.showPlaceholder&&this._renderer.drawPlaceholder(a,t,l),this._fullyCleared=!1}}}}viewportResize(t){if(!this._images.size)return void(this._viewportMetrics=t);if(this._viewportMetrics.cols>=t.cols)return void(this._viewportMetrics=t);let i=this._terminal._core.buffer,s=i.lines.length,e=this._viewportMetrics.cols-1;for(let h=0;h<s;++h){let s=i.lines.get(h);if(268435456&s.getBg(e)){let i=s._extendedAttrs[e]||rc,h=i.imageId;if(void 0===h||-1===h)continue;let r=this._images.get(h);if(!r)continue;let n=Math.ceil((r.actual?.width||0)/r.actualCellSize.width);if(i.tileId%n+1>=n)continue;let o=!1;for(let i=e+1;i>t.cols;++i)if(4194303&s._data[3*i+0]){o=!0;break}if(o)continue;let a=Math.min(t.cols,n-i.tileId%n+e),l=i.tileId;for(let t=e+1;t<a;++t)this._writeToCell(s,t,h,++l),r.tileCount++}}this._viewportMetrics=t}getImageAtBufferCell(t,i){let s=this._terminal._core.buffer.lines.get(i);if(s&&268435456&s.getBg(t)){let i=s._extendedAttrs[t]||rc;if(i.imageId&&-1!==i.imageId){let t=this._images.get(i.imageId)?.orig;if(window.ImageBitmap&&t instanceof ImageBitmap){let i=sc.createCanvas(window.document,t.width,t.height);return i.getContext("2d")?.drawImage(t,0,0,t.width,t.height),i}return t}}}extractTileAtBufferCell(t,i){let s=this._terminal._core.buffer.lines.get(i);if(s&&268435456&s.getBg(t)){let i=s._extendedAttrs[t]||rc;if(i.imageId&&-1!==i.imageId&&-1!==i.tileId){let t=this._images.get(i.imageId);if(t)return this._renderer.extractTile(t,i.tileId)}}}_evictOldest(t){let i=this._getStoredPixels(),s=i;for(;this._pixelLimit<s+t&&this._images.size;){let t=this._images.get(++this._lowestId);t&&t.orig&&(s-=t.orig.width*t.orig.height,t.actual&&t.orig!==t.actual&&(s-=t.actual.width*t.actual.height),t.marker?.dispose(),this._delImg(this._lowestId))}return i-s}_writeToCell(t,i,s,e){if(268435456&t._data[3*i+2]){let h=t._extendedAttrs[i];if(h){if(void 0!==h.imageId){let t=this._images.get(h.imageId);return t&&t.tileCount--,h.imageId=s,void(h.tileId=e)}return void(t._extendedAttrs[i]=new hc(h.ext,h.urlId,s,e))}}t._data[3*i+2]|=268435456,t._extendedAttrs[i]=new hc(0,0,s,e)}_evictOnAlternate(){for(let t of this._images.values())"alternate"===t.bufferType&&(t.tileCount=0);let t=this._terminal._core.buffer;for(let i=0;i<this._terminal.rows;++i){let s=t.lines.get(i);if(s)for(let t=0;t<this._terminal.cols;++t)if(268435456&s._data[3*t+2]){let i=s._extendedAttrs[t]?.imageId;if(i){let t=this._images.get(i);t&&t.tileCount++}}}let i=[];for(let[t,s]of this._images.entries())"alternate"===s.bufferType&&!s.tileCount&&(s.marker?.dispose(),i.push(t));for(let t of i)this._delImg(t)}},oc=Ol(ql());function ac(t){let i="";for(let s=0;s<t.length;++s)i+=String.fromCharCode(t[s]);return i}function lc(t){let i=0;for(let s=0;s<t.length;++s){if(t[s]<48||t[s]>57)throw new Error("illegal char");i=10*i+t[s]-48}return i}function cc(t){let i=ac(t);if(!i.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw new Error("illegal size");return i}var uc={inline:lc,size:lc,name:function(t){if(typeof Buffer<"u")return Buffer.from(ac(t),"base64").toString();let i=atob(ac(t)),s=new Uint8Array(i.length);for(let t=0;t<s.length;++t)s[t]=i.charCodeAt(t);return(new TextDecoder).decode(s)},width:cc,height:cc,preserveAspectRatio:lc},Ac=[70,105,108,101],fc=1024,dc=class{constructor(){this.state=0,this._buffer=new Uint32Array(fc),this._position=0,this._key="",this.fields={}}reset(){this._buffer.fill(0),this.state=0,this._position=0,this.fields={},this._key=""}parse(t,i,s){let e=this.state,h=this._position,r=this._buffer;if(1===e||4===e||0===e&&h>6)return-1;for(let n=i;n<s;++n){let i=t[n];switch(i){case 59:if(!this._storeValue(h))return this._a();e=2,h=0;break;case 61:if(0===e){for(let t=0;t<Ac.length;++t)if(r[t]!==Ac[t])return this._a();e=2,h=0}else if(2===e){if(!this._storeKey(h))return this._a();e=3,h=0}else if(3===e){if(h>=fc)return this._a();r[h++]=i}break;case 58:return 3!==e||this._storeValue(h)?(this.state=4,n+1):this._a();default:if(h>=fc)return this._a();r[h++]=i}}return this.state=e,this._position=h,-2}_a(){return this.state=1,-1}_storeKey(t){let i=ac(this._buffer.subarray(0,t));return!!i&&(this._key=i,this.fields[i]=null,!0)}_storeValue(t){if(this._key){try{let i=this._buffer.slice(0,t);this.fields[this._key]=uc[this._key]?uc[this._key](i):i}catch{return!1}return!0}return!1}},gc={mime:"unsupported",width:0,height:0},wc={name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},pc=class{constructor(t,i,s,e){this._opts=t,this._renderer=i,this._storage=s,this._coreTerminal=e,this._aborted=!1,this._hp=new dc,this._header=wc,this._dec=new oc.default(4194304),this._metrics=gc}reset(){}start(){this._aborted=!1,this._header=wc,this._metrics=gc,this._hp.reset()}put(t,i,s){if(!this._aborted)if(4===this._hp.state)this._dec.put(t,i,s)&&(this._dec.release(),this._aborted=!0);else{let e=this._hp.parse(t,i,s);if(-1===e)return void(this._aborted=!0);if(e>0){if(this._header=Object.assign({},wc,this._hp.fields),!this._header.inline||!this._header.size||this._header.size>this._opts.iipSizeLimit)return void(this._aborted=!0);this._dec.init(this._header.size),this._dec.put(t,e,s)&&(this._dec.release(),this._aborted=!0)}}}end(t){if(this._aborted)return!0;let i=0,s=0,e=!0;if((e=t)&&(e=!this._dec.end())&&(this._metrics=function(t){if(t.length<24)return gc;let i=new Uint32Array(t.buffer,t.byteOffset,6);if(1196314761===i[0]&&169478669===i[1]&&1380206665===i[3])return{mime:"image/png",width:t[16]<<24|t[17]<<16|t[18]<<8|t[19],height:t[20]<<24|t[21]<<16|t[22]<<8|t[23]};if(255===t[0]&&216===t[1]&&255===t[2]){let[i,s]=function(t){let i=t.length,s=4,e=t[s]<<8|t[s+1];for(;;){if(s+=e,s>=i)return[0,0];if(255!==t[s])return[0,0];if(192===t[s+1]||194===t[s+1])return s+8<i?[t[s+7]<<8|t[s+8],t[s+5]<<8|t[s+6]]:[0,0];s+=2,e=t[s]<<8|t[s+1]}}(t);return{mime:"image/jpeg",width:i,height:s}}return 944130375!==i[0]||55!==t[4]&&57!==t[4]||97!==t[5]?gc:{mime:"image/gif",width:t[7]<<8|t[6],height:t[9]<<8|t[8]}}(this._dec.data8),(e="unsupported"!==this._metrics.mime)&&(i=this._metrics.width,s=this._metrics.height,(e=i&&s&&i*s<this._opts.pixelLimit)&&([i,s]=this._resize(i,s).map(Math.floor),e=i&&s&&i*s<this._opts.pixelLimit))),!e)return this._dec.release(),!0;let h=new Blob([this._dec.data8],{type:this._metrics.mime});if(this._dec.release(),!window.createImageBitmap){let t=URL.createObjectURL(h),e=new Image;return new Promise((h=>{e.addEventListener("load",(()=>{URL.revokeObjectURL(t);let r=sc.createCanvas(window.document,i,s);r.getContext("2d")?.drawImage(e,0,0,i,s),this._storage.addImage(r),h(!0)})),e.src=t,setTimeout((()=>h(!0)),1e3)}))}return createImageBitmap(h,{resizeWidth:i,resizeHeight:s}).then((t=>(this._storage.addImage(t),!0)))}_resize(t,i){let s=this._renderer.dimensions?.css.cell.width||ec.width,e=this._renderer.dimensions?.css.cell.height||ec.height,h=this._renderer.dimensions?.css.canvas.width||s*this._coreTerminal.cols,r=this._renderer.dimensions?.css.canvas.height||e*this._coreTerminal.rows,n=this._dim(this._header.width,h,s),o=this._dim(this._header.height,r,e);if(!n&&!o){let s=Math.min(h/t,(r-e)/i);return s<1?[t*s,i*s]:[t,i]}return n?!this._header.preserveAspectRatio&&n&&o?[n,o]:[n,i*n/t]:[t*o/i,o]}_dim(t,i,s){return"auto"===t?0:t.endsWith("%")?parseInt(t.slice(0,-1))*i/100:t.endsWith("px")?parseInt(t.slice(0,-2)):parseInt(t)*s}},Cc=Ol(Wl()),mc=Ol(jl()),Ic=Cc.PALETTE_ANSI_256;Ic.set(Cc.PALETTE_VT340_COLOR);var vc=class{constructor(t,i,s){this._opts=t,this._storage=i,this._coreTerminal=s,this._size=0,this._aborted=!1,(0,mc.DecoderAsync)({memoryLimit:4*this._opts.pixelLimit,palette:Ic,paletteLimit:this._opts.sixelPaletteLimit}).then((t=>this._dec=t))}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,Ic,this._opts.sixelPaletteLimit))}hook(t){if(this._size=0,this._aborted=!1,this._dec){let i=1===t.params[1]?0:function(t,i){let s=0;if(!i)return s;if(t.isInverse())if(t.isFgDefault())s=Bc(i.foreground.rgba);else if(t.isFgRGB()){let i=t.constructor.toColorRGB(t.getFgColor());s=(0,Cc.toRGBA8888)(...i)}else s=Bc(i.ansi[t.getFgColor()].rgba);else if(t.isBgDefault())s=Bc(i.background.rgba);else if(t.isBgRGB()){let i=t.constructor.toColorRGB(t.getBgColor());s=(0,Cc.toRGBA8888)(...i)}else s=Bc(i.ansi[t.getBgColor()].rgba);return s}(this._coreTerminal._core._inputHandler._curAttrData,this._coreTerminal._core._themeService?.colors);this._dec.init(i,null,this._opts.sixelPaletteLimit)}}put(t,i,s){if(!this._aborted&&this._dec){if(this._size+=s-i,this._size>this._opts.sixelSizeLimit)return console.warn("SIXEL: too much data, aborting"),this._aborted=!0,void this._dec.release();try{this._dec.decode(t,i,s)}catch(t){console.warn(`SIXEL: error while decoding image - ${t}`),this._aborted=!0,this._dec.release()}}}unhook(t){if(this._aborted||!t||!this._dec)return!0;let i=this._dec.width,s=this._dec.height;if(!i||!s)return s&&this._storage.advanceCursor(s),!0;let e=sc.createCanvas(void 0,i,s);return e.getContext("2d")?.putImageData(new ImageData(this._dec.data8,i,s),0,0),this._dec.memoryUsage>4194304&&this._dec.release(),this._storage.addImage(e),!0}};function Bc(t){return Cc.BIG_ENDIAN?t:(255&t)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255}var bc={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7},Mc=class{constructor(t){this._disposables=[],this._handlers=new Map,this._opts=Object.assign({},bc,t),this._defaultOpts=Object.assign({},bc,t)}dispose(){for(let t of this._disposables)t.dispose();this._disposables.length=0,this._handlers.clear()}_disposeLater(...t){for(let i of t)this._disposables.push(i)}activate(t){if(this._terminal=t,this._renderer=new sc(t),this._storage=new nc(t,this._renderer,this._opts),this._opts.enableSizeReports){let i=t.options.windowOptions||{};i.getWinSizePixels=!0,i.getCellSizePixels=!0,i.getWinSizeChars=!0,t.options.windowOptions=i}if(this._disposeLater(this._renderer,this._storage,t.parser.registerCsiHandler({prefix:"?",final:"h"},(t=>this._decset(t))),t.parser.registerCsiHandler({prefix:"?",final:"l"},(t=>this._decrst(t))),t.parser.registerCsiHandler({final:"c"},(t=>this._da1(t))),t.parser.registerCsiHandler({prefix:"?",final:"S"},(t=>this._xtermGraphicsAttributes(t))),t.onRender((t=>this._storage?.render(t))),t.parser.registerCsiHandler({intermediates:"!",final:"p"},(()=>this.reset())),t.parser.registerEscHandler({final:"c"},(()=>this.reset())),t._core._inputHandler.onRequestReset((()=>this.reset())),t.buffer.onBufferChange((()=>this._storage?.wipeAlternate())),t.onResize((t=>this._storage?.viewportResize(t)))),this._opts.sixelSupport){let i=new vc(this._opts,this._storage,t);this._handlers.set("sixel",i),this._disposeLater(t._core._inputHandler._parser.registerDcsHandler({final:"q"},i))}if(this._opts.iipSupport){let i=new pc(this._opts,this._renderer,this._storage,t);this._handlers.set("iip",i),this._disposeLater(t._core._inputHandler._parser.registerOscHandler(1337,i))}}reset(){this._opts.sixelScrolling=this._defaultOpts.sixelScrolling,this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._storage?.reset();for(let t of this._handlers.values())t.reset();return!1}get storageLimit(){return this._storage?.getLimit()||-1}set storageLimit(t){this._storage?.setLimit(t),this._opts.storageLimit=t}get storageUsage(){return this._storage?this._storage.getUsage():-1}get showPlaceholder(){return this._opts.showPlaceholder}set showPlaceholder(t){this._opts.showPlaceholder=t,this._renderer?.showPlaceholder(t)}getImageAtBufferCell(t,i){return this._storage?.getImageAtBufferCell(t,i)}extractTileAtBufferCell(t,i){return this._storage?.extractTileAtBufferCell(t,i)}_report(t){this._terminal?._core.coreService.triggerDataEvent(t)}_decset(t){for(let i=0;i<t.length;++i)80===t[i]&&(this._opts.sixelScrolling=!1);return!1}_decrst(t){for(let i=0;i<t.length;++i)80===t[i]&&(this._opts.sixelScrolling=!0);return!1}_da1(t){return!!t[0]||!!this._opts.sixelSupport&&(this._report("[?62;4;9;22c"),!0)}_xtermGraphicsAttributes(t){if(t.length<2)return!0;if(1===t[0])switch(t[1]){case 1:return this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`),!0;case 2:this._opts.sixelPaletteLimit=this._defaultOpts.sixelPaletteLimit,this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`);for(let t of this._handlers.values())t.reset();return!0;case 3:return t.length>2&&!(t[2]instanceof Array)&&t[2]<=4096?(this._opts.sixelPaletteLimit=t[2],this._report(`[?${t[0]};0;${this._opts.sixelPaletteLimit}S`)):this._report(`[?${t[0]};2S`),!0;case 4:return this._report(`[?${t[0]};0;4096S`),!0;default:return this._report(`[?${t[0]};2S`),!0}if(2===t[0])switch(t[1]){case 1:let i=this._renderer?.dimensions?.css.canvas.width,s=this._renderer?.dimensions?.css.canvas.height;if(!i||!s){let t=ec;i=(this._terminal?.cols||80)*t.width,s=(this._terminal?.rows||24)*t.height}if(i*s<this._opts.pixelLimit)this._report(`[?${t[0]};0;${i.toFixed(0)};${s.toFixed(0)}S`);else{let i=Math.floor(Math.sqrt(this._opts.pixelLimit));this._report(`[?${t[0]};0;${i};${i}S`)}return!0;case 4:let e=Math.floor(Math.sqrt(this._opts.pixelLimit));return this._report(`[?${t[0]};0;${e};${e}S`),!0;default:return this._report(`[?${t[0]};2S`),!0}return this._report(`[?${t[0]};1S`),!0}};class yc{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,Sc.unregister(this),t}free(){const t=this.__destroy_into_raw();iu.__wbg_channel_free(t,0)}authenticate(t,i,s){const e=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),h=su,r=jc(i,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_authenticate(this.__wbg_ptr,e,h,r,su,qc(s)?4294967297:s>>>0)}connect(){iu.channel_connect(this.__wbg_ptr)}disconnect(){iu.channel_disconnect(this.__wbg_ptr)}is_connected(){return 0!==iu.channel_is_connected(this.__wbg_ptr)}is_disconnected(){return 0!==iu.channel_is_disconnected(this.__wbg_ptr)}constructor(t,i,s){const e=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),h=su,r=jc(i,iu.__wbindgen_export,iu.__wbindgen_export2),n=su;var o=qc(s)?0:jc(s,iu.__wbindgen_export,iu.__wbindgen_export2);const a=iu.channel_new(e,h,r,n,o,su);return this.__wbg_ptr=a>>>0,Sc.register(this,this.__wbg_ptr,this),this}on_connection_close(t){iu.channel_on_connection_close(this.__wbg_ptr,qc(t)?0:$c(t))}on_connection_error(t){iu.channel_on_connection_error(this.__wbg_ptr,qc(t)?0:$c(t))}on_connection_message(t){iu.channel_on_connection_message(this.__wbg_ptr,qc(t)?0:$c(t))}on_connection_open(t){iu.channel_on_connection_open(this.__wbg_ptr,qc(t)?0:$c(t))}on_protocol_message(t){iu.channel_on_protocol_message(this.__wbg_ptr,qc(t)?0:$c(t))}open_sftp_tunnel(t,i,s,e){const h=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),r=su;var n=qc(i)?0:jc(i,iu.__wbindgen_export,iu.__wbindgen_export2),o=su,a=qc(s)?0:jc(s,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_open_sftp_tunnel(this.__wbg_ptr,h,r,n,o,a,su,qc(e)?4294967297:e>>>0)}open_ssh_tunnel(t,i,s,e){const h=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),r=su;var n=qc(i)?0:jc(i,iu.__wbindgen_export,iu.__wbindgen_export2),o=su,a=qc(s)?0:jc(s,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_open_ssh_tunnel(this.__wbg_ptr,h,r,n,o,a,su,qc(e)?4294967297:e>>>0)}send_sftp_delete(t,i,s,e,h){const r=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),n=su,o=jc(s,iu.__wbindgen_export,iu.__wbindgen_export2),a=su,l=jc(e,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_send_sftp_delete(this.__wbg_ptr,r,n,i,o,a,l,su,qc(h)?4294967297:h>>>0)}send_sftp_download_chunk(t,i,s,e,h){const r=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_send_sftp_download_chunk(this.__wbg_ptr,r,su,i,s,e,qc(h)?4294967297:h>>>0)}send_sftp_download_start(t,i,s,e,h){const r=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),n=su,o=jc(s,iu.__wbindgen_export,iu.__wbindgen_export2),a=su,l=jc(e,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_send_sftp_download_start(this.__wbg_ptr,r,n,i,o,a,l,su,qc(h)?4294967297:h>>>0)}send_sftp_list_data(t,i,s,e){const h=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),r=su,n=jc(s,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_send_sftp_list_data(this.__wbg_ptr,h,r,i,n,su,qc(e)?4294967297:e>>>0)}send_sftp_upload_chunk(t,i,s,e,h,r,n){const o=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),a=su,l=function(t){const i=(0,iu.__wbindgen_export)(1*t.length,1)>>>0;return Pc().set(t,i/1),su=t.length,i}(r);iu.channel_send_sftp_upload_chunk(this.__wbg_ptr,o,a,i,s,e,h,l,su,qc(n)?4294967297:n>>>0)}send_sftp_upload_start(t,i,s,e,h,r,n){const o=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),a=su,l=jc(s,iu.__wbindgen_export,iu.__wbindgen_export2),c=su,u=jc(e,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_send_sftp_upload_start(this.__wbg_ptr,o,a,i,l,c,u,su,h,r,qc(n)?4294967297:n>>>0)}send_ssh_terminal_resize(t,i,s,e,h,r){const n=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_send_ssh_terminal_resize(this.__wbg_ptr,n,su,i,s,e,h,r)}send_ssh_tunnel_data(t,i,s){const e=jc(t,iu.__wbindgen_export,iu.__wbindgen_export2),h=su,r=jc(s,iu.__wbindgen_export,iu.__wbindgen_export2);iu.channel_send_ssh_tunnel_data(this.__wbg_ptr,e,h,i,r,su)}start_heartbeat(t){iu.channel_start_heartbeat(this.__wbg_ptr,t)}stop_heartbeat(){iu.channel_stop_heartbeat(this.__wbg_ptr)}}Symbol.dispose&&(yc.prototype[Symbol.dispose]=yc.prototype.free);const Ec=Object.freeze({Generic:0,0:"Generic",RequiresUsername:100,100:"RequiresUsername",RequiresPassword:110,110:"RequiresPassword"});function Qc(){const t={__proto__:null,__wbg_Error_2e59b1b37a9a34c3:function(t,i){return $c(Error(Tc(t,i)))},__wbg_String_8564e559799eccda:function(t,i){const s=jc(String(Jc(i)),iu.__wbindgen_export,iu.__wbindgen_export2),e=su;Uc().setInt32(t+4,e,!0),Uc().setInt32(t+0,s,!0)},__wbg___wbindgen_debug_string_dd5d2d07ce9e6c57:function(t,i){const s=jc(Nc(Jc(i)),iu.__wbindgen_export,iu.__wbindgen_export2),e=su;Uc().setInt32(t+4,e,!0),Uc().setInt32(t+0,s,!0)},__wbg___wbindgen_string_get_914df97fcfa788f2:function(t,i){const s=Jc(i),e="string"==typeof s?s:void 0;var h=qc(e)?0:jc(e,iu.__wbindgen_export,iu.__wbindgen_export2),r=su;Uc().setInt32(t+4,r,!0),Uc().setInt32(t+0,h,!0)},__wbg___wbindgen_throw_81fc77679af83bc6:function(t,i){throw new Error(Tc(t,i))},__wbg__wbg_cb_unref_3c3b4f651835fbcb:function(t){Jc(t)._wbg_cb_unref()},__wbg_call_7f2987183bb62793:function(){return Oc((function(t,i){return $c(Jc(t).call(Jc(i)))}),arguments)},__wbg_call_d578befcc3145dee:function(){return Oc((function(t,i,s){return $c(Jc(t).call(Jc(i),Jc(s)))}),arguments)},__wbg_clearInterval_26ba580547547579:function(t){return $c(clearInterval(Yc(t)))},__wbg_close_f181fdc02ee236e6:function(){return Oc((function(t){Jc(t).close()}),arguments)},__wbg_data_60b50110c5bd9349:function(t){return $c(Jc(t).data)},__wbg_from_741da0f916ab74aa:function(t){return $c(Array.from(Jc(t)))},__wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a:function(t){let i;try{i=Jc(t)instanceof ArrayBuffer}catch(t){i=!1}return i},__wbg_length_0c32cb8543c8e4c8:function(t){return Jc(t).length},__wbg_new_4f9fafbb3909af72:function(){return $c(new Object)},__wbg_new_a560378ea1240b14:function(t){return $c(new Uint8Array(Jc(t)))},__wbg_new_f3c9df4f38f3f798:function(){return $c(new Array)},__wbg_new_with_str_7cf464e6e0f54ec2:function(){return Oc((function(t,i,s,e){return $c(new WebSocket(Tc(t,i),Tc(s,e)))}),arguments)},__wbg_prototypesetcall_3e05eb9545565046:function(t,i,s){Uint8Array.prototype.set.call(Fc(t,i),Jc(s))},__wbg_readyState_631d9f7c37e595d7:function(t){return Jc(t).readyState},__wbg_send_64dd480ad0d86a31:function(){return Oc((function(t,i,s){Jc(t).send(Fc(i,s))}),arguments)},__wbg_setInterval_cbf1c35c6a692d37:function(){return Oc((function(t,i){return $c(setInterval(Jc(t),i))}),arguments)},__wbg_set_6be42768c690e380:function(t,i,s){Jc(t)[Yc(i)]=Yc(s)},__wbg_set_6c60b2e8ad0e9383:function(t,i,s){Jc(t)[i>>>0]=Yc(s)},__wbg_set_binaryType_95c0a0f7586a3903:function(t,i){Jc(t).binaryType=_c[i]},__wbg_set_onclose_47cce56c686db4fb:function(t,i){Jc(t).onclose=Jc(i)},__wbg_set_onerror_3db8bc3e52b2b10b:function(t,i){Jc(t).onerror=Jc(i)},__wbg_set_onmessage_45bd33b110c54f5b:function(t,i){Jc(t).onmessage=Jc(i)},__wbg_set_onopen_7ffeb01f8a628209:function(t,i){Jc(t).onopen=Jc(i)},__wbg_warn_97be992ef0100a92:function(t,i){console.warn(Tc(t,i))},__wbindgen_cast_0000000000000001:function(t,i){return $c(Kc(t,i,xc))},__wbindgen_cast_0000000000000002:function(t,i){return $c(Kc(t,i,Dc))},__wbindgen_cast_0000000000000003:function(t,i){return $c(Kc(t,i,Lc))},__wbindgen_cast_0000000000000004:function(t,i){return $c(Kc(t,i,kc))},__wbindgen_cast_0000000000000005:function(t){return $c(t)},__wbindgen_cast_0000000000000006:function(t,i){return $c(Fc(t,i))},__wbindgen_cast_0000000000000007:function(t,i){return $c(Tc(t,i))},__wbindgen_cast_0000000000000008:function(t){return $c(BigInt.asUintN(64,t))},__wbindgen_object_clone_ref:function(t){return $c(Jc(t))},__wbindgen_object_drop_ref:function(t){Yc(t)}};return{__proto__:null,"./phirepass-channel_bg.js":t}}function kc(t,i){iu.__wasm_bindgen_func_elem_41(t,i)}function xc(t,i,s){iu.__wasm_bindgen_func_elem_37(t,i,$c(s))}function Dc(t,i,s){iu.__wasm_bindgen_func_elem_37_1(t,i,$c(s))}function Lc(t,i,s){iu.__wasm_bindgen_func_elem_37_2(t,i,$c(s))}const _c=["blob","arraybuffer"],Sc="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>iu.__wbg_channel_free(t>>>0,1)));function $c(t){zc===Wc.length&&Wc.push(Wc.length+1);const i=zc;return zc=Wc[i],Wc[i]=t,i}const Rc="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>iu.__wbindgen_export4(t.a,t.b)));function Nc(t){const i=typeof t;if("number"==i||"boolean"==i||null==t)return`${t}`;if("string"==i)return`"${t}"`;if("symbol"==i){const i=t.description;return null==i?"Symbol":`Symbol(${i})`}if("function"==i){const i=t.name;return"string"==typeof i&&i.length>0?`Function(${i})`:"Function"}if(Array.isArray(t)){const i=t.length;let s="[";i>0&&(s+=Nc(t[0]));for(let e=1;e<i;e++)s+=", "+Nc(t[e]);return s+="]",s}const s=/\[object ([^\]]+)\]/.exec(toString.call(t));let e;if(!(s&&s.length>1))return toString.call(t);if(e=s[1],"Object"==e)try{return"Object("+JSON.stringify(t)+")"}catch(t){return"Object"}return t instanceof Error?`${t.name}: ${t.message}\n${t.stack}`:e}function Fc(t,i){return t>>>=0,Pc().subarray(t/1,t/1+i)}let Hc=null;function Uc(){return(null===Hc||!0===Hc.buffer.detached||void 0===Hc.buffer.detached&&Hc.buffer!==iu.memory.buffer)&&(Hc=new DataView(iu.memory.buffer)),Hc}function Tc(t,i){return function(t,i){return Vc+=i,Vc>=Xc&&(Zc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Zc.decode(),Vc=i),Zc.decode(Pc().subarray(t,t+i))}(t>>>=0,i)}let Gc=null;function Pc(){return null!==Gc&&0!==Gc.byteLength||(Gc=new Uint8Array(iu.memory.buffer)),Gc}function Jc(t){return Wc[t]}function Oc(t,i){try{return t.apply(this,i)}catch(t){iu.__wbindgen_export3($c(t))}}let Wc=new Array(1024).fill(void 0);Wc.push(void 0,null,!0,!1);let zc=Wc.length;function qc(t){return null==t}function Kc(t,i,s){const e={a:t,b:i,cnt:1},h=(...t)=>{e.cnt++;const i=e.a;e.a=0;try{return s(i,e.b,...t)}finally{e.a=i,h._wbg_cb_unref()}};return h._wbg_cb_unref=()=>{0==--e.cnt&&(iu.__wbindgen_export4(e.a,e.b),e.a=0,Rc.unregister(e))},Rc.register(h,e,e),h}function jc(t,i,s){if(void 0===s){const s=tu.encode(t),e=i(s.length,1)>>>0;return Pc().subarray(e,e+s.length).set(s),su=s.length,e}let e=t.length,h=i(e,1)>>>0;const r=Pc();let n=0;for(;n<e;n++){const i=t.charCodeAt(n);if(i>127)break;r[h+n]=i}if(n!==e){0!==n&&(t=t.slice(n)),h=s(h,e,e=n+3*t.length,1)>>>0;const i=Pc().subarray(h+n,h+e);n+=tu.encodeInto(t,i).written,h=s(h,e,n,1)>>>0}return su=n,h}function Yc(t){const i=Jc(t);return function(t){t<1028||(Wc[t]=zc,zc=t)}(t),i}let Zc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Zc.decode();const Xc=2146435072;let Vc=0;const tu=new TextEncoder;"encodeInto"in tu||(tu.encodeInto=function(t,i){const s=tu.encode(t);return i.set(s),{read:t.length,written:s.length}});let iu,su=0;var eu,hu;!function(t){t[t.Username=0]="Username",t[t.Password=1]="Password",t[t.Default=2]="Default"}(eu||(eu={})),function(t){t.Disconnected="disconnected",t.Connected="connected",t.Error="error"}(hu||(hu={}));const ru=class{constructor(s){t(this,s),this.connectionStateChanged=i(this,"connectionStateChanged")}terminal;fitAddon;webLinksAddon;searchAddon;webglAddon;serializeAddon;imageAddon;channel;containerEl;domReady=!1;runtimeReady=!1;connected=!1;inputMode=eu.Default;resizeObserver;resizeDebounceHandle;session_id;usernameBuffer="";passwordBuffer="";xtermImageSettings={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7};get el(){return s(this)}terminalOptions={termName:"xterm-256color",rendererType:"canvas",allowTransparency:!1,fontFamily:'"Berkeley Mono", "Fira Code", "SFMono-Regular", Menlo, monospace',fontSize:12,letterSpacing:0,lineHeight:1,allowProposedApi:!0,cursorBlink:!0,cursorWidth:1,theme:{background:"#0b1021",foreground:"#e2e8f0",cursor:"#67e8f9"},scrollback:1e4,fastScrollModifier:"shift",fastScrollSensitivity:5,bellStyle:"sound",convertEol:!1,disableStdin:!1,rightClickSelectsWord:!0,drawBoldTextInBrightColors:!0,minimumContrastRatio:1,windowsMode:!1,macOptionIsMeta:!1,altClickMovesCursor:!0};serverHost="phirepass.com";serverPort=443;allowInsecure=!1;heartbeatInterval=3e4;nodeId;token;onNodeIdChange(t,i){this.reset_session_state(),this.terminal.reset(),this.channel&&this.channel.is_connected()&&this.close_comms(),t&&(this.open_comms(),this.channel.connect())}serverId;onServerIdChange(t,i){this.onNodeIdChange(this.nodeId,this.nodeId)}connectionStateChanged;create_web_socket_endpoint(){const t=this.allowInsecure?"ws":"wss";return this.allowInsecure||443!==this.serverPort?this.allowInsecure&&80===this.serverPort?`${t}://${this.serverHost}`:`${t}://${this.serverHost}:${this.serverPort}`:`${t}://${this.serverHost}`}async connectedCallback(){await async function(t){if(void 0!==iu)return iu;void 0!==t&&(Object.getPrototypeOf(t)===Object.prototype?({module_or_path:t}=t):console.warn("using deprecated parameters for the initialization function; pass a single object instead")),void 0===t&&(t=new URL("phirepass-channel_bg.wasm",import.meta.url));const i=Qc();("string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL)&&(t=fetch(t));const{instance:s}=await async function(t,i){if("function"==typeof Response&&t instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(t,i)}catch(i){if(!t.ok||!function(t){switch(t){case"basic":case"cors":case"default":return!0}return!1}(t.type)||"application/wasm"===t.headers.get("Content-Type"))throw i;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",i)}const s=await t.arrayBuffer();return await WebAssembly.instantiate(s,i)}{const s=await WebAssembly.instantiate(t,i);return s instanceof WebAssembly.Instance?{instance:s,module:t}:s}}(await t,i);return function(t){return iu=t.exports,Hc=null,Gc=null,iu}(s)}(),this.setup_terminal(),this.open_comms(),this.runtimeReady=!0,this.nodeId?this.try_connect():console.warn("Prop node_id is not set. Cannot connect to terminal.")}componentDidLoad(){this.domReady=!0,this.try_connect()}async disconnectedCallback(){this.resizeObserver&&this.resizeObserver.disconnect(),this.connected=!1,this.domReady=!1,this.runtimeReady=!1,this.close_comms(),this.destroy_terminal()}try_connect(){!this.connected&&this.domReady&&this.runtimeReady&&this.containerEl&&this.terminal&&this.channel&&this.connect()}setup_terminal(){this.terminal=new pr(this.terminalOptions),this.fitAddon=new Cr,this.terminal.loadAddon(this.fitAddon),this.webLinksAddon=new Mr,this.terminal.loadAddon(this.webLinksAddon),this.searchAddon=new yn,this.terminal.loadAddon(this.searchAddon),this.serializeAddon=new Rl,this.terminal.loadAddon(this.serializeAddon),this.imageAddon=new Mc(this.xtermImageSettings),this.terminal.loadAddon(this.imageAddon);try{this.webglAddon=new ml,this.terminal.loadAddon(this.webglAddon)}catch(t){console.warn("WebGL addon not available or failed to load:",t)}"function"==typeof this.terminal.onResize&&this.terminal.onResize((()=>{this.send_ssh_terminal_resize()}))}destroy_terminal(){this.terminal&&(this.terminal.reset(),"function"==typeof this.terminal.dispose&&this.terminal.dispose())}open_comms(){this.channel=this.serverId?new yc(`${this.create_web_socket_endpoint()}/api/web/ws`,this.nodeId,this.serverId):new yc(`${this.create_web_socket_endpoint()}/api/web/ws`,this.nodeId),this.channel.on_connection_open((()=>{this.connectionStateChanged.emit([hu.Connected]),this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.connectionStateChanged.emit([hu.Disconnected]),this.terminal.reset()})),this.channel.on_connection_error((t=>{this.connectionStateChanged.emit([hu.Error,t])})),this.channel.on_connection_message((()=>{})),this.channel.on_protocol_message((t=>{const{web:i}=t.data;switch(i.type){case"Error":this.handle_error(i);break;case"AuthSuccess":this.handle_auth_success(i);break;case"TunnelOpened":this.handle_tunnel_opened(i);break;case"TunnelClosed":this.handle_tunnel_closed(i);break;case"TunnelData":this.handle_tunnel_data(i);break;default:console.warn("Unknown protocol message type:",i)}}))}send_ssh_terminal_resize(){if(!this.containerEl)return void console.warn("Cannot send terminal resize: container element not available");if(!this.nodeId)return void console.warn("Cannot send terminal resize: node_id is missing");if(!this.channel)return void console.warn("Cannot send terminal resize: channel is not initialized");if(!this.channel.is_connected())return void console.warn("Cannot send terminal resize: channel not connected");if(!this.session_id)return void console.warn("Cannot send terminal resize: session_id is missing");this.fitAddon.fit();const t=this.terminal?.cols??0,i=this.terminal?.rows??0,s=this.containerEl.clientWidth??0,e=this.containerEl.clientHeight??0;if(t<=0||i<=0||s<=0||e<=0)console.warn(`Cannot send terminal resize: invalid terminal dimensions cols=${t}, rows=${i}, px_width=${s}, px_height=${e}`);else try{console.log(`Sending terminal resize: cols=${t}, rows=${i}, px_width=${s}, px_height=${e}`),this.channel.send_ssh_terminal_resize(this.nodeId,this.session_id,t,i,s,e)}catch(t){console.error("Failed to send terminal resize:",t)}}send_ssh_data(t){this.channel.is_connected()&&this.session_id&&this.channel.send_ssh_tunnel_data(this.nodeId,this.session_id,t)}handle_error(t){switch(t.kind){case Ec.Generic:this.terminal.reset(),this.terminal.write(t.message+"\r\n"),this.terminal.focus();break;case Ec.RequiresUsername:this.terminal.reset(),this.inputMode=eu.Username,this.usernameBuffer="",this.terminal.write("Enter your username: "),this.terminal.focus();break;case Ec.RequiresPassword:this.terminal.reset(),this.inputMode=eu.Password,this.passwordBuffer="",this.terminal.write("Enter your password: "),this.terminal.focus();break;default:console.warn("Unknown error kind:",t)}}close_comms(){this.channel.stop_heartbeat(),this.channel.disconnect()}cancel_credential_entry(){this.inputMode=eu.Default,this.clear_creds_buffer(),this.terminal.writeln("Authentication cancelled."),this.terminal.reset(),this.close_comms()}clear_creds_buffer(){this.usernameBuffer="",this.passwordBuffer=""}reset_session_state(){this.session_id=void 0,this.inputMode=eu.Default,this.clear_creds_buffer()}handle_auth_success(t){this.clear_creds_buffer(),this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.channel.open_ssh_tunnel(this.nodeId)}handle_tunnel_opened(t){this.session_id=t.sid,this.terminal.reset(),this.fitAddon.fit(),this.send_ssh_terminal_resize()}handle_tunnel_data(t){this.terminal.write(new Uint8Array(t.data))}handle_tunnel_closed(t){this.session_id=void 0,this.inputMode=eu.Default,this.clear_creds_buffer(),this.terminal.reset(),this.terminal.writeln("Connection closed."),this.close_comms()}connect(){const t=this.containerEl;console.log("Attempting to connect terminal to container:",t),t&&(this.terminal.open(t),console.log("Terminal opened in container"),this.fitAddon.fit(),this.terminal.focus(),this.terminal.onData(this.handle_terminal_data.bind(this)),this.channel.connect(),this.setup_resize_observer(),this.connected=!0,console.log("Terminal connected and ready"))}setup_resize_observer(){this.resizeObserver=new ResizeObserver((()=>{console.log("Container resized, fitting terminal"),this.resizeDebounceHandle&&clearTimeout(this.resizeDebounceHandle),this.resizeDebounceHandle=setTimeout((()=>{this.fitAddon.fit(),this.send_ssh_terminal_resize()}),100)})),this.resizeObserver.observe(this.containerEl??this.el)}handle_terminal_data(t){switch(this.inputMode){case eu.Username:this.handle_username_input(t);break;case eu.Password:this.handle_password_input(t);break;case eu.Default:this.send_ssh_data(t)}}handle_username_input(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submit_username()):""===t?(this.terminal.write("^C\r\n"),void this.cancel_credential_entry()):void(""!==t?t>=" "&&t<="~"&&(this.usernameBuffer+=t,this.terminal.write(t)):this.usernameBuffer.length&&(this.usernameBuffer=this.usernameBuffer.slice(0,-1),this.terminal.write("\b \b")))}submit_username(){if(!this.channel.is_connected())return;const t=this.usernameBuffer.trim();if(!t)return this.terminal.writeln(""),this.terminal.write("Enter your username: "),void(this.usernameBuffer="");this.inputMode=eu.Default,this.channel.open_ssh_tunnel(this.nodeId,t)}handle_password_input(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submit_password()):""===t?(this.terminal.write("^C\r\n"),void this.cancel_credential_entry()):void(""!==t?t>=" "&&t<="~"&&(this.passwordBuffer+=t,this.terminal.write("*")):this.passwordBuffer.length&&(this.passwordBuffer=this.passwordBuffer.slice(0,-1),this.terminal.write("\b \b")))}submit_password(){if(!this.channel.is_connected())return;const t=this.passwordBuffer;if(!t)return this.terminal.writeln(""),this.terminal.write("Enter your password: "),void(this.passwordBuffer="");this.inputMode=eu.Default,this.channel.open_ssh_tunnel(this.nodeId,this.usernameBuffer.trim(),t),this.passwordBuffer="",this.usernameBuffer=""}render(){return e(h,{key:"6c6080f3b370c76871ab48695046557c64d173b6"},e("div",{key:"17c80b9c99de88dc53e61e0bf8725dafcf96d3b6",id:"ccc",ref:t=>this.containerEl=t}))}static get watchers(){return{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}}};ru.style=".xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#FFF;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1 !important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px !important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:rgba(0,0,0,0);transition:opacity 100ms linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity 800ms linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}:host{display:block;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}:host #ccc{width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}";export{ru as phirepass_terminal}
@@ -1 +1 @@
1
- import{p as e,b as r}from"./p-C8ZFkLEv.js";export{s as setNonce}from"./p-C8ZFkLEv.js";import{g as t}from"./p-DQuL1Twl.js";(()=>{const r=import.meta.url,s={};return""!==r&&(s.resourcesUrl=new URL(".",r).href),e(s)})().then((async e=>(await t(),r([["p-376ef3af",[[257,"phirepass-sftp-client"]]],["p-57c38d54",[[513,"phirepass-terminal",{terminalOptions:[16],serverHost:[1,"server-host"],serverPort:[2,"server-port"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],nodeId:[1,"node-id"],token:[1],serverId:[1,"server-id"]},null,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]]]],e))));
1
+ import{p as e,b as r}from"./p-C8ZFkLEv.js";export{s as setNonce}from"./p-C8ZFkLEv.js";import{g as t}from"./p-DQuL1Twl.js";(()=>{const r=import.meta.url,s={};return""!==r&&(s.resourcesUrl=new URL(".",r).href),e(s)})().then((async e=>(await t(),r([["p-376ef3af",[[257,"phirepass-sftp-client"]]],["p-773287e0",[[513,"phirepass-terminal",{terminalOptions:[16],serverHost:[1,"server-host"],serverPort:[2,"server-port"],allowInsecure:[4,"allow-insecure"],heartbeatInterval:[2,"heartbeat-interval"],nodeId:[1,"node-id"],token:[1],serverId:[1,"server-id"]},null,{nodeId:[{onNodeIdChange:0}],serverId:[{onServerIdChange:0}]}]]]],e))));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phirepass-widgets",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "description": "Phirepass widgets for the web application",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -57,6 +57,6 @@
57
57
  "@xterm/addon-web-links": "^0.12.0",
58
58
  "@xterm/addon-webgl": "^0.19.0",
59
59
  "@xterm/xterm": "^6.0.0",
60
- "phirepass-channel": "^0.1.180"
60
+ "phirepass-channel": "^0.1.183"
61
61
  }
62
62
  }