phirepass-widgets 0.0.17 → 0.0.18

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.
@@ -446,7 +446,11 @@ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRen
446
446
  }
447
447
  let isProp = isMemberInElement(elm, memberName);
448
448
  memberName.toLowerCase();
449
- if (memberName === "key") ; else if (memberName[0] === "a" && memberName.startsWith("attr:")) {
449
+ if (memberName === "key") ; else if (memberName === "ref") {
450
+ if (newValue) {
451
+ queueRefAttachment(newValue, elm);
452
+ }
453
+ } else if (memberName[0] === "a" && memberName.startsWith("attr:")) {
450
454
  const propName = memberName.slice(5);
451
455
  let attrName;
452
456
  {
@@ -552,6 +556,8 @@ function sortedAttrNames(attrNames) {
552
556
  var hostTagName;
553
557
  var useNativeShadowDom = false;
554
558
  var isSvgMode = false;
559
+ var refCallbacksToRemove = [];
560
+ var refCallbacksToAttach = [];
555
561
  var createElm = (oldParentVNode, newParentVNode, childIndex) => {
556
562
  const newVNode2 = newParentVNode.$children$[childIndex];
557
563
  let i2 = 0;
@@ -623,6 +629,7 @@ var removeVnodes = (vnodes, startIdx, endIdx) => {
623
629
  const vnode = vnodes[index];
624
630
  if (vnode) {
625
631
  const elm = vnode.$elm$;
632
+ nullifyVNodeRefs(vnode);
626
633
  if (elm) {
627
634
  elm.remove();
628
635
  }
@@ -753,6 +760,27 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
753
760
  } else ;
754
761
  }
755
762
  };
763
+ var nullifyVNodeRefs = (vNode) => {
764
+ {
765
+ if (vNode.$attrs$ && vNode.$attrs$.ref) {
766
+ refCallbacksToRemove.push(() => vNode.$attrs$.ref(null));
767
+ }
768
+ vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
769
+ }
770
+ };
771
+ var queueRefAttachment = (refCallback, elm) => {
772
+ {
773
+ refCallbacksToAttach.push(() => refCallback(elm));
774
+ }
775
+ };
776
+ var flushQueuedRefCallbacks = () => {
777
+ {
778
+ refCallbacksToRemove.forEach((cb) => cb());
779
+ refCallbacksToRemove.length = 0;
780
+ refCallbacksToAttach.forEach((cb) => cb());
781
+ refCallbacksToAttach.length = 0;
782
+ }
783
+ };
756
784
  var insertBefore = (parent, newNode, reference, isInitialLoad) => {
757
785
  if (parent.__insertBefore) {
758
786
  return parent.__insertBefore(newNode, reference);
@@ -780,6 +808,7 @@ var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
780
808
  rootVnode.$elm$ = oldVNode.$elm$ = hostElm.shadowRoot || hostElm ;
781
809
  useNativeShadowDom = !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) && !(cmpMeta.$flags$ & 128 /* shadowNeedsScopedCss */);
782
810
  patch(oldVNode, rootVnode, isInitialLoad);
811
+ flushQueuedRefCallbacks();
783
812
  };
784
813
 
785
814
  // src/runtime/update-component.ts
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-D6ygTbCo.js');
3
+ var index = require('./index-L0_45iFE.js');
4
4
  var appGlobals = require('./app-globals-V2Kpy_OQ.js');
5
5
 
6
6
  const defineCustomElements = async (win, options) => {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-D6ygTbCo.js');
3
+ var index = require('./index-L0_45iFE.js');
4
4
 
5
5
  const phirepassSftpClientCss = () => `:host{display:block}`;
6
6
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-D6ygTbCo.js');
3
+ var index = require('./index-L0_45iFE.js');
4
4
 
5
5
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
6
6
  /**
@@ -998,6 +998,10 @@ const PhirepassTerminal = class {
998
998
  serializeAddon;
999
999
  imageAddon;
1000
1000
  channel;
1001
+ containerEl;
1002
+ domReady = false;
1003
+ runtimeReady = false;
1004
+ connected = false;
1001
1005
  inputMode = InputMode.Default;
1002
1006
  resizeObserver;
1003
1007
  resizeDebounceHandle;
@@ -1102,19 +1106,36 @@ const PhirepassTerminal = class {
1102
1106
  console.log('Terminal setup complete');
1103
1107
  this.open_comms();
1104
1108
  console.log('Comms opened');
1109
+ this.runtimeReady = true;
1105
1110
  if (!this.nodeId) {
1106
1111
  console.warn('Prop node_id is not set. Cannot connect to terminal.');
1107
1112
  return;
1108
1113
  }
1109
- this.connect();
1114
+ this.try_connect();
1115
+ }
1116
+ componentDidLoad() {
1117
+ this.domReady = true;
1118
+ this.try_connect();
1110
1119
  }
1111
1120
  async disconnectedCallback() {
1112
1121
  if (this.resizeObserver) {
1113
1122
  this.resizeObserver.disconnect();
1114
1123
  }
1124
+ this.connected = false;
1125
+ this.domReady = false;
1126
+ this.runtimeReady = false;
1115
1127
  this.close_comms();
1116
1128
  this.destroy_terminal();
1117
1129
  }
1130
+ try_connect() {
1131
+ if (this.connected || !this.domReady || !this.runtimeReady) {
1132
+ return;
1133
+ }
1134
+ if (!this.containerEl || !this.terminal || !this.channel) {
1135
+ return;
1136
+ }
1137
+ this.connect();
1138
+ }
1118
1139
  setup_terminal() {
1119
1140
  this.terminal = new Dl(this.terminalOptions);
1120
1141
  this.fitAddon = new o();
@@ -1266,7 +1287,7 @@ const PhirepassTerminal = class {
1266
1287
  this.terminal.writeln("Connection closed.");
1267
1288
  }
1268
1289
  connect() {
1269
- const container = this.el.shadowRoot.getElementById('ccc');
1290
+ const container = this.containerEl;
1270
1291
  console.log('Attempting to connect terminal to container:', container);
1271
1292
  if (container) {
1272
1293
  this.terminal.open(container);
@@ -1276,6 +1297,7 @@ const PhirepassTerminal = class {
1276
1297
  this.terminal.onData(this.handleTerminalData.bind(this));
1277
1298
  this.channel.connect();
1278
1299
  this.setupResizeObserver();
1300
+ this.connected = true;
1279
1301
  console.log('Terminal connected and ready');
1280
1302
  }
1281
1303
  }
@@ -1384,7 +1406,7 @@ const PhirepassTerminal = class {
1384
1406
  this.usernameBuffer = "";
1385
1407
  }
1386
1408
  render() {
1387
- return (index.h(index.Host, { key: '1456c7a70c91f451ee9da4382e97b1b69a786fa0' }, index.h("div", { key: 'acdc106e9687508da70cb2f9b5897c67537da012', id: "ccc" })));
1409
+ return (index.h(index.Host, { key: '16372280bf650813e7aae4e28fae8b761b87a096' }, index.h("div", { key: '5a387d5d9d0772510ded9b50c764ab4ae4b14abc', id: "ccc", ref: el => (this.containerEl = el) })));
1388
1410
  }
1389
1411
  static get watchers() { return {
1390
1412
  "nodeId": [{
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-D6ygTbCo.js');
3
+ var index = require('./index-L0_45iFE.js');
4
4
  var appGlobals = require('./app-globals-V2Kpy_OQ.js');
5
5
 
6
6
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
@@ -23,6 +23,10 @@ export class PhirepassTerminal {
23
23
  serializeAddon;
24
24
  imageAddon;
25
25
  channel;
26
+ containerEl;
27
+ domReady = false;
28
+ runtimeReady = false;
29
+ connected = false;
26
30
  inputMode = InputMode.Default;
27
31
  resizeObserver;
28
32
  resizeDebounceHandle;
@@ -127,19 +131,36 @@ export class PhirepassTerminal {
127
131
  console.log('Terminal setup complete');
128
132
  this.open_comms();
129
133
  console.log('Comms opened');
134
+ this.runtimeReady = true;
130
135
  if (!this.nodeId) {
131
136
  console.warn('Prop node_id is not set. Cannot connect to terminal.');
132
137
  return;
133
138
  }
134
- this.connect();
139
+ this.try_connect();
140
+ }
141
+ componentDidLoad() {
142
+ this.domReady = true;
143
+ this.try_connect();
135
144
  }
136
145
  async disconnectedCallback() {
137
146
  if (this.resizeObserver) {
138
147
  this.resizeObserver.disconnect();
139
148
  }
149
+ this.connected = false;
150
+ this.domReady = false;
151
+ this.runtimeReady = false;
140
152
  this.close_comms();
141
153
  this.destroy_terminal();
142
154
  }
155
+ try_connect() {
156
+ if (this.connected || !this.domReady || !this.runtimeReady) {
157
+ return;
158
+ }
159
+ if (!this.containerEl || !this.terminal || !this.channel) {
160
+ return;
161
+ }
162
+ this.connect();
163
+ }
143
164
  setup_terminal() {
144
165
  this.terminal = new Terminal(this.terminalOptions);
145
166
  this.fitAddon = new FitAddon();
@@ -291,7 +312,7 @@ export class PhirepassTerminal {
291
312
  this.terminal.writeln("Connection closed.");
292
313
  }
293
314
  connect() {
294
- const container = this.el.shadowRoot.getElementById('ccc');
315
+ const container = this.containerEl;
295
316
  console.log('Attempting to connect terminal to container:', container);
296
317
  if (container) {
297
318
  this.terminal.open(container);
@@ -301,6 +322,7 @@ export class PhirepassTerminal {
301
322
  this.terminal.onData(this.handleTerminalData.bind(this));
302
323
  this.channel.connect();
303
324
  this.setupResizeObserver();
325
+ this.connected = true;
304
326
  console.log('Terminal connected and ready');
305
327
  }
306
328
  }
@@ -409,7 +431,7 @@ export class PhirepassTerminal {
409
431
  this.usernameBuffer = "";
410
432
  }
411
433
  render() {
412
- return (h(Host, { key: '1456c7a70c91f451ee9da4382e97b1b69a786fa0' }, h("div", { key: 'acdc106e9687508da70cb2f9b5897c67537da012', id: "ccc" })));
434
+ return (h(Host, { key: '16372280bf650813e7aae4e28fae8b761b87a096' }, h("div", { key: '5a387d5d9d0772510ded9b50c764ab4ae4b14abc', id: "ccc", ref: el => (this.containerEl = el) })));
413
435
  }
414
436
  static get is() { return "phirepass-terminal"; }
415
437
  static get encapsulation() { return "shadow"; }
@@ -1 +1 @@
1
- function t(t,e,n){const l="undefined"!=typeof HTMLElement?HTMLElement.prototype:null;for(;t&&t!==l;){const l=Object.getOwnPropertyDescriptor(t,e);if(l&&(!n||l.get))return l;t=Object.getPrototypeOf(t)}}var e,n=(e,n)=>{var l;Object.entries(null!=(l=n.l.t)?l:{}).map((([l,[o]])=>{if(31&o||32&o){const o=e[l],s=t(Object.getPrototypeOf(e),l,!0)||Object.getOwnPropertyDescriptor(e,l);s&&Object.defineProperty(e,l,{get(){return s.get.call(this)},set(t){s.set.call(this,t)},configurable:!0,enumerable:!0}),n.o.has(l)?e[l]=n.o.get(l):void 0!==o&&(e[l]=o)}}))},l=t=>{if(t.__stencil__getHostRef)return t.__stencil__getHostRef()},o=(t,e)=>(0,console.error)(t,e),s=new Map,i="undefined"!=typeof window?window:{},r=i.HTMLElement||class{},c={i:0,u:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,n,l)=>t.addEventListener(e,n,l),rel:(t,e,n,l)=>t.removeEventListener(e,n,l),ce:(t,e)=>new CustomEvent(t,e)},u=(()=>{try{return!!i.document.adoptedStyleSheets&&(new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync)}catch(t){}return!1})(),f=!!u&&(()=>!!i.document&&Object.getOwnPropertyDescriptor(i.document.adoptedStyleSheets,"length").writable)(),a=!1,d=[],h=[],p=(t,e)=>n=>{t.push(n),a||(a=!0,e&&4&c.i?$(y):c.raf(y))},m=t=>{for(let e=0;e<t.length;e++)try{t[e](performance.now())}catch(t){o(t)}t.length=0},y=()=>{m(d),m(h),(a=d.length>0)&&c.raf(y)},$=t=>Promise.resolve(void 0).then(t),b=p(h,!0),v=t=>{const e=new URL(t,c.u);return e.origin!==i.location.origin?e.href:e.pathname},w=t=>c.u=t;function g(){const t=this.attachShadow({mode:"open"});void 0===e&&(e=null),e&&(f?t.adoptedStyleSheets.push(e):t.adoptedStyleSheets=[...t.adoptedStyleSheets,e])}var j,O=new WeakMap,S=t=>"sc-"+t.h,M=t=>"object"==(t=typeof t)||"function"===t,k=(t,e,...n)=>{let l=null,o=null,s=!1,i=!1;const r=[],c=e=>{for(let n=0;n<e.length;n++)l=e[n],Array.isArray(l)?c(l):null!=l&&"boolean"!=typeof l&&((s="function"!=typeof t&&!M(l))&&(l+=""),s&&i?r[r.length-1].p+=l:r.push(s?E(null,l):l),i=s)};c(n),e&&e.key&&(o=e.key);const u=E(t,null);return u.m=e,r.length>0&&(u.$=r),u.v=o,u},E=(t,e)=>({i:0,j:t,p:null!=e?e:null,O:null,$:null,m:null,v:null}),A={},C=(t,e)=>null==t||M(t)?t:4&e?"false"!==t&&(""===t||!!t):2&e?"string"==typeof t?parseFloat(t):"number"==typeof t?t:NaN:1&e?t+"":t,L=(t,e,n,o,s,i)=>{if(n===o)return;let r=((t,e)=>e in t)(t,e);if(e.toLowerCase(),"key"===e);else{if("a"===e[0]&&e.startsWith("attr:")){const n=e.slice(5);let s;{const e=l(t);if(e&&e.l&&e.l.t){const t=e.l.t[n];t&&t[1]&&(s=t[1])}}return s||(s=n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()),void(null==o||!1===o?!1===o&&""!==t.getAttribute(s)||t.removeAttribute(s):t.setAttribute(s,!0===o?"":o))}if("p"===e[0]&&e.startsWith("prop:")){const n=e.slice(5);try{t[n]=o}catch(t){}return}{const l=M(o);if((r||l&&null!==o)&&!s)try{if(t.tagName.includes("-"))t[e]!==o&&(t[e]=o);else{const l=null==o?"":o;"list"===e?r=!1:null!=n&&t[e]===l||("function"==typeof t.__lookupSetter__(e)?t[e]=l:t.setAttribute(e,l))}}catch(t){}null==o||!1===o?!1===o&&""!==t.getAttribute(e)||t.removeAttribute(e):(!r||4&i||s)&&!l&&1===t.nodeType&&t.setAttribute(e,o=!0===o?"":o)}}},N=(t,e,n)=>{const l=11===e.O.nodeType&&e.O.host?e.O.host:e.O,o=t&&t.m||{},s=e.m||{};for(const t of _(Object.keys(o)))t in s||L(l,t,o[t],void 0,n,e.i);for(const t of _(Object.keys(s)))L(l,t,o[t],s[t],n,e.i)};function _(t){return t.includes("ref")?[...t.filter((t=>"ref"!==t)),"ref"]:t}var x=!1,D=!1,H=(t,e,n)=>{const l=e.$[n];let o,s,r=0;if(!i.document)throw Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.");if(o=l.O=i.document.createElement(l.j),N(null,l,D),l.$){const e="template"===l.j?o.content:o;for(r=0;r<l.$.length;++r)s=H(t,l,r),s&&e.appendChild(s)}return o["s-hn"]=j,o},P=(t,e,n,l,o,s)=>{let i,r=t;for(r.shadowRoot&&r.tagName===j&&(r=r.shadowRoot),"template"===n.j&&(r=r.content);o<=s;++o)l[o]&&(i=H(null,n,o),i&&(l[o].O=i,F(r,i,e)))},U=(t,e,n)=>{for(let l=e;l<=n;++l){const e=t[l];if(e){const t=e.O;t&&t.remove()}}},R=(t,e,n=!1)=>t.j===e.j&&(n?(n&&!t.v&&e.v&&(t.v=e.v),!0):t.v===e.v),W=(t,e,n=!1)=>{const l=e.O=t.O,o=t.$,s=e.$;"slot"!==e.j||x||t.S!==e.S&&(e.O["s-sn"]=e.S||"",(t=>{c.i|=1;const e=t.closest(j.toLowerCase());if(null!=e){const n=Array.from(e.__childNodes||e.childNodes).find((t=>t["s-cr"])),l=Array.from(t.__childNodes||t.childNodes);for(const t of n?l.reverse():l)null!=t["s-sh"]&&(F(e,t,null!=n?n:null),t["s-sh"]=void 0)}c.i&=-2})(e.O.parentElement)),N(t,e,D),null!==o&&null!==s?((t,e,n,l,o=!1)=>{let s,i,r=0,c=0,u=0,f=0,a=e.length-1,d=e[0],h=e[a],p=l.length-1,m=l[0],y=l[p];const $="template"===n.j?t.content:t;for(;r<=a&&c<=p;)if(null==d)d=e[++r];else if(null==h)h=e[--a];else if(null==m)m=l[++c];else if(null==y)y=l[--p];else if(R(d,m,o))W(d,m,o),d=e[++r],m=l[++c];else if(R(h,y,o))W(h,y,o),h=e[--a],y=l[--p];else if(R(d,y,o))W(d,y,o),F($,d.O,h.O.nextSibling),d=e[++r],y=l[--p];else if(R(h,m,o))W(h,m,o),F($,h.O,d.O),h=e[--a],m=l[++c];else{for(u=-1,f=r;f<=a;++f)if(e[f]&&null!==e[f].v&&e[f].v===m.v){u=f;break}u>=0?(i=e[u],i.j!==m.j?s=H(e&&e[c],n,u):(W(i,m,o),e[u]=void 0,s=i.O),m=l[++c]):(s=H(e&&e[c],n,c),m=l[++c]),s&&F(d.O.parentNode,s,d.O)}r>a?P(t,null==l[p+1]?null:l[p+1].O,n,l,c,p):c>p&&U(e,r,a)})(l,o,e,s,n):null!==s?P(l,null,e,s,0,s.length-1):!n&&null!==o&&U(o,0,o.length-1)},F=(t,e,n)=>t.__insertBefore?t.__insertBefore(e,n):null==t?void 0:t.insertBefore(e,n),q=(t,e,n=!1)=>{const l=t.$hostElement$,o=t.l,s=t.M||E(null,null),i=(t=>t&&t.j===A)(e)?e:k(null,null,e);if(j=l.tagName,n&&i.m)for(const t of Object.keys(i.m))l.hasAttribute(t)&&!["key","ref","style","class"].includes(t)&&(i.m[t]=l[t]);i.j=null,i.i|=4,t.M=i,i.O=s.O=l.shadowRoot||l,x=!(!(1&o.i)||128&o.i),W(s,i,n)},z=(t,e)=>{if(e&&!t.k&&e["s-p"]){const n=e["s-p"].push(new Promise((l=>t.k=()=>{e["s-p"].splice(n-1,1),l()})))}},T=(t,e)=>{if(t.i|=16,4&t.i)return void(t.i|=512);z(t,t.A);const n=()=>V(t,e);if(!e)return b(n);queueMicrotask((()=>{n()}))},V=(t,e)=>{const n=t.$hostElement$,l=n;if(!l)throw Error(`Can't render component <${n.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);let o;return o=K(l,e?"componentWillLoad":"componentWillUpdate",void 0,n),o=Y(o,(()=>K(l,"componentWillRender",void 0,n))),Y(o,(()=>B(t,l,e)))},Y=(t,e)=>Z(t)?t.then(e).catch((t=>{console.error(t),e()})):e(),Z=t=>t instanceof Promise||t&&t.then&&"function"==typeof t.then,B=async(t,e,n)=>{var l;const o=t.$hostElement$,r=o["s-rc"];n&&(t=>{const e=t.l,n=t.$hostElement$,l=e.i,o=((t,e)=>{var n,l,o;const r=S(e),a=s.get(r);if(!i.document)return r;if(t=11===t.nodeType?t:i.document,a)if("string"==typeof a){let o,s=O.get(t=t.head||t);if(s||O.set(t,s=new Set),!s.has(r)){o=i.document.createElement("style"),o.textContent=a;const d=null!=(n=c.C)?n:function(){var t,e,n;return null!=(n=null==(e=null==(t=i.document.head)?void 0:t.querySelector('meta[name="csp-nonce"]'))?void 0:e.getAttribute("content"))?n:void 0}();if(null!=d&&o.setAttribute("nonce",d),!(1&e.i))if("HEAD"===t.nodeName){const e=t.querySelectorAll("link[rel=preconnect]"),n=e.length>0?e[e.length-1].nextSibling:t.querySelector("style");t.insertBefore(o,(null==n?void 0:n.parentNode)===t?n:null)}else if("host"in t)if(u){const e=new(null!=(l=t.defaultView)?l:t.ownerDocument.defaultView).CSSStyleSheet;e.replaceSync(a),f?t.adoptedStyleSheets.unshift(e):t.adoptedStyleSheets=[e,...t.adoptedStyleSheets]}else{const e=t.querySelector("style");e?e.textContent=a+e.textContent:t.prepend(o)}else t.append(o);1&e.i&&t.insertBefore(o,null),4&e.i&&(o.textContent+="slot-fb{display:contents}slot-fb[hidden]{display:none}"),s&&s.add(r)}}else{let e=O.get(t);if(e||O.set(t,e=new Set),!e.has(r)){const n=null!=(o=t.defaultView)?o:t.ownerDocument.defaultView;let l;if(a.constructor===n.CSSStyleSheet)l=a;else{l=new n.CSSStyleSheet;for(let t=0;t<a.cssRules.length;t++)l.insertRule(a.cssRules[t].cssText,t)}f?t.adoptedStyleSheets.push(l):t.adoptedStyleSheets=[...t.adoptedStyleSheets,l],e.add(r)}}return r})(n.shadowRoot?n.shadowRoot:n.getRootNode(),e);10&l&&(n["s-sc"]=o,n.classList.add(o+"-h"))})(t);G(t,e,o,n),r&&(r.map((t=>t())),o["s-rc"]=void 0);{const e=null!=(l=o["s-p"])?l:[],n=()=>I(t);0===e.length?n():(Promise.all(e).then(n).catch(n),t.i|=4,e.length=0)}},G=(t,e,n,l)=>{try{e=e.render(),t.i&=-17,t.i|=2,q(t,e,l)}catch(e){o(e,t.$hostElement$)}return null},I=t=>{const e=t.$hostElement$,n=e,l=t.A;K(n,"componentDidRender",void 0,e),64&t.i?K(n,"componentDidUpdate",void 0,e):(t.i|=64,Q(e),K(n,"componentDidLoad",void 0,e),t.L(e),l||J()),t.k&&(t.k(),t.k=void 0),512&t.i&&$((()=>T(t,!1))),t.i&=-517},J=()=>{$((()=>(t=>{const e=c.ce("appload",{detail:{namespace:"phirepass-widgets"}});return t.dispatchEvent(e),e})(i)))},K=(t,e,n,l)=>{if(t&&t[e])try{return t[e](n)}catch(t){o(t,l)}},Q=t=>t.classList.add("hydrated"),X=(t,e,n,s)=>{const i=l(t);if(!i)return;const r=t,c=i.o.get(e),u=i.i,f=r;if(!((n=C(n,s.t[e][0]))===c||Number.isNaN(c)&&Number.isNaN(n))){if(i.o.set(e,n),s.N){const t=s.N[e];t&&t.map((t=>{try{const[[l,o]]=Object.entries(t);(128&u||1&o)&&(f?f[l](n,c,e):i._.push((()=>{i.D[l](n,c,e)})))}catch(t){o(t,r)}}))}if(2&u){if(f.componentShouldUpdate&&!1===f.componentShouldUpdate(n,c,e)&&!(16&u))return;16&u||T(i,!1)}}},tt=(e,n)=>{var o,s;const i=e.prototype;{e.watchers&&!n.N&&(n.N=e.watchers),e.deserializers&&!n.H&&(n.H=e.deserializers),e.serializers&&!n.P&&(n.P=e.serializers);const r=Object.entries(null!=(o=n.t)?o:{});r.map((([e,[o]])=>{if(31&o||32&o){const{get:s,set:r}=t(i,e)||{};s&&(n.t[e][0]|=2048),r&&(n.t[e][0]|=4096),Object.defineProperty(i,e,{get(){return s?s.apply(this):((t,e)=>l(this).o.get(e))(0,e)},configurable:!0,enumerable:!0}),Object.defineProperty(i,e,{set(t){const s=l(this);if(s){if(r)return void 0===(32&o?this[e]:s.$hostElement$[e])&&s.o.get(e)&&(t=s.o.get(e)),r.call(this,C(t,o)),void X(this,e,t=32&o?this[e]:s.$hostElement$[e],n);X(this,e,t,n)}}})}}));{const t=new Map;i.attributeChangedCallback=function(e,o,s){c.jmp((()=>{var c;const u=t.get(e),f=l(this);if(this.hasOwnProperty(u),i.hasOwnProperty(u)&&"number"==typeof this[u]&&this[u]==s)return;if(null==u){const t=null==f?void 0:f.i;if(f&&t&&!(8&t)&&s!==o){const l=this,i=null==(c=n.N)?void 0:c[e];null==i||i.forEach((n=>{const[[i,r]]=Object.entries(n);null!=l[i]&&(128&t||1&r)&&l[i].call(l,s,o,e)}))}return}const a=r.find((([t])=>t===u));a&&4&a[1][0]&&(s=null!==s&&"false"!==s);const d=Object.getOwnPropertyDescriptor(i,u);s==this[u]||d.get&&!d.set||(this[u]=s)}))},e.observedAttributes=Array.from(new Set([...Object.keys(null!=(s=n.N)?s:{}),...r.filter((([t,e])=>31&e[0])).map((([e,n])=>{const l=n[1]||e;return t.set(l,e),l}))]))}}return e},et=(t,e)=>{const i={i:e[0],h:e[1]};try{i.t=e[2],i.N=t.N,i.H=t.H,i.P=t.P;const r=t.prototype.connectedCallback,f=t.prototype.disconnectedCallback;return Object.assign(t.prototype,{__hasHostListenerAttached:!1,__registerHost(){((t,e)=>{const l={i:0,$hostElement$:t,l:e,o:new Map,U:new Map};l.R=new Promise((t=>l.L=t)),t["s-p"]=[],t["s-rc"]=[];const o=l;t.__stencil__getHostRef=()=>o,512&e.i&&n(t,l)})(this,i)},connectedCallback(){if(!this.__hasHostListenerAttached){if(!l(this))return;this.__hasHostListenerAttached=!0}(t=>{if(!(1&c.i)){const e=l(t);if(!e)return;const n=e.l,i=()=>{};if(1&e.i)(null==e?void 0:e.D)||(null==e?void 0:e.R)&&e.R.then((()=>{}));else{e.i|=1;{let n=t;for(;n=n.parentNode||n.host;)if(n["s-p"]){z(e,e.A=n);break}}n.t&&Object.entries(n.t).map((([e,[n]])=>{if(31&n&&Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];delete t[e],t[e]=n}})),(async(t,e,n)=>{let l;try{if(!(32&e.i)&&(e.i|=32,l=t.constructor,customElements.whenDefined(t.localName).then((()=>e.i|=128)),l&&l.style)){let t;"string"==typeof l.style&&(t=l.style);const e=S(n);if(!s.has(e)){const l=()=>{};((t,e,n)=>{let l=s.get(t);u&&n?(l=l||new CSSStyleSheet,"string"==typeof l?l=e:l.replaceSync(e)):l=e,s.set(t,l)})(e,t,!!(1&n.i)),l()}}const o=e.A,i=()=>T(e,!0);o&&o["s-rc"]?o["s-rc"].push(i):i()}catch(n){o(n,t),e.k&&(e.k(),e.k=void 0),e.L&&e.L(t)}})(t,e,n)}i()}})(this),r&&r.call(this)},disconnectedCallback(){(async t=>{O.has(t)&&O.delete(t),t.shadowRoot&&O.has(t.shadowRoot)&&O.delete(t.shadowRoot)})(this),f&&f.call(this)},__attachShadow(){if(this.shadowRoot){if("open"!==this.shadowRoot.mode)throw Error(`Unable to re-use existing shadow root for ${i.h}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else g.call(this,i)}}),Object.defineProperty(t,"is",{value:i.h,configurable:!0}),tt(t,i)}catch(e){return o(e),t}},nt=t=>c.C=t,lt=t=>Object.assign(c,t);function ot(t,e){q({l:{i:0,h:e.tagName},$hostElement$:e},t)}function st(t){return t}export{r as H,A as a,v as getAssetPath,k as h,et as p,ot as render,w as setAssetPath,nt as setNonce,lt as setPlatformOptions,st as t}
1
+ function t(t,e,n){const l="undefined"!=typeof HTMLElement?HTMLElement.prototype:null;for(;t&&t!==l;){const l=Object.getOwnPropertyDescriptor(t,e);if(l&&(!n||l.get))return l;t=Object.getPrototypeOf(t)}}var e,n=(e,n)=>{var l;Object.entries(null!=(l=n.l.t)?l:{}).map((([l,[o]])=>{if(31&o||32&o){const o=e[l],s=t(Object.getPrototypeOf(e),l,!0)||Object.getOwnPropertyDescriptor(e,l);s&&Object.defineProperty(e,l,{get(){return s.get.call(this)},set(t){s.set.call(this,t)},configurable:!0,enumerable:!0}),n.o.has(l)?e[l]=n.o.get(l):void 0!==o&&(e[l]=o)}}))},l=t=>{if(t.__stencil__getHostRef)return t.__stencil__getHostRef()},o=(t,e)=>(0,console.error)(t,e),s=new Map,i="undefined"!=typeof window?window:{},r=i.HTMLElement||class{},c={i:0,u:"",jmp:t=>t(),raf:t=>requestAnimationFrame(t),ael:(t,e,n,l)=>t.addEventListener(e,n,l),rel:(t,e,n,l)=>t.removeEventListener(e,n,l),ce:(t,e)=>new CustomEvent(t,e)},u=(()=>{try{return!!i.document.adoptedStyleSheets&&(new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync)}catch(t){}return!1})(),f=!!u&&(()=>!!i.document&&Object.getOwnPropertyDescriptor(i.document.adoptedStyleSheets,"length").writable)(),a=!1,d=[],h=[],p=(t,e)=>n=>{t.push(n),a||(a=!0,e&&4&c.i?$(y):c.raf(y))},m=t=>{for(let e=0;e<t.length;e++)try{t[e](performance.now())}catch(t){o(t)}t.length=0},y=()=>{m(d),m(h),(a=d.length>0)&&c.raf(y)},$=t=>Promise.resolve(void 0).then(t),b=p(h,!0),v=t=>{const e=new URL(t,c.u);return e.origin!==i.location.origin?e.href:e.pathname},w=t=>c.u=t;function g(){const t=this.attachShadow({mode:"open"});void 0===e&&(e=null),e&&(f?t.adoptedStyleSheets.push(e):t.adoptedStyleSheets=[...t.adoptedStyleSheets,e])}var j,O=new WeakMap,S=t=>"sc-"+t.h,M=t=>"object"==(t=typeof t)||"function"===t,k=(t,e,...n)=>{let l=null,o=null,s=!1,i=!1;const r=[],c=e=>{for(let n=0;n<e.length;n++)l=e[n],Array.isArray(l)?c(l):null!=l&&"boolean"!=typeof l&&((s="function"!=typeof t&&!M(l))&&(l+=""),s&&i?r[r.length-1].p+=l:r.push(s?E(null,l):l),i=s)};c(n),e&&e.key&&(o=e.key);const u=E(t,null);return u.m=e,r.length>0&&(u.$=r),u.v=o,u},E=(t,e)=>({i:0,j:t,p:null!=e?e:null,O:null,$:null,m:null,v:null}),A={},C=(t,e)=>null==t||M(t)?t:4&e?"false"!==t&&(""===t||!!t):2&e?"string"==typeof t?parseFloat(t):"number"==typeof t?t:NaN:1&e?t+"":t,L=(t,e,n,o,s,i)=>{if(n===o)return;let r=((t,e)=>e in t)(t,e);if(e.toLowerCase(),"key"===e);else if("ref"===e)o&&T(o,t);else{if("a"===e[0]&&e.startsWith("attr:")){const n=e.slice(5);let s;{const e=l(t);if(e&&e.l&&e.l.t){const t=e.l.t[n];t&&t[1]&&(s=t[1])}}return s||(s=n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()),void(null==o||!1===o?!1===o&&""!==t.getAttribute(s)||t.removeAttribute(s):t.setAttribute(s,!0===o?"":o))}if("p"===e[0]&&e.startsWith("prop:")){const n=e.slice(5);try{t[n]=o}catch(t){}return}{const l=M(o);if((r||l&&null!==o)&&!s)try{if(t.tagName.includes("-"))t[e]!==o&&(t[e]=o);else{const l=null==o?"":o;"list"===e?r=!1:null!=n&&t[e]===l||("function"==typeof t.__lookupSetter__(e)?t[e]=l:t.setAttribute(e,l))}}catch(t){}null==o||!1===o?!1===o&&""!==t.getAttribute(e)||t.removeAttribute(e):(!r||4&i||s)&&!l&&1===t.nodeType&&t.setAttribute(e,o=!0===o?"":o)}}},N=(t,e,n)=>{const l=11===e.O.nodeType&&e.O.host?e.O.host:e.O,o=t&&t.m||{},s=e.m||{};for(const t of _(Object.keys(o)))t in s||L(l,t,o[t],void 0,n,e.i);for(const t of _(Object.keys(s)))L(l,t,o[t],s[t],n,e.i)};function _(t){return t.includes("ref")?[...t.filter((t=>"ref"!==t)),"ref"]:t}var x=!1,D=!1,H=[],P=[],U=(t,e,n)=>{const l=e.$[n];let o,s,r=0;if(!i.document)throw Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.");if(o=l.O=i.document.createElement(l.j),N(null,l,D),l.$){const e="template"===l.j?o.content:o;for(r=0;r<l.$.length;++r)s=U(t,l,r),s&&e.appendChild(s)}return o["s-hn"]=j,o},R=(t,e,n,l,o,s)=>{let i,r=t;for(r.shadowRoot&&r.tagName===j&&(r=r.shadowRoot),"template"===n.j&&(r=r.content);o<=s;++o)l[o]&&(i=U(null,n,o),i&&(l[o].O=i,V(r,i,e)))},W=(t,e,n)=>{for(let l=e;l<=n;++l){const e=t[l];if(e){const t=e.O;z(e),t&&t.remove()}}},F=(t,e,n=!1)=>t.j===e.j&&(n?(n&&!t.v&&e.v&&(t.v=e.v),!0):t.v===e.v),q=(t,e,n=!1)=>{const l=e.O=t.O,o=t.$,s=e.$;"slot"!==e.j||x||t.S!==e.S&&(e.O["s-sn"]=e.S||"",(t=>{c.i|=1;const e=t.closest(j.toLowerCase());if(null!=e){const n=Array.from(e.__childNodes||e.childNodes).find((t=>t["s-cr"])),l=Array.from(t.__childNodes||t.childNodes);for(const t of n?l.reverse():l)null!=t["s-sh"]&&(V(e,t,null!=n?n:null),t["s-sh"]=void 0)}c.i&=-2})(e.O.parentElement)),N(t,e,D),null!==o&&null!==s?((t,e,n,l,o=!1)=>{let s,i,r=0,c=0,u=0,f=0,a=e.length-1,d=e[0],h=e[a],p=l.length-1,m=l[0],y=l[p];const $="template"===n.j?t.content:t;for(;r<=a&&c<=p;)if(null==d)d=e[++r];else if(null==h)h=e[--a];else if(null==m)m=l[++c];else if(null==y)y=l[--p];else if(F(d,m,o))q(d,m,o),d=e[++r],m=l[++c];else if(F(h,y,o))q(h,y,o),h=e[--a],y=l[--p];else if(F(d,y,o))q(d,y,o),V($,d.O,h.O.nextSibling),d=e[++r],y=l[--p];else if(F(h,m,o))q(h,m,o),V($,h.O,d.O),h=e[--a],m=l[++c];else{for(u=-1,f=r;f<=a;++f)if(e[f]&&null!==e[f].v&&e[f].v===m.v){u=f;break}u>=0?(i=e[u],i.j!==m.j?s=U(e&&e[c],n,u):(q(i,m,o),e[u]=void 0,s=i.O),m=l[++c]):(s=U(e&&e[c],n,c),m=l[++c]),s&&V(d.O.parentNode,s,d.O)}r>a?R(t,null==l[p+1]?null:l[p+1].O,n,l,c,p):c>p&&W(e,r,a)})(l,o,e,s,n):null!==s?R(l,null,e,s,0,s.length-1):!n&&null!==o&&W(o,0,o.length-1)},z=t=>{t.m&&t.m.ref&&H.push((()=>t.m.ref(null))),t.$&&t.$.map(z)},T=(t,e)=>{P.push((()=>t(e)))},V=(t,e,n)=>t.__insertBefore?t.__insertBefore(e,n):null==t?void 0:t.insertBefore(e,n),Y=(t,e,n=!1)=>{const l=t.$hostElement$,o=t.l,s=t.M||E(null,null),i=(t=>t&&t.j===A)(e)?e:k(null,null,e);if(j=l.tagName,n&&i.m)for(const t of Object.keys(i.m))l.hasAttribute(t)&&!["key","ref","style","class"].includes(t)&&(i.m[t]=l[t]);i.j=null,i.i|=4,t.M=i,i.O=s.O=l.shadowRoot||l,x=!(!(1&o.i)||128&o.i),q(s,i,n),H.forEach((t=>t())),H.length=0,P.forEach((t=>t())),P.length=0},Z=(t,e)=>{if(e&&!t.k&&e["s-p"]){const n=e["s-p"].push(new Promise((l=>t.k=()=>{e["s-p"].splice(n-1,1),l()})))}},B=(t,e)=>{if(t.i|=16,4&t.i)return void(t.i|=512);Z(t,t.A);const n=()=>G(t,e);if(!e)return b(n);queueMicrotask((()=>{n()}))},G=(t,e)=>{const n=t.$hostElement$,l=n;if(!l)throw Error(`Can't render component <${n.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);let o;return o=et(l,e?"componentWillLoad":"componentWillUpdate",void 0,n),o=I(o,(()=>et(l,"componentWillRender",void 0,n))),I(o,(()=>K(t,l,e)))},I=(t,e)=>J(t)?t.then(e).catch((t=>{console.error(t),e()})):e(),J=t=>t instanceof Promise||t&&t.then&&"function"==typeof t.then,K=async(t,e,n)=>{var l;const o=t.$hostElement$,r=o["s-rc"];n&&(t=>{const e=t.l,n=t.$hostElement$,l=e.i,o=((t,e)=>{var n,l,o;const r=S(e),a=s.get(r);if(!i.document)return r;if(t=11===t.nodeType?t:i.document,a)if("string"==typeof a){let o,s=O.get(t=t.head||t);if(s||O.set(t,s=new Set),!s.has(r)){o=i.document.createElement("style"),o.textContent=a;const d=null!=(n=c.C)?n:function(){var t,e,n;return null!=(n=null==(e=null==(t=i.document.head)?void 0:t.querySelector('meta[name="csp-nonce"]'))?void 0:e.getAttribute("content"))?n:void 0}();if(null!=d&&o.setAttribute("nonce",d),!(1&e.i))if("HEAD"===t.nodeName){const e=t.querySelectorAll("link[rel=preconnect]"),n=e.length>0?e[e.length-1].nextSibling:t.querySelector("style");t.insertBefore(o,(null==n?void 0:n.parentNode)===t?n:null)}else if("host"in t)if(u){const e=new(null!=(l=t.defaultView)?l:t.ownerDocument.defaultView).CSSStyleSheet;e.replaceSync(a),f?t.adoptedStyleSheets.unshift(e):t.adoptedStyleSheets=[e,...t.adoptedStyleSheets]}else{const e=t.querySelector("style");e?e.textContent=a+e.textContent:t.prepend(o)}else t.append(o);1&e.i&&t.insertBefore(o,null),4&e.i&&(o.textContent+="slot-fb{display:contents}slot-fb[hidden]{display:none}"),s&&s.add(r)}}else{let e=O.get(t);if(e||O.set(t,e=new Set),!e.has(r)){const n=null!=(o=t.defaultView)?o:t.ownerDocument.defaultView;let l;if(a.constructor===n.CSSStyleSheet)l=a;else{l=new n.CSSStyleSheet;for(let t=0;t<a.cssRules.length;t++)l.insertRule(a.cssRules[t].cssText,t)}f?t.adoptedStyleSheets.push(l):t.adoptedStyleSheets=[...t.adoptedStyleSheets,l],e.add(r)}}return r})(n.shadowRoot?n.shadowRoot:n.getRootNode(),e);10&l&&(n["s-sc"]=o,n.classList.add(o+"-h"))})(t);Q(t,e,o,n),r&&(r.map((t=>t())),o["s-rc"]=void 0);{const e=null!=(l=o["s-p"])?l:[],n=()=>X(t);0===e.length?n():(Promise.all(e).then(n).catch(n),t.i|=4,e.length=0)}},Q=(t,e,n,l)=>{try{e=e.render(),t.i&=-17,t.i|=2,Y(t,e,l)}catch(e){o(e,t.$hostElement$)}return null},X=t=>{const e=t.$hostElement$,n=e,l=t.A;et(n,"componentDidRender",void 0,e),64&t.i?et(n,"componentDidUpdate",void 0,e):(t.i|=64,nt(e),et(n,"componentDidLoad",void 0,e),t.L(e),l||tt()),t.k&&(t.k(),t.k=void 0),512&t.i&&$((()=>B(t,!1))),t.i&=-517},tt=()=>{$((()=>(t=>{const e=c.ce("appload",{detail:{namespace:"phirepass-widgets"}});return t.dispatchEvent(e),e})(i)))},et=(t,e,n,l)=>{if(t&&t[e])try{return t[e](n)}catch(t){o(t,l)}},nt=t=>t.classList.add("hydrated"),lt=(t,e,n,s)=>{const i=l(t);if(!i)return;const r=t,c=i.o.get(e),u=i.i,f=r;if(!((n=C(n,s.t[e][0]))===c||Number.isNaN(c)&&Number.isNaN(n))){if(i.o.set(e,n),s.N){const t=s.N[e];t&&t.map((t=>{try{const[[l,o]]=Object.entries(t);(128&u||1&o)&&(f?f[l](n,c,e):i._.push((()=>{i.D[l](n,c,e)})))}catch(t){o(t,r)}}))}if(2&u){if(f.componentShouldUpdate&&!1===f.componentShouldUpdate(n,c,e)&&!(16&u))return;16&u||B(i,!1)}}},ot=(e,n)=>{var o,s;const i=e.prototype;{e.watchers&&!n.N&&(n.N=e.watchers),e.deserializers&&!n.H&&(n.H=e.deserializers),e.serializers&&!n.P&&(n.P=e.serializers);const r=Object.entries(null!=(o=n.t)?o:{});r.map((([e,[o]])=>{if(31&o||32&o){const{get:s,set:r}=t(i,e)||{};s&&(n.t[e][0]|=2048),r&&(n.t[e][0]|=4096),Object.defineProperty(i,e,{get(){return s?s.apply(this):((t,e)=>l(this).o.get(e))(0,e)},configurable:!0,enumerable:!0}),Object.defineProperty(i,e,{set(t){const s=l(this);if(s){if(r)return void 0===(32&o?this[e]:s.$hostElement$[e])&&s.o.get(e)&&(t=s.o.get(e)),r.call(this,C(t,o)),void lt(this,e,t=32&o?this[e]:s.$hostElement$[e],n);lt(this,e,t,n)}}})}}));{const t=new Map;i.attributeChangedCallback=function(e,o,s){c.jmp((()=>{var c;const u=t.get(e),f=l(this);if(this.hasOwnProperty(u),i.hasOwnProperty(u)&&"number"==typeof this[u]&&this[u]==s)return;if(null==u){const t=null==f?void 0:f.i;if(f&&t&&!(8&t)&&s!==o){const l=this,i=null==(c=n.N)?void 0:c[e];null==i||i.forEach((n=>{const[[i,r]]=Object.entries(n);null!=l[i]&&(128&t||1&r)&&l[i].call(l,s,o,e)}))}return}const a=r.find((([t])=>t===u));a&&4&a[1][0]&&(s=null!==s&&"false"!==s);const d=Object.getOwnPropertyDescriptor(i,u);s==this[u]||d.get&&!d.set||(this[u]=s)}))},e.observedAttributes=Array.from(new Set([...Object.keys(null!=(s=n.N)?s:{}),...r.filter((([t,e])=>31&e[0])).map((([e,n])=>{const l=n[1]||e;return t.set(l,e),l}))]))}}return e},st=(t,e)=>{const i={i:e[0],h:e[1]};try{i.t=e[2],i.N=t.N,i.H=t.H,i.P=t.P;const r=t.prototype.connectedCallback,f=t.prototype.disconnectedCallback;return Object.assign(t.prototype,{__hasHostListenerAttached:!1,__registerHost(){((t,e)=>{const l={i:0,$hostElement$:t,l:e,o:new Map,U:new Map};l.R=new Promise((t=>l.L=t)),t["s-p"]=[],t["s-rc"]=[];const o=l;t.__stencil__getHostRef=()=>o,512&e.i&&n(t,l)})(this,i)},connectedCallback(){if(!this.__hasHostListenerAttached){if(!l(this))return;this.__hasHostListenerAttached=!0}(t=>{if(!(1&c.i)){const e=l(t);if(!e)return;const n=e.l,i=()=>{};if(1&e.i)(null==e?void 0:e.D)||(null==e?void 0:e.R)&&e.R.then((()=>{}));else{e.i|=1;{let n=t;for(;n=n.parentNode||n.host;)if(n["s-p"]){Z(e,e.A=n);break}}n.t&&Object.entries(n.t).map((([e,[n]])=>{if(31&n&&Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];delete t[e],t[e]=n}})),(async(t,e,n)=>{let l;try{if(!(32&e.i)&&(e.i|=32,l=t.constructor,customElements.whenDefined(t.localName).then((()=>e.i|=128)),l&&l.style)){let t;"string"==typeof l.style&&(t=l.style);const e=S(n);if(!s.has(e)){const l=()=>{};((t,e,n)=>{let l=s.get(t);u&&n?(l=l||new CSSStyleSheet,"string"==typeof l?l=e:l.replaceSync(e)):l=e,s.set(t,l)})(e,t,!!(1&n.i)),l()}}const o=e.A,i=()=>B(e,!0);o&&o["s-rc"]?o["s-rc"].push(i):i()}catch(n){o(n,t),e.k&&(e.k(),e.k=void 0),e.L&&e.L(t)}})(t,e,n)}i()}})(this),r&&r.call(this)},disconnectedCallback(){(async t=>{O.has(t)&&O.delete(t),t.shadowRoot&&O.has(t.shadowRoot)&&O.delete(t.shadowRoot)})(this),f&&f.call(this)},__attachShadow(){if(this.shadowRoot){if("open"!==this.shadowRoot.mode)throw Error(`Unable to re-use existing shadow root for ${i.h}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else g.call(this,i)}}),Object.defineProperty(t,"is",{value:i.h,configurable:!0}),ot(t,i)}catch(e){return o(e),t}},it=t=>c.C=t,rt=t=>Object.assign(c,t);function ct(t,e){Y({l:{i:0,h:e.tagName},$hostElement$:e},t)}function ut(t){return t}export{r as H,A as a,v as getAssetPath,k as h,st as p,ct as render,w as setAssetPath,it as setNonce,rt as setPlatformOptions,ut as t}
@@ -46,4 +46,4 @@ import{t,p as i,H as s,h as e,a as h}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 Ja(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})(Ma||={}),(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)}})(ya||={});var Oa=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(ya.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)}};Oa.DISABLE_DISPOSED_WARNING=!1;var Wa=Oa,qa=class{constructor(){this._store=new Wa}dispose(){this._store.dispose()}_register(t){if(t===this)throw Error("Cannot register a disposable on itself!");return this._store.add(t)}};qa.None=Object.freeze({dispose(){}});var za=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}},Ka=class t extends qa{constructor(t){super(),this._terminal=t,this._optionsRefresh=this._register(new za),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:Ja((()=>{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,l=Math.ceil(o.width/r),a=i%l*r,c=Math.floor(i/l)*n,u=s*r,A=e*n,f=h*r+a>o.width?o.width-a:h*r,d=c+n>o.height?o.height-c:n;this._ctx.drawImage(o,Math.floor(a),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,l=Math.floor(s/n)*h,a=e+o>r.width?r.width-o:e,c=l+h>r.height?r.height-l:h,u=t.createCanvas(this.document,a,c),A=u.getContext("2d");return A?(A.drawImage(r,Math.floor(o),Math.floor(l),Math.floor(a),Math.floor(c),0,0,Math.floor(a),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,Ga.toRGBA8888)(0,0,0),l=(0,Ga.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]=l}h.putImageData(r,0,0);let a=screen.width+s-1&-32||4096;this._placeholder=t.createCanvas(this.document,a,i);let c=this._placeholder.getContext("2d",{alpha:!1});if(c){for(let t=0;t<a;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}},ja={width:7,height:14},Ya=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}},Za=new Ya,Xa=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=ja);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=ja);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,l=r.x,a=r.y,c=l,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=l,r.y=a);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]||Za,r=e.imageId;if(void 0===r||-1===r)continue;let n=this._images.get(r);if(-1!==e.tileId){let o=e.tileId,l=s,a=1;for(;++s<h&&268435456&i.getBg(s)&&(e=i._extendedAttrs[s]||Za)&&e.imageId===r&&e.tileId===o+a;)a++;s--,n?n.actual&&this._renderer.draw(n,o,l,t,a):this._opts.showPlaceholder&&this._renderer.drawPlaceholder(l,t,a),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]||Za,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 l=Math.min(t.cols,n-i.tileId%n+e),a=i.tileId;for(let t=e+1;t<l;++t)this._writeToCell(s,t,h,++a),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]||Za;if(i.imageId&&-1!==i.imageId){let t=this._images.get(i.imageId)?.orig;if(window.ImageBitmap&&t instanceof ImageBitmap){let i=Ka.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]||Za;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 Ya(h.ext,h.urlId,s,e))}}t._data[3*i+2]|=268435456,t._extendedAttrs[i]=new Ya(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)}},Va=Na(Ta());function tc(t){let i="";for(let s=0;s<t.length;++s)i+=String.fromCharCode(t[s]);return i}function ic(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 sc(t){let i=tc(t);if(!i.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw Error("illegal size");return i}var ec={inline:ic,size:ic,name:function(t){if(typeof Buffer<"u")return""+Buffer.from(tc(t),"base64");let i=atob(tc(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:sc,height:sc,preserveAspectRatio:ic},hc=[70,105,108,101],rc=1024,nc=class{constructor(){this.state=0,this._buffer=new Uint32Array(rc),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]!==hc[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>=rc)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>=rc)return this._a();r[h++]=i}}return this.state=e,this._position=h,-2}_a(){return this.state=1,-1}_storeKey(t){let i=tc(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]=ec[this._key]?ec[this._key](i):i}catch{return!1}return!0}return!1}},oc={mime:"unsupported",width:0,height:0},lc={name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},ac=class{constructor(t,i,s,e){this._opts=t,this._renderer=i,this._storage=s,this._coreTerminal=e,this._aborted=!1,this._hp=new nc,this._header=lc,this._dec=new Va.default(4194304),this._metrics=oc}reset(){}start(){this._aborted=!1,this._header=lc,this._metrics=oc,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 oc;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]?oc:{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=Ka.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||ja.width,e=this._renderer.dimensions?.css.cell.height||ja.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=Na(Fa()),uc=Na(Pa()),Ac=cc.PALETTE_ANSI_256;Ac.set(cc.PALETTE_VT340_COLOR);var fc=class{constructor(t,i,s){this._opts=t,this._storage=i,this._coreTerminal=s,this._size=0,this._aborted=!1,(0,uc.DecoderAsync)({memoryLimit:4*this._opts.pixelLimit,palette:Ac,paletteLimit:this._opts.sixelPaletteLimit}).then((t=>this._dec=t))}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,Ac,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=dc(i.foreground.rgba);else if(t.isFgRGB()){let i=t.constructor.toColorRGB(t.getFgColor());s=(0,cc.toRGBA8888)(...i)}else s=dc(i.ansi[t.getFgColor()].rgba);else if(t.isBgDefault())s=dc(i.background.rgba);else if(t.isBgRGB()){let i=t.constructor.toColorRGB(t.getBgColor());s=(0,cc.toRGBA8888)(...i)}else s=dc(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=Ka.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 dc(t){return cc.BIG_ENDIAN?t:(255&t)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255}var gc={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7},wc=class{constructor(t){this._disposables=[],this._handlers=new Map,this._opts=Object.assign({},gc,t),this._defaultOpts=Object.assign({},gc,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 Ka(t),this._storage=new Xa(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 fc(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 ac(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=ja;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 pc{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,yc.unregister(this),t}free(){const t=this.__destroy_into_raw();zc.__wbg_channel_free(t,0)}authenticate(t,i,s){const e=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),h=Kc,r=Pc(i,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_authenticate(this.__wbg_ptr,e,h,r,Kc,Tc(s)?4294967297:s>>>0)}connect(){zc.channel_connect(this.__wbg_ptr)}disconnect(){zc.channel_disconnect(this.__wbg_ptr)}is_connected(){return 0!==zc.channel_is_connected(this.__wbg_ptr)}is_disconnected(){return 0!==zc.channel_is_disconnected(this.__wbg_ptr)}constructor(t,i,s){const e=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),h=Kc,r=Pc(i,zc.__wbindgen_export,zc.__wbindgen_export2),n=Kc;var o=Tc(s)?0:Pc(s,zc.__wbindgen_export,zc.__wbindgen_export2);const l=zc.channel_new(e,h,r,n,o,Kc);return this.__wbg_ptr=l>>>0,yc.register(this,this.__wbg_ptr,this),this}on_connection_close(t){zc.channel_on_connection_close(this.__wbg_ptr,Tc(t)?0:Ec(t))}on_connection_error(t){zc.channel_on_connection_error(this.__wbg_ptr,Tc(t)?0:Ec(t))}on_connection_message(t){zc.channel_on_connection_message(this.__wbg_ptr,Tc(t)?0:Ec(t))}on_connection_open(t){zc.channel_on_connection_open(this.__wbg_ptr,Tc(t)?0:Ec(t))}on_protocol_message(t){zc.channel_on_protocol_message(this.__wbg_ptr,Tc(t)?0:Ec(t))}open_sftp_tunnel(t,i,s,e){const h=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),r=Kc;var n=Tc(i)?0:Pc(i,zc.__wbindgen_export,zc.__wbindgen_export2),o=Kc,l=Tc(s)?0:Pc(s,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_open_sftp_tunnel(this.__wbg_ptr,h,r,n,o,l,Kc,Tc(e)?4294967297:e>>>0)}open_ssh_tunnel(t,i,s,e){const h=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),r=Kc;var n=Tc(i)?0:Pc(i,zc.__wbindgen_export,zc.__wbindgen_export2),o=Kc,l=Tc(s)?0:Pc(s,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_open_ssh_tunnel(this.__wbg_ptr,h,r,n,o,l,Kc,Tc(e)?4294967297:e>>>0)}send_sftp_delete(t,i,s,e,h){const r=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),n=Kc,o=Pc(s,zc.__wbindgen_export,zc.__wbindgen_export2),l=Kc,a=Pc(e,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_send_sftp_delete(this.__wbg_ptr,r,n,i,o,l,a,Kc,Tc(h)?4294967297:h>>>0)}send_sftp_download_chunk(t,i,s,e,h){const r=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_send_sftp_download_chunk(this.__wbg_ptr,r,Kc,i,s,e,Tc(h)?4294967297:h>>>0)}send_sftp_download_start(t,i,s,e,h){const r=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),n=Kc,o=Pc(s,zc.__wbindgen_export,zc.__wbindgen_export2),l=Kc,a=Pc(e,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_send_sftp_download_start(this.__wbg_ptr,r,n,i,o,l,a,Kc,Tc(h)?4294967297:h>>>0)}send_sftp_list_data(t,i,s,e){const h=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),r=Kc,n=Pc(s,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_send_sftp_list_data(this.__wbg_ptr,h,r,i,n,Kc,Tc(e)?4294967297:e>>>0)}send_sftp_upload_chunk(t,i,s,e,h,r,n){const o=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),l=Kc,a=function(t){const i=(0,zc.__wbindgen_export)(1*t.length,1)>>>0;return $c().set(t,i/1),Kc=t.length,i}(r);zc.channel_send_sftp_upload_chunk(this.__wbg_ptr,o,l,i,s,e,h,a,Kc,Tc(n)?4294967297:n>>>0)}send_sftp_upload_start(t,i,s,e,h,r,n){const o=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),l=Kc,a=Pc(s,zc.__wbindgen_export,zc.__wbindgen_export2),c=Kc,u=Pc(e,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_send_sftp_upload_start(this.__wbg_ptr,o,l,i,a,c,u,Kc,h,r,Tc(n)?4294967297:n>>>0)}send_ssh_terminal_resize(t,i,s,e){const h=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_send_ssh_terminal_resize(this.__wbg_ptr,h,Kc,i,s,e)}send_ssh_tunnel_data(t,i,s){const e=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),h=Kc,r=Pc(s,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_send_ssh_tunnel_data(this.__wbg_ptr,e,h,i,r,Kc)}start_heartbeat(t){zc.channel_start_heartbeat(this.__wbg_ptr,t)}stop_heartbeat(){zc.channel_stop_heartbeat(this.__wbg_ptr)}}Symbol.dispose&&(pc.prototype[Symbol.dispose]=pc.prototype.free);const Cc=Object.freeze({Generic:0,0:"Generic",RequiresUsername:100,100:"RequiresUsername",RequiresPassword:110,110:"RequiresPassword"});function mc(){const t={__proto__:null,__wbg_Error_83742b46f01ce22d:function(t,i){return Ec(Error(_c(t,i)))},__wbg_String_8564e559799eccda:function(t,i){const s=Pc(Rc(i)+"",zc.__wbindgen_export,zc.__wbindgen_export2),e=Kc;Lc().setInt32(t+4,e,!0),Lc().setInt32(t+0,s,!0)},__wbg___wbindgen_debug_string_5398f5bb970e0daa:function(t,i){const s=Pc(kc(Rc(i)),zc.__wbindgen_export,zc.__wbindgen_export2),e=Kc;Lc().setInt32(t+4,e,!0),Lc().setInt32(t+0,s,!0)},__wbg___wbindgen_string_get_395e606bd0ee4427:function(t,i){const s=Rc(i),e="string"==typeof s?s:void 0;var h=Tc(e)?0:Pc(e,zc.__wbindgen_export,zc.__wbindgen_export2),r=Kc;Lc().setInt32(t+4,r,!0),Lc().setInt32(t+0,h,!0)},__wbg___wbindgen_throw_6ddd609b62940d55:function(t,i){throw Error(_c(t,i))},__wbg__wbg_cb_unref_6b5b6b8576d35cb1:function(t){Rc(t)._wbg_cb_unref()},__wbg_call_2d781c1f4d5c0ef8:function(){return Nc((function(t,i,s){return Ec(Rc(t).call(Rc(i),Rc(s)))}),arguments)},__wbg_call_e133b57c9155d22c:function(){return Nc((function(t,i){return Ec(Rc(t).call(Rc(i)))}),arguments)},__wbg_clearInterval_16e8cbbce92291d0:function(t){return Ec(clearInterval(Gc(t)))},__wbg_close_af26905c832a88cb:function(){return Nc((function(t){Rc(t).close()}),arguments)},__wbg_data_a3d9ff9cdd801002:function(t){return Ec(Rc(t).data)},__wbg_from_4bdf88943703fd48:function(t){return Ec(Array.from(Rc(t)))},__wbg_instanceof_ArrayBuffer_101e2bf31071a9f6:function(t){let i;try{i=Rc(t)instanceof ArrayBuffer}catch(t){i=!1}return i},__wbg_length_ea16607d7b61445b:function(t){return Rc(t).length},__wbg_new_5f486cdf45a04d78:function(t){return Ec(new Uint8Array(Rc(t)))},__wbg_new_a70fbab9066b301f:function(){return Ec([])},__wbg_new_ab79df5bd7c26067:function(){return Ec({})},__wbg_new_with_str_299114bdb2430303:function(){return Nc((function(t,i,s,e){return Ec(new WebSocket(_c(t,i),_c(s,e)))}),arguments)},__wbg_prototypesetcall_d62e5099504357e6:function(t,i,s){Uint8Array.prototype.set.call(xc(t,i),Rc(s))},__wbg_readyState_1f1e7f1bdf9f4d42:function(t){return Rc(t).readyState},__wbg_send_d31a693c975dea74:function(){return Nc((function(t,i,s){Rc(t).send(xc(i,s))}),arguments)},__wbg_setInterval_84b64f01452a246e:function(){return Nc((function(t,i){return Ec(setInterval(Rc(t),i))}),arguments)},__wbg_set_282384002438957f:function(t,i,s){Rc(t)[i>>>0]=Gc(s)},__wbg_set_6be42768c690e380:function(t,i,s){Rc(t)[Gc(i)]=Gc(s)},__wbg_set_binaryType_3dcf8281ec100a8f:function(t,i){Rc(t).binaryType=Mc[i]},__wbg_set_onclose_8da801226bdd7a7b:function(t,i){Rc(t).onclose=Rc(i)},__wbg_set_onerror_901ca711f94a5bbb:function(t,i){Rc(t).onerror=Rc(i)},__wbg_set_onmessage_6f80ab771bf151aa:function(t,i){Rc(t).onmessage=Rc(i)},__wbg_set_onopen_34e3e24cf9337ddd:function(t,i){Rc(t).onopen=Rc(i)},__wbg_warn_805e04431c9f73c4:function(t,i){console.warn(_c(t,i))},__wbindgen_cast_0000000000000001:function(t,i){return Ec(Uc(t,i,zc.__wasm_bindgen_func_elem_37,vc))},__wbindgen_cast_0000000000000002:function(t,i){return Ec(Uc(t,i,zc.__wasm_bindgen_func_elem_37,Bc))},__wbindgen_cast_0000000000000003:function(t,i){return Ec(Uc(t,i,zc.__wasm_bindgen_func_elem_37,bc))},__wbindgen_cast_0000000000000004:function(t,i){return Ec(Uc(t,i,zc.__wasm_bindgen_func_elem_37,Ic))},__wbindgen_cast_0000000000000005:function(t){return Ec(t)},__wbindgen_cast_0000000000000006:function(t,i){return Ec(xc(t,i))},__wbindgen_cast_0000000000000007:function(t,i){return Ec(_c(t,i))},__wbindgen_cast_0000000000000008:function(t){return Ec(BigInt.asUintN(64,t))},__wbindgen_object_clone_ref:function(t){return Ec(Rc(t))},__wbindgen_object_drop_ref:function(t){Gc(t)}};return{__proto__:null,"./phirepass-channel_bg.js":t}}function Ic(t,i){zc.__wasm_bindgen_func_elem_41(t,i)}function vc(t,i,s){zc.__wasm_bindgen_func_elem_38(t,i,Ec(s))}function Bc(t,i,s){zc.__wasm_bindgen_func_elem_38_1(t,i,Ec(s))}function bc(t,i,s){zc.__wasm_bindgen_func_elem_38_2(t,i,Ec(s))}const Mc=["blob","arraybuffer"],yc="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>zc.__wbg_channel_free(t>>>0,1)));function Ec(t){Hc===Fc.length&&Fc.push(Fc.length+1);const i=Hc;return Hc=Fc[i],Fc[i]=t,i}const Qc="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>t.dtor(t.a,t.b)));function kc(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+=kc(t[0]));for(let e=1;e<i;e++)s+=", "+kc(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 xc(t,i){return t>>>=0,$c().subarray(t/1,t/1+i)}let Dc=null;function Lc(){return(null===Dc||!0===Dc.buffer.detached||void 0===Dc.buffer.detached&&Dc.buffer!==zc.memory.buffer)&&(Dc=new DataView(zc.memory.buffer)),Dc}function _c(t,i){return function(t,i){return Wc+=i,Wc>=Oc&&(Jc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Jc.decode(),Wc=i),Jc.decode($c().subarray(t,t+i))}(t>>>=0,i)}let Sc=null;function $c(){return null!==Sc&&0!==Sc.byteLength||(Sc=new Uint8Array(zc.memory.buffer)),Sc}function Rc(t){return Fc[t]}function Nc(t,i){try{return t.apply(this,i)}catch(t){zc.__wbindgen_export3(Ec(t))}}let Fc=Array(1024).fill(void 0);Fc.push(void 0,null,!0,!1);let Hc=Fc.length;function Tc(t){return null==t}function Uc(t,i,s,e){const h={a:t,b:i,cnt:1,dtor:s},r=(...t)=>{h.cnt++;const i=h.a;h.a=0;try{return e(i,h.b,...t)}finally{h.a=i,r._wbg_cb_unref()}};return r._wbg_cb_unref=()=>{0==--h.cnt&&(h.dtor(h.a,h.b),h.a=0,Qc.unregister(h))},Qc.register(r,h,h),r}function Pc(t,i,s){if(void 0===s){const s=qc.encode(t),e=i(s.length,1)>>>0;return $c().subarray(e,e+s.length).set(s),Kc=s.length,e}let e=t.length,h=i(e,1)>>>0;const r=$c();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=$c().subarray(h+n,h+e);n+=qc.encodeInto(t,i).written,h=s(h,e,n,1)>>>0}return Kc=n,h}function Gc(t){const i=Rc(t);return function(t){t<1028||(Fc[t]=Hc,Hc=t)}(t),i}let Jc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Jc.decode();const Oc=2146435072;let Wc=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 zc,Kc=0;var jc;!function(t){t[t.Username=0]="Username",t[t.Password=1]="Password",t[t.Default=2]="Default"}(jc||(jc={}));const Yc=i(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow()}terminal;fitAddon;webLinksAddon;searchAddon;webglAddon;serializeAddon;imageAddon;channel;inputMode=jc.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)}createWebSocketEndpoint(){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(){console.log("PhirepassTerminal connected to DOM"),await async function(t){if(void 0!==zc)return zc;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=mc();("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 zc=t.exports,Dc=null,Sc=null,zc}(s)}(),console.log("PhirepassChannel module initialized"),this.setup_terminal(),console.log("Terminal setup complete"),this.open_comms(),console.log("Comms opened"),this.nodeId?this.connect():console.warn("Prop node_id is not set. Cannot connect to terminal.")}async disconnectedCallback(){this.resizeObserver&&this.resizeObserver.disconnect(),this.close_comms(),this.destroy_terminal()}setup_terminal(){this.terminal=new fr(this.terminalOptions),this.fitAddon=new dr,this.terminal.loadAddon(this.fitAddon),this.webLinksAddon=new Ir,this.terminal.loadAddon(this.webLinksAddon),this.searchAddon=new mn,this.terminal.loadAddon(this.searchAddon),this.serializeAddon=new Qa,this.terminal.loadAddon(this.serializeAddon),this.imageAddon=new wc(this.xtermImageSettings),this.terminal.loadAddon(this.imageAddon);try{this.webglAddon=new ua,this.terminal.loadAddon(this.webglAddon)}catch(t){console.warn("WebGL addon not available or failed to load:",t)}this.fitAddon.fit()}destroy_terminal(){this.terminal&&(this.terminal.reset(),"function"==typeof this.terminal.dispose&&this.terminal.dispose())}open_comms(){this.channel=this.serverId?new pc(this.createWebSocketEndpoint()+"/api/web/ws",this.nodeId,this.serverId):new pc(this.createWebSocketEndpoint()+"/api/web/ws",this.nodeId),this.channel.on_connection_open((()=>{this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.terminal.reset()})),this.channel.on_connection_error((t=>{console.error(">> connection 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.handleAuthSuccess(i);break;case"TunnelOpened":this.session_id=i.sid,this.terminal.reset(),this.send_ssh_terminal_resize();break;case"TunnelClosed":this.handleTunnelClosed();break;case"TunnelData":this.terminal.write(new Uint8Array(i.data));break;default:console.warn("Unknown protocol message type:",i)}}))}send_ssh_terminal_resize(){if(!this.channel||!this.channel.is_connected()||!this.session_id)return;const t=this.terminal?.cols??0,i=this.terminal?.rows??0;if(!(t<=0||i<=0))try{this.channel.send_ssh_terminal_resize(this.nodeId,this.session_id,t,i)}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 Cc.Generic:this.terminal.reset(),this.terminal.write(t.message+"\r\n"),this.terminal.focus();break;case Cc.RequiresUsername:this.terminal.reset(),this.inputMode=jc.Username,this.usernameBuffer="",this.terminal.write("Enter your username: "),this.terminal.focus();break;case Cc.RequiresPassword:this.terminal.reset(),this.inputMode=jc.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=jc.Default,this.clear_creds_buffer(),this.terminal.writeln("Authentication cancelled."),this.terminal.reset()}clear_creds_buffer(){this.usernameBuffer="",this.passwordBuffer=""}reset_session_state(){this.session_id=void 0,this.inputMode=jc.Default,this.clear_creds_buffer()}handleAuthSuccess(t){this.clear_creds_buffer(),this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.channel.open_ssh_tunnel(this.nodeId)}handleTunnelClosed(){this.session_id=void 0,this.inputMode=jc.Default,this.clear_creds_buffer(),this.terminal.reset(),this.terminal.writeln("Connection closed.")}connect(){const t=this.el.shadowRoot.getElementById("ccc");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.handleTerminalData.bind(this)),this.channel.connect(),this.setupResizeObserver(),console.log("Terminal connected and ready"))}setupResizeObserver(){this.resizeObserver=new ResizeObserver((()=>{this.resizeDebounceHandle&&clearTimeout(this.resizeDebounceHandle),this.resizeDebounceHandle=setTimeout((()=>{this.fitAddon.fit(),this.send_ssh_terminal_resize()}),100)})),this.resizeObserver.observe(this.el)}handleTerminalData(t){switch(this.inputMode){case jc.Username:this.handleUsernameInput(t);break;case jc.Password:this.handlePasswordInput(t);break;case jc.Default:this.send_ssh_data(t)}}handleUsernameInput(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submitUsername()):""===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")))}submitUsername(){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=jc.Default,this.channel.open_ssh_tunnel(this.nodeId,t)}handlePasswordInput(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submitPassword()):""===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")))}submitPassword(){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=jc.Default,this.channel.open_ssh_tunnel(this.nodeId,this.usernameBuffer.trim(),t),this.passwordBuffer="",this.usernameBuffer=""}render(){return e(h,{key:"1456c7a70c91f451ee9da4382e97b1b69a786fa0"},e("div",{key:"acdc106e9687508da70cb2f9b5897c67537da012",id:"ccc"}))}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%}:host #ccc{width:inherit;height:inherit}:host #ccc .terminal{height:inherit}:host #ccc .terminal .xterm-scrollable-element{height:inherit}"}},[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 Zc(){"undefined"!=typeof customElements&&["phirepass-terminal"].forEach((i=>{"phirepass-terminal"===i&&(customElements.get(t(i))||customElements.define(t(i),Yc))}))}Zc();const Xc=Yc,Vc=Zc;export{Xc as PhirepassTerminal,Vc as defineCustomElement}
49
+ */function Ja(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})(Ma||={}),(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)}})(ya||={});var Oa=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(ya.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)}};Oa.DISABLE_DISPOSED_WARNING=!1;var Wa=Oa,qa=class{constructor(){this._store=new Wa}dispose(){this._store.dispose()}_register(t){if(t===this)throw Error("Cannot register a disposable on itself!");return this._store.add(t)}};qa.None=Object.freeze({dispose(){}});var za=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}},Ka=class t extends qa{constructor(t){super(),this._terminal=t,this._optionsRefresh=this._register(new za),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:Ja((()=>{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,l=Math.ceil(o.width/r),a=i%l*r,c=Math.floor(i/l)*n,u=s*r,A=e*n,f=h*r+a>o.width?o.width-a:h*r,d=c+n>o.height?o.height-c:n;this._ctx.drawImage(o,Math.floor(a),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,l=Math.floor(s/n)*h,a=e+o>r.width?r.width-o:e,c=l+h>r.height?r.height-l:h,u=t.createCanvas(this.document,a,c),A=u.getContext("2d");return A?(A.drawImage(r,Math.floor(o),Math.floor(l),Math.floor(a),Math.floor(c),0,0,Math.floor(a),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,Ga.toRGBA8888)(0,0,0),l=(0,Ga.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]=l}h.putImageData(r,0,0);let a=screen.width+s-1&-32||4096;this._placeholder=t.createCanvas(this.document,a,i);let c=this._placeholder.getContext("2d",{alpha:!1});if(c){for(let t=0;t<a;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}},ja={width:7,height:14},Ya=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}},Za=new Ya,Xa=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=ja);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=ja);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,l=r.x,a=r.y,c=l,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=l,r.y=a);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]||Za,r=e.imageId;if(void 0===r||-1===r)continue;let n=this._images.get(r);if(-1!==e.tileId){let o=e.tileId,l=s,a=1;for(;++s<h&&268435456&i.getBg(s)&&(e=i._extendedAttrs[s]||Za)&&e.imageId===r&&e.tileId===o+a;)a++;s--,n?n.actual&&this._renderer.draw(n,o,l,t,a):this._opts.showPlaceholder&&this._renderer.drawPlaceholder(l,t,a),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]||Za,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 l=Math.min(t.cols,n-i.tileId%n+e),a=i.tileId;for(let t=e+1;t<l;++t)this._writeToCell(s,t,h,++a),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]||Za;if(i.imageId&&-1!==i.imageId){let t=this._images.get(i.imageId)?.orig;if(window.ImageBitmap&&t instanceof ImageBitmap){let i=Ka.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]||Za;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 Ya(h.ext,h.urlId,s,e))}}t._data[3*i+2]|=268435456,t._extendedAttrs[i]=new Ya(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)}},Va=Na(Ta());function tc(t){let i="";for(let s=0;s<t.length;++s)i+=String.fromCharCode(t[s]);return i}function ic(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 sc(t){let i=tc(t);if(!i.match(/^((auto)|(\d+?((px)|(%)){0,1}))$/))throw Error("illegal size");return i}var ec={inline:ic,size:ic,name:function(t){if(typeof Buffer<"u")return""+Buffer.from(tc(t),"base64");let i=atob(tc(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:sc,height:sc,preserveAspectRatio:ic},hc=[70,105,108,101],rc=1024,nc=class{constructor(){this.state=0,this._buffer=new Uint32Array(rc),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]!==hc[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>=rc)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>=rc)return this._a();r[h++]=i}}return this.state=e,this._position=h,-2}_a(){return this.state=1,-1}_storeKey(t){let i=tc(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]=ec[this._key]?ec[this._key](i):i}catch{return!1}return!0}return!1}},oc={mime:"unsupported",width:0,height:0},lc={name:"Unnamed file",size:0,width:"auto",height:"auto",preserveAspectRatio:1,inline:0},ac=class{constructor(t,i,s,e){this._opts=t,this._renderer=i,this._storage=s,this._coreTerminal=e,this._aborted=!1,this._hp=new nc,this._header=lc,this._dec=new Va.default(4194304),this._metrics=oc}reset(){}start(){this._aborted=!1,this._header=lc,this._metrics=oc,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 oc;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]?oc:{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=Ka.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||ja.width,e=this._renderer.dimensions?.css.cell.height||ja.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=Na(Fa()),uc=Na(Pa()),Ac=cc.PALETTE_ANSI_256;Ac.set(cc.PALETTE_VT340_COLOR);var fc=class{constructor(t,i,s){this._opts=t,this._storage=i,this._coreTerminal=s,this._size=0,this._aborted=!1,(0,uc.DecoderAsync)({memoryLimit:4*this._opts.pixelLimit,palette:Ac,paletteLimit:this._opts.sixelPaletteLimit}).then((t=>this._dec=t))}reset(){this._dec&&(this._dec.release(),this._dec._palette.fill(0),this._dec.init(0,Ac,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=dc(i.foreground.rgba);else if(t.isFgRGB()){let i=t.constructor.toColorRGB(t.getFgColor());s=(0,cc.toRGBA8888)(...i)}else s=dc(i.ansi[t.getFgColor()].rgba);else if(t.isBgDefault())s=dc(i.background.rgba);else if(t.isBgRGB()){let i=t.constructor.toColorRGB(t.getBgColor());s=(0,cc.toRGBA8888)(...i)}else s=dc(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=Ka.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 dc(t){return cc.BIG_ENDIAN?t:(255&t)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255}var gc={enableSizeReports:!0,pixelLimit:16777216,sixelSupport:!0,sixelScrolling:!0,sixelPaletteLimit:256,sixelSizeLimit:25e6,storageLimit:128,showPlaceholder:!0,iipSupport:!0,iipSizeLimit:2e7},wc=class{constructor(t){this._disposables=[],this._handlers=new Map,this._opts=Object.assign({},gc,t),this._defaultOpts=Object.assign({},gc,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 Ka(t),this._storage=new Xa(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 fc(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 ac(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=ja;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 pc{__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,yc.unregister(this),t}free(){const t=this.__destroy_into_raw();zc.__wbg_channel_free(t,0)}authenticate(t,i,s){const e=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),h=Kc,r=Pc(i,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_authenticate(this.__wbg_ptr,e,h,r,Kc,Tc(s)?4294967297:s>>>0)}connect(){zc.channel_connect(this.__wbg_ptr)}disconnect(){zc.channel_disconnect(this.__wbg_ptr)}is_connected(){return 0!==zc.channel_is_connected(this.__wbg_ptr)}is_disconnected(){return 0!==zc.channel_is_disconnected(this.__wbg_ptr)}constructor(t,i,s){const e=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),h=Kc,r=Pc(i,zc.__wbindgen_export,zc.__wbindgen_export2),n=Kc;var o=Tc(s)?0:Pc(s,zc.__wbindgen_export,zc.__wbindgen_export2);const l=zc.channel_new(e,h,r,n,o,Kc);return this.__wbg_ptr=l>>>0,yc.register(this,this.__wbg_ptr,this),this}on_connection_close(t){zc.channel_on_connection_close(this.__wbg_ptr,Tc(t)?0:Ec(t))}on_connection_error(t){zc.channel_on_connection_error(this.__wbg_ptr,Tc(t)?0:Ec(t))}on_connection_message(t){zc.channel_on_connection_message(this.__wbg_ptr,Tc(t)?0:Ec(t))}on_connection_open(t){zc.channel_on_connection_open(this.__wbg_ptr,Tc(t)?0:Ec(t))}on_protocol_message(t){zc.channel_on_protocol_message(this.__wbg_ptr,Tc(t)?0:Ec(t))}open_sftp_tunnel(t,i,s,e){const h=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),r=Kc;var n=Tc(i)?0:Pc(i,zc.__wbindgen_export,zc.__wbindgen_export2),o=Kc,l=Tc(s)?0:Pc(s,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_open_sftp_tunnel(this.__wbg_ptr,h,r,n,o,l,Kc,Tc(e)?4294967297:e>>>0)}open_ssh_tunnel(t,i,s,e){const h=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),r=Kc;var n=Tc(i)?0:Pc(i,zc.__wbindgen_export,zc.__wbindgen_export2),o=Kc,l=Tc(s)?0:Pc(s,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_open_ssh_tunnel(this.__wbg_ptr,h,r,n,o,l,Kc,Tc(e)?4294967297:e>>>0)}send_sftp_delete(t,i,s,e,h){const r=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),n=Kc,o=Pc(s,zc.__wbindgen_export,zc.__wbindgen_export2),l=Kc,a=Pc(e,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_send_sftp_delete(this.__wbg_ptr,r,n,i,o,l,a,Kc,Tc(h)?4294967297:h>>>0)}send_sftp_download_chunk(t,i,s,e,h){const r=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_send_sftp_download_chunk(this.__wbg_ptr,r,Kc,i,s,e,Tc(h)?4294967297:h>>>0)}send_sftp_download_start(t,i,s,e,h){const r=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),n=Kc,o=Pc(s,zc.__wbindgen_export,zc.__wbindgen_export2),l=Kc,a=Pc(e,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_send_sftp_download_start(this.__wbg_ptr,r,n,i,o,l,a,Kc,Tc(h)?4294967297:h>>>0)}send_sftp_list_data(t,i,s,e){const h=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),r=Kc,n=Pc(s,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_send_sftp_list_data(this.__wbg_ptr,h,r,i,n,Kc,Tc(e)?4294967297:e>>>0)}send_sftp_upload_chunk(t,i,s,e,h,r,n){const o=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),l=Kc,a=function(t){const i=(0,zc.__wbindgen_export)(1*t.length,1)>>>0;return $c().set(t,i/1),Kc=t.length,i}(r);zc.channel_send_sftp_upload_chunk(this.__wbg_ptr,o,l,i,s,e,h,a,Kc,Tc(n)?4294967297:n>>>0)}send_sftp_upload_start(t,i,s,e,h,r,n){const o=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),l=Kc,a=Pc(s,zc.__wbindgen_export,zc.__wbindgen_export2),c=Kc,u=Pc(e,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_send_sftp_upload_start(this.__wbg_ptr,o,l,i,a,c,u,Kc,h,r,Tc(n)?4294967297:n>>>0)}send_ssh_terminal_resize(t,i,s,e){const h=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_send_ssh_terminal_resize(this.__wbg_ptr,h,Kc,i,s,e)}send_ssh_tunnel_data(t,i,s){const e=Pc(t,zc.__wbindgen_export,zc.__wbindgen_export2),h=Kc,r=Pc(s,zc.__wbindgen_export,zc.__wbindgen_export2);zc.channel_send_ssh_tunnel_data(this.__wbg_ptr,e,h,i,r,Kc)}start_heartbeat(t){zc.channel_start_heartbeat(this.__wbg_ptr,t)}stop_heartbeat(){zc.channel_stop_heartbeat(this.__wbg_ptr)}}Symbol.dispose&&(pc.prototype[Symbol.dispose]=pc.prototype.free);const Cc=Object.freeze({Generic:0,0:"Generic",RequiresUsername:100,100:"RequiresUsername",RequiresPassword:110,110:"RequiresPassword"});function mc(){const t={__proto__:null,__wbg_Error_83742b46f01ce22d:function(t,i){return Ec(Error(_c(t,i)))},__wbg_String_8564e559799eccda:function(t,i){const s=Pc(Rc(i)+"",zc.__wbindgen_export,zc.__wbindgen_export2),e=Kc;Lc().setInt32(t+4,e,!0),Lc().setInt32(t+0,s,!0)},__wbg___wbindgen_debug_string_5398f5bb970e0daa:function(t,i){const s=Pc(kc(Rc(i)),zc.__wbindgen_export,zc.__wbindgen_export2),e=Kc;Lc().setInt32(t+4,e,!0),Lc().setInt32(t+0,s,!0)},__wbg___wbindgen_string_get_395e606bd0ee4427:function(t,i){const s=Rc(i),e="string"==typeof s?s:void 0;var h=Tc(e)?0:Pc(e,zc.__wbindgen_export,zc.__wbindgen_export2),r=Kc;Lc().setInt32(t+4,r,!0),Lc().setInt32(t+0,h,!0)},__wbg___wbindgen_throw_6ddd609b62940d55:function(t,i){throw Error(_c(t,i))},__wbg__wbg_cb_unref_6b5b6b8576d35cb1:function(t){Rc(t)._wbg_cb_unref()},__wbg_call_2d781c1f4d5c0ef8:function(){return Nc((function(t,i,s){return Ec(Rc(t).call(Rc(i),Rc(s)))}),arguments)},__wbg_call_e133b57c9155d22c:function(){return Nc((function(t,i){return Ec(Rc(t).call(Rc(i)))}),arguments)},__wbg_clearInterval_16e8cbbce92291d0:function(t){return Ec(clearInterval(Gc(t)))},__wbg_close_af26905c832a88cb:function(){return Nc((function(t){Rc(t).close()}),arguments)},__wbg_data_a3d9ff9cdd801002:function(t){return Ec(Rc(t).data)},__wbg_from_4bdf88943703fd48:function(t){return Ec(Array.from(Rc(t)))},__wbg_instanceof_ArrayBuffer_101e2bf31071a9f6:function(t){let i;try{i=Rc(t)instanceof ArrayBuffer}catch(t){i=!1}return i},__wbg_length_ea16607d7b61445b:function(t){return Rc(t).length},__wbg_new_5f486cdf45a04d78:function(t){return Ec(new Uint8Array(Rc(t)))},__wbg_new_a70fbab9066b301f:function(){return Ec([])},__wbg_new_ab79df5bd7c26067:function(){return Ec({})},__wbg_new_with_str_299114bdb2430303:function(){return Nc((function(t,i,s,e){return Ec(new WebSocket(_c(t,i),_c(s,e)))}),arguments)},__wbg_prototypesetcall_d62e5099504357e6:function(t,i,s){Uint8Array.prototype.set.call(xc(t,i),Rc(s))},__wbg_readyState_1f1e7f1bdf9f4d42:function(t){return Rc(t).readyState},__wbg_send_d31a693c975dea74:function(){return Nc((function(t,i,s){Rc(t).send(xc(i,s))}),arguments)},__wbg_setInterval_84b64f01452a246e:function(){return Nc((function(t,i){return Ec(setInterval(Rc(t),i))}),arguments)},__wbg_set_282384002438957f:function(t,i,s){Rc(t)[i>>>0]=Gc(s)},__wbg_set_6be42768c690e380:function(t,i,s){Rc(t)[Gc(i)]=Gc(s)},__wbg_set_binaryType_3dcf8281ec100a8f:function(t,i){Rc(t).binaryType=Mc[i]},__wbg_set_onclose_8da801226bdd7a7b:function(t,i){Rc(t).onclose=Rc(i)},__wbg_set_onerror_901ca711f94a5bbb:function(t,i){Rc(t).onerror=Rc(i)},__wbg_set_onmessage_6f80ab771bf151aa:function(t,i){Rc(t).onmessage=Rc(i)},__wbg_set_onopen_34e3e24cf9337ddd:function(t,i){Rc(t).onopen=Rc(i)},__wbg_warn_805e04431c9f73c4:function(t,i){console.warn(_c(t,i))},__wbindgen_cast_0000000000000001:function(t,i){return Ec(Uc(t,i,zc.__wasm_bindgen_func_elem_37,vc))},__wbindgen_cast_0000000000000002:function(t,i){return Ec(Uc(t,i,zc.__wasm_bindgen_func_elem_37,Bc))},__wbindgen_cast_0000000000000003:function(t,i){return Ec(Uc(t,i,zc.__wasm_bindgen_func_elem_37,bc))},__wbindgen_cast_0000000000000004:function(t,i){return Ec(Uc(t,i,zc.__wasm_bindgen_func_elem_37,Ic))},__wbindgen_cast_0000000000000005:function(t){return Ec(t)},__wbindgen_cast_0000000000000006:function(t,i){return Ec(xc(t,i))},__wbindgen_cast_0000000000000007:function(t,i){return Ec(_c(t,i))},__wbindgen_cast_0000000000000008:function(t){return Ec(BigInt.asUintN(64,t))},__wbindgen_object_clone_ref:function(t){return Ec(Rc(t))},__wbindgen_object_drop_ref:function(t){Gc(t)}};return{__proto__:null,"./phirepass-channel_bg.js":t}}function Ic(t,i){zc.__wasm_bindgen_func_elem_41(t,i)}function vc(t,i,s){zc.__wasm_bindgen_func_elem_38(t,i,Ec(s))}function Bc(t,i,s){zc.__wasm_bindgen_func_elem_38_1(t,i,Ec(s))}function bc(t,i,s){zc.__wasm_bindgen_func_elem_38_2(t,i,Ec(s))}const Mc=["blob","arraybuffer"],yc="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>zc.__wbg_channel_free(t>>>0,1)));function Ec(t){Hc===Fc.length&&Fc.push(Fc.length+1);const i=Hc;return Hc=Fc[i],Fc[i]=t,i}const Qc="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>t.dtor(t.a,t.b)));function kc(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+=kc(t[0]));for(let e=1;e<i;e++)s+=", "+kc(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 xc(t,i){return t>>>=0,$c().subarray(t/1,t/1+i)}let Dc=null;function Lc(){return(null===Dc||!0===Dc.buffer.detached||void 0===Dc.buffer.detached&&Dc.buffer!==zc.memory.buffer)&&(Dc=new DataView(zc.memory.buffer)),Dc}function _c(t,i){return function(t,i){return Wc+=i,Wc>=Oc&&(Jc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Jc.decode(),Wc=i),Jc.decode($c().subarray(t,t+i))}(t>>>=0,i)}let Sc=null;function $c(){return null!==Sc&&0!==Sc.byteLength||(Sc=new Uint8Array(zc.memory.buffer)),Sc}function Rc(t){return Fc[t]}function Nc(t,i){try{return t.apply(this,i)}catch(t){zc.__wbindgen_export3(Ec(t))}}let Fc=Array(1024).fill(void 0);Fc.push(void 0,null,!0,!1);let Hc=Fc.length;function Tc(t){return null==t}function Uc(t,i,s,e){const h={a:t,b:i,cnt:1,dtor:s},r=(...t)=>{h.cnt++;const i=h.a;h.a=0;try{return e(i,h.b,...t)}finally{h.a=i,r._wbg_cb_unref()}};return r._wbg_cb_unref=()=>{0==--h.cnt&&(h.dtor(h.a,h.b),h.a=0,Qc.unregister(h))},Qc.register(r,h,h),r}function Pc(t,i,s){if(void 0===s){const s=qc.encode(t),e=i(s.length,1)>>>0;return $c().subarray(e,e+s.length).set(s),Kc=s.length,e}let e=t.length,h=i(e,1)>>>0;const r=$c();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=$c().subarray(h+n,h+e);n+=qc.encodeInto(t,i).written,h=s(h,e,n,1)>>>0}return Kc=n,h}function Gc(t){const i=Rc(t);return function(t){t<1028||(Fc[t]=Hc,Hc=t)}(t),i}let Jc=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Jc.decode();const Oc=2146435072;let Wc=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 zc,Kc=0;var jc;!function(t){t[t.Username=0]="Username",t[t.Password=1]="Password",t[t.Default=2]="Default"}(jc||(jc={}));const Yc=i(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow()}terminal;fitAddon;webLinksAddon;searchAddon;webglAddon;serializeAddon;imageAddon;channel;containerEl;domReady=!1;runtimeReady=!1;connected=!1;inputMode=jc.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)}createWebSocketEndpoint(){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(){console.log("PhirepassTerminal connected to DOM"),await async function(t){if(void 0!==zc)return zc;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=mc();("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 zc=t.exports,Dc=null,Sc=null,zc}(s)}(),console.log("PhirepassChannel module initialized"),this.setup_terminal(),console.log("Terminal setup complete"),this.open_comms(),console.log("Comms opened"),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 fr(this.terminalOptions),this.fitAddon=new dr,this.terminal.loadAddon(this.fitAddon),this.webLinksAddon=new Ir,this.terminal.loadAddon(this.webLinksAddon),this.searchAddon=new mn,this.terminal.loadAddon(this.searchAddon),this.serializeAddon=new Qa,this.terminal.loadAddon(this.serializeAddon),this.imageAddon=new wc(this.xtermImageSettings),this.terminal.loadAddon(this.imageAddon);try{this.webglAddon=new ua,this.terminal.loadAddon(this.webglAddon)}catch(t){console.warn("WebGL addon not available or failed to load:",t)}this.fitAddon.fit()}destroy_terminal(){this.terminal&&(this.terminal.reset(),"function"==typeof this.terminal.dispose&&this.terminal.dispose())}open_comms(){this.channel=this.serverId?new pc(this.createWebSocketEndpoint()+"/api/web/ws",this.nodeId,this.serverId):new pc(this.createWebSocketEndpoint()+"/api/web/ws",this.nodeId),this.channel.on_connection_open((()=>{this.channel.authenticate(this.token,this.nodeId)})),this.channel.on_connection_close((()=>{this.terminal.reset()})),this.channel.on_connection_error((t=>{console.error(">> connection 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.handleAuthSuccess(i);break;case"TunnelOpened":this.session_id=i.sid,this.terminal.reset(),this.send_ssh_terminal_resize();break;case"TunnelClosed":this.handleTunnelClosed();break;case"TunnelData":this.terminal.write(new Uint8Array(i.data));break;default:console.warn("Unknown protocol message type:",i)}}))}send_ssh_terminal_resize(){if(!this.channel||!this.channel.is_connected()||!this.session_id)return;const t=this.terminal?.cols??0,i=this.terminal?.rows??0;if(!(t<=0||i<=0))try{this.channel.send_ssh_terminal_resize(this.nodeId,this.session_id,t,i)}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 Cc.Generic:this.terminal.reset(),this.terminal.write(t.message+"\r\n"),this.terminal.focus();break;case Cc.RequiresUsername:this.terminal.reset(),this.inputMode=jc.Username,this.usernameBuffer="",this.terminal.write("Enter your username: "),this.terminal.focus();break;case Cc.RequiresPassword:this.terminal.reset(),this.inputMode=jc.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=jc.Default,this.clear_creds_buffer(),this.terminal.writeln("Authentication cancelled."),this.terminal.reset()}clear_creds_buffer(){this.usernameBuffer="",this.passwordBuffer=""}reset_session_state(){this.session_id=void 0,this.inputMode=jc.Default,this.clear_creds_buffer()}handleAuthSuccess(t){this.clear_creds_buffer(),this.channel.start_heartbeat(this.heartbeatInterval<=15e3?3e4:this.heartbeatInterval),this.channel.open_ssh_tunnel(this.nodeId)}handleTunnelClosed(){this.session_id=void 0,this.inputMode=jc.Default,this.clear_creds_buffer(),this.terminal.reset(),this.terminal.writeln("Connection closed.")}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.handleTerminalData.bind(this)),this.channel.connect(),this.setupResizeObserver(),this.connected=!0,console.log("Terminal connected and ready"))}setupResizeObserver(){this.resizeObserver=new ResizeObserver((()=>{this.resizeDebounceHandle&&clearTimeout(this.resizeDebounceHandle),this.resizeDebounceHandle=setTimeout((()=>{this.fitAddon.fit(),this.send_ssh_terminal_resize()}),100)})),this.resizeObserver.observe(this.el)}handleTerminalData(t){switch(this.inputMode){case jc.Username:this.handleUsernameInput(t);break;case jc.Password:this.handlePasswordInput(t);break;case jc.Default:this.send_ssh_data(t)}}handleUsernameInput(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submitUsername()):""===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")))}submitUsername(){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=jc.Default,this.channel.open_ssh_tunnel(this.nodeId,t)}handlePasswordInput(t){return"\r"===t||"\n"===t?(this.terminal.write("\r\n"),void this.submitPassword()):""===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")))}submitPassword(){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=jc.Default,this.channel.open_ssh_tunnel(this.nodeId,this.usernameBuffer.trim(),t),this.passwordBuffer="",this.usernameBuffer=""}render(){return e(h,{key:"16372280bf650813e7aae4e28fae8b761b87a096"},e("div",{key:"5a387d5d9d0772510ded9b50c764ab4ae4b14abc",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%}:host #ccc{width:inherit;height:inherit}:host #ccc .terminal{height:inherit}:host #ccc .terminal .xterm-scrollable-element{height:inherit}"}},[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 Zc(){"undefined"!=typeof customElements&&["phirepass-terminal"].forEach((i=>{"phirepass-terminal"===i&&(customElements.get(t(i))||customElements.define(t(i),Yc))}))}Zc();const Xc=Yc,Vc=Zc;export{Xc as PhirepassTerminal,Vc as defineCustomElement}