UNPKG

ssh-terminal

Version:

SSH Terminal component based on xterm.js for multiple frontend frameworks

74 lines 619 kB
(function(Me,Pe){typeof exports=="object"&&typeof module!="undefined"?Pe(exports):typeof define=="function"&&define.amd?define(["exports"],Pe):(Me=typeof globalThis!="undefined"?globalThis:Me||self,Pe(Me.SSHTerminalVue2={}))})(this,function(Me){"use strict";var Bc=Object.defineProperty,Ic=Object.defineProperties;var Lc=Object.getOwnPropertyDescriptors;var xn=Object.getOwnPropertySymbols;var kc=Object.prototype.hasOwnProperty,Rc=Object.prototype.propertyIsEnumerable;var Zi=(Me,Pe,He)=>Pe in Me?Bc(Me,Pe,{enumerable:!0,configurable:!0,writable:!0,value:He}):Me[Pe]=He,Gt=(Me,Pe)=>{for(var He in Pe||(Pe={}))kc.call(Pe,He)&&Zi(Me,He,Pe[He]);if(xn)for(var He of xn(Pe))Rc.call(Pe,He)&&Zi(Me,He,Pe[He]);return Me},wn=(Me,Pe)=>Ic(Me,Lc(Pe));var Tn=(Me,Pe,He)=>(Zi(Me,typeof Pe!="symbol"?Pe+"":Pe,He),He);var Ve=(Me,Pe,He)=>new Promise((lr,Tr)=>{var Ji=Et=>{try{cr(He.next(Et))}catch(hr){Tr(hr)}},ri=Et=>{try{cr(He.throw(Et))}catch(hr){Tr(hr)}},cr=Et=>Et.done?lr(Et.value):Promise.resolve(Et.value).then(Ji,ri);cr((He=He.apply(Me,Pe)).next())});function Pe(e,t){for(var i=0;i<t.length;i++){const r=t[i];if(typeof r!="string"&&!Array.isArray(r)){for(const n in r)if(n!=="default"&&!(n in e)){const c=Object.getOwnPropertyDescriptor(r,n);c&&Object.defineProperty(e,n,c.get?c:{enumerable:!0,get:()=>r[n]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const He="",lr={name:"SSHTerminal",props:{computingId:{type:String,required:!0},userToken:{type:String,required:!0},websocketUrl:{type:String,default:"wss://ssh-proxy.dev.longvan.vn"},options:{type:Object,default:function(){return{}}}},data:function(){return{terminal:null}},mounted:function(){this.initTerminal(),window.addEventListener("resize",this.handleResize)},beforeDestroy:function(){this.terminal&&this.terminal.dispose(),window.removeEventListener("resize",this.handleResize)},methods:{initTerminal:function(){var e=this,t=this.$refs.terminalContainer;Promise.all([Promise.resolve().then(()=>Un),Promise.resolve().then(()=>Pn),Promise.resolve().then(()=>Nn)]).then(function(i){var r=i[0].createTerminal,n=i[1].default,c=i[2].default,a=c.createContextLogger("Vue2Terminal"),s={computingId:e.computingId,userToken:e.userToken,wsUrl:e.websocketUrl},l=n.validateComputingConfig(s);if(!l.isValid){a.error("Invalid Computing ID config in Vue2 component",{errors:l.errors}),e.$emit("error",{message:"Invalid Computing ID configuration",errors:l.errors});return}var o=n.validateTerminalOptions(e.options);if(!o.isValid){a.error("Invalid terminal options in Vue2 component",{errors:o.errors}),e.$emit("error",{message:"Invalid terminal options",errors:o.errors});return}try{e.terminal=r(t,s,e.options),a.info("Terminal created successfully with Computing ID"),e.$emit("ready",e.terminal)}catch(f){a.error("Failed to create terminal",{error:f.message}),e.$emit("error",{message:"Failed to create terminal",error:f.message})}}).catch(function(i){console.error("Failed to load terminal dependencies:",i),e.$emit("error",{message:"Failed to load terminal dependencies",error:i.message})})},handleResize:function(){this.terminal&&this.terminal.resize()}},render:function(e){return e("div",{ref:"terminalContainer",class:"ssh-terminal-container",style:{width:"100%",height:"100%",minHeight:"300px",backgroundColor:"#000"}})}};class Tr{constructor(){this.tabId=this.getOrCreateTabId()}getOrCreateTabId(){const t=`tab-${Date.now()}-${Math.random().toString(36).substr(2,9)}`;return console.log("🆕 Created new Tab ID:",t),t}getTabId(){return this.tabId}}const ri=new Tr;var cr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Et(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function hr(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var i=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};i.prototype=t.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(i,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}),i}var es={exports:{}};(function(e,t){(function(i,r){e.exports=r()})(self,()=>(()=>{var i={4567:function(a,s,l){var o=this&&this.__decorate||function(v,C,S,b){var w,E=arguments.length,x=E<3?C:b===null?b=Object.getOwnPropertyDescriptor(C,S):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(v,C,S,b);else for(var k=v.length-1;k>=0;k--)(w=v[k])&&(x=(E<3?w(x):E>3?w(C,S,x):w(C,S))||x);return E>3&&x&&Object.defineProperty(C,S,x),x},f=this&&this.__param||function(v,C){return function(S,b){C(S,b,v)}};Object.defineProperty(s,"__esModule",{value:!0}),s.AccessibilityManager=void 0;const u=l(9042),g=l(6114),_=l(9924),y=l(844),m=l(5596),h=l(4725),d=l(3656);let p=s.AccessibilityManager=class extends y.Disposable{constructor(v,C){super(),this._terminal=v,this._renderService=C,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let S=0;S<this._terminal.rows;S++)this._rowElements[S]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[S]);if(this._topBoundaryFocusListener=S=>this._handleBoundaryFocus(S,0),this._bottomBoundaryFocusListener=S=>this._handleBoundaryFocus(S,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new _.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize(S=>this._handleResize(S.rows))),this.register(this._terminal.onRender(S=>this._refreshRows(S.start,S.end))),this.register(this._terminal.onScroll(()=>this._refreshRows())),this.register(this._terminal.onA11yChar(S=>this._handleChar(S))),this.register(this._terminal.onLineFeed(()=>this._handleChar(`
`))),this.register(this._terminal.onA11yTab(S=>this._handleTab(S))),this.register(this._terminal.onKey(S=>this._handleKey(S.key))),this.register(this._terminal.onBlur(()=>this._clearLiveRegion())),this.register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._screenDprMonitor=new m.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener(()=>this._refreshRowsDimensions()),this.register((0,d.addDisposableDomListener)(window,"resize",()=>this._refreshRowsDimensions())),this._refreshRows(),this.register((0,y.toDisposable)(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(v){for(let C=0;C<v;C++)this._handleChar(" ")}_handleChar(v){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==v&&(this._charsToAnnounce+=v):this._charsToAnnounce+=v,v===`
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=u.tooMuchOutput)),g.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout(()=>{this._accessibilityContainer.appendChild(this._liveRegion)},0))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,g.isMac&&this._liveRegion.remove()}_handleKey(v){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(v)||this._charsToConsume.push(v)}_refreshRows(v,C){this._liveRegionDebouncer.refresh(v,C,this._terminal.rows)}_renderRows(v,C){const S=this._terminal.buffer,b=S.lines.length.toString();for(let w=v;w<=C;w++){const E=S.translateBufferLineToString(S.ydisp+w,!0),x=(S.ydisp+w+1).toString(),k=this._rowElements[w];k&&(E.length===0?k.innerText=" ":k.textContent=E,k.setAttribute("aria-posinset",x),k.setAttribute("aria-setsize",b))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(v,C){const S=v.target,b=this._rowElements[C===0?1:this._rowElements.length-2];if(S.getAttribute("aria-posinset")===(C===0?"1":`${this._terminal.buffer.lines.length}`)||v.relatedTarget!==b)return;let w,E;if(C===0?(w=S,E=this._rowElements.pop(),this._rowContainer.removeChild(E)):(w=this._rowElements.shift(),E=S,this._rowContainer.removeChild(w)),w.removeEventListener("focus",this._topBoundaryFocusListener),E.removeEventListener("focus",this._bottomBoundaryFocusListener),C===0){const x=this._createAccessibilityTreeNode();this._rowElements.unshift(x),this._rowContainer.insertAdjacentElement("afterbegin",x)}else{const x=this._createAccessibilityTreeNode();this._rowElements.push(x),this._rowContainer.appendChild(x)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(C===0?-1:1),this._rowElements[C===0?1:this._rowElements.length-2].focus(),v.preventDefault(),v.stopImmediatePropagation()}_handleResize(v){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let C=this._rowContainer.children.length;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);for(;this._rowElements.length>v;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const v=document.createElement("div");return v.setAttribute("role","listitem"),v.tabIndex=-1,this._refreshRowDimensions(v),v}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let v=0;v<this._terminal.rows;v++)this._refreshRowDimensions(this._rowElements[v])}}_refreshRowDimensions(v){v.style.height=`${this._renderService.dimensions.css.cell.height}px`}};s.AccessibilityManager=p=o([f(1,h.IRenderService)],p)},3614:(a,s)=>{function l(g){return g.replace(/\r?\n/g,"\r")}function o(g,_){return _?"\x1B[200~"+g+"\x1B[201~":g}function f(g,_,y,m){g=o(g=l(g),y.decPrivateModes.bracketedPasteMode&&m.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(g,!0),_.value=""}function u(g,_,y){const m=y.getBoundingClientRect(),h=g.clientX-m.left-10,d=g.clientY-m.top-10;_.style.width="20px",_.style.height="20px",_.style.left=`${h}px`,_.style.top=`${d}px`,_.style.zIndex="1000",_.focus()}Object.defineProperty(s,"__esModule",{value:!0}),s.rightClickHandler=s.moveTextAreaUnderMouseCursor=s.paste=s.handlePasteEvent=s.copyHandler=s.bracketTextForPaste=s.prepareTextForTerminal=void 0,s.prepareTextForTerminal=l,s.bracketTextForPaste=o,s.copyHandler=function(g,_){g.clipboardData&&g.clipboardData.setData("text/plain",_.selectionText),g.preventDefault()},s.handlePasteEvent=function(g,_,y,m){g.stopPropagation(),g.clipboardData&&f(g.clipboardData.getData("text/plain"),_,y,m)},s.paste=f,s.moveTextAreaUnderMouseCursor=u,s.rightClickHandler=function(g,_,y,m,h){u(g,_,y),h&&m.rightClickSelect(g),_.value=m.selectionText,_.select()}},7239:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ColorContrastCache=void 0;const o=l(1505);s.ColorContrastCache=class{constructor(){this._color=new o.TwoKeyMap,this._css=new o.TwoKeyMap}setCss(f,u,g){this._css.set(f,u,g)}getCss(f,u){return this._css.get(f,u)}setColor(f,u,g){this._color.set(f,u,g)}getColor(f,u){return this._color.get(f,u)}clear(){this._color.clear(),this._css.clear()}}},3656:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.addDisposableDomListener=void 0,s.addDisposableDomListener=function(l,o,f,u){l.addEventListener(o,f,u);let g=!1;return{dispose:()=>{g||(g=!0,l.removeEventListener(o,f,u))}}}},6465:function(a,s,l){var o=this&&this.__decorate||function(h,d,p,v){var C,S=arguments.length,b=S<3?d:v===null?v=Object.getOwnPropertyDescriptor(d,p):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(h,d,p,v);else for(var w=h.length-1;w>=0;w--)(C=h[w])&&(b=(S<3?C(b):S>3?C(d,p,b):C(d,p))||b);return S>3&&b&&Object.defineProperty(d,p,b),b},f=this&&this.__param||function(h,d){return function(p,v){d(p,v,h)}};Object.defineProperty(s,"__esModule",{value:!0}),s.Linkifier2=void 0;const u=l(3656),g=l(8460),_=l(844),y=l(2585);let m=s.Linkifier2=class extends _.Disposable{get currentLink(){return this._currentLink}constructor(h){super(),this._bufferService=h,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,_.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,_.toDisposable)(()=>{this._lastMouseEvent=void 0})),this.register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0}))}registerLinkProvider(h){return this._linkProviders.push(h),{dispose:()=>{const d=this._linkProviders.indexOf(h);d!==-1&&this._linkProviders.splice(d,1)}}}attachToDom(h,d,p){this._element=h,this._mouseService=d,this._renderService=p,this.register((0,u.addDisposableDomListener)(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this.register((0,u.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,u.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,u.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(h){if(this._lastMouseEvent=h,!this._element||!this._mouseService)return;const d=this._positionFromMouseEvent(h,this._element,this._mouseService);if(!d)return;this._isMouseOut=!1;const p=h.composedPath();for(let v=0;v<p.length;v++){const C=p[v];if(C.classList.contains("xterm"))break;if(C.classList.contains("xterm-hover"))return}this._lastBufferCell&&d.x===this._lastBufferCell.x&&d.y===this._lastBufferCell.y||(this._handleHover(d),this._lastBufferCell=d)}_handleHover(h){if(this._activeLine!==h.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(h,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,h)||(this._clearCurrentLink(),this._askForLink(h,!0))}_askForLink(h,d){var p,v;this._activeProviderReplies&&d||((p=this._activeProviderReplies)===null||p===void 0||p.forEach(S=>{S==null||S.forEach(b=>{b.link.dispose&&b.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=h.y);let C=!1;for(const[S,b]of this._linkProviders.entries())d?!((v=this._activeProviderReplies)===null||v===void 0)&&v.get(S)&&(C=this._checkLinkProviderResult(S,h,C)):b.provideLinks(h.y,w=>{var E,x;if(this._isMouseOut)return;const k=w==null?void 0:w.map(D=>({link:D}));(E=this._activeProviderReplies)===null||E===void 0||E.set(S,k),C=this._checkLinkProviderResult(S,h,C),((x=this._activeProviderReplies)===null||x===void 0?void 0:x.size)===this._linkProviders.length&&this._removeIntersectingLinks(h.y,this._activeProviderReplies)})}_removeIntersectingLinks(h,d){const p=new Set;for(let v=0;v<d.size;v++){const C=d.get(v);if(C)for(let S=0;S<C.length;S++){const b=C[S],w=b.link.range.start.y<h?0:b.link.range.start.x,E=b.link.range.end.y>h?this._bufferService.cols:b.link.range.end.x;for(let x=w;x<=E;x++){if(p.has(x)){C.splice(S--,1);break}p.add(x)}}}}_checkLinkProviderResult(h,d,p){var v;if(!this._activeProviderReplies)return p;const C=this._activeProviderReplies.get(h);let S=!1;for(let b=0;b<h;b++)this._activeProviderReplies.has(b)&&!this._activeProviderReplies.get(b)||(S=!0);if(!S&&C){const b=C.find(w=>this._linkAtPosition(w.link,d));b&&(p=!0,this._handleNewLink(b))}if(this._activeProviderReplies.size===this._linkProviders.length&&!p)for(let b=0;b<this._activeProviderReplies.size;b++){const w=(v=this._activeProviderReplies.get(b))===null||v===void 0?void 0:v.find(E=>this._linkAtPosition(E.link,d));if(w){p=!0,this._handleNewLink(w);break}}return p}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(h){if(!this._element||!this._mouseService||!this._currentLink)return;const d=this._positionFromMouseEvent(h,this._element,this._mouseService);d&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,d)&&this._currentLink.link.activate(h,this._currentLink.link.text)}_clearCurrentLink(h,d){this._element&&this._currentLink&&this._lastMouseEvent&&(!h||!d||this._currentLink.link.range.start.y>=h&&this._currentLink.link.range.end.y<=d)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,_.disposeArray)(this._linkCacheDisposables))}_handleNewLink(h){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const d=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);d&&this._linkAtPosition(h.link,d)&&(this._currentLink=h,this._currentLink.state={decorations:{underline:h.link.decorations===void 0||h.link.decorations.underline,pointerCursor:h.link.decorations===void 0||h.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,h.link,this._lastMouseEvent),h.link.decorations={},Object.defineProperties(h.link.decorations,{pointerCursor:{get:()=>{var p,v;return(v=(p=this._currentLink)===null||p===void 0?void 0:p.state)===null||v===void 0?void 0:v.decorations.pointerCursor},set:p=>{var v,C;!((v=this._currentLink)===null||v===void 0)&&v.state&&this._currentLink.state.decorations.pointerCursor!==p&&(this._currentLink.state.decorations.pointerCursor=p,this._currentLink.state.isHovered&&((C=this._element)===null||C===void 0||C.classList.toggle("xterm-cursor-pointer",p)))}},underline:{get:()=>{var p,v;return(v=(p=this._currentLink)===null||p===void 0?void 0:p.state)===null||v===void 0?void 0:v.decorations.underline},set:p=>{var v,C,S;!((v=this._currentLink)===null||v===void 0)&&v.state&&((S=(C=this._currentLink)===null||C===void 0?void 0:C.state)===null||S===void 0?void 0:S.decorations.underline)!==p&&(this._currentLink.state.decorations.underline=p,this._currentLink.state.isHovered&&this._fireUnderlineEvent(h.link,p))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(p=>{if(!this._currentLink)return;const v=p.start===0?0:p.start+1+this._bufferService.buffer.ydisp,C=this._bufferService.buffer.ydisp+1+p.end;if(this._currentLink.link.range.start.y>=v&&this._currentLink.link.range.end.y<=C&&(this._clearCurrentLink(v,C),this._lastMouseEvent&&this._element)){const S=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);S&&this._askForLink(S,!1)}})))}_linkHover(h,d,p){var v;!((v=this._currentLink)===null||v===void 0)&&v.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!0),this._currentLink.state.decorations.pointerCursor&&h.classList.add("xterm-cursor-pointer")),d.hover&&d.hover(p,d.text)}_fireUnderlineEvent(h,d){const p=h.range,v=this._bufferService.buffer.ydisp,C=this._createLinkUnderlineEvent(p.start.x-1,p.start.y-v-1,p.end.x,p.end.y-v-1,void 0);(d?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(C)}_linkLeave(h,d,p){var v;!((v=this._currentLink)===null||v===void 0)&&v.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!1),this._currentLink.state.decorations.pointerCursor&&h.classList.remove("xterm-cursor-pointer")),d.leave&&d.leave(p,d.text)}_linkAtPosition(h,d){const p=h.range.start.y*this._bufferService.cols+h.range.start.x,v=h.range.end.y*this._bufferService.cols+h.range.end.x,C=d.y*this._bufferService.cols+d.x;return p<=C&&C<=v}_positionFromMouseEvent(h,d,p){const v=p.getCoords(h,d,this._bufferService.cols,this._bufferService.rows);if(v)return{x:v[0],y:v[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(h,d,p,v,C){return{x1:h,y1:d,x2:p,y2:v,cols:this._bufferService.cols,fg:C}}};s.Linkifier2=m=o([f(0,y.IBufferService)],m)},9042:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.tooMuchOutput=s.promptLabel=void 0,s.promptLabel="Terminal input",s.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(a,s,l){var o=this&&this.__decorate||function(m,h,d,p){var v,C=arguments.length,S=C<3?h:p===null?p=Object.getOwnPropertyDescriptor(h,d):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(m,h,d,p);else for(var b=m.length-1;b>=0;b--)(v=m[b])&&(S=(C<3?v(S):C>3?v(h,d,S):v(h,d))||S);return C>3&&S&&Object.defineProperty(h,d,S),S},f=this&&this.__param||function(m,h){return function(d,p){h(d,p,m)}};Object.defineProperty(s,"__esModule",{value:!0}),s.OscLinkProvider=void 0;const u=l(511),g=l(2585);let _=s.OscLinkProvider=class{constructor(m,h,d){this._bufferService=m,this._optionsService=h,this._oscLinkService=d}provideLinks(m,h){var d;const p=this._bufferService.buffer.lines.get(m-1);if(!p)return void h(void 0);const v=[],C=this._optionsService.rawOptions.linkHandler,S=new u.CellData,b=p.getTrimmedLength();let w=-1,E=-1,x=!1;for(let k=0;k<b;k++)if(E!==-1||p.hasContent(k)){if(p.loadCell(k,S),S.hasExtendedAttrs()&&S.extended.urlId){if(E===-1){E=k,w=S.extended.urlId;continue}x=S.extended.urlId!==w}else E!==-1&&(x=!0);if(x||E!==-1&&k===b-1){const D=(d=this._oscLinkService.getLinkData(w))===null||d===void 0?void 0:d.uri;if(D){const R={start:{x:E+1,y:m},end:{x:k+(x||k!==b-1?0:1),y:m}};let O=!1;if(!(C!=null&&C.allowNonHttpProtocols))try{const G=new URL(D);["http:","https:"].includes(G.protocol)||(O=!0)}catch(G){O=!0}O||v.push({text:D,range:R,activate:(G,q)=>C?C.activate(G,q,R):y(0,q),hover:(G,q)=>{var X;return(X=C==null?void 0:C.hover)===null||X===void 0?void 0:X.call(C,G,q,R)},leave:(G,q)=>{var X;return(X=C==null?void 0:C.leave)===null||X===void 0?void 0:X.call(C,G,q,R)}})}x=!1,S.hasExtendedAttrs()&&S.extended.urlId?(E=k,w=S.extended.urlId):(E=-1,w=-1)}}h(v)}};function y(m,h){if(confirm(`Do you want to navigate to ${h}?

WARNING: This link could potentially be dangerous`)){const d=window.open();if(d){try{d.opener=null}catch(p){}d.location.href=h}else console.warn("Opening link blocked as opener could not be cleared")}}s.OscLinkProvider=_=o([f(0,g.IBufferService),f(1,g.IOptionsService),f(2,g.IOscLinkService)],_)},6193:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.RenderDebouncer=void 0,s.RenderDebouncer=class{constructor(l,o){this._parentWindow=l,this._renderCallback=o,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(l){return this._refreshCallbacks.push(l),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(l,o,f){this._rowCount=f,l=l!==void 0?l:0,o=o!==void 0?o:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,l):l,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,o):o,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const l=Math.max(this._rowStart,0),o=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(l,o),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const l of this._refreshCallbacks)l(0);this._refreshCallbacks=[]}}},5596:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ScreenDprMonitor=void 0;const o=l(844);class f extends o.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,o.toDisposable)(()=>{this.clearListener()}))}setListener(g){this._listener&&this.clearListener(),this._listener=g,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var g;this._outerListener&&((g=this._resolutionMediaMatchList)===null||g===void 0||g.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}s.ScreenDprMonitor=f},3236:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Terminal=void 0;const o=l(3614),f=l(3656),u=l(6465),g=l(9042),_=l(3730),y=l(1680),m=l(3107),h=l(5744),d=l(2950),p=l(1296),v=l(428),C=l(4269),S=l(5114),b=l(8934),w=l(3230),E=l(9312),x=l(4725),k=l(6731),D=l(8055),R=l(8969),O=l(8460),G=l(844),q=l(6114),X=l(8437),W=l(2584),L=l(7399),P=l(5941),N=l(9074),U=l(2585),z=l(5435),$=l(4567),se=typeof window!="undefined"?window.document:null;class te extends R.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(I={}){super(I),this.browser=q,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new G.MutableDisposable),this._onCursorMove=this.register(new O.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new O.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new O.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new O.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new O.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new O.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new O.EventEmitter),this._onBlur=this.register(new O.EventEmitter),this._onA11yCharEmitter=this.register(new O.EventEmitter),this._onA11yTabEmitter=this.register(new O.EventEmitter),this._onWillOpen=this.register(new O.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(u.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(_.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(N.DecorationService),this._instantiationService.setService(U.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this.register(this._inputHandler.onRequestRefreshRows((V,Q)=>this.refresh(V,Q))),this.register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this.register(this._inputHandler.onRequestReset(()=>this.reset())),this.register(this._inputHandler.onRequestWindowsOptionsReport(V=>this._reportWindowsOptions(V))),this.register(this._inputHandler.onColor(V=>this._handleColorEvent(V))),this.register((0,O.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,O.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,O.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,O.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize(V=>this._afterResize(V.cols,V.rows))),this.register((0,G.toDisposable)(()=>{var V,Q;this._customKeyEventHandler=void 0,(Q=(V=this.element)===null||V===void 0?void 0:V.parentNode)===null||Q===void 0||Q.removeChild(this.element)}))}_handleColorEvent(I){if(this._themeService)for(const V of I){let Q,j="";switch(V.index){case 256:Q="foreground",j="10";break;case 257:Q="background",j="11";break;case 258:Q="cursor",j="12";break;default:Q="ansi",j="4;"+V.index}switch(V.type){case 0:const ce=D.color.toColorRGB(Q==="ansi"?this._themeService.colors.ansi[V.index]:this._themeService.colors[Q]);this.coreService.triggerDataEvent(`${W.C0.ESC}]${j};${(0,P.toRgbString)(ce)}${W.C1_ESCAPED.ST}`);break;case 1:if(Q==="ansi")this._themeService.modifyColors(ie=>ie.ansi[V.index]=D.rgba.toColor(...V.color));else{const ie=Q;this._themeService.modifyColors(pe=>pe[ie]=D.rgba.toColor(...V.color))}break;case 2:this._themeService.restoreColor(V.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(I){I?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance($.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(I){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(W.C0.ESC+"[I"),this.updateCursorStyle(I),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var I;return(I=this.textarea)===null||I===void 0?void 0:I.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(W.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const I=this.buffer.ybase+this.buffer.y,V=this.buffer.lines.get(I);if(!V)return;const Q=Math.min(this.buffer.x,this.cols-1),j=this._renderService.dimensions.css.cell.height,ce=V.getWidth(Q),ie=this._renderService.dimensions.css.cell.width*ce,pe=this.buffer.y*this._renderService.dimensions.css.cell.height,xe=Q*this._renderService.dimensions.css.cell.width;this.textarea.style.left=xe+"px",this.textarea.style.top=pe+"px",this.textarea.style.width=ie+"px",this.textarea.style.height=j+"px",this.textarea.style.lineHeight=j+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,f.addDisposableDomListener)(this.element,"copy",V=>{this.hasSelection()&&(0,o.copyHandler)(V,this._selectionService)}));const I=V=>(0,o.handlePasteEvent)(V,this.textarea,this.coreService,this.optionsService);this.register((0,f.addDisposableDomListener)(this.textarea,"paste",I)),this.register((0,f.addDisposableDomListener)(this.element,"paste",I)),q.isFirefox?this.register((0,f.addDisposableDomListener)(this.element,"mousedown",V=>{V.button===2&&(0,o.rightClickHandler)(V,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this.register((0,f.addDisposableDomListener)(this.element,"contextmenu",V=>{(0,o.rightClickHandler)(V,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),q.isLinux&&this.register((0,f.addDisposableDomListener)(this.element,"auxclick",V=>{V.button===1&&(0,o.moveTextAreaUnderMouseCursor)(V,this.textarea,this.screenElement)}))}_bindKeys(){this.register((0,f.addDisposableDomListener)(this.textarea,"keyup",I=>this._keyUp(I),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keydown",I=>this._keyDown(I),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keypress",I=>this._keyPress(I),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionupdate",I=>this._compositionHelper.compositionupdate(I))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this.register((0,f.addDisposableDomListener)(this.textarea,"input",I=>this._inputEvent(I),!0)),this.register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(I){var V;if(!I)throw new Error("Terminal requires a parent element.");I.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=I.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),I.appendChild(this.element);const Q=se.createDocumentFragment();this._viewportElement=se.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),Q.appendChild(this._viewportElement),this._viewportScrollArea=se.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=se.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=se.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),Q.appendChild(this.screenElement),this.textarea=se.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),q.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this._instantiationService.createInstance(S.CoreBrowserService,this.textarea,(V=this._document.defaultView)!==null&&V!==void 0?V:window),this._instantiationService.setService(x.ICoreBrowserService,this._coreBrowserService),this.register((0,f.addDisposableDomListener)(this.textarea,"focus",j=>this._handleTextAreaFocus(j))),this.register((0,f.addDisposableDomListener)(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(v.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(x.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(k.ThemeService),this._instantiationService.setService(x.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(C.CharacterJoinerService),this._instantiationService.setService(x.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(w.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(x.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange(j=>this._onRender.fire(j))),this.onResize(j=>this._renderService.resize(j.cols,j.rows)),this._compositionView=se.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(d.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(Q);try{this._onWillOpen.fire(this.element)}catch(j){}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(b.MouseService),this._instantiationService.setService(x.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(y.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines(j=>this.scrollLines(j.amount,j.suppressScrollEvent,1)),this.register(this._inputHandler.onRequestSyncScrollBar(()=>this.viewport.syncScrollArea())),this.register(this.viewport),this.register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this.register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this.register(this.onBlur(()=>this._renderService.handleBlur())),this.register(this.onFocus(()=>this._renderService.handleFocus())),this.register(this._renderService.onDimensionsChange(()=>this.viewport.syncScrollArea())),this._selectionService=this.register(this._instantiationService.createInstance(E.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(x.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines(j=>this.scrollLines(j.amount,j.suppressScrollEvent))),this.register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this.register(this._selectionService.onRequestRedraw(j=>this._renderService.handleSelectionChanged(j.start,j.end,j.columnSelectMode))),this.register(this._selectionService.onLinuxMouseSelection(j=>{this.textarea.value=j,this.textarea.focus(),this.textarea.select()})),this.register(this._onScroll.event(j=>{this.viewport.syncScrollArea(),this._selectionService.refresh()})),this.register((0,f.addDisposableDomListener)(this._viewportElement,"scroll",()=>this._selectionService.refresh())),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(m.BufferDecorationRenderer,this.screenElement)),this.register((0,f.addDisposableDomListener)(this.element,"mousedown",j=>this._selectionService.handleMouseDown(j))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance($.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",j=>this._handleScreenReaderModeOptionChange(j))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(h.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",j=>{!this._overviewRulerRenderer&&j&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(h.OverviewRulerRenderer,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(p.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const I=this,V=this.element;function Q(ie){const pe=I._mouseService.getMouseReportCoords(ie,I.screenElement);if(!pe)return!1;let xe,Ae;switch(ie.overrideType||ie.type){case"mousemove":Ae=32,ie.buttons===void 0?(xe=3,ie.button!==void 0&&(xe=ie.button<3?ie.button:3)):xe=1&ie.buttons?0:4&ie.buttons?1:2&ie.buttons?2:3;break;case"mouseup":Ae=0,xe=ie.button<3?ie.button:3;break;case"mousedown":Ae=1,xe=ie.button<3?ie.button:3;break;case"wheel":if(I.viewport.getLinesScrolled(ie)===0)return!1;Ae=ie.deltaY<0?0:1,xe=4;break;default:return!1}return!(Ae===void 0||xe===void 0||xe>4)&&I.coreMouseService.triggerMouseEvent({col:pe.col,row:pe.row,x:pe.x,y:pe.y,button:xe,action:Ae,ctrl:ie.ctrlKey,alt:ie.altKey,shift:ie.shiftKey})}const j={mouseup:null,wheel:null,mousedrag:null,mousemove:null},ce={mouseup:ie=>(Q(ie),ie.buttons||(this._document.removeEventListener("mouseup",j.mouseup),j.mousedrag&&this._document.removeEventListener("mousemove",j.mousedrag)),this.cancel(ie)),wheel:ie=>(Q(ie),this.cancel(ie,!0)),mousedrag:ie=>{ie.buttons&&Q(ie)},mousemove:ie=>{ie.buttons||Q(ie)}};this.register(this.coreMouseService.onProtocolChange(ie=>{ie?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(ie)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&ie?j.mousemove||(V.addEventListener("mousemove",ce.mousemove),j.mousemove=ce.mousemove):(V.removeEventListener("mousemove",j.mousemove),j.mousemove=null),16&ie?j.wheel||(V.addEventListener("wheel",ce.wheel,{passive:!1}),j.wheel=ce.wheel):(V.removeEventListener("wheel",j.wheel),j.wheel=null),2&ie?j.mouseup||(V.addEventListener("mouseup",ce.mouseup),j.mouseup=ce.mouseup):(this._document.removeEventListener("mouseup",j.mouseup),V.removeEventListener("mouseup",j.mouseup),j.mouseup=null),4&ie?j.mousedrag||(j.mousedrag=ce.mousedrag):(this._document.removeEventListener("mousemove",j.mousedrag),j.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,f.addDisposableDomListener)(V,"mousedown",ie=>{if(ie.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(ie))return Q(ie),j.mouseup&&this._document.addEventListener("mouseup",j.mouseup),j.mousedrag&&this._document.addEventListener("mousemove",j.mousedrag),this.cancel(ie)})),this.register((0,f.addDisposableDomListener)(V,"wheel",ie=>{if(!j.wheel){if(!this.buffer.hasScrollback){const pe=this.viewport.getLinesScrolled(ie);if(pe===0)return;const xe=W.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(ie.deltaY<0?"A":"B");let Ae="";for(let or=0;or<Math.abs(pe);or++)Ae+=xe;return this.coreService.triggerDataEvent(Ae,!0),this.cancel(ie,!0)}return this.viewport.handleWheel(ie)?this.cancel(ie):void 0}},{passive:!1})),this.register((0,f.addDisposableDomListener)(V,"touchstart",ie=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(ie),this.cancel(ie)},{passive:!0})),this.register((0,f.addDisposableDomListener)(V,"touchmove",ie=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(ie)?void 0:this.cancel(ie)},{passive:!1}))}refresh(I,V){var Q;(Q=this._renderService)===null||Q===void 0||Q.refreshRows(I,V)}updateCursorStyle(I){var V;!((V=this._selectionService)===null||V===void 0)&&V.shouldColumnSelect(I)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(I,V,Q=0){var j;Q===1?(super.scrollLines(I,V,Q),this.refresh(0,this.rows-1)):(j=this.viewport)===null||j===void 0||j.scrollLines(I)}paste(I){(0,o.paste)(I,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(I){this._customKeyEventHandler=I}registerLinkProvider(I){return this.linkifier2.registerLinkProvider(I)}registerCharacterJoiner(I){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const V=this._characterJoinerService.register(I);return this.refresh(0,this.rows-1),V}deregisterCharacterJoiner(I){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(I)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(I){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+I)}registerDecoration(I){return this._decorationService.registerDecoration(I)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(I,V,Q){this._selectionService.setSelection(I,V,Q)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var I;(I=this._selectionService)===null||I===void 0||I.clearSelection()}selectAll(){var I;(I=this._selectionService)===null||I===void 0||I.selectAll()}selectLines(I,V){var Q;(Q=this._selectionService)===null||Q===void 0||Q.selectLines(I,V)}_keyDown(I){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(I)===!1)return!1;const V=this.browser.isMac&&this.options.macOptionIsMeta&&I.altKey;if(!V&&!this._compositionHelper.keydown(I))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;V||I.key!=="Dead"&&I.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const Q=(0,L.evaluateKeyboardEvent)(I,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(I),Q.type===3||Q.type===2){const j=this.rows-1;return this.scrollLines(Q.type===2?-j:j),this.cancel(I,!0)}return Q.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,I)||(Q.cancel&&this.cancel(I,!0),!Q.key||!!(I.key&&!I.ctrlKey&&!I.altKey&&!I.metaKey&&I.key.length===1&&I.key.charCodeAt(0)>=65&&I.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(Q.key!==W.C0.ETX&&Q.key!==W.C0.CR||(this.textarea.value=""),this._onKey.fire({key:Q.key,domEvent:I}),this._showCursor(),this.coreService.triggerDataEvent(Q.key,!0),!this.optionsService.rawOptions.screenReaderMode||I.altKey||I.ctrlKey?this.cancel(I,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(I,V){const Q=I.isMac&&!this.options.macOptionIsMeta&&V.altKey&&!V.ctrlKey&&!V.metaKey||I.isWindows&&V.altKey&&V.ctrlKey&&!V.metaKey||I.isWindows&&V.getModifierState("AltGraph");return V.type==="keypress"?Q:Q&&(!V.keyCode||V.keyCode>47)}_keyUp(I){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(I)===!1||(function(V){return V.keyCode===16||V.keyCode===17||V.keyCode===18}(I)||this.focus(),this.updateCursorStyle(I),this._keyPressHandled=!1)}_keyPress(I){let V;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(I)===!1)return!1;if(this.cancel(I),I.charCode)V=I.charCode;else if(I.which===null||I.which===void 0)V=I.keyCode;else{if(I.which===0||I.charCode===0)return!1;V=I.which}return!(!V||(I.altKey||I.ctrlKey||I.metaKey)&&!this._isThirdLevelShift(this.browser,I)||(V=String.fromCharCode(V),this._onKey.fire({key:V,domEvent:I}),this._showCursor(),this.coreService.triggerDataEvent(V,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(I){if(I.data&&I.inputType==="insertText"&&(!I.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const V=I.data;return this.coreService.triggerDataEvent(V,!0),this.cancel(I),!0}return!1}resize(I,V){I!==this.cols||V!==this.rows?super.resize(I,V):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(I,V){var Q,j;(Q=this._charSizeService)===null||Q===void 0||Q.measure(),(j=this.viewport)===null||j===void 0||j.syncScrollArea(!0)}clear(){var I;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let V=1;V<this.rows;V++)this.buffer.lines.push(this.buffer.getBlankLine(X.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(I=this.viewport)===null||I===void 0||I.reset(),this.refresh(0,this.rows-1)}}reset(){var I,V;this.options.rows=this.rows,this.options.cols=this.cols;const Q=this._customKeyEventHandler;this._setup(),super.reset(),(I=this._selectionService)===null||I===void 0||I.reset(),this._decorationService.reset(),(V=this.viewport)===null||V===void 0||V.reset(),this._customKeyEventHandler=Q,this.refresh(0,this.rows-1)}clearTextureAtlas(){var I;(I=this._renderService)===null||I===void 0||I.clearTextureAtlas()}_reportFocus(){var I;!((I=this.element)===null||I===void 0)&&I.classList.contains("focus")?this.coreService.triggerDataEvent(W.C0.ESC+"[I"):this.coreService.triggerDataEvent(W.C0.ESC+"[O")}_reportWindowsOptions(I){if(this._renderService)switch(I){case z.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const V=this._renderService.dimensions.css.canvas.width.toFixed(0),Q=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${W.C0.ESC}[4;${Q};${V}t`);break;case z.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const j=this._renderService.dimensions.css.cell.width.toFixed(0),ce=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${W.C0.ESC}[6;${ce};${j}t`)}}cancel(I,V){if(this.options.cancelEvents||V)return I.preventDefault(),I.stopPropagation(),!1}}s.Terminal=te},9924:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.TimeBasedDebouncer=void 0,s.TimeBasedDebouncer=class{constructor(l,o=1e3){this._renderCallback=l,this._debounceThresholdMS=o,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(l,o,f){this._rowCount=f,l=l!==void 0?l:0,o=o!==void 0?o:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,l):l,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,o):o;const u=Date.now();if(u-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=u,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=u-this._lastRefreshMs,_=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},_)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const l=Math.max(this._rowStart,0),o=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(l,o)}}},1680:function(a,s,l){var o=this&&this.__decorate||function(d,p,v,C){var S,b=arguments.length,w=b<3?p:C===null?C=Object.getOwnPropertyDescriptor(p,v):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(d,p,v,C);else for(var E=d.length-1;E>=0;E--)(S=d[E])&&(w=(b<3?S(w):b>3?S(p,v,w):S(p,v))||w);return b>3&&w&&Object.defineProperty(p,v,w),w},f=this&&this.__param||function(d,p){return function(v,C){p(v,C,d)}};Object.defineProperty(s,"__esModule",{value:!0}),s.Viewport=void 0;const u=l(3656),g=l(4725),_=l(8460),y=l(844),m=l(2585);let h=s.Viewport=class extends y.Disposable{constructor(d,p,v,C,S,b,w,E){super(),this._viewportElement=d,this._scrollArea=p,this._bufferService=v,this._optionsService=C,this._charSizeService=S,this._renderService=b,this._coreBrowserService=w,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new _.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,u.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate(x=>this._activeBuffer=x.activeBuffer)),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange(x=>this._renderDimensions=x)),this._handleThemeChange(E.colors),this.register(E.onChangeColors(x=>this._handleThemeChange(x))),this.register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.syncScrollArea())),setTimeout(()=>this.syncScrollArea())}_handleThemeChange(d){this._viewportElement.style.backgroundColor=d.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame(()=>this.syncScrollArea())}_refresh(d){if(d)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const p=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==p&&(this._lastRecordedBufferHeight=p,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const d=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==d&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=d),this._refreshAnimationFrame=null}syncScrollArea(d=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(d);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(d)}_handleScroll(d){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const p=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:p,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const d=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(d*(this._smoothScrollState.target-this._smoothScrollState.origin)),d<1?this._coreBrowserService.window.requestAnimationFrame(()=>this._smoothScroll()):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(d,p){const v=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(p<0&&this._viewportElement.scrollTop!==0||p>0&&v<this._lastRecordedBufferHeight)||(d.cancelable&&d.preventDefault(),!1)}handleWheel(d){const p=this._getPixelsScrolled(d);return p!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+p:this._smoothScrollState.target+=p,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=p,this._bubbleScroll(d,p))}scrollLines(d){if(d!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const p=d*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+p,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:d,suppressScrollEvent:!1})}_getPixelsScrolled(d){if(d.deltaY===0||d.shiftKey)return 0;let p=this._applyScrollModifier(d.deltaY,d);return d.deltaMode===WheelEvent.DOM_DELTA_LINE?p*=this._currentRowHeight:d.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(p*=this._currentRowHeight*this._bufferService.rows),p}getBufferElements(d,p){var v;let C,S="";const b=[],w=p!=null?p:this._bufferService.buffer.lines.length,E=this._bufferService.buffer.lines;for(let x=d;x<w;x++){const k=E.get(x);if(!k)continue;const D=(v=E.get(x+1))===null||v===void 0?void 0:v.isWrapped;if(S+=k.translateToString(!D),!D||x===E.length-1){const R=document.createElement("div");R.textContent=S,b.push(R),S.length>0&&(C=R),S=""}}return{bufferElements:b,cursorElement:C}}getLinesScrolled(d){if(d.deltaY===0||d.shiftKey)return 0;let p=this._applyScrollModifier(d.deltaY,d);return d.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(p/=this._currentRowHeight+0,this._wheelPartialScroll+=p,p=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):d.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(p*=this._bufferService.rows),p}_applyScrollModifier(d,p){const v=this._optionsService.rawOptions.fastScrollModifier;return v==="alt"&&p.altKey||v==="ctrl"&&p.ctrlKey||v==="shift"&&p.shiftKey?d*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:d*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(d){this._lastTouchY=d.touches[0].pageY}handleTouchMove(d){const p=this._lastTouchY-d.touches[0].pageY;return this._lastTouchY=d.touches[0].pageY,p!==0&&(this._viewportElement.scrollTop+=p,this._bubbleScroll(d,p))}};s.Viewport=h=o([f(2,m.IBufferService),f(3,m.IOptionsService),f(4,g.ICharSizeService),f(5,g.IRenderService),f(6,g.ICoreBrowserService),f(7,g.IThemeService)],h)},3107:function(a,s,l){var o=this&&this.__decorate||function(h,d,p,v){var C,S=arguments.length,b=S<3?d:v===null?v=Object.getOwnPropertyDescriptor(d,p):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(h,d,p,v);else for(var w=h.length-1;w>=0;w--)(C=h[w])&&(b=(S<3?C(b):S>3?C(d,p,b):C(d,p))||b);return S>3&&b&&Object.defineProperty(d,p,b),b},f=this&&this.__param||function(h,d){return function(p,v){d(p,v,h)}};Object.defineProperty(s,"__esModule",{value:!0}),s.BufferDecorationRenderer=void 0;const u=l(3656),g=l(4725),_=l(844),y=l(2585);let m=s.BufferDecorationRenderer=class extends _.Disposable{constructor(h,d,p,v){super(),this._screenElement=h,this._bufferService=d,this._decorationService=p,this._renderService=v,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this.register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this.register((0,u.addDisposableDomListener)(window,"resize",()=>this._queueRefresh())),this.register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this.register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this.register(this._decorationService.onDecorationRemoved(C=>this._removeDecoration(C))),this.register((0,_.toDisposable)(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(const h of this._decorationService.decorations)this._renderDecoration(h);this._dimensionsChanged=!1}_renderDecoration(h){this._refreshStyle(h),this._dimensionsChanged&&this._refreshXPosition(h)}_createElement(h){var d,p;const v=document.createElement("div");v.classList.add("xterm-decoration"),v.classList.toggle("xterm-decoration-top-layer",((d=h==null?void 0:h.options)===null||d===void 0?void 0:d.layer)==="top"),v.style.width=`${Math.round((h.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,v.style.height=(h.options.height||1)*this._renderService.dimensions.css.cell.height+"px",v.style.top=(h.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",v.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const C=(p=h.options.x)!==null&&p!==void 0?p:0;return C&&C>this._bufferService.cols&&(v.style.display="none"),this._refreshXPosition(h,v),v}_refreshStyle(h){const d=h.marker.line-this._bufferService.buffers.active.ydisp;if(d<0||d>=this._bufferService.rows)h.element&&(h.element.style.display="none",h.onRenderEmitter.fire(h.element));else{let p=this._decorationElements.get(h);p||(p=this._createElement(h),h.element=p,this._decorationElements.set(h,p),this._container.appendChild(p),h.onDispose(()=>{this._decorationElements.delete(h),p.remove()})),p.style.top=d*this._renderService.dimensions.css.cell.height+"px",p.style.display=this._altBufferIsActive?"none":"block",h.onRenderEmitter.fire(p)}}_refreshXPosition(h,d=h.element){var p;if(!d)return;const v=(p=h.options.x)!==null&&p!==void 0?p:0;(h.options.anchor||"left")==="right"?d.style.right=v?v*this._renderService.dimensions.css.cell.width+"px":"":d.style.left=v?v*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(h){var d;(d=this._decorationElements.get(h))===null||d===void 0||d.remove(),this._decorationElements.delete(h),h.dispose()}};s.BufferDecorationRenderer=m=o([f(1,y.IBufferService),f(2,y.IDecorationService),f(3,g.IRenderService)],m)},5871:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ColorZoneStore=void 0,s.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(l){if(l.options.overviewRulerOptions){for(const o of this._zones)if(o.color===l.options.overviewRulerOptions.color&&o.position===l.options.overviewRulerOptions.position){if(this._lineIntersectsZone(o,l.marker.line))return;if(this._lineAdjacentToZone(o,l.marker.line,l.options.overviewRulerOptions.position))return void this._addLineToZone(o,l.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=l.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=l.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=l.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=l.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:l.options.overviewRulerOptions.color,position:l.options.overviewRulerOptions.position,startBufferLine:l.marker.line,endBufferLine:l.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(l){this._linePadding=l}_lineIntersectsZone(l,o){return o>=l.startBufferLine&&o<=l.endBufferLine}_lineAdjacentToZone(l,o,f){return o>=l.startBufferLine-this._linePadding[f||"full"]&&o<=l.endBufferLine+this._linePadding[f||"full"]}_addLineToZone(l,o){l.startBufferLine=Math.min(l.startBufferLine,o),l.endBufferLine=Math.max(l.endBufferLine,o)}}},5744:function(a,s,l){var o=this&&this.__decorate||function(C,S,b,w){var E,x=arguments.length,k=x<3?S:w===null?w=Object.getOwnPropertyDescriptor(S,b):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(C,S,b,w);else for(var D=C.length-1;D>=0;D--)(E=C[D])&&(k=(x<3?E(k):x>3?E(S,b,k):E(S,b))||k);return x>3&&k&&Object.defineProperty(S,b,k),k},f=this&&this.__param||function(C,S){return function(b,w){S(b,w,C)}};Object.defineProperty(s,"__esModule",{value:!0}),s.OverviewRulerRenderer=void 0;const u=l(5871),g=l(3656),_=l(4725),y=l(844),m=l(2585),h={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0},p={full:0,left:0,center:0,right:0};let v=s.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(C,S,b,w,E,x,k){var D;super(),this._viewportElement=C,this._screenElement=S,this._bufferService=b,this._decorationService=w,this._renderService=E,this._optionsService=x,this._coreBrowseService=k,this._colorZoneStore=new u.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(D=this._viewportElement.parentElement)===null||D===void 0||D.insertBefore(this._canvas,this._viewportElement);const R=this._canvas.getContext("2d");if(!R)throw new Error("Ctx cannot be null");this._ctx=R,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)(()=>{var O;(O=this._canvas)===null||O===void 0||O.remove()}))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this.register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0)))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this.register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this.register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())}))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender(()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",()=>this._queueRefresh(!0))),this.register((0,g.addDisposableDomListener)(this._coreBrowseService.window,"resize",()=>this._queueRefresh(!0))),this._queueRefresh(!0)}_refreshDrawConstants(){const C=Math.floor(this._canvas.width/3),S=Math.ceil(this._canvas.width/3);d.full=this._canvas.width,d.left=C,d.center=S,d.right=C,this._refreshDrawHeightConstants(),p.full=0,p.left=0,p.center=d.left,p.right=d.left+d.center}_refreshDrawHeightConstants(){h.full=Math.round(2*this._coreBrowseService.dpr);const C=this._canvas.height/this._bufferService.buffer.lines.length,S=Math.round(Math.max(Math.min(C,12),6)*this._coreBrowseService.dpr);h.left=S,h.center=S,h.right=S}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*h.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*h.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*h.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*h.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const S of this._decorationService.decorations)this._colorZoneStore.addDecoration(S);this._ctx.lineWidth=1;const C=this._colorZoneStore.zones;for(const S of C)S.position!=="full"&&this._renderColorZone(S);for(const S of C)S.position==="full"&&this._renderColorZone(S);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(C){this._ctx.fillStyle=C.color,this._ctx.fillRect(p[C.position||"full"],Math.round((this._canvas.height-1)*(C.startBufferLine/this._bufferService.buffers.active.lines.length)-h[C.position||"full"]/2),d[C.position||"full"],Math.round((this._canvas.height-1)*((C.endBufferLine-C.startBufferLine)/this._bufferService.buffers.active.lines.length)+h[C.position||"full"]))}_queueRefresh(C,S){this._shouldUpdateDimensions=C||this._shouldUpdateDimensions,this._shouldUpdateAnchor=S||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};s.OverviewRulerRenderer=v=o([f(2,m.IBufferService),f(3,m.IDecorationService),f(4,_.IRenderService),f(5,m.IOptionsService),f(6,_.ICoreBrowserService)],v)},2950:function(a,s,l){var o=this&&this.__decorate||function(m,h,d,p){var v,C=arguments.length,S=C<3?h:p===null?p=Object.getOwnPropertyDescriptor(h,d):p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(m,h,d,p);else for(var b=m.length-1;b>=0;b--)(v=m[b])&&(S=(C<3?v(S):C>3?v(h,d,S):v(h,d))||S);return C>3&&S&&Object.defineProperty(h,d,S),S},f=this&&this.__param||function(m,h){return function(d,p){h(d,p,m)}};Object.defineProperty(s,"__esModule",{value:!0}),s.CompositionHelper=void 0;const u=l(4725),g=l(2585),_=l(2584);let y=s.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(m,h,d,p,v,C){this._textarea=m,this._compositionView=h,this._bufferService=d,this._optionsService=p,this._coreService=v,this._renderService=C,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(m){this._compositionView.textContent=m.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(m){if(this._isComposing||this._isSendingComposition){if(m.keyCode===229||m.keyCode===16||m.keyCode===17||m.keyCode===18)return!1;this._finalizeComposition(!1)}return m.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(m){if(this._compositionView.classList.remove("active"),this._isComposing=!1,m){const h={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){let d;this._isSendingComposition=!1,h.start+=this._dataAlreadySent.length,d=this._isComposing?this._textarea.value.substring(h.start,h.end):this._textarea.value.substring(h.start),d.length>0&&this._coreService.triggerDataEvent(d,!0)}},0)}else{this._isSendingComposition=!1;const h=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(h,!0)}}_handleAnyTextareaChanges(){const m=this._textarea.value;setTimeout(()=>{if(!this._isComposing){const h=this._textarea.value,d=h.replace(m,"");this._dataAlreadySent=d,h.length>m.length?this._coreService.triggerDataEvent(d,!0):h.length<m.length?this._coreService.triggerDataEvent(`${_.C0.DEL}`,!0):h.length===m.length&&h!==m&&this._coreService.triggerDataEvent(h,!0)}},0)}updateCompositionElements(m){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const h=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),d=this._renderService.dimensions.css.cell.height,p=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,v=h*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=v+"px",this._compositionView.style.top=p+"px",this._compositionView.style.height=d+"px",this._compositionView.style.lineHeight=d+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const C=this._compositionView.getBoundingClientRect();this._textarea.style.left=v+"px",this._textarea.style.top=p+"px",this._textarea.style.width=Math.max(C.width,1)+"px",this._textarea.style.height=Math.max(C.height,1)+"px",this._textarea.style.lineHeight=C.height+"px"}m||setTimeout(()=>this.updateCompositionElements(!0),0)}}};s.CompositionHelper=y=o([f(2,g.IBufferService),f(3,g.IOptionsService),f(4,g.ICoreService),f(5,u.IRenderService)],y)},9806:(a,s)=>{function l(o,f,u){const g=u.getBoundingClientRect(),_=o.getComputedStyle(u),y=parseInt(_.getPropertyValue("padding-left")),m=parseInt(_.getPropertyValue("padding-top"));return[f.clientX-g.left-y,f.clientY-g.top-m]}Object.defineProperty(s,"__esModule",{value:!0}),s.getCoords=s.getCoordsRelativeToElement=void 0,s.getCoordsRelativeToElement=l,s.getCoords=function(o,f,u,g,_,y,m,h,d){if(!y)return;const p=l(o,f,u);return p?(p[0]=Math.ceil((p[0]+(d?m/2:0))/m),p[1]=Math.ceil(p[1]/h),p[0]=Math.min(Math.max(p[0],1),g+(d?1:0)),p[1]=Math.min(Math.max(p[1],1),_),p):void 0}},9504:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.moveToCellSequence=void 0;const o=l(2584);function f(h,d,p,v){const C=h-u(h,p),S=d-u(d,p),b=Math.abs(C-S)-function(w,E,x){let k=0;const D=w-u(w,x),R=E-u(E,x);for(let O=0;O<Math.abs(D-R);O++){const G=g(w,E)==="A"?-1:1,q=x.buffer.lines.get(D+G*O);q!=null&&q.isWrapped&&k++}return k}(h,d,p);return m(b,y(g(h,d),v))}function u(h,d){let p=0,v=d.buffer.lines.get(h),C=v==null?void 0:v.isWrapped;for(;C&&h>=0&&h<d.rows;)p++,v=d.buffer.lines.get(--h),C=v==null?void 0:v.isWrapped;return p}function g(h,d){return h>d?"A":"B"}function _(h,d,p,v,C,S){let b=h,w=d,E="";for(;b!==p||w!==v;)b+=C?1:-1,C&&b>S.cols-1?(E+=S.buffer.translateBufferLineToString(w,!1,h,b),b=0,h=0,w++):!C&&b<0&&(E+=S.buffer.translateBufferLineToString(w,!1,0,h+1),b=S.cols-1,h=b,w--);return E+S.buffer.translateBufferLineToString(w,!1,h,b)}function y(h,d){const p=d?"O":"[";return o.C0.ESC+p+h}function m(h,d){h=Math.floor(h);let p="";for(let v=0;v<h;v++)p+=d;return p}s.moveToCellSequence=function(h,d,p,v){const C=p.buffer.x,S=p.buffer.y;if(!p.buffer.hasScrollback)return function(E,x,k,D,R,O){return f(x,D,R,O).length===0?"":m(_(E,x,E,x-u(x,R),!1,R).length,y("D",O))}(C,S,0,d,p,v)+f(S,d,p,v)+function(E,x,k,D,R,O){let G;G=f(x,D,R,O).length>0?D-u(D,R):x;const q=D,X=function(W,L,P,N,U,z){let $;return $=f(P,N,U,z).length>0?N-u(N,U):L,W<P&&$<=N||W>=P&&$<N?"C":"D"}(E,x,k,D,R,O);return m(_(E,G,k,q,X==="C",R).length,y(X,O))}(C,S,h,d,p,v);let b;if(S===d)return b=C>h?"D":"C",m(Math.abs(C-h),y(b,v));b=S>d?"D":"C";const w=Math.abs(S-d);return m(function(E,x){return x.cols-E}(S>d?h:C,p)+(w-1)*p.cols+1+((S>d?C:h)-1),y(b,v))}},1296:function(a,s,l){var o=this&&this.__decorate||function(R,O,G,q){var X,W=arguments.length,L=W<3?O:q===null?q=Object.getOwnPropertyDescriptor(O,G):q;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(R,O,G,q);else for(var P=R.length-1;P>=0;P--)(X=R[P])&&(L=(W<3?X(L):W>3?X(O,G,L):X(O,G))||L);return W>3&&L&&Object.defineProperty(O,G,L),L},f=this&&this.__param||function(R,O){return function(G,q){O(G,q,R)}};Object.defineProperty(s,"__esModule",{value:!0}),s.DomRenderer=void 0;const u=l(3787),g=l(2550),_=l(2223),y=l(6171),m=l(4725),h=l(8055),d=l(8460),p=l(844),v=l(2585),C="xterm-dom-renderer-owner-",S="xterm-rows",b="xterm-fg-",w="xterm-bg-",E="xterm-focus",x="xterm-selection";let k=1,D=s.DomRenderer=class extends p.Disposable{constructor(R,O,G,q,X,W,L,P,N,U){super(),this._element=R,this._screenElement=O,this._viewportElement=G,this._linkifier2=q,this._charSizeService=W,this._optionsService=L,this._bufferService=P,this._coreBrowserService=N,this._themeService=U,this._terminalClass=k++,this._rowElements=[],this.onRequestRedraw=this.register(new d.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(S),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(x),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,y.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this.register(this._themeService.onChangeColors(z=>this._injectCss(z))),this._injectCss(this._themeService.colors),this._rowFactory=X.createInstance(u.DomRendererRowFactory,document),this._element.classList.add(C+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline(z=>this._handleLinkHover(z))),this.register(this._linkifier2.onHideLinkUnderline(z=>this._handleLinkLeave(z))),this.register((0,p.toDisposable)(()=>{this._element.classList.remove(C+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new g.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const R=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*R,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*R),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/R),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/R),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const G of this._rowElements)G.style.width=`${this.dimensions.css.canvas.width}px`,G.style.height=`${this.dimensions.css.cell.height}px`,G.style.lineHeight=`${this.dimensions.css.cell.height}px`,G.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const O=`${this._terminalSelector} .${S} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=O,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(R){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let O=`${this._terminalSelector} .${S} { color: ${R.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;O+=`${this._terminalSelector} .${S} .xterm-dim { color: ${h.color.multiplyOpacity(R.foreground,.5).css};}`,O+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`,O+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% {  border-bottom-style: hidden; }}",O+="@keyframes blink_block_"+this._terminalClass+` { 0% {  background-color: ${R.cursor.css};  color: ${R.cursorAccent.css}; } 50% {  background-color: inherit;  color: ${R.cursor.css}; }}`,O+=`${this._terminalSelector} .${S}.${E} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S}.${E} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-block { background-color: ${R.cursor.css}; color: ${R.cursorAccent.css};}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${R.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${R.cursor.css} inset;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${R.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,O+=`${this._terminalSelector} .${x} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${x} div { position: absolute; background-color: ${R.selectionBackgroundOpaque.css};}${this._terminalSelector} .${x} div { position: absolute; background-color: ${R.selectionInactiveBackgroundOpaque.css};}`;for(const[G,q]of R.ansi.entries())O+=`${this._terminalSelector} .${b}${G} { color: ${q.css}; }${this._terminalSelector} .${b}${G}.xterm-dim { color: ${h.color.multiplyOpacity(q,.5).css}; }${this._terminalSelector} .${w}${G} { background-color: ${q.css}; }`;O+=`${this._terminalSelector} .${b}${_.INVERTED_DEFAULT_COLOR} { color: ${h.color.opaque(R.background).css}; }${this._terminalSelector} .${b}${_.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${h.color.multiplyOpacity(h.color.opaque(R.background),.5).css}; }${this._terminalSelector} .${w}${_.INVERTED_DEFAULT_COLOR} { background-color: ${R.foreground.css}; }`,this._themeStyleElement.textContent=O}_setDefaultSpacing(){const R=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${R}px`,this._rowFactory.defaultSpacing=R}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(R,O){for(let G=this._rowElements.length;G<=O;G++){const q=document.createElement("div");this._rowContainer.appendChild(q),this._rowElements.push(q)}for(;this._rowElements.length>O;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(R,O){this._refreshRowElements(R,O),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(E)}handleFocus(){this._rowContainer.classList.add(E),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(R,O,G){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(R,O,G),this.renderRows(0,this._bufferService.rows-1),!R||!O)return;const q=R[1]-this._bufferService.buffer.ydisp,X=O[1]-this._bufferService.buffer.ydisp,W=Math.max(q,0),L=Math.min(X,this._bufferService.rows-1);if(W>=this._bufferService.rows||L<0)return;const P=document.createDocumentFragment();if(G){const N=R[0]>O[0];P.appendChild(this._createSelectionElement(W,N?O[0]:R[0],N?R[0]:O[0],L-W+1))}else{const N=q===W?R[0]:0,U=W===X?O[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(W,N,U));const z=L-W-1;if(P.appendChild(this._createSelectionElement(W+1,0,this._bufferService.cols,z)),W!==L){const $=X===L?O[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(L,0,$))}}this._selectionContainer.appendChild(P)}_createSelectionElement(R,O,G,q=1){const X=document.createElement("div");return X.style.height=q*this.dimensions.css.cell.height+"px",X.style.top=R*this.dimensions.css.cell.height+"px",X.style.left=O*this.dimensions.css.cell.width+"px",X.style.width=this.dimensions.css.cell.width*(G-O)+"px",X}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const R of this._rowElements)R.replaceChildren()}renderRows(R,O){const G=this._bufferService.buffer,q=G.ybase+G.y,X=Math.min(G.x,this._bufferService.cols-1),W=this._optionsService.rawOptions.cursorBlink,L=this._optionsService.rawOptions.cursorStyle,P=this._optionsService.rawOptions.cursorInactiveStyle;for(let N=R;N<=O;N++){const U=N+G.ydisp,z=this._rowElements[N],$=G.lines.get(U);if(!z||!$)break;z.replaceChildren(...this._rowFactory.createRow($,U,U===q,L,P,X,W,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${C}${this._terminalClass}`}_handleLinkHover(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!0)}_handleLinkLeave(R){this._setCellUnderline(R.x1,R.x2,R.y1,R.y2,R.cols,!1)}_setCellUnderline(R,O,G,q,X,W){G<0&&(R=0),q<0&&(O=0);const L=this._bufferService.rows-1;G=Math.max(Math.min(G,L),0),q=Math.max(Math.min(q,L),0),X=Math.min(X,this._bufferService.cols);const P=this._bufferService.buffer,N=P.ybase+P.y,U=Math.min(P.x,X-1),z=this._optionsService.rawOptions.cursorBlink,$=this._optionsService.rawOptions.cursorStyle,se=this._optionsService.rawOptions.cursorInactiveStyle;for(let te=G;te<=q;++te){const de=te+P.ydisp,I=this._rowElements[te],V=P.lines.get(de);if(!I||!V)break;I.replaceChildren(...this._rowFactory.createRow(V,de,de===N,$,se,U,z,this.dimensions.css.cell.width,this._widthCache,W?te===G?R:0:-1,W?(te===q?O:X)-1:-1))}}};s.DomRenderer=D=o([f(4,v.IInstantiationService),f(5,m.ICharSizeService),f(6,v.IOptionsService),f(7,v.IBufferService),f(8,m.ICoreBrowserService),f(9,m.IThemeService)],D)},3787:function(a,s,l){var o=this&&this.__decorate||function(b,w,E,x){var k,D=arguments.length,R=D<3?w:x===null?x=Object.getOwnPropertyDescriptor(w,E):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(b,w,E,x);else for(var O=b.length-1;O>=0;O--)(k=b[O])&&(R=(D<3?k(R):D>3?k(w,E,R):k(w,E))||R);return D>3&&R&&Object.defineProperty(w,E,R),R},f=this&&this.__param||function(b,w){return function(E,x){w(E,x,b)}};Object.defineProperty(s,"__esModule",{value:!0}),s.DomRendererRowFactory=void 0;const u=l(2223),g=l(643),_=l(511),y=l(2585),m=l(8055),h=l(4725),d=l(4269),p=l(6171),v=l(3734);let C=s.DomRendererRowFactory=class{constructor(b,w,E,x,k,D,R){this._document=b,this._characterJoinerService=w,this._optionsService=E,this._coreBrowserService=x,this._coreService=k,this._decorationService=D,this._themeService=R,this._workCell=new _.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(b,w,E){this._selectionStart=b,this._selectionEnd=w,this._columnSelectMode=E}createRow(b,w,E,x,k,D,R,O,G,q,X){const W=[],L=this._characterJoinerService.getJoinedCharacters(w),P=this._themeService.colors;let N,U=b.getNoBgTrimmedLength();E&&U<D+1&&(U=D+1);let z=0,$="",se=0,te=0,de=0,I=!1,V=0,Q=!1,j=0;const ce=[],ie=q!==-1&&X!==-1;for(let pe=0;pe<U;pe++){b.loadCell(pe,this._workCell);let xe=this._workCell.getWidth();if(xe===0)continue;let Ae=!1,or=pe,Se=this._workCell;if(L.length>0&&pe===L[0][0]){Ae=!0;const Oe=L.shift();Se=new d.JoinedCellData(this._workCell,b.translateToString(!0,Oe[0],Oe[1]),Oe[1]-Oe[0]),or=Oe[1]-1,xe=Se.getWidth()}const Er=this._isCellInSelection(pe,w),Gi=E&&pe===D,ji=ie&&pe>=q&&pe<=X;let Qi=!1;this._decorationService.forEachDecorationAtCell(pe,w,void 0,Oe=>{Qi=!0});let ti=Se.getChars()||g.WHITESPACE_CELL_CHAR;if(ti===" "&&(Se.isUnderline()||Se.isOverline())&&(ti=" "),j=xe*O-G.get(ti,Se.isBold(),Se.isItalic()),N){if(z&&(Er&&Q||!Er&&!Q&&Se.bg===se)&&(Er&&Q&&P.selectionForeground||Se.fg===te)&&Se.extended.ext===de&&ji===I&&j===V&&!Gi&&!Ae&&!Qi){$+=ti,z++;continue}z&&(N.textContent=$),N=this._document.createElement("span"),z=0,$=""}else N=this._document.createElement("span");if(se=Se.bg,te=Se.fg,de=Se.extended.ext,I=ji,V=j,Q=Er,Ae&&D>=pe&&D<=or&&(D=pe),!this._coreService.isCursorHidden&&Gi){if(ce.push("xterm-cursor"),this._coreBrowserService.isFocused)R&&ce.push("xterm-cursor-blink"),ce.push(x==="bar"?"xterm-cursor-bar":x==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(k)switch(k){case"outline":ce.push("xterm-cursor-outline");break;case"block":ce.push("xterm-cursor-block");break;case"bar":ce.push("xterm-cursor-bar");break;case"underline":ce.push("xterm-cursor-underline")}}if(Se.isBold()&&ce.push("xterm-bold"),Se.isItalic()&&ce.push("xterm-italic"),Se.isDim()&&ce.push("xterm-dim"),$=Se.isInvisible()?g.WHITESPACE_CELL_CHAR:Se.getChars()||g.WHITESPACE_CELL_CHAR,Se.isUnderline()&&(ce.push(`xterm-underline-${Se.extended.underlineStyle}`),$===" "&&($=" "),!Se.isUnderlineColorDefault()))if(Se.isUnderlineColorRGB())N.style.textDecorationColor=`rgb(${v.AttributeData.toColorRGB(Se.getUnderlineColor()).join(",")})`;else{let Oe=Se.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&Se.isBold()&&Oe<8&&(Oe+=8),N.style.textDecorationColor=P.ansi[Oe].css}Se.isOverline()&&(ce.push("xterm-overline"),$===" "&&($=" ")),Se.isStrikethrough()&&ce.push("xterm-strikethrough"),ji&&(N.style.textDecoration="underline");let ct=Se.getFgColor(),br=Se.getFgColorMode(),St=Se.getBgColor(),xr=Se.getBgColorMode();const Yi=!!Se.isInverse();if(Yi){const Oe=ct;ct=St,St=Oe;const Ac=br;br=xr,xr=Ac}let Mt,Xi,Ut,wr=!1;switch(this._decorationService.forEachDecorationAtCell(pe,w,void 0,Oe=>{Oe.options.layer!=="top"&&wr||(Oe.backgroundColorRGB&&(xr=50331648,St=Oe.backgroundColorRGB.rgba>>8&16777215,Mt=Oe.backgroundColorRGB),Oe.foregroundColorRGB&&(br=50331648,ct=Oe.foregroundColorRGB.rgba>>8&16777215,Xi=Oe.foregroundColorRGB),wr=Oe.options.layer==="top")}),!wr&&Er&&(Mt=this._coreBrowserService.isFocused?P.selectionBackgroundOpaque:P.selectionInactiveBackgroundOpaque,St=Mt.rgba>>8&16777215,xr=50331648,wr=!0,P.selectionForeground&&(br=50331648,ct=P.selectionForeground.rgba>>8&16777215,Xi=P.selectionForeground)),wr&&ce.push("xterm-decoration-top"),xr){case 16777216:case 33554432:Ut=P.ansi[St],ce.push(`xterm-bg-${St}`);break;case 50331648:Ut=m.rgba.toColor(St>>16,St>>8&255,255&St),this._addStyle(N,`background-color:#${S((St>>>0).toString(16),"0",6)}`);break;default:Yi?(Ut=P.foreground,ce.push(`xterm-bg-${u.INVERTED_DEFAULT_COLOR}`)):Ut=P.background}switch(Mt||Se.isDim()&&(Mt=m.color.multiplyOpacity(Ut,.5)),br){case 16777216:case 33554432:Se.isBold()&&ct<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ct+=8),this._applyMinimumContrast(N,Ut,P.ansi[ct],Se,Mt,void 0)||ce.push(`xterm-fg-${ct}`);break;case 50331648:const Oe=m.rgba.toColor(ct>>16&255,ct>>8&255,255&ct);this._applyMinimumContrast(N,Ut,Oe,Se,Mt,Xi)||this._addStyle(N,`color:#${S(ct.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(N,Ut,P.foreground,Se,Mt,void 0)||Yi&&ce.push(`xterm-fg-${u.INVERTED_DEFAULT_COLOR}`)}ce.length&&(N.className=ce.join(" "),ce.length=0),Gi||Ae||Qi?N.textContent=$:z++,j!==this.defaultSpacing&&(N.style.letterSpacing=`${j}px`),W.push(N),pe=or}return N&&z&&(N.textContent=$),W}_applyMinimumContrast(b,w,E,x,k,D){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,p.excludeFromContrastRatioDemands)(x.getCode()))return!1;const R=this._getContrastCache(x);let O;if(k||D||(O=R.getColor(w.rgba,E.rgba)),O===void 0){const G=this._optionsService.rawOptions.minimumContrastRatio/(x.isDim()?2:1);O=m.color.ensureContrastRatio(k||w,D||E,G),R.setColor((k||w).rgba,(D||E).rgba,O!=null?O:null)}return!!O&&(this._addStyle(b,`color:${O.css}`),!0)}_getContrastCache(b){return b.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(b,w){b.setAttribute("style",`${b.getAttribute("style")||""}${w};`)}_isCellInSelection(b,w){const E=this._selectionStart,x=this._selectionEnd;return!(!E||!x)&&(this._columnSelectMode?E[0]<=x[0]?b>=E[0]&&w>=E[1]&&b<x[0]&&w<=x[1]:b<E[0]&&w>=E[1]&&b>=x[0]&&w<=x[1]:w>E[1]&&w<x[1]||E[1]===x[1]&&w===E[1]&&b>=E[0]&&b<x[0]||E[1]<x[1]&&w===x[1]&&b<x[0]||E[1]<x[1]&&w===E[1]&&b>=E[0])}};function S(b,w,E){for(;b.length<E;)b=w+b;return b}s.DomRendererRowFactory=C=o([f(1,h.ICharacterJoinerService),f(2,y.IOptionsService),f(3,h.ICoreBrowserService),f(4,y.ICoreService),f(5,y.IDecorationService),f(6,h.IThemeService)],C)},2550:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.WidthCache=void 0,s.WidthCache=class{constructor(l){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=l.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const o=l.createElement("span"),f=l.createElement("span");f.style.fontWeight="bold";const u=l.createElement("span");u.style.fontStyle="italic";const g=l.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[o,f,u,g],this._container.appendChild(o),this._container.appendChild(f),this._container.appendChild(u),this._container.appendChild(g),l.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(l,o,f,u){l===this._font&&o===this._fontSize&&f===this._weight&&u===this._weightBold||(this._font=l,this._fontSize=o,this._weight=f,this._weightBold=u,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${f}`,this._measureElements[1].style.fontWeight=`${u}`,this._measureElements[2].style.fontWeight=`${f}`,this._measureElements[3].style.fontWeight=`${u}`,this.clear())}get(l,o,f){let u=0;if(!o&&!f&&l.length===1&&(u=l.charCodeAt(0))<256)return this._flat[u]!==-9999?this._flat[u]:this._flat[u]=this._measure(l,0);let g=l;o&&(g+="B"),f&&(g+="I");let _=this._holey.get(g);if(_===void 0){let y=0;o&&(y|=1),f&&(y|=2),_=this._measure(l,y),this._holey.set(g,_)}return _}_measure(l,o){const f=this._measureElements[o];return f.textContent=l.repeat(32),f.offsetWidth/32}}},2223:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.TEXT_BASELINE=s.DIM_OPACITY=s.INVERTED_DEFAULT_COLOR=void 0;const o=l(6114);s.INVERTED_DEFAULT_COLOR=257,s.DIM_OPACITY=.5,s.TEXT_BASELINE=o.isFirefox||o.isLegacyEdge?"bottom":"ideographic"},6171:(a,s)=>{function l(o){return 57508<=o&&o<=57558}Object.defineProperty(s,"__esModule",{value:!0}),s.createRenderDimensions=s.excludeFromContrastRatioDemands=s.isRestrictedPowerlineGlyph=s.isPowerlineGlyph=s.throwIfFalsy=void 0,s.throwIfFalsy=function(o){if(!o)throw new Error("value must not be falsy");return o},s.isPowerlineGlyph=l,s.isRestrictedPowerlineGlyph=function(o){return 57520<=o&&o<=57527},s.excludeFromContrastRatioDemands=function(o){return l(o)||function(f){return 9472<=f&&f<=9631}(o)},s.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.SelectionModel=void 0,s.SelectionModel=class{constructor(l){this._bufferService=l,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const l=this.selectionStart[0]+this.selectionStartLength;return l>this._bufferService.cols?l%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(l/this._bufferService.cols)-1]:[l%this._bufferService.cols,this.selectionStart[1]+Math.floor(l/this._bufferService.cols)]:[l,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const l=this.selectionStart[0]+this.selectionStartLength;return l>this._bufferService.cols?[l%this._bufferService.cols,this.selectionStart[1]+Math.floor(l/this._bufferService.cols)]:[Math.max(l,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const l=this.selectionStart,o=this.selectionEnd;return!(!l||!o)&&(l[1]>o[1]||l[1]===o[1]&&l[0]>o[0])}handleTrim(l){return this.selectionStart&&(this.selectionStart[1]-=l),this.selectionEnd&&(this.selectionEnd[1]-=l),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(a,s,l){var o=this&&this.__decorate||function(h,d,p,v){var C,S=arguments.length,b=S<3?d:v===null?v=Object.getOwnPropertyDescriptor(d,p):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(h,d,p,v);else for(var w=h.length-1;w>=0;w--)(C=h[w])&&(b=(S<3?C(b):S>3?C(d,p,b):C(d,p))||b);return S>3&&b&&Object.defineProperty(d,p,b),b},f=this&&this.__param||function(h,d){return function(p,v){d(p,v,h)}};Object.defineProperty(s,"__esModule",{value:!0}),s.CharSizeService=void 0;const u=l(2585),g=l(8460),_=l(844);let y=s.CharSizeService=class extends _.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(h,d,p){super(),this._optionsService=p,this.width=0,this.height=0,this._onCharSizeChange=this.register(new g.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new m(h,d,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}measure(){const h=this._measureStrategy.measure();h.width===this.width&&h.height===this.height||(this.width=h.width,this.height=h.height,this._onCharSizeChange.fire())}};s.CharSizeService=y=o([f(2,u.IOptionsService)],y);class m{constructor(d,p,v){this._document=d,this._parentElement=p,this._optionsService=v,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const d={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return d.width!==0&&d.height!==0&&(this._result.width=d.width/32,this._result.height=Math.ceil(d.height)),this._result}}},4269:function(a,s,l){var o=this&&this.__decorate||function(d,p,v,C){var S,b=arguments.length,w=b<3?p:C===null?C=Object.getOwnPropertyDescriptor(p,v):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(d,p,v,C);else for(var E=d.length-1;E>=0;E--)(S=d[E])&&(w=(b<3?S(w):b>3?S(p,v,w):S(p,v))||w);return b>3&&w&&Object.defineProperty(p,v,w),w},f=this&&this.__param||function(d,p){return function(v,C){p(v,C,d)}};Object.defineProperty(s,"__esModule",{value:!0}),s.CharacterJoinerService=s.JoinedCellData=void 0;const u=l(3734),g=l(643),_=l(511),y=l(2585);class m extends u.AttributeData{constructor(p,v,C){super(),this.content=0,this.combinedData="",this.fg=p.fg,this.bg=p.bg,this.combinedData=v,this._width=C}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(p){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}s.JoinedCellData=m;let h=s.CharacterJoinerService=class An{constructor(p){this._bufferService=p,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new _.CellData}register(p){const v={id:this._nextCharacterJoinerId++,handler:p};return this._characterJoiners.push(v),v.id}deregister(p){for(let v=0;v<this._characterJoiners.length;v++)if(this._characterJoiners[v].id===p)return this._characterJoiners.splice(v,1),!0;return!1}getJoinedCharacters(p){if(this._characterJoiners.length===0)return[];const v=this._bufferService.buffer.lines.get(p);if(!v||v.length===0)return[];const C=[],S=v.translateToString(!0);let b=0,w=0,E=0,x=v.getFg(0),k=v.getBg(0);for(let D=0;D<v.getTrimmedLength();D++)if(v.loadCell(D,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==x||this._workCell.bg!==k){if(D-b>1){const R=this._getJoinedRanges(S,E,w,v,b);for(let O=0;O<R.length;O++)C.push(R[O])}b=D,E=w,x=this._workCell.fg,k=this._workCell.bg}w+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-b>1){const D=this._getJoinedRanges(S,E,w,v,b);for(let R=0;R<D.length;R++)C.push(D[R])}return C}_getJoinedRanges(p,v,C,S,b){const w=p.substring(v,C);let E=[];try{E=this._characterJoiners[0].handler(w)}catch(x){console.error(x)}for(let x=1;x<this._characterJoiners.length;x++)try{const k=this._characterJoiners[x].handler(w);for(let D=0;D<k.length;D++)An._mergeRanges(E,k[D])}catch(k){console.error(k)}return this._stringRangesToCellRanges(E,S,b),E}_stringRangesToCellRanges(p,v,C){let S=0,b=!1,w=0,E=p[S];if(E){for(let x=C;x<this._bufferService.cols;x++){const k=v.getWidth(x),D=v.getString(x).length||g.WHITESPACE_CELL_CHAR.length;if(k!==0){if(!b&&E[0]<=w&&(E[0]=x,b=!0),E[1]<=w){if(E[1]=x,E=p[++S],!E)break;E[0]<=w?(E[0]=x,b=!0):b=!1}w+=D}}E&&(E[1]=this._bufferService.cols)}}static _mergeRanges(p,v){let C=!1;for(let S=0;S<p.length;S++){const b=p[S];if(C){if(v[1]<=b[0])return p[S-1][1]=v[1],p;if(v[1]<=b[1])return p[S-1][1]=Math.max(v[1],b[1]),p.splice(S,1),p;p.splice(S,1),S--}else{if(v[1]<=b[0])return p.splice(S,0,v),p;if(v[1]<=b[1])return b[0]=Math.min(v[0],b[0]),p;v[0]<b[1]&&(b[0]=Math.min(v[0],b[0]),C=!0)}}return C?p[p.length-1][1]=v[1]:p.push(v),p}};s.CharacterJoinerService=h=o([f(0,y.IBufferService)],h)},5114:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CoreBrowserService=void 0,s.CoreBrowserService=class{constructor(l,o){this._textarea=l,this.window=o,this._isFocused=!1,this._cachedIsFocused=void 0,this._textarea.addEventListener("focus",()=>this._isFocused=!0),this._textarea.addEventListener("blur",()=>this._isFocused=!1)}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}}},8934:function(a,s,l){var o=this&&this.__decorate||function(y,m,h,d){var p,v=arguments.length,C=v<3?m:d===null?d=Object.getOwnPropertyDescriptor(m,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(y,m,h,d);else for(var S=y.length-1;S>=0;S--)(p=y[S])&&(C=(v<3?p(C):v>3?p(m,h,C):p(m,h))||C);return v>3&&C&&Object.defineProperty(m,h,C),C},f=this&&this.__param||function(y,m){return function(h,d){m(h,d,y)}};Object.defineProperty(s,"__esModule",{value:!0}),s.MouseService=void 0;const u=l(4725),g=l(9806);let _=s.MouseService=class{constructor(y,m){this._renderService=y,this._charSizeService=m}getCoords(y,m,h,d,p){return(0,g.getCoords)(window,y,m,h,d,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,p)}getMouseReportCoords(y,m){const h=(0,g.getCoordsRelativeToElement)(window,y,m);if(this._charSizeService.hasValidSize)return h[0]=Math.min(Math.max(h[0],0),this._renderService.dimensions.css.canvas.width-1),h[1]=Math.min(Math.max(h[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(h[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(h[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(h[0]),y:Math.floor(h[1])}}};s.MouseService=_=o([f(0,u.IRenderService),f(1,u.ICharSizeService)],_)},3230:function(a,s,l){var o=this&&this.__decorate||function(C,S,b,w){var E,x=arguments.length,k=x<3?S:w===null?w=Object.getOwnPropertyDescriptor(S,b):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(C,S,b,w);else for(var D=C.length-1;D>=0;D--)(E=C[D])&&(k=(x<3?E(k):x>3?E(S,b,k):E(S,b))||k);return x>3&&k&&Object.defineProperty(S,b,k),k},f=this&&this.__param||function(C,S){return function(b,w){S(b,w,C)}};Object.defineProperty(s,"__esModule",{value:!0}),s.RenderService=void 0;const u=l(3656),g=l(6193),_=l(5596),y=l(4725),m=l(8460),h=l(844),d=l(7226),p=l(2585);let v=s.RenderService=class extends h.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(C,S,b,w,E,x,k,D){if(super(),this._rowCount=C,this._charSizeService=w,this._renderer=this.register(new h.MutableDisposable),this._pausedResizeTask=new d.DebouncedIdleTask,this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new m.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new m.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new m.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new m.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(k.window,(R,O)=>this._renderRows(R,O)),this.register(this._renderDebouncer),this._screenDprMonitor=new _.ScreenDprMonitor(k.window),this._screenDprMonitor.setListener(()=>this.handleDevicePixelRatioChange()),this.register(this._screenDprMonitor),this.register(x.onResize(()=>this._fullRefresh())),this.register(x.buffers.onBufferActivate(()=>{var R;return(R=this._renderer.value)===null||R===void 0?void 0:R.clear()})),this.register(b.onOptionChange(()=>this._handleOptionsChanged())),this.register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this.register(E.onDecorationRegistered(()=>this._fullRefresh())),this.register(E.onDecorationRemoved(()=>this._fullRefresh())),this.register(b.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],()=>{this.clear(),this.handleResize(x.cols,x.rows),this._fullRefresh()})),this.register(b.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(x.buffer.y,x.buffer.y,!0))),this.register((0,u.addDisposableDomListener)(k.window,"resize",()=>this.handleDevicePixelRatioChange())),this.register(D.onChangeColors(()=>this._fullRefresh())),"IntersectionObserver"in k.window){const R=new k.window.IntersectionObserver(O=>this._handleIntersectionChange(O[O.length-1]),{threshold:0});R.observe(S),this.register({dispose:()=>R.disconnect()})}}_handleIntersectionChange(C){this._isPaused=C.isIntersecting===void 0?C.intersectionRatio===0:!C.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(C,S,b=!1){this._isPaused?this._needsFullRefresh=!0:(b||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(C,S,this._rowCount))}_renderRows(C,S){this._renderer.value&&(C=Math.min(C,this._rowCount-1),S=Math.min(S,this._rowCount-1),this._renderer.value.renderRows(C,S),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:C,end:S}),this._onRender.fire({start:C,end:S}),this._isNextRenderRedrawOnly=!0)}resize(C,S){this._rowCount=S,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(C){this._renderer.value=C,this._renderer.value.onRequestRedraw(S=>this.refreshRows(S.start,S.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(C){return this._renderDebouncer.addRefreshCallback(C)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var C,S;this._renderer.value&&((S=(C=this._renderer.value).clearTextureAtlas)===null||S===void 0||S.call(C),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(C,S){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value.handleResize(C,S)):this._renderer.value.handleResize(C,S),this._fullRefresh())}handleCharSizeChanged(){var C;(C=this._renderer.value)===null||C===void 0||C.handleCharSizeChanged()}handleBlur(){var C;(C=this._renderer.value)===null||C===void 0||C.handleBlur()}handleFocus(){var C;(C=this._renderer.value)===null||C===void 0||C.handleFocus()}handleSelectionChanged(C,S,b){var w;this._selectionState.start=C,this._selectionState.end=S,this._selectionState.columnSelectMode=b,(w=this._renderer.value)===null||w===void 0||w.handleSelectionChanged(C,S,b)}handleCursorMove(){var C;(C=this._renderer.value)===null||C===void 0||C.handleCursorMove()}clear(){var C;(C=this._renderer.value)===null||C===void 0||C.clear()}};s.RenderService=v=o([f(2,p.IOptionsService),f(3,y.ICharSizeService),f(4,p.IDecorationService),f(5,p.IBufferService),f(6,y.ICoreBrowserService),f(7,y.IThemeService)],v)},9312:function(a,s,l){var o=this&&this.__decorate||function(E,x,k,D){var R,O=arguments.length,G=O<3?x:D===null?D=Object.getOwnPropertyDescriptor(x,k):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")G=Reflect.decorate(E,x,k,D);else for(var q=E.length-1;q>=0;q--)(R=E[q])&&(G=(O<3?R(G):O>3?R(x,k,G):R(x,k))||G);return O>3&&G&&Object.defineProperty(x,k,G),G},f=this&&this.__param||function(E,x){return function(k,D){x(k,D,E)}};Object.defineProperty(s,"__esModule",{value:!0}),s.SelectionService=void 0;const u=l(9806),g=l(9504),_=l(456),y=l(4725),m=l(8460),h=l(844),d=l(6114),p=l(4841),v=l(511),C=l(2585),S=String.fromCharCode(160),b=new RegExp(S,"g");let w=s.SelectionService=class extends h.Disposable{constructor(E,x,k,D,R,O,G,q,X){super(),this._element=E,this._screenElement=x,this._linkifier=k,this._bufferService=D,this._coreService=R,this._mouseService=O,this._optionsService=G,this._renderService=q,this._coreBrowserService=X,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new v.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new m.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new m.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new m.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new m.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=W=>this._handleMouseMove(W),this._mouseUpListener=W=>this._handleMouseUp(W),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(W=>this._handleTrim(W)),this.register(this._bufferService.buffers.onBufferActivate(W=>this._handleBufferActivate(W))),this.enable(),this._model=new _.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,h.toDisposable)(()=>{this._removeMouseDownListeners()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const E=this._model.finalSelectionStart,x=this._model.finalSelectionEnd;return!(!E||!x||E[0]===x[0]&&E[1]===x[1])}get selectionText(){const E=this._model.finalSelectionStart,x=this._model.finalSelectionEnd;if(!E||!x)return"";const k=this._bufferService.buffer,D=[];if(this._activeSelectionMode===3){if(E[0]===x[0])return"";const R=E[0]<x[0]?E[0]:x[0],O=E[0]<x[0]?x[0]:E[0];for(let G=E[1];G<=x[1];G++){const q=k.translateBufferLineToString(G,!0,R,O);D.push(q)}}else{const R=E[1]===x[1]?x[0]:void 0;D.push(k.translateBufferLineToString(E[1],!0,E[0],R));for(let O=E[1]+1;O<=x[1]-1;O++){const G=k.lines.get(O),q=k.translateBufferLineToString(O,!0);G!=null&&G.isWrapped?D[D.length-1]+=q:D.push(q)}if(E[1]!==x[1]){const O=k.lines.get(x[1]),G=k.translateBufferLineToString(x[1],!0,0,x[0]);O&&O.isWrapped?D[D.length-1]+=G:D.push(G)}}return D.map(R=>R.replace(b," ")).join(d.isWindows?`\r
`:`
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(E){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),d.isLinux&&E&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(E){const x=this._getMouseBufferCoords(E),k=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;return!!(k&&D&&x)&&this._areCoordsInSelection(x,k,D)}isCellInSelection(E,x){const k=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;return!(!k||!D)&&this._areCoordsInSelection([E,x],k,D)}_areCoordsInSelection(E,x,k){return E[1]>x[1]&&E[1]<k[1]||x[1]===k[1]&&E[1]===x[1]&&E[0]>=x[0]&&E[0]<k[0]||x[1]<k[1]&&E[1]===k[1]&&E[0]<k[0]||x[1]<k[1]&&E[1]===x[1]&&E[0]>=x[0]}_selectWordAtCursor(E,x){var k,D;const R=(D=(k=this._linkifier.currentLink)===null||k===void 0?void 0:k.link)===null||D===void 0?void 0:D.range;if(R)return this._model.selectionStart=[R.start.x-1,R.start.y-1],this._model.selectionStartLength=(0,p.getRangeLength)(R,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const O=this._getMouseBufferCoords(E);return!!O&&(this._selectWordAt(O,x),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(E,x){this._model.clearSelection(),E=Math.max(E,0),x=Math.min(x,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,E],this._model.selectionEnd=[this._bufferService.cols,x],this.refresh(),this._onSelectionChange.fire()}_handleTrim(E){this._model.handleTrim(E)&&this.refresh()}_getMouseBufferCoords(E){const x=this._mouseService.getCoords(E,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(x)return x[0]--,x[1]--,x[1]+=this._bufferService.buffer.ydisp,x}_getMouseEventScrollAmount(E){let x=(0,u.getCoordsRelativeToElement)(this._coreBrowserService.window,E,this._screenElement)[1];const k=this._renderService.dimensions.css.canvas.height;return x>=0&&x<=k?0:(x>k&&(x-=k),x=Math.min(Math.max(x,-50),50),x/=50,x/Math.abs(x)+Math.round(14*x))}shouldForceSelection(E){return d.isMac?E.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:E.shiftKey}handleMouseDown(E){if(this._mouseDownTimeStamp=E.timeStamp,(E.button!==2||!this.hasSelection)&&E.button===0){if(!this._enabled){if(!this.shouldForceSelection(E))return;E.stopPropagation()}E.preventDefault(),this._dragScrollAmount=0,this._enabled&&E.shiftKey?this._handleIncrementalClick(E):E.detail===1?this._handleSingleClick(E):E.detail===2?this._handleDoubleClick(E):E.detail===3&&this._handleTripleClick(E),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(E){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(E))}_handleSingleClick(E){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(E)?3:0,this._model.selectionStart=this._getMouseBufferCoords(E),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const x=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);x&&x.length!==this._model.selectionStart[0]&&x.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(E){this._selectWordAtCursor(E,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(E){const x=this._getMouseBufferCoords(E);x&&(this._activeSelectionMode=2,this._selectLineAt(x[1]))}shouldColumnSelect(E){return E.altKey&&!(d.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(E){if(E.stopImmediatePropagation(),!this._model.selectionStart)return;const x=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(E),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(E),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const k=this._bufferService.buffer;if(this._model.selectionEnd[1]<k.lines.length){const D=k.lines.get(this._model.selectionEnd[1]);D&&D.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}x&&x[0]===this._model.selectionEnd[0]&&x[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const E=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(E.ydisp+this._bufferService.rows,E.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=E.ydisp),this.refresh()}}_handleMouseUp(E){const x=E.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&x<500&&E.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const k=this._mouseService.getCoords(E,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(k&&k[0]!==void 0&&k[1]!==void 0){const D=(0,g.moveToCellSequence)(k[0]-1,k[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(D,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const E=this._model.finalSelectionStart,x=this._model.finalSelectionEnd,k=!(!E||!x||E[0]===x[0]&&E[1]===x[1]);k?E&&x&&(this._oldSelectionStart&&this._oldSelectionEnd&&E[0]===this._oldSelectionStart[0]&&E[1]===this._oldSelectionStart[1]&&x[0]===this._oldSelectionEnd[0]&&x[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(E,x,k)):this._oldHasSelection&&this._fireOnSelectionChange(E,x,k)}_fireOnSelectionChange(E,x,k){this._oldSelectionStart=E,this._oldSelectionEnd=x,this._oldHasSelection=k,this._onSelectionChange.fire()}_handleBufferActivate(E){this.clearSelection(),this._trimListener.dispose(),this._trimListener=E.activeBuffer.lines.onTrim(x=>this._handleTrim(x))}_convertViewportColToCharacterIndex(E,x){let k=x;for(let D=0;x>=D;D++){const R=E.loadCell(D,this._workCell).getChars().length;this._workCell.getWidth()===0?k--:R>1&&x!==D&&(k+=R-1)}return k}setSelection(E,x,k){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[E,x],this._model.selectionStartLength=k,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(E){this._isClickInSelection(E)||(this._selectWordAtCursor(E,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(E,x,k=!0,D=!0){if(E[0]>=this._bufferService.cols)return;const R=this._bufferService.buffer,O=R.lines.get(E[1]);if(!O)return;const G=R.translateBufferLineToString(E[1],!1);let q=this._convertViewportColToCharacterIndex(O,E[0]),X=q;const W=E[0]-q;let L=0,P=0,N=0,U=0;if(G.charAt(q)===" "){for(;q>0&&G.charAt(q-1)===" ";)q--;for(;X<G.length&&G.charAt(X+1)===" ";)X++}else{let se=E[0],te=E[0];O.getWidth(se)===0&&(L++,se--),O.getWidth(te)===2&&(P++,te++);const de=O.getString(te).length;for(de>1&&(U+=de-1,X+=de-1);se>0&&q>0&&!this._isCharWordSeparator(O.loadCell(se-1,this._workCell));){O.loadCell(se-1,this._workCell);const I=this._workCell.getChars().length;this._workCell.getWidth()===0?(L++,se--):I>1&&(N+=I-1,q-=I-1),q--,se--}for(;te<O.length&&X+1<G.length&&!this._isCharWordSeparator(O.loadCell(te+1,this._workCell));){O.loadCell(te+1,this._workCell);const I=this._workCell.getChars().length;this._workCell.getWidth()===2?(P++,te++):I>1&&(U+=I-1,X+=I-1),X++,te++}}X++;let z=q+W-L+N,$=Math.min(this._bufferService.cols,X-q+L+P-N-U);if(x||G.slice(q,X).trim()!==""){if(k&&z===0&&O.getCodePoint(0)!==32){const se=R.lines.get(E[1]-1);if(se&&O.isWrapped&&se.getCodePoint(this._bufferService.cols-1)!==32){const te=this._getWordAt([this._bufferService.cols-1,E[1]-1],!1,!0,!1);if(te){const de=this._bufferService.cols-te.start;z-=de,$+=de}}}if(D&&z+$===this._bufferService.cols&&O.getCodePoint(this._bufferService.cols-1)!==32){const se=R.lines.get(E[1]+1);if(se!=null&&se.isWrapped&&se.getCodePoint(0)!==32){const te=this._getWordAt([0,E[1]+1],!1,!1,!0);te&&($+=te.length)}}return{start:z,length:$}}}_selectWordAt(E,x){const k=this._getWordAt(E,x);if(k){for(;k.start<0;)k.start+=this._bufferService.cols,E[1]--;this._model.selectionStart=[k.start,E[1]],this._model.selectionStartLength=k.length}}_selectToWordAt(E){const x=this._getWordAt(E,!0);if(x){let k=E[1];for(;x.start<0;)x.start+=this._bufferService.cols,k--;if(!this._model.areSelectionValuesReversed())for(;x.start+x.length>this._bufferService.cols;)x.length-=this._bufferService.cols,k++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?x.start:x.start+x.length,k]}}_isCharWordSeparator(E){return E.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(E.getChars())>=0}_selectLineAt(E){const x=this._bufferService.buffer.getWrappedRangeForLine(E),k={start:{x:0,y:x.first},end:{x:this._bufferService.cols-1,y:x.last}};this._model.selectionStart=[0,x.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,p.getRangeLength)(k,this._bufferService.cols)}};s.SelectionService=w=o([f(3,C.IBufferService),f(4,C.ICoreService),f(5,y.IMouseService),f(6,C.IOptionsService),f(7,y.IRenderService),f(8,y.ICoreBrowserService)],w)},4725:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.IThemeService=s.ICharacterJoinerService=s.ISelectionService=s.IRenderService=s.IMouseService=s.ICoreBrowserService=s.ICharSizeService=void 0;const o=l(8343);s.ICharSizeService=(0,o.createDecorator)("CharSizeService"),s.ICoreBrowserService=(0,o.createDecorator)("CoreBrowserService"),s.IMouseService=(0,o.createDecorator)("MouseService"),s.IRenderService=(0,o.createDecorator)("RenderService"),s.ISelectionService=(0,o.createDecorator)("SelectionService"),s.ICharacterJoinerService=(0,o.createDecorator)("CharacterJoinerService"),s.IThemeService=(0,o.createDecorator)("ThemeService")},6731:function(a,s,l){var o=this&&this.__decorate||function(w,E,x,k){var D,R=arguments.length,O=R<3?E:k===null?k=Object.getOwnPropertyDescriptor(E,x):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(w,E,x,k);else for(var G=w.length-1;G>=0;G--)(D=w[G])&&(O=(R<3?D(O):R>3?D(E,x,O):D(E,x))||O);return R>3&&O&&Object.defineProperty(E,x,O),O},f=this&&this.__param||function(w,E){return function(x,k){E(x,k,w)}};Object.defineProperty(s,"__esModule",{value:!0}),s.ThemeService=s.DEFAULT_ANSI_COLORS=void 0;const u=l(7239),g=l(8055),_=l(8460),y=l(844),m=l(2585),h=g.css.toColor("#ffffff"),d=g.css.toColor("#000000"),p=g.css.toColor("#ffffff"),v=g.css.toColor("#000000"),C={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};s.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const w=[g.css.toColor("#2e3436"),g.css.toColor("#cc0000"),g.css.toColor("#4e9a06"),g.css.toColor("#c4a000"),g.css.toColor("#3465a4"),g.css.toColor("#75507b"),g.css.toColor("#06989a"),g.css.toColor("#d3d7cf"),g.css.toColor("#555753"),g.css.toColor("#ef2929"),g.css.toColor("#8ae234"),g.css.toColor("#fce94f"),g.css.toColor("#729fcf"),g.css.toColor("#ad7fa8"),g.css.toColor("#34e2e2"),g.css.toColor("#eeeeec")],E=[0,95,135,175,215,255];for(let x=0;x<216;x++){const k=E[x/36%6|0],D=E[x/6%6|0],R=E[x%6];w.push({css:g.channels.toCss(k,D,R),rgba:g.channels.toRgba(k,D,R)})}for(let x=0;x<24;x++){const k=8+10*x;w.push({css:g.channels.toCss(k,k,k),rgba:g.channels.toRgba(k,k,k)})}return w})());let S=s.ThemeService=class extends y.Disposable{get colors(){return this._colors}constructor(w){super(),this._optionsService=w,this._contrastCache=new u.ColorContrastCache,this._halfContrastCache=new u.ColorContrastCache,this._onChangeColors=this.register(new _.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:h,background:d,cursor:p,cursorAccent:v,selectionForeground:void 0,selectionBackgroundTransparent:C,selectionBackgroundOpaque:g.color.blend(d,C),selectionInactiveBackgroundTransparent:C,selectionInactiveBackgroundOpaque:g.color.blend(d,C),ansi:s.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this.register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}_setTheme(w={}){const E=this._colors;if(E.foreground=b(w.foreground,h),E.background=b(w.background,d),E.cursor=b(w.cursor,p),E.cursorAccent=b(w.cursorAccent,v),E.selectionBackgroundTransparent=b(w.selectionBackground,C),E.selectionBackgroundOpaque=g.color.blend(E.background,E.selectionBackgroundTransparent),E.selectionInactiveBackgroundTransparent=b(w.selectionInactiveBackground,E.selectionBackgroundTransparent),E.selectionInactiveBackgroundOpaque=g.color.blend(E.background,E.selectionInactiveBackgroundTransparent),E.selectionForeground=w.selectionForeground?b(w.selectionForeground,g.NULL_COLOR):void 0,E.selectionForeground===g.NULL_COLOR&&(E.selectionForeground=void 0),g.color.isOpaque(E.selectionBackgroundTransparent)&&(E.selectionBackgroundTransparent=g.color.opacity(E.selectionBackgroundTransparent,.3)),g.color.isOpaque(E.selectionInactiveBackgroundTransparent)&&(E.selectionInactiveBackgroundTransparent=g.color.opacity(E.selectionInactiveBackgroundTransparent,.3)),E.ansi=s.DEFAULT_ANSI_COLORS.slice(),E.ansi[0]=b(w.black,s.DEFAULT_ANSI_COLORS[0]),E.ansi[1]=b(w.red,s.DEFAULT_ANSI_COLORS[1]),E.ansi[2]=b(w.green,s.DEFAULT_ANSI_COLORS[2]),E.ansi[3]=b(w.yellow,s.DEFAULT_ANSI_COLORS[3]),E.ansi[4]=b(w.blue,s.DEFAULT_ANSI_COLORS[4]),E.ansi[5]=b(w.magenta,s.DEFAULT_ANSI_COLORS[5]),E.ansi[6]=b(w.cyan,s.DEFAULT_ANSI_COLORS[6]),E.ansi[7]=b(w.white,s.DEFAULT_ANSI_COLORS[7]),E.ansi[8]=b(w.brightBlack,s.DEFAULT_ANSI_COLORS[8]),E.ansi[9]=b(w.brightRed,s.DEFAULT_ANSI_COLORS[9]),E.ansi[10]=b(w.brightGreen,s.DEFAULT_ANSI_COLORS[10]),E.ansi[11]=b(w.brightYellow,s.DEFAULT_ANSI_COLORS[11]),E.ansi[12]=b(w.brightBlue,s.DEFAULT_ANSI_COLORS[12]),E.ansi[13]=b(w.brightMagenta,s.DEFAULT_ANSI_COLORS[13]),E.ansi[14]=b(w.brightCyan,s.DEFAULT_ANSI_COLORS[14]),E.ansi[15]=b(w.brightWhite,s.DEFAULT_ANSI_COLORS[15]),w.extendedAnsi){const x=Math.min(E.ansi.length-16,w.extendedAnsi.length);for(let k=0;k<x;k++)E.ansi[k+16]=b(w.extendedAnsi[k],s.DEFAULT_ANSI_COLORS[k+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(w){this._restoreColor(w),this._onChangeColors.fire(this.colors)}_restoreColor(w){if(w!==void 0)switch(w){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[w]=this._restoreColors.ansi[w]}else for(let E=0;E<this._restoreColors.ansi.length;++E)this._colors.ansi[E]=this._restoreColors.ansi[E]}modifyColors(w){w(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function b(w,E){if(w!==void 0)try{return g.css.toColor(w)}catch(x){}return E}s.ThemeService=S=o([f(0,m.IOptionsService)],S)},6349:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CircularList=void 0;const o=l(8460),f=l(844);class u extends f.Disposable{constructor(_){super(),this._maxLength=_,this.onDeleteEmitter=this.register(new o.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new o.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new o.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(_){if(this._maxLength===_)return;const y=new Array(_);for(let m=0;m<Math.min(_,this.length);m++)y[m]=this._array[this._getCyclicIndex(m)];this._array=y,this._maxLength=_,this._startIndex=0}get length(){return this._length}set length(_){if(_>this._length)for(let y=this._length;y<_;y++)this._array[y]=void 0;this._length=_}get(_){return this._array[this._getCyclicIndex(_)]}set(_,y){this._array[this._getCyclicIndex(_)]=y}push(_){this._array[this._getCyclicIndex(this._length)]=_,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(_,y,...m){if(y){for(let h=_;h<this._length-y;h++)this._array[this._getCyclicIndex(h)]=this._array[this._getCyclicIndex(h+y)];this._length-=y,this.onDeleteEmitter.fire({index:_,amount:y})}for(let h=this._length-1;h>=_;h--)this._array[this._getCyclicIndex(h+m.length)]=this._array[this._getCyclicIndex(h)];for(let h=0;h<m.length;h++)this._array[this._getCyclicIndex(_+h)]=m[h];if(m.length&&this.onInsertEmitter.fire({index:_,amount:m.length}),this._length+m.length>this._maxLength){const h=this._length+m.length-this._maxLength;this._startIndex+=h,this._length=this._maxLength,this.onTrimEmitter.fire(h)}else this._length+=m.length}trimStart(_){_>this._length&&(_=this._length),this._startIndex+=_,this._length-=_,this.onTrimEmitter.fire(_)}shiftElements(_,y,m){if(!(y<=0)){if(_<0||_>=this._length)throw new Error("start argument out of range");if(_+m<0)throw new Error("Cannot shift elements in list beyond index 0");if(m>0){for(let d=y-1;d>=0;d--)this.set(_+d+m,this.get(_+d));const h=_+y+m-this._length;if(h>0)for(this._length+=h;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let h=0;h<y;h++)this.set(_+h+m,this.get(_+h))}}_getCyclicIndex(_){return(this._startIndex+_)%this._maxLength}}s.CircularList=u},1439:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.clone=void 0,s.clone=function l(o,f=5){if(typeof o!="object")return o;const u=Array.isArray(o)?[]:{};for(const g in o)u[g]=f<=1?o[g]:o[g]&&l(o[g],f-1);return u}},8055:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.contrastRatio=s.toPaddedHex=s.rgba=s.rgb=s.css=s.color=s.channels=s.NULL_COLOR=void 0;const o=l(6114);let f=0,u=0,g=0,_=0;var y,m,h,d,p;function v(S){const b=S.toString(16);return b.length<2?"0"+b:b}function C(S,b){return S<b?(b+.05)/(S+.05):(S+.05)/(b+.05)}s.NULL_COLOR={css:"#00000000",rgba:0},function(S){S.toCss=function(b,w,E,x){return x!==void 0?`#${v(b)}${v(w)}${v(E)}${v(x)}`:`#${v(b)}${v(w)}${v(E)}`},S.toRgba=function(b,w,E,x=255){return(b<<24|w<<16|E<<8|x)>>>0}}(y||(s.channels=y={})),function(S){function b(w,E){return _=Math.round(255*E),[f,u,g]=p.toChannels(w.rgba),{css:y.toCss(f,u,g,_),rgba:y.toRgba(f,u,g,_)}}S.blend=function(w,E){if(_=(255&E.rgba)/255,_===1)return{css:E.css,rgba:E.rgba};const x=E.rgba>>24&255,k=E.rgba>>16&255,D=E.rgba>>8&255,R=w.rgba>>24&255,O=w.rgba>>16&255,G=w.rgba>>8&255;return f=R+Math.round((x-R)*_),u=O+Math.round((k-O)*_),g=G+Math.round((D-G)*_),{css:y.toCss(f,u,g),rgba:y.toRgba(f,u,g)}},S.isOpaque=function(w){return(255&w.rgba)==255},S.ensureContrastRatio=function(w,E,x){const k=p.ensureContrastRatio(w.rgba,E.rgba,x);if(k)return p.toColor(k>>24&255,k>>16&255,k>>8&255)},S.opaque=function(w){const E=(255|w.rgba)>>>0;return[f,u,g]=p.toChannels(E),{css:y.toCss(f,u,g),rgba:E}},S.opacity=b,S.multiplyOpacity=function(w,E){return _=255&w.rgba,b(w,_*E/255)},S.toColorRGB=function(w){return[w.rgba>>24&255,w.rgba>>16&255,w.rgba>>8&255]}}(m||(s.color=m={})),function(S){let b,w;if(!o.isNode){const E=document.createElement("canvas");E.width=1,E.height=1;const x=E.getContext("2d",{willReadFrequently:!0});x&&(b=x,b.globalCompositeOperation="copy",w=b.createLinearGradient(0,0,1,1))}S.toColor=function(E){if(E.match(/#[\da-f]{3,8}/i))switch(E.length){case 4:return f=parseInt(E.slice(1,2).repeat(2),16),u=parseInt(E.slice(2,3).repeat(2),16),g=parseInt(E.slice(3,4).repeat(2),16),p.toColor(f,u,g);case 5:return f=parseInt(E.slice(1,2).repeat(2),16),u=parseInt(E.slice(2,3).repeat(2),16),g=parseInt(E.slice(3,4).repeat(2),16),_=parseInt(E.slice(4,5).repeat(2),16),p.toColor(f,u,g,_);case 7:return{css:E,rgba:(parseInt(E.slice(1),16)<<8|255)>>>0};case 9:return{css:E,rgba:parseInt(E.slice(1),16)>>>0}}const x=E.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(x)return f=parseInt(x[1]),u=parseInt(x[2]),g=parseInt(x[3]),_=Math.round(255*(x[5]===void 0?1:parseFloat(x[5]))),p.toColor(f,u,g,_);if(!b||!w)throw new Error("css.toColor: Unsupported css format");if(b.fillStyle=w,b.fillStyle=E,typeof b.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(b.fillRect(0,0,1,1),[f,u,g,_]=b.getImageData(0,0,1,1).data,_!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(f,u,g,_),css:E}}}(h||(s.css=h={})),function(S){function b(w,E,x){const k=w/255,D=E/255,R=x/255;return .2126*(k<=.03928?k/12.92:Math.pow((k+.055)/1.055,2.4))+.7152*(D<=.03928?D/12.92:Math.pow((D+.055)/1.055,2.4))+.0722*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))}S.relativeLuminance=function(w){return b(w>>16&255,w>>8&255,255&w)},S.relativeLuminance2=b}(d||(s.rgb=d={})),function(S){function b(E,x,k){const D=E>>24&255,R=E>>16&255,O=E>>8&255;let G=x>>24&255,q=x>>16&255,X=x>>8&255,W=C(d.relativeLuminance2(G,q,X),d.relativeLuminance2(D,R,O));for(;W<k&&(G>0||q>0||X>0);)G-=Math.max(0,Math.ceil(.1*G)),q-=Math.max(0,Math.ceil(.1*q)),X-=Math.max(0,Math.ceil(.1*X)),W=C(d.relativeLuminance2(G,q,X),d.relativeLuminance2(D,R,O));return(G<<24|q<<16|X<<8|255)>>>0}function w(E,x,k){const D=E>>24&255,R=E>>16&255,O=E>>8&255;let G=x>>24&255,q=x>>16&255,X=x>>8&255,W=C(d.relativeLuminance2(G,q,X),d.relativeLuminance2(D,R,O));for(;W<k&&(G<255||q<255||X<255);)G=Math.min(255,G+Math.ceil(.1*(255-G))),q=Math.min(255,q+Math.ceil(.1*(255-q))),X=Math.min(255,X+Math.ceil(.1*(255-X))),W=C(d.relativeLuminance2(G,q,X),d.relativeLuminance2(D,R,O));return(G<<24|q<<16|X<<8|255)>>>0}S.ensureContrastRatio=function(E,x,k){const D=d.relativeLuminance(E>>8),R=d.relativeLuminance(x>>8);if(C(D,R)<k){if(R<D){const q=b(E,x,k),X=C(D,d.relativeLuminance(q>>8));if(X<k){const W=w(E,x,k);return X>C(D,d.relativeLuminance(W>>8))?q:W}return q}const O=w(E,x,k),G=C(D,d.relativeLuminance(O>>8));if(G<k){const q=b(E,x,k);return G>C(D,d.relativeLuminance(q>>8))?O:q}return O}},S.reduceLuminance=b,S.increaseLuminance=w,S.toChannels=function(E){return[E>>24&255,E>>16&255,E>>8&255,255&E]},S.toColor=function(E,x,k,D){return{css:y.toCss(E,x,k,D),rgba:y.toRgba(E,x,k,D)}}}(p||(s.rgba=p={})),s.toPaddedHex=v,s.contrastRatio=C},8969:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CoreTerminal=void 0;const o=l(844),f=l(2585),u=l(4348),g=l(7866),_=l(744),y=l(7302),m=l(6975),h=l(8460),d=l(1753),p=l(1480),v=l(7994),C=l(9282),S=l(5435),b=l(5981),w=l(2660);let E=!1;class x extends o.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new h.EventEmitter),this._onScroll.event(D=>{var R;(R=this._onScrollApi)===null||R===void 0||R.fire(D.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(D){for(const R in D)this.optionsService.options[R]=D[R]}constructor(D){super(),this._windowsWrappingHeuristics=this.register(new o.MutableDisposable),this._onBinary=this.register(new h.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new h.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new h.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new h.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new h.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new h.EventEmitter),this._instantiationService=new u.InstantiationService,this.optionsService=this.register(new y.OptionsService(D)),this._instantiationService.setService(f.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(_.BufferService)),this._instantiationService.setService(f.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(f.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(m.CoreService)),this._instantiationService.setService(f.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(d.CoreMouseService)),this._instantiationService.setService(f.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(p.UnicodeService)),this._instantiationService.setService(f.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(v.CharsetService),this._instantiationService.setService(f.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(w.OscLinkService),this._instantiationService.setService(f.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new S.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,h.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,h.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,h.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,h.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom())),this.register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this.register(this._bufferService.onScroll(R=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this.register(this._inputHandler.onScroll(R=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this.register(new b.WriteBuffer((R,O)=>this._inputHandler.parse(R,O))),this.register((0,h.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(D,R){this._writeBuffer.write(D,R)}writeSync(D,R){this._logService.logLevel<=f.LogLevelEnum.WARN&&!E&&(this._logService.warn("writeSync is unreliable and will be removed soon."),E=!0),this._writeBuffer.writeSync(D,R)}resize(D,R){isNaN(D)||isNaN(R)||(D=Math.max(D,_.MINIMUM_COLS),R=Math.max(R,_.MINIMUM_ROWS),this._bufferService.resize(D,R))}scroll(D,R=!1){this._bufferService.scroll(D,R)}scrollLines(D,R,O){this._bufferService.scrollLines(D,R,O)}scrollPages(D){this.scrollLines(D*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(D){const R=D-this._bufferService.buffer.ydisp;R!==0&&this.scrollLines(R)}registerEscHandler(D,R){return this._inputHandler.registerEscHandler(D,R)}registerDcsHandler(D,R){return this._inputHandler.registerDcsHandler(D,R)}registerCsiHandler(D,R){return this._inputHandler.registerCsiHandler(D,R)}registerOscHandler(D,R){return this._inputHandler.registerOscHandler(D,R)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let D=!1;const R=this.optionsService.rawOptions.windowsPty;R&&R.buildNumber!==void 0&&R.buildNumber!==void 0?D=R.backend==="conpty"&&R.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(D=!0),D?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const D=[];D.push(this.onLineFeed(C.updateWindowsModeWrappedState.bind(null,this._bufferService))),D.push(this.registerCsiHandler({final:"H"},()=>((0,C.updateWindowsModeWrappedState)(this._bufferService),!1))),this._windowsWrappingHeuristics.value=(0,o.toDisposable)(()=>{for(const R of D)R.dispose()})}}}s.CoreTerminal=x},8460:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.forwardEvent=s.EventEmitter=void 0,s.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=l=>(this._listeners.push(l),{dispose:()=>{if(!this._disposed){for(let o=0;o<this._listeners.length;o++)if(this._listeners[o]===l)return void this._listeners.splice(o,1)}}})),this._event}fire(l,o){const f=[];for(let u=0;u<this._listeners.length;u++)f.push(this._listeners[u]);for(let u=0;u<f.length;u++)f[u].call(void 0,l,o)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},s.forwardEvent=function(l,o){return l(f=>o.fire(f))}},5435:function(a,s,l){var o=this&&this.__decorate||function(W,L,P,N){var U,z=arguments.length,$=z<3?L:N===null?N=Object.getOwnPropertyDescriptor(L,P):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")$=Reflect.decorate(W,L,P,N);else for(var se=W.length-1;se>=0;se--)(U=W[se])&&($=(z<3?U($):z>3?U(L,P,$):U(L,P))||$);return z>3&&$&&Object.defineProperty(L,P,$),$},f=this&&this.__param||function(W,L){return function(P,N){L(P,N,W)}};Object.defineProperty(s,"__esModule",{value:!0}),s.InputHandler=s.WindowsOptionsReportType=void 0;const u=l(2584),g=l(7116),_=l(2015),y=l(844),m=l(482),h=l(8437),d=l(8460),p=l(643),v=l(511),C=l(3734),S=l(2585),b=l(6242),w=l(6351),E=l(5941),x={"(":0,")":1,"*":2,"+":3,"-":1,".":2},k=131072;function D(W,L){if(W>24)return L.setWinLines||!1;switch(W){case 1:return!!L.restoreWin;case 2:return!!L.minimizeWin;case 3:return!!L.setWinPosition;case 4:return!!L.setWinSizePixels;case 5:return!!L.raiseWin;case 6:return!!L.lowerWin;case 7:return!!L.refreshWin;case 8:return!!L.setWinSizeChars;case 9:return!!L.maximizeWin;case 10:return!!L.fullscreenWin;case 11:return!!L.getWinState;case 13:return!!L.getWinPosition;case 14:return!!L.getWinSizePixels;case 15:return!!L.getScreenSizePixels;case 16:return!!L.getCellSizePixels;case 18:return!!L.getWinSizeChars;case 19:return!!L.getScreenSizeChars;case 20:return!!L.getIconTitle;case 21:return!!L.getWinTitle;case 22:return!!L.pushTitle;case 23:return!!L.popTitle;case 24:return!!L.setWinLines}return!1}var R;(function(W){W[W.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",W[W.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(R||(s.WindowsOptionsReportType=R={}));let O=0;class G extends y.Disposable{getAttrData(){return this._curAttrData}constructor(L,P,N,U,z,$,se,te,de=new _.EscapeSequenceParser){super(),this._bufferService=L,this._charsetService=P,this._coreService=N,this._logService=U,this._optionsService=z,this._oscLinkService=$,this._coreMouseService=se,this._unicodeService=te,this._parser=de,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new m.StringToUtf32,this._utf8Decoder=new m.Utf8ToUtf32,this._workCell=new v.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=h.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=h.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new d.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new d.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new d.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new d.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new d.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new d.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new d.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new d.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new d.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new d.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new d.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new d.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new d.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new q(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate(I=>this._activeBuffer=I.activeBuffer)),this._parser.setCsiHandlerFallback((I,V)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(I),params:V.toArray()})}),this._parser.setEscHandlerFallback(I=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(I)})}),this._parser.setExecuteHandlerFallback(I=>{this._logService.debug("Unknown EXECUTE code: ",{code:I})}),this._parser.setOscHandlerFallback((I,V,Q)=>{this._logService.debug("Unknown OSC code: ",{identifier:I,action:V,data:Q})}),this._parser.setDcsHandlerFallback((I,V,Q)=>{V==="HOOK"&&(Q=Q.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(I),action:V,payload:Q})}),this._parser.setPrintHandler((I,V,Q)=>this.print(I,V,Q)),this._parser.registerCsiHandler({final:"@"},I=>this.insertChars(I)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},I=>this.scrollLeft(I)),this._parser.registerCsiHandler({final:"A"},I=>this.cursorUp(I)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},I=>this.scrollRight(I)),this._parser.registerCsiHandler({final:"B"},I=>this.cursorDown(I)),this._parser.registerCsiHandler({final:"C"},I=>this.cursorForward(I)),this._parser.registerCsiHandler({final:"D"},I=>this.cursorBackward(I)),this._parser.registerCsiHandler({final:"E"},I=>this.cursorNextLine(I)),this._parser.registerCsiHandler({final:"F"},I=>this.cursorPrecedingLine(I)),this._parser.registerCsiHandler({final:"G"},I=>this.cursorCharAbsolute(I)),this._parser.registerCsiHandler({final:"H"},I=>this.cursorPosition(I)),this._parser.registerCsiHandler({final:"I"},I=>this.cursorForwardTab(I)),this._parser.registerCsiHandler({final:"J"},I=>this.eraseInDisplay(I,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},I=>this.eraseInDisplay(I,!0)),this._parser.registerCsiHandler({final:"K"},I=>this.eraseInLine(I,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},I=>this.eraseInLine(I,!0)),this._parser.registerCsiHandler({final:"L"},I=>this.insertLines(I)),this._parser.registerCsiHandler({final:"M"},I=>this.deleteLines(I)),this._parser.registerCsiHandler({final:"P"},I=>this.deleteChars(I)),this._parser.registerCsiHandler({final:"S"},I=>this.scrollUp(I)),this._parser.registerCsiHandler({final:"T"},I=>this.scrollDown(I)),this._parser.registerCsiHandler({final:"X"},I=>this.eraseChars(I)),this._parser.registerCsiHandler({final:"Z"},I=>this.cursorBackwardTab(I)),this._parser.registerCsiHandler({final:"`"},I=>this.charPosAbsolute(I)),this._parser.registerCsiHandler({final:"a"},I=>this.hPositionRelative(I)),this._parser.registerCsiHandler({final:"b"},I=>this.repeatPrecedingCharacter(I)),this._parser.registerCsiHandler({final:"c"},I=>this.sendDeviceAttributesPrimary(I)),this._parser.registerCsiHandler({prefix:">",final:"c"},I=>this.sendDeviceAttributesSecondary(I)),this._parser.registerCsiHandler({final:"d"},I=>this.linePosAbsolute(I)),this._parser.registerCsiHandler({final:"e"},I=>this.vPositionRelative(I)),this._parser.registerCsiHandler({final:"f"},I=>this.hVPosition(I)),this._parser.registerCsiHandler({final:"g"},I=>this.tabClear(I)),this._parser.registerCsiHandler({final:"h"},I=>this.setMode(I)),this._parser.registerCsiHandler({prefix:"?",final:"h"},I=>this.setModePrivate(I)),this._parser.registerCsiHandler({final:"l"},I=>this.resetMode(I)),this._parser.registerCsiHandler({prefix:"?",final:"l"},I=>this.resetModePrivate(I)),this._parser.registerCsiHandler({final:"m"},I=>this.charAttributes(I)),this._parser.registerCsiHandler({final:"n"},I=>this.deviceStatus(I)),this._parser.registerCsiHandler({prefix:"?",final:"n"},I=>this.deviceStatusPrivate(I)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},I=>this.softReset(I)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},I=>this.setCursorStyle(I)),this._parser.registerCsiHandler({final:"r"},I=>this.setScrollRegion(I)),this._parser.registerCsiHandler({final:"s"},I=>this.saveCursor(I)),this._parser.registerCsiHandler({final:"t"},I=>this.windowOptions(I)),this._parser.registerCsiHandler({final:"u"},I=>this.restoreCursor(I)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},I=>this.insertColumns(I)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},I=>this.deleteColumns(I)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},I=>this.selectProtected(I)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},I=>this.requestMode(I,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},I=>this.requestMode(I,!1)),this._parser.setExecuteHandler(u.C0.BEL,()=>this.bell()),this._parser.setExecuteHandler(u.C0.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(u.C0.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(u.C0.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(u.C0.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(u.C0.BS,()=>this.backspace()),this._parser.setExecuteHandler(u.C0.HT,()=>this.tab()),this._parser.setExecuteHandler(u.C0.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(u.C0.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(u.C1.IND,()=>this.index()),this._parser.setExecuteHandler(u.C1.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(u.C1.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new b.OscHandler(I=>(this.setTitle(I),this.setIconName(I),!0))),this._parser.registerOscHandler(1,new b.OscHandler(I=>this.setIconName(I))),this._parser.registerOscHandler(2,new b.OscHandler(I=>this.setTitle(I))),this._parser.registerOscHandler(4,new b.OscHandler(I=>this.setOrReportIndexedColor(I))),this._parser.registerOscHandler(8,new b.OscHandler(I=>this.setHyperlink(I))),this._parser.registerOscHandler(10,new b.OscHandler(I=>this.setOrReportFgColor(I))),this._parser.registerOscHandler(11,new b.OscHandler(I=>this.setOrReportBgColor(I))),this._parser.registerOscHandler(12,new b.OscHandler(I=>this.setOrReportCursorColor(I))),this._parser.registerOscHandler(104,new b.OscHandler(I=>this.restoreIndexedColor(I))),this._parser.registerOscHandler(110,new b.OscHandler(I=>this.restoreFgColor(I))),this._parser.registerOscHandler(111,new b.OscHandler(I=>this.restoreBgColor(I))),this._parser.registerOscHandler(112,new b.OscHandler(I=>this.restoreCursorColor(I))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(const I in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:I},()=>this.selectCharset("("+I)),this._parser.registerEscHandler({intermediates:")",final:I},()=>this.selectCharset(")"+I)),this._parser.registerEscHandler({intermediates:"*",final:I},()=>this.selectCharset("*"+I)),this._parser.registerEscHandler({intermediates:"+",final:I},()=>this.selectCharset("+"+I)),this._parser.registerEscHandler({intermediates:"-",final:I},()=>this.selectCharset("-"+I)),this._parser.registerEscHandler({intermediates:".",final:I},()=>this.selectCharset("."+I)),this._parser.registerEscHandler({intermediates:"/",final:I},()=>this.selectCharset("/"+I));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(I=>(this._logService.error("Parsing error: ",I),I)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new w.DcsHandler((I,V)=>this.requestStatusString(I,V)))}_preserveStack(L,P,N,U){this._parseStack.paused=!0,this._parseStack.cursorStartX=L,this._parseStack.cursorStartY=P,this._parseStack.decodedLength=N,this._parseStack.position=U}_logSlowResolvingAsync(L){this._logService.logLevel<=S.LogLevelEnum.WARN&&Promise.race([L,new Promise((P,N)=>setTimeout(()=>N("#SLOW_TIMEOUT"),5e3))]).catch(P=>{if(P!=="#SLOW_TIMEOUT")throw P;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(L,P){let N,U=this._activeBuffer.x,z=this._activeBuffer.y,$=0;const se=this._parseStack.paused;if(se){if(N=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,P))return this._logSlowResolvingAsync(N),N;U=this._parseStack.cursorStartX,z=this._parseStack.cursorStartY,this._parseStack.paused=!1,L.length>k&&($=this._parseStack.position+k)}if(this._logService.logLevel<=S.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof L=="string"?` "${L}"`:` "${Array.prototype.map.call(L,te=>String.fromCharCode(te)).join("")}"`),typeof L=="string"?L.split("").map(te=>te.charCodeAt(0)):L),this._parseBuffer.length<L.length&&this._parseBuffer.length<k&&(this._parseBuffer=new Uint32Array(Math.min(L.length,k))),se||this._dirtyRowTracker.clearRange(),L.length>k)for(let te=$;te<L.length;te+=k){const de=te+k<L.length?te+k:L.length,I=typeof L=="string"?this._stringDecoder.decode(L.substring(te,de),this._parseBuffer):this._utf8Decoder.decode(L.subarray(te,de),this._parseBuffer);if(N=this._parser.parse(this._parseBuffer,I))return this._preserveStack(U,z,I,te),this._logSlowResolvingAsync(N),N}else if(!se){const te=typeof L=="string"?this._stringDecoder.decode(L,this._parseBuffer):this._utf8Decoder.decode(L,this._parseBuffer);if(N=this._parser.parse(this._parseBuffer,te))return this._preserveStack(U,z,te,0),this._logSlowResolvingAsync(N),N}this._activeBuffer.x===U&&this._activeBuffer.y===z||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(L,P,N){let U,z;const $=this._charsetService.charset,se=this._optionsService.rawOptions.screenReaderMode,te=this._bufferService.cols,de=this._coreService.decPrivateModes.wraparound,I=this._coreService.modes.insertMode,V=this._curAttrData;let Q=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&N-P>0&&Q.getWidth(this._activeBuffer.x-1)===2&&Q.setCellFromCodePoint(this._activeBuffer.x-1,0,1,V.fg,V.bg,V.extended);for(let j=P;j<N;++j){if(U=L[j],z=this._unicodeService.wcwidth(U),U<127&&$){const ce=$[String.fromCharCode(U)];ce&&(U=ce.charCodeAt(0))}if(se&&this._onA11yChar.fire((0,m.stringFromCodePoint)(U)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),z||!this._activeBuffer.x){if(this._activeBuffer.x+z-1>=te){if(de){for(;this._activeBuffer.x<te;)Q.setCellFromCodePoint(this._activeBuffer.x++,0,1,V.fg,V.bg,V.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),Q=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=te-1,z===2)continue}if(I&&(Q.insertCells(this._activeBuffer.x,z,this._activeBuffer.getNullCell(V),V),Q.getWidth(te-1)===2&&Q.setCellFromCodePoint(te-1,p.NULL_CELL_CODE,p.NULL_CELL_WIDTH,V.fg,V.bg,V.extended)),Q.setCellFromCodePoint(this._activeBuffer.x++,U,z,V.fg,V.bg,V.extended),z>0)for(;--z;)Q.setCellFromCodePoint(this._activeBuffer.x++,0,0,V.fg,V.bg,V.extended)}else Q.getWidth(this._activeBuffer.x-1)?Q.addCodepointToCell(this._activeBuffer.x-1,U):Q.addCodepointToCell(this._activeBuffer.x-2,U)}N-P>0&&(Q.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<te&&N-P>0&&Q.getWidth(this._activeBuffer.x)===0&&!Q.hasContent(this._activeBuffer.x)&&Q.setCellFromCodePoint(this._activeBuffer.x,0,1,V.fg,V.bg,V.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(L,P){return L.final!=="t"||L.prefix||L.intermediates?this._parser.registerCsiHandler(L,P):this._parser.registerCsiHandler(L,N=>!D(N.params[0],this._optionsService.rawOptions.windowOptions)||P(N))}registerDcsHandler(L,P){return this._parser.registerDcsHandler(L,new w.DcsHandler(P))}registerEscHandler(L,P){return this._parser.registerEscHandler(L,P)}registerOscHandler(L,P){return this._parser.registerOscHandler(L,new b.OscHandler(P))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var L;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((L=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||L===void 0)&&L.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);P.hasWidth(this._activeBuffer.x)&&!P.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const L=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-L),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(L=this._bufferService.cols-1){this._activeBuffer.x=Math.min(L,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(L,P){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=L,this._activeBuffer.y=this._activeBuffer.scrollTop+P):(this._activeBuffer.x=L,this._activeBuffer.y=P),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(L,P){this._restrictCursor(),this._setCursor(this._activeBuffer.x+L,this._activeBuffer.y+P)}cursorUp(L){const P=this._activeBuffer.y-this._activeBuffer.scrollTop;return P>=0?this._moveCursor(0,-Math.min(P,L.params[0]||1)):this._moveCursor(0,-(L.params[0]||1)),!0}cursorDown(L){const P=this._activeBuffer.scrollBottom-this._activeBuffer.y;return P>=0?this._moveCursor(0,Math.min(P,L.params[0]||1)):this._moveCursor(0,L.params[0]||1),!0}cursorForward(L){return this._moveCursor(L.params[0]||1,0),!0}cursorBackward(L){return this._moveCursor(-(L.params[0]||1),0),!0}cursorNextLine(L){return this.cursorDown(L),this._activeBuffer.x=0,!0}cursorPrecedingLine(L){return this.cursorUp(L),this._activeBuffer.x=0,!0}cursorCharAbsolute(L){return this._setCursor((L.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(L){return this._setCursor(L.length>=2?(L.params[1]||1)-1:0,(L.params[0]||1)-1),!0}charPosAbsolute(L){return this._setCursor((L.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(L){return this._moveCursor(L.params[0]||1,0),!0}linePosAbsolute(L){return this._setCursor(this._activeBuffer.x,(L.params[0]||1)-1),!0}vPositionRelative(L){return this._moveCursor(0,L.params[0]||1),!0}hVPosition(L){return this.cursorPosition(L),!0}tabClear(L){const P=L.params[0];return P===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:P===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(L){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=L.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(L){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=L.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(L){const P=L.params[0];return P===1&&(this._curAttrData.bg|=536870912),P!==2&&P!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(L,P,N,U=!1,z=!1){const $=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);$.replaceCells(P,N,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),z),U&&($.isWrapped=!1)}_resetBufferLine(L,P=!1){const N=this._activeBuffer.lines.get(this._activeBuffer.ybase+L);N&&(N.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),P),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+L),N.isWrapped=!1)}eraseInDisplay(L,P=!1){let N;switch(this._restrictCursor(this._bufferService.cols),L.params[0]){case 0:for(N=this._activeBuffer.y,this._dirtyRowTracker.markDirty(N),this._eraseInBufferLine(N++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);N<this._bufferService.rows;N++)this._resetBufferLine(N,P);this._dirtyRowTracker.markDirty(N);break;case 1:for(N=this._activeBuffer.y,this._dirtyRowTracker.markDirty(N),this._eraseInBufferLine(N,0,this._activeBuffer.x+1,!0,P),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(N+1).isWrapped=!1);N--;)this._resetBufferLine(N,P);this._dirtyRowTracker.markDirty(0);break;case 2:for(N=this._bufferService.rows,this._dirtyRowTracker.markDirty(N-1);N--;)this._resetBufferLine(N,P);this._dirtyRowTracker.markDirty(0);break;case 3:const U=this._activeBuffer.lines.length-this._bufferService.rows;U>0&&(this._activeBuffer.lines.trimStart(U),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-U,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-U,0),this._onScroll.fire(0))}return!0}eraseInLine(L,P=!1){switch(this._restrictCursor(this._bufferService.cols),L.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,P);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,P)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(L){this._restrictCursor();let P=L.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const N=this._activeBuffer.ybase+this._activeBuffer.y,U=this._bufferService.rows-1-this._activeBuffer.scrollBottom,z=this._bufferService.rows-1+this._activeBuffer.ybase-U+1;for(;P--;)this._activeBuffer.lines.splice(z-1,1),this._activeBuffer.lines.splice(N,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(L){this._restrictCursor();let P=L.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const N=this._activeBuffer.ybase+this._activeBuffer.y;let U;for(U=this._bufferService.rows-1-this._activeBuffer.scrollBottom,U=this._bufferService.rows-1+this._activeBuffer.ybase-U;P--;)this._activeBuffer.lines.splice(N,1),this._activeBuffer.lines.splice(U,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(L){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.insertCells(this._activeBuffer.x,L.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(L){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.deleteCells(this._activeBuffer.x,L.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(L){let P=L.params[0]||1;for(;P--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(L){let P=L.params[0]||1;for(;P--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(h.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(L){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=L.params[0]||1;for(let N=this._activeBuffer.scrollTop;N<=this._activeBuffer.scrollBottom;++N){const U=this._activeBuffer.lines.get(this._activeBuffer.ybase+N);U.deleteCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),U.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(L){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=L.params[0]||1;for(let N=this._activeBuffer.scrollTop;N<=this._activeBuffer.scrollBottom;++N){const U=this._activeBuffer.lines.get(this._activeBuffer.ybase+N);U.insertCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),U.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(L){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=L.params[0]||1;for(let N=this._activeBuffer.scrollTop;N<=this._activeBuffer.scrollBottom;++N){const U=this._activeBuffer.lines.get(this._activeBuffer.ybase+N);U.insertCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),U.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(L){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=L.params[0]||1;for(let N=this._activeBuffer.scrollTop;N<=this._activeBuffer.scrollBottom;++N){const U=this._activeBuffer.lines.get(this._activeBuffer.ybase+N);U.deleteCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),U.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(L){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(L.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(L){if(!this._parser.precedingCodepoint)return!0;const P=L.params[0]||1,N=new Uint32Array(P);for(let U=0;U<P;++U)N[U]=this._parser.precedingCodepoint;return this.print(N,0,N.length),!0}sendDeviceAttributesPrimary(L){return L.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(u.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(u.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(L){return L.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(u.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(u.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(L.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(u.C0.ESC+"[>83;40003;0c")),!0}_is(L){return(this._optionsService.rawOptions.termName+"").indexOf(L)===0}setMode(L){for(let P=0;P<L.length;P++)switch(L.params[P]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(L){for(let P=0;P<L.length;P++)switch(L.params[P]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),this._charsetService.setgCharset(1,g.DEFAULT_CHARSET),this._charsetService.setgCharset(2,g.DEFAULT_CHARSET),this._charsetService.setgCharset(3,g.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(L){for(let P=0;P<L.length;P++)switch(L.params[P]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(L){for(let P=0;P<L.length;P++)switch(L.params[P]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),L.params[P]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(L,P){const N=this._coreService.decPrivateModes,{activeProtocol:U,activeEncoding:z}=this._coreMouseService,$=this._coreService,{buffers:se,cols:te}=this._bufferService,{active:de,alt:I}=se,V=this._optionsService.rawOptions,Q=pe=>pe?1:2,j=L.params[0];return ce=j,ie=P?j===2?4:j===4?Q($.modes.insertMode):j===12?3:j===20?Q(V.convertEol):0:j===1?Q(N.applicationCursorKeys):j===3?V.windowOptions.setWinLines?te===80?2:te===132?1:0:0:j===6?Q(N.origin):j===7?Q(N.wraparound):j===8?3:j===9?Q(U==="X10"):j===12?Q(V.cursorBlink):j===25?Q(!$.isCursorHidden):j===45?Q(N.reverseWraparound):j===66?Q(N.applicationKeypad):j===67?4:j===1e3?Q(U==="VT200"):j===1002?Q(U==="DRAG"):j===1003?Q(U==="ANY"):j===1004?Q(N.sendFocus):j===1005?4:j===1006?Q(z==="SGR"):j===1015?4:j===1016?Q(z==="SGR_PIXELS"):j===1048?1:j===47||j===1047||j===1049?Q(de===I):j===2004?Q(N.bracketedPasteMode):0,$.triggerDataEvent(`${u.C0.ESC}[${P?"":"?"}${ce};${ie}$y`),!0;var ce,ie}_updateAttrColor(L,P,N,U,z){return P===2?(L|=50331648,L&=-16777216,L|=C.AttributeData.fromColorRGB([N,U,z])):P===5&&(L&=-50331904,L|=33554432|255&N),L}_extractColor(L,P,N){const U=[0,0,-1,0,0,0];let z=0,$=0;do{if(U[$+z]=L.params[P+$],L.hasSubParams(P+$)){const se=L.getSubParams(P+$);let te=0;do U[1]===5&&(z=1),U[$+te+1+z]=se[te];while(++te<se.length&&te+$+1+z<U.length);break}if(U[1]===5&&$+z>=2||U[1]===2&&$+z>=5)break;U[1]&&(z=1)}while(++$+P<L.length&&$+z<U.length);for(let se=2;se<U.length;++se)U[se]===-1&&(U[se]=0);switch(U[0]){case 38:N.fg=this._updateAttrColor(N.fg,U[1],U[3],U[4],U[5]);break;case 48:N.bg=this._updateAttrColor(N.bg,U[1],U[3],U[4],U[5]);break;case 58:N.extended=N.extended.clone(),N.extended.underlineColor=this._updateAttrColor(N.extended.underlineColor,U[1],U[3],U[4],U[5])}return $}_processUnderline(L,P){P.extended=P.extended.clone(),(!~L||L>5)&&(L=1),P.extended.underlineStyle=L,P.fg|=268435456,L===0&&(P.fg&=-268435457),P.updateExtended()}_processSGR0(L){L.fg=h.DEFAULT_ATTR_DATA.fg,L.bg=h.DEFAULT_ATTR_DATA.bg,L.extended=L.extended.clone(),L.extended.underlineStyle=0,L.extended.underlineColor&=-67108864,L.updateExtended()}charAttributes(L){if(L.length===1&&L.params[0]===0)return this._processSGR0(this._curAttrData),!0;const P=L.length;let N;const U=this._curAttrData;for(let z=0;z<P;z++)N=L.params[z],N>=30&&N<=37?(U.fg&=-50331904,U.fg|=16777216|N-30):N>=40&&N<=47?(U.bg&=-50331904,U.bg|=16777216|N-40):N>=90&&N<=97?(U.fg&=-50331904,U.fg|=16777224|N-90):N>=100&&N<=107?(U.bg&=-50331904,U.bg|=16777224|N-100):N===0?this._processSGR0(U):N===1?U.fg|=134217728:N===3?U.bg|=67108864:N===4?(U.fg|=268435456,this._processUnderline(L.hasSubParams(z)?L.getSubParams(z)[0]:1,U)):N===5?U.fg|=536870912:N===7?U.fg|=67108864:N===8?U.fg|=1073741824:N===9?U.fg|=2147483648:N===2?U.bg|=134217728:N===21?this._processUnderline(2,U):N===22?(U.fg&=-134217729,U.bg&=-134217729):N===23?U.bg&=-67108865:N===24?(U.fg&=-268435457,this._processUnderline(0,U)):N===25?U.fg&=-536870913:N===27?U.fg&=-67108865:N===28?U.fg&=-1073741825:N===29?U.fg&=2147483647:N===39?(U.fg&=-67108864,U.fg|=16777215&h.DEFAULT_ATTR_DATA.fg):N===49?(U.bg&=-67108864,U.bg|=16777215&h.DEFAULT_ATTR_DATA.bg):N===38||N===48||N===58?z+=this._extractColor(L,z,U):N===53?U.bg|=1073741824:N===55?U.bg&=-1073741825:N===59?(U.extended=U.extended.clone(),U.extended.underlineColor=-1,U.updateExtended()):N===100?(U.fg&=-67108864,U.fg|=16777215&h.DEFAULT_ATTR_DATA.fg,U.bg&=-67108864,U.bg|=16777215&h.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",N);return!0}deviceStatus(L){switch(L.params[0]){case 5:this._coreService.triggerDataEvent(`${u.C0.ESC}[0n`);break;case 6:const P=this._activeBuffer.y+1,N=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${u.C0.ESC}[${P};${N}R`)}return!0}deviceStatusPrivate(L){if(L.params[0]===6){const P=this._activeBuffer.y+1,N=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${u.C0.ESC}[?${P};${N}R`)}return!0}softReset(L){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=h.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(L){const P=L.params[0]||1;switch(P){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const N=P%2==1;return this._optionsService.options.cursorBlink=N,!0}setScrollRegion(L){const P=L.params[0]||1;let N;return(L.length<2||(N=L.params[1])>this._bufferService.rows||N===0)&&(N=this._bufferService.rows),N>P&&(this._activeBuffer.scrollTop=P-1,this._activeBuffer.scrollBottom=N-1,this._setCursor(0,0)),!0}windowOptions(L){if(!D(L.params[0],this._optionsService.rawOptions.windowOptions))return!0;const P=L.length>1?L.params[1]:0;switch(L.params[0]){case 14:P!==2&&this._onRequestWindowsOptionsReport.fire(R.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(R.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${u.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:P!==0&&P!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),P!==0&&P!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:P!==0&&P!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),P!==0&&P!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(L){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(L){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(L){return this._windowTitle=L,this._onTitleChange.fire(L),!0}setIconName(L){return this._iconName=L,!0}setOrReportIndexedColor(L){const P=[],N=L.split(";");for(;N.length>1;){const U=N.shift(),z=N.shift();if(/^\d+$/.exec(U)){const $=parseInt(U);if(X($))if(z==="?")P.push({type:0,index:$});else{const se=(0,E.parseColor)(z);se&&P.push({type:1,index:$,color:se})}}}return P.length&&this._onColor.fire(P),!0}setHyperlink(L){const P=L.split(";");return!(P.length<2)&&(P[1]?this._createHyperlink(P[0],P[1]):!P[0]&&this._finishHyperlink())}_createHyperlink(L,P){this._getCurrentLinkId()&&this._finishHyperlink();const N=L.split(":");let U;const z=N.findIndex($=>$.startsWith("id="));return z!==-1&&(U=N[z].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:U,uri:P}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(L,P){const N=L.split(";");for(let U=0;U<N.length&&!(P>=this._specialColors.length);++U,++P)if(N[U]==="?")this._onColor.fire([{type:0,index:this._specialColors[P]}]);else{const z=(0,E.parseColor)(N[U]);z&&this._onColor.fire([{type:1,index:this._specialColors[P],color:z}])}return!0}setOrReportFgColor(L){return this._setOrReportSpecialColor(L,0)}setOrReportBgColor(L){return this._setOrReportSpecialColor(L,1)}setOrReportCursorColor(L){return this._setOrReportSpecialColor(L,2)}restoreIndexedColor(L){if(!L)return this._onColor.fire([{type:2}]),!0;const P=[],N=L.split(";");for(let U=0;U<N.length;++U)if(/^\d+$/.exec(N[U])){const z=parseInt(N[U]);X(z)&&P.push({type:2,index:z})}return P.length&&this._onColor.fire(P),!0}restoreFgColor(L){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(L){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(L){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),!0}selectCharset(L){return L.length!==2?(this.selectDefaultCharset(),!0):(L[0]==="/"||this._charsetService.setgCharset(x[L[0]],g.CHARSETS[L[1]]||g.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const L=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,L,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=h.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=h.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(L){return this._charsetService.setgLevel(L),!0}screenAlignmentPattern(){const L=new v.CellData;L.content=4194304|"E".charCodeAt(0),L.fg=this._curAttrData.fg,L.bg=this._curAttrData.bg,this._setCursor(0,0);for(let P=0;P<this._bufferService.rows;++P){const N=this._activeBuffer.ybase+this._activeBuffer.y+P,U=this._activeBuffer.lines.get(N);U&&(U.fill(L),U.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(L,P){const N=this._bufferService.buffer,U=this._optionsService.rawOptions;return(z=>(this._coreService.triggerDataEvent(`${u.C0.ESC}${z}${u.C0.ESC}\\`),!0))(L==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:L==='"p'?'P1$r61;1"p':L==="r"?`P1$r${N.scrollTop+1};${N.scrollBottom+1}r`:L==="m"?"P1$r0m":L===" q"?`P1$r${{block:2,underline:4,bar:6}[U.cursorStyle]-(U.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(L,P){this._dirtyRowTracker.markRangeDirty(L,P)}}s.InputHandler=G;let q=class{constructor(W){this._bufferService=W,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(W){W<this.start?this.start=W:W>this.end&&(this.end=W)}markRangeDirty(W,L){W>L&&(O=W,W=L,L=O),W<this.start&&(this.start=W),L>this.end&&(this.end=L)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function X(W){return 0<=W&&W<256}q=o([f(0,S.IBufferService)],q)},844:(a,s)=>{function l(o){for(const f of o)f.dispose();o.length=0}Object.defineProperty(s,"__esModule",{value:!0}),s.getDisposeArrayDisposable=s.disposeArray=s.toDisposable=s.MutableDisposable=s.Disposable=void 0,s.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const o of this._disposables)o.dispose();this._disposables.length=0}register(o){return this._disposables.push(o),o}unregister(o){const f=this._disposables.indexOf(o);f!==-1&&this._disposables.splice(f,1)}},s.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(o){var f;this._isDisposed||o===this._value||((f=this._value)===null||f===void 0||f.dispose(),this._value=o)}clear(){this.value=void 0}dispose(){var o;this._isDisposed=!0,(o=this._value)===null||o===void 0||o.dispose(),this._value=void 0}},s.toDisposable=function(o){return{dispose:o}},s.disposeArray=l,s.getDisposeArrayDisposable=function(o){return{dispose:()=>l(o)}}},1505:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.FourKeyMap=s.TwoKeyMap=void 0;class l{constructor(){this._data={}}set(f,u,g){this._data[f]||(this._data[f]={}),this._data[f][u]=g}get(f,u){return this._data[f]?this._data[f][u]:void 0}clear(){this._data={}}}s.TwoKeyMap=l,s.FourKeyMap=class{constructor(){this._data=new l}set(o,f,u,g,_){this._data.get(o,f)||this._data.set(o,f,new l),this._data.get(o,f).set(u,g,_)}get(o,f,u,g){var _;return(_=this._data.get(o,f))===null||_===void 0?void 0:_.get(u,g)}clear(){this._data.clear()}}},6114:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.isChromeOS=s.isLinux=s.isWindows=s.isIphone=s.isIpad=s.isMac=s.getSafariVersion=s.isSafari=s.isLegacyEdge=s.isFirefox=s.isNode=void 0,s.isNode=typeof navigator=="undefined";const l=s.isNode?"node":navigator.userAgent,o=s.isNode?"node":navigator.platform;s.isFirefox=l.includes("Firefox"),s.isLegacyEdge=l.includes("Edge"),s.isSafari=/^((?!chrome|android).)*safari/i.test(l),s.getSafariVersion=function(){if(!s.isSafari)return 0;const f=l.match(/Version\/(\d+)/);return f===null||f.length<2?0:parseInt(f[1])},s.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(o),s.isIpad=o==="iPad",s.isIphone=o==="iPhone",s.isWindows=["Windows","Win16","Win32","WinCE"].includes(o),s.isLinux=o.indexOf("Linux")>=0,s.isChromeOS=/\bCrOS\b/.test(l)},6106:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.SortedList=void 0;let l=0;s.SortedList=class{constructor(o){this._getKey=o,this._array=[]}clear(){this._array.length=0}insert(o){this._array.length!==0?(l=this._search(this._getKey(o)),this._array.splice(l,0,o)):this._array.push(o)}delete(o){if(this._array.length===0)return!1;const f=this._getKey(o);if(f===void 0||(l=this._search(f),l===-1)||this._getKey(this._array[l])!==f)return!1;do if(this._array[l]===o)return this._array.splice(l,1),!0;while(++l<this._array.length&&this._getKey(this._array[l])===f);return!1}*getKeyIterator(o){if(this._array.length!==0&&(l=this._search(o),!(l<0||l>=this._array.length)&&this._getKey(this._array[l])===o))do yield this._array[l];while(++l<this._array.length&&this._getKey(this._array[l])===o)}forEachByKey(o,f){if(this._array.length!==0&&(l=this._search(o),!(l<0||l>=this._array.length)&&this._getKey(this._array[l])===o))do f(this._array[l]);while(++l<this._array.length&&this._getKey(this._array[l])===o)}values(){return[...this._array].values()}_search(o){let f=0,u=this._array.length-1;for(;u>=f;){let g=f+u>>1;const _=this._getKey(this._array[g]);if(_>o)u=g-1;else{if(!(_<o)){for(;g>0&&this._getKey(this._array[g-1])===o;)g--;return g}f=g+1}}return f}}},7226:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.DebouncedIdleTask=s.IdleTaskQueue=s.PriorityTaskQueue=void 0;const o=l(6114);class f{constructor(){this._tasks=[],this._i=0}enqueue(_){this._tasks.push(_),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(_){this._idleCallback=void 0;let y=0,m=0,h=_.timeRemaining(),d=0;for(;this._i<this._tasks.length;){if(y=Date.now(),this._tasks[this._i]()||this._i++,y=Math.max(1,Date.now()-y),m=Math.max(y,m),d=_.timeRemaining(),1.5*m>d)return h-y<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(h-y))}ms`),void this._start();h=d}this.clear()}}class u extends f{_requestCallback(_){return setTimeout(()=>_(this._createDeadline(16)))}_cancelCallback(_){clearTimeout(_)}_createDeadline(_){const y=Date.now()+_;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}s.PriorityTaskQueue=u,s.IdleTaskQueue=!o.isNode&&"requestIdleCallback"in window?class extends f{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:u,s.DebouncedIdleTask=class{constructor(){this._queue=new s.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.updateWindowsModeWrappedState=void 0;const o=l(643);s.updateWindowsModeWrappedState=function(f){const u=f.buffer.lines.get(f.buffer.ybase+f.buffer.y-1),g=u==null?void 0:u.get(f.cols-1),_=f.buffer.lines.get(f.buffer.ybase+f.buffer.y);_&&g&&(_.isWrapped=g[o.CHAR_DATA_CODE_INDEX]!==o.NULL_CELL_CODE&&g[o.CHAR_DATA_CODE_INDEX]!==o.WHITESPACE_CELL_CODE)}},3734:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ExtendedAttrs=s.AttributeData=void 0;class l{constructor(){this.fg=0,this.bg=0,this.extended=new o}static toColorRGB(u){return[u>>>16&255,u>>>8&255,255&u]}static fromColorRGB(u){return(255&u[0])<<16|(255&u[1])<<8|255&u[2]}clone(){const u=new l;return u.fg=this.fg,u.bg=this.bg,u.extended=this.extended.clone(),u}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}s.AttributeData=l;class o{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(u){this._ext=u}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(u){this._ext&=-469762049,this._ext|=u<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(u){this._ext&=-67108864,this._ext|=67108863&u}get urlId(){return this._urlId}set urlId(u){this._urlId=u}constructor(u=0,g=0){this._ext=0,this._urlId=0,this._ext=u,this._urlId=g}clone(){return new o(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}s.ExtendedAttrs=o},9092:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Buffer=s.MAX_BUFFER_SIZE=void 0;const o=l(6349),f=l(7226),u=l(3734),g=l(8437),_=l(4634),y=l(511),m=l(643),h=l(4863),d=l(7116);s.MAX_BUFFER_SIZE=4294967295,s.Buffer=class{constructor(p,v,C){this._hasScrollback=p,this._optionsService=v,this._bufferService=C,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=g.DEFAULT_ATTR_DATA.clone(),this.savedCharset=d.DEFAULT_CHARSET,this.markers=[],this._nullCell=y.CellData.fromCharData([0,m.NULL_CELL_CHAR,m.NULL_CELL_WIDTH,m.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,m.WHITESPACE_CELL_CHAR,m.WHITESPACE_CELL_WIDTH,m.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new f.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new o.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(p){return p?(this._nullCell.fg=p.fg,this._nullCell.bg=p.bg,this._nullCell.extended=p.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new u.ExtendedAttrs),this._nullCell}getWhitespaceCell(p){return p?(this._whitespaceCell.fg=p.fg,this._whitespaceCell.bg=p.bg,this._whitespaceCell.extended=p.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new u.ExtendedAttrs),this._whitespaceCell}getBlankLine(p,v){return new g.BufferLine(this._bufferService.cols,this.getNullCell(p),v)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const p=this.ybase+this.y-this.ydisp;return p>=0&&p<this._rows}_getCorrectBufferLength(p){if(!this._hasScrollback)return p;const v=p+this._optionsService.rawOptions.scrollback;return v>s.MAX_BUFFER_SIZE?s.MAX_BUFFER_SIZE:v}fillViewportRows(p){if(this.lines.length===0){p===void 0&&(p=g.DEFAULT_ATTR_DATA);let v=this._rows;for(;v--;)this.lines.push(this.getBlankLine(p))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new o.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(p,v){const C=this.getNullCell(g.DEFAULT_ATTR_DATA);let S=0;const b=this._getCorrectBufferLength(v);if(b>this.lines.maxLength&&(this.lines.maxLength=b),this.lines.length>0){if(this._cols<p)for(let E=0;E<this.lines.length;E++)S+=+this.lines.get(E).resize(p,C);let w=0;if(this._rows<v)for(let E=this._rows;E<v;E++)this.lines.length<v+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new g.BufferLine(p,C)):this.ybase>0&&this.lines.length<=this.ybase+this.y+w+1?(this.ybase--,w++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(p,C)));else for(let E=this._rows;E>v;E--)this.lines.length>v+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(b<this.lines.maxLength){const E=this.lines.length-b;E>0&&(this.lines.trimStart(E),this.ybase=Math.max(this.ybase-E,0),this.ydisp=Math.max(this.ydisp-E,0),this.savedY=Math.max(this.savedY-E,0)),this.lines.maxLength=b}this.x=Math.min(this.x,p-1),this.y=Math.min(this.y,v-1),w&&(this.y+=w),this.savedX=Math.min(this.savedX,p-1),this.scrollTop=0}if(this.scrollBottom=v-1,this._isReflowEnabled&&(this._reflow(p,v),this._cols>p))for(let w=0;w<this.lines.length;w++)S+=+this.lines.get(w).resize(p,C);this._cols=p,this._rows=v,this._memoryCleanupQueue.clear(),S>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let p=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,p=!1);let v=0;for(;this._memoryCleanupPosition<this.lines.length;)if(v+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),v>100)return!0;return p}get _isReflowEnabled(){const p=this._optionsService.rawOptions.windowsPty;return p&&p.buildNumber?this._hasScrollback&&p.backend==="conpty"&&p.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(p,v){this._cols!==p&&(p>this._cols?this._reflowLarger(p,v):this._reflowSmaller(p,v))}_reflowLarger(p,v){const C=(0,_.reflowLargerGetLinesToRemove)(this.lines,this._cols,p,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(C.length>0){const S=(0,_.reflowLargerCreateNewLayout)(this.lines,C);(0,_.reflowLargerApplyNewLayout)(this.lines,S.layout),this._reflowLargerAdjustViewport(p,v,S.countRemoved)}}_reflowLargerAdjustViewport(p,v,C){const S=this.getNullCell(g.DEFAULT_ATTR_DATA);let b=C;for(;b-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<v&&this.lines.push(new g.BufferLine(p,S))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-C,0)}_reflowSmaller(p,v){const C=this.getNullCell(g.DEFAULT_ATTR_DATA),S=[];let b=0;for(let w=this.lines.length-1;w>=0;w--){let E=this.lines.get(w);if(!E||!E.isWrapped&&E.getTrimmedLength()<=p)continue;const x=[E];for(;E.isWrapped&&w>0;)E=this.lines.get(--w),x.unshift(E);const k=this.ybase+this.y;if(k>=w&&k<w+x.length)continue;const D=x[x.length-1].getTrimmedLength(),R=(0,_.reflowSmallerGetNewLineLengths)(x,this._cols,p),O=R.length-x.length;let G;G=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+O):Math.max(0,this.lines.length-this.lines.maxLength+O);const q=[];for(let U=0;U<O;U++){const z=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);q.push(z)}q.length>0&&(S.push({start:w+x.length+b,newLines:q}),b+=q.length),x.push(...q);let X=R.length-1,W=R[X];W===0&&(X--,W=R[X]);let L=x.length-O-1,P=D;for(;L>=0;){const U=Math.min(P,W);if(x[X]===void 0)break;if(x[X].copyCellsFrom(x[L],P-U,W-U,U,!0),W-=U,W===0&&(X--,W=R[X]),P-=U,P===0){L--;const z=Math.max(L,0);P=(0,_.getWrappedLineTrimmedLength)(x,z,this._cols)}}for(let U=0;U<x.length;U++)R[U]<p&&x[U].setCell(R[U],C);let N=O-G;for(;N-- >0;)this.ybase===0?this.y<v-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+b)-v&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+O,this.ybase+v-1)}if(S.length>0){const w=[],E=[];for(let X=0;X<this.lines.length;X++)E.push(this.lines.get(X));const x=this.lines.length;let k=x-1,D=0,R=S[D];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+b);let O=0;for(let X=Math.min(this.lines.maxLength-1,x+b-1);X>=0;X--)if(R&&R.start>k+O){for(let W=R.newLines.length-1;W>=0;W--)this.lines.set(X--,R.newLines[W]);X++,w.push({index:k+1,amount:R.newLines.length}),O+=R.newLines.length,R=S[++D]}else this.lines.set(X,E[k--]);let G=0;for(let X=w.length-1;X>=0;X--)w[X].index+=G,this.lines.onInsertEmitter.fire(w[X]),G+=w[X].amount;const q=Math.max(0,x+b-this.lines.maxLength);q>0&&this.lines.onTrimEmitter.fire(q)}}translateBufferLineToString(p,v,C=0,S){const b=this.lines.get(p);return b?b.translateToString(v,C,S):""}getWrappedRangeForLine(p){let v=p,C=p;for(;v>0&&this.lines.get(v).isWrapped;)v--;for(;C+1<this.lines.length&&this.lines.get(C+1).isWrapped;)C++;return{first:v,last:C}}setupTabStops(p){for(p!=null?this.tabs[p]||(p=this.prevStop(p)):(this.tabs={},p=0);p<this._cols;p+=this._optionsService.rawOptions.tabStopWidth)this.tabs[p]=!0}prevStop(p){for(p==null&&(p=this.x);!this.tabs[--p]&&p>0;);return p>=this._cols?this._cols-1:p<0?0:p}nextStop(p){for(p==null&&(p=this.x);!this.tabs[++p]&&p<this._cols;);return p>=this._cols?this._cols-1:p<0?0:p}clearMarkers(p){this._isClearing=!0;for(let v=0;v<this.markers.length;v++)this.markers[v].line===p&&(this.markers[v].dispose(),this.markers.splice(v--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let p=0;p<this.markers.length;p++)this.markers[p].dispose(),this.markers.splice(p--,1);this._isClearing=!1}addMarker(p){const v=new h.Marker(p);return this.markers.push(v),v.register(this.lines.onTrim(C=>{v.line-=C,v.line<0&&v.dispose()})),v.register(this.lines.onInsert(C=>{v.line>=C.index&&(v.line+=C.amount)})),v.register(this.lines.onDelete(C=>{v.line>=C.index&&v.line<C.index+C.amount&&v.dispose(),v.line>C.index&&(v.line-=C.amount)})),v.register(v.onDispose(()=>this._removeMarker(v))),v}_removeMarker(p){this._isClearing||this.markers.splice(this.markers.indexOf(p),1)}}},8437:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BufferLine=s.DEFAULT_ATTR_DATA=void 0;const o=l(3734),f=l(511),u=l(643),g=l(482);s.DEFAULT_ATTR_DATA=Object.freeze(new o.AttributeData);let _=0;class y{constructor(h,d,p=!1){this.isWrapped=p,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*h);const v=d||f.CellData.fromCharData([0,u.NULL_CELL_CHAR,u.NULL_CELL_WIDTH,u.NULL_CELL_CODE]);for(let C=0;C<h;++C)this.setCell(C,v);this.length=h}get(h){const d=this._data[3*h+0],p=2097151&d;return[this._data[3*h+1],2097152&d?this._combined[h]:p?(0,g.stringFromCodePoint)(p):"",d>>22,2097152&d?this._combined[h].charCodeAt(this._combined[h].length-1):p]}set(h,d){this._data[3*h+1]=d[u.CHAR_DATA_ATTR_INDEX],d[u.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[h]=d[1],this._data[3*h+0]=2097152|h|d[u.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*h+0]=d[u.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|d[u.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(h){return this._data[3*h+0]>>22}hasWidth(h){return 12582912&this._data[3*h+0]}getFg(h){return this._data[3*h+1]}getBg(h){return this._data[3*h+2]}hasContent(h){return 4194303&this._data[3*h+0]}getCodePoint(h){const d=this._data[3*h+0];return 2097152&d?this._combined[h].charCodeAt(this._combined[h].length-1):2097151&d}isCombined(h){return 2097152&this._data[3*h+0]}getString(h){const d=this._data[3*h+0];return 2097152&d?this._combined[h]:2097151&d?(0,g.stringFromCodePoint)(2097151&d):""}isProtected(h){return 536870912&this._data[3*h+2]}loadCell(h,d){return _=3*h,d.content=this._data[_+0],d.fg=this._data[_+1],d.bg=this._data[_+2],2097152&d.content&&(d.combinedData=this._combined[h]),268435456&d.bg&&(d.extended=this._extendedAttrs[h]),d}setCell(h,d){2097152&d.content&&(this._combined[h]=d.combinedData),268435456&d.bg&&(this._extendedAttrs[h]=d.extended),this._data[3*h+0]=d.content,this._data[3*h+1]=d.fg,this._data[3*h+2]=d.bg}setCellFromCodePoint(h,d,p,v,C,S){268435456&C&&(this._extendedAttrs[h]=S),this._data[3*h+0]=d|p<<22,this._data[3*h+1]=v,this._data[3*h+2]=C}addCodepointToCell(h,d){let p=this._data[3*h+0];2097152&p?this._combined[h]+=(0,g.stringFromCodePoint)(d):(2097151&p?(this._combined[h]=(0,g.stringFromCodePoint)(2097151&p)+(0,g.stringFromCodePoint)(d),p&=-2097152,p|=2097152):p=d|4194304,this._data[3*h+0]=p)}insertCells(h,d,p,v){if((h%=this.length)&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h-1,0,1,(v==null?void 0:v.fg)||0,(v==null?void 0:v.bg)||0,(v==null?void 0:v.extended)||new o.ExtendedAttrs),d<this.length-h){const C=new f.CellData;for(let S=this.length-h-d-1;S>=0;--S)this.setCell(h+d+S,this.loadCell(h+S,C));for(let S=0;S<d;++S)this.setCell(h+S,p)}else for(let C=h;C<this.length;++C)this.setCell(C,p);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,(v==null?void 0:v.fg)||0,(v==null?void 0:v.bg)||0,(v==null?void 0:v.extended)||new o.ExtendedAttrs)}deleteCells(h,d,p,v){if(h%=this.length,d<this.length-h){const C=new f.CellData;for(let S=0;S<this.length-h-d;++S)this.setCell(h+S,this.loadCell(h+d+S,C));for(let S=this.length-d;S<this.length;++S)this.setCell(S,p)}else for(let C=h;C<this.length;++C)this.setCell(C,p);h&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h-1,0,1,(v==null?void 0:v.fg)||0,(v==null?void 0:v.bg)||0,(v==null?void 0:v.extended)||new o.ExtendedAttrs),this.getWidth(h)!==0||this.hasContent(h)||this.setCellFromCodePoint(h,0,1,(v==null?void 0:v.fg)||0,(v==null?void 0:v.bg)||0,(v==null?void 0:v.extended)||new o.ExtendedAttrs)}replaceCells(h,d,p,v,C=!1){if(C)for(h&&this.getWidth(h-1)===2&&!this.isProtected(h-1)&&this.setCellFromCodePoint(h-1,0,1,(v==null?void 0:v.fg)||0,(v==null?void 0:v.bg)||0,(v==null?void 0:v.extended)||new o.ExtendedAttrs),d<this.length&&this.getWidth(d-1)===2&&!this.isProtected(d)&&this.setCellFromCodePoint(d,0,1,(v==null?void 0:v.fg)||0,(v==null?void 0:v.bg)||0,(v==null?void 0:v.extended)||new o.ExtendedAttrs);h<d&&h<this.length;)this.isProtected(h)||this.setCell(h,p),h++;else for(h&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h-1,0,1,(v==null?void 0:v.fg)||0,(v==null?void 0:v.bg)||0,(v==null?void 0:v.extended)||new o.ExtendedAttrs),d<this.length&&this.getWidth(d-1)===2&&this.setCellFromCodePoint(d,0,1,(v==null?void 0:v.fg)||0,(v==null?void 0:v.bg)||0,(v==null?void 0:v.extended)||new o.ExtendedAttrs);h<d&&h<this.length;)this.setCell(h++,p)}resize(h,d){if(h===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const p=3*h;if(h>this.length){if(this._data.buffer.byteLength>=4*p)this._data=new Uint32Array(this._data.buffer,0,p);else{const v=new Uint32Array(p);v.set(this._data),this._data=v}for(let v=this.length;v<h;++v)this.setCell(v,d)}else{this._data=this._data.subarray(0,p);const v=Object.keys(this._combined);for(let S=0;S<v.length;S++){const b=parseInt(v[S],10);b>=h&&delete this._combined[b]}const C=Object.keys(this._extendedAttrs);for(let S=0;S<C.length;S++){const b=parseInt(C[S],10);b>=h&&delete this._extendedAttrs[b]}}return this.length=h,4*p*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const h=new Uint32Array(this._data.length);return h.set(this._data),this._data=h,1}return 0}fill(h,d=!1){if(d)for(let p=0;p<this.length;++p)this.isProtected(p)||this.setCell(p,h);else{this._combined={},this._extendedAttrs={};for(let p=0;p<this.length;++p)this.setCell(p,h)}}copyFrom(h){this.length!==h.length?this._data=new Uint32Array(h._data):this._data.set(h._data),this.length=h.length,this._combined={};for(const d in h._combined)this._combined[d]=h._combined[d];this._extendedAttrs={};for(const d in h._extendedAttrs)this._extendedAttrs[d]=h._extendedAttrs[d];this.isWrapped=h.isWrapped}clone(){const h=new y(0);h._data=new Uint32Array(this._data),h.length=this.length;for(const d in this._combined)h._combined[d]=this._combined[d];for(const d in this._extendedAttrs)h._extendedAttrs[d]=this._extendedAttrs[d];return h.isWrapped=this.isWrapped,h}getTrimmedLength(){for(let h=this.length-1;h>=0;--h)if(4194303&this._data[3*h+0])return h+(this._data[3*h+0]>>22);return 0}getNoBgTrimmedLength(){for(let h=this.length-1;h>=0;--h)if(4194303&this._data[3*h+0]||50331648&this._data[3*h+2])return h+(this._data[3*h+0]>>22);return 0}copyCellsFrom(h,d,p,v,C){const S=h._data;if(C)for(let w=v-1;w>=0;w--){for(let E=0;E<3;E++)this._data[3*(p+w)+E]=S[3*(d+w)+E];268435456&S[3*(d+w)+2]&&(this._extendedAttrs[p+w]=h._extendedAttrs[d+w])}else for(let w=0;w<v;w++){for(let E=0;E<3;E++)this._data[3*(p+w)+E]=S[3*(d+w)+E];268435456&S[3*(d+w)+2]&&(this._extendedAttrs[p+w]=h._extendedAttrs[d+w])}const b=Object.keys(h._combined);for(let w=0;w<b.length;w++){const E=parseInt(b[w],10);E>=d&&(this._combined[E-d+p]=h._combined[E])}}translateToString(h=!1,d=0,p=this.length){h&&(p=Math.min(p,this.getTrimmedLength()));let v="";for(;d<p;){const C=this._data[3*d+0],S=2097151&C;v+=2097152&C?this._combined[d]:S?(0,g.stringFromCodePoint)(S):u.WHITESPACE_CELL_CHAR,d+=C>>22||1}return v}}s.BufferLine=y},4841:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.getRangeLength=void 0,s.getRangeLength=function(l,o){if(l.start.y>l.end.y)throw new Error(`Buffer range end (${l.end.x}, ${l.end.y}) cannot be before start (${l.start.x}, ${l.start.y})`);return o*(l.end.y-l.start.y)+(l.end.x-l.start.x+1)}},4634:(a,s)=>{function l(o,f,u){if(f===o.length-1)return o[f].getTrimmedLength();const g=!o[f].hasContent(u-1)&&o[f].getWidth(u-1)===1,_=o[f+1].getWidth(0)===2;return g&&_?u-1:u}Object.defineProperty(s,"__esModule",{value:!0}),s.getWrappedLineTrimmedLength=s.reflowSmallerGetNewLineLengths=s.reflowLargerApplyNewLayout=s.reflowLargerCreateNewLayout=s.reflowLargerGetLinesToRemove=void 0,s.reflowLargerGetLinesToRemove=function(o,f,u,g,_){const y=[];for(let m=0;m<o.length-1;m++){let h=m,d=o.get(++h);if(!d.isWrapped)continue;const p=[o.get(m)];for(;h<o.length&&d.isWrapped;)p.push(d),d=o.get(++h);if(g>=m&&g<h){m+=p.length-1;continue}let v=0,C=l(p,v,f),S=1,b=0;for(;S<p.length;){const E=l(p,S,f),x=E-b,k=u-C,D=Math.min(x,k);p[v].copyCellsFrom(p[S],b,C,D,!1),C+=D,C===u&&(v++,C=0),b+=D,b===E&&(S++,b=0),C===0&&v!==0&&p[v-1].getWidth(u-1)===2&&(p[v].copyCellsFrom(p[v-1],u-1,C++,1,!1),p[v-1].setCell(u-1,_))}p[v].replaceCells(C,u,_);let w=0;for(let E=p.length-1;E>0&&(E>v||p[E].getTrimmedLength()===0);E--)w++;w>0&&(y.push(m+p.length-w),y.push(w)),m+=p.length-1}return y},s.reflowLargerCreateNewLayout=function(o,f){const u=[];let g=0,_=f[g],y=0;for(let m=0;m<o.length;m++)if(_===m){const h=f[++g];o.onDeleteEmitter.fire({index:m-y,amount:h}),m+=h-1,y+=h,_=f[++g]}else u.push(m);return{layout:u,countRemoved:y}},s.reflowLargerApplyNewLayout=function(o,f){const u=[];for(let g=0;g<f.length;g++)u.push(o.get(f[g]));for(let g=0;g<u.length;g++)o.set(g,u[g]);o.length=f.length},s.reflowSmallerGetNewLineLengths=function(o,f,u){const g=[],_=o.map((d,p)=>l(o,p,f)).reduce((d,p)=>d+p);let y=0,m=0,h=0;for(;h<_;){if(_-h<u){g.push(_-h);break}y+=u;const d=l(o,m,f);y>d&&(y-=d,m++);const p=o[m].getWidth(y-1)===2;p&&y--;const v=p?u-1:u;g.push(v),h+=v}return g},s.getWrappedLineTrimmedLength=l},5295:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BufferSet=void 0;const o=l(8460),f=l(844),u=l(9092);class g extends f.Disposable{constructor(y,m){super(),this._optionsService=y,this._bufferService=m,this._onBufferActivate=this.register(new o.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new u.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new u.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(y){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(y),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(y,m){this._normal.resize(y,m),this._alt.resize(y,m),this.setupTabStops(y)}setupTabStops(y){this._normal.setupTabStops(y),this._alt.setupTabStops(y)}}s.BufferSet=g},511:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CellData=void 0;const o=l(482),f=l(643),u=l(3734);class g extends u.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new u.ExtendedAttrs,this.combinedData=""}static fromCharData(y){const m=new g;return m.setFromCharData(y),m}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,o.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(y){this.fg=y[f.CHAR_DATA_ATTR_INDEX],this.bg=0;let m=!1;if(y[f.CHAR_DATA_CHAR_INDEX].length>2)m=!0;else if(y[f.CHAR_DATA_CHAR_INDEX].length===2){const h=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=h&&h<=56319){const d=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=d&&d<=57343?this.content=1024*(h-55296)+d-56320+65536|y[f.CHAR_DATA_WIDTH_INDEX]<<22:m=!0}else m=!0}else this.content=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[f.CHAR_DATA_WIDTH_INDEX]<<22;m&&(this.combinedData=y[f.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[f.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}s.CellData=g},643:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.WHITESPACE_CELL_CODE=s.WHITESPACE_CELL_WIDTH=s.WHITESPACE_CELL_CHAR=s.NULL_CELL_CODE=s.NULL_CELL_WIDTH=s.NULL_CELL_CHAR=s.CHAR_DATA_CODE_INDEX=s.CHAR_DATA_WIDTH_INDEX=s.CHAR_DATA_CHAR_INDEX=s.CHAR_DATA_ATTR_INDEX=s.DEFAULT_EXT=s.DEFAULT_ATTR=s.DEFAULT_COLOR=void 0,s.DEFAULT_COLOR=0,s.DEFAULT_ATTR=256|s.DEFAULT_COLOR<<9,s.DEFAULT_EXT=0,s.CHAR_DATA_ATTR_INDEX=0,s.CHAR_DATA_CHAR_INDEX=1,s.CHAR_DATA_WIDTH_INDEX=2,s.CHAR_DATA_CODE_INDEX=3,s.NULL_CELL_CHAR="",s.NULL_CELL_WIDTH=1,s.NULL_CELL_CODE=0,s.WHITESPACE_CELL_CHAR=" ",s.WHITESPACE_CELL_WIDTH=1,s.WHITESPACE_CELL_CODE=32},4863:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Marker=void 0;const o=l(8460),f=l(844);class u{get id(){return this._id}constructor(_){this.line=_,this.isDisposed=!1,this._disposables=[],this._id=u._nextId++,this._onDispose=this.register(new o.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,f.disposeArray)(this._disposables),this._disposables.length=0)}register(_){return this._disposables.push(_),_}}s.Marker=u,u._nextId=1},7116:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.DEFAULT_CHARSET=s.CHARSETS=void 0,s.CHARSETS={},s.DEFAULT_CHARSET=s.CHARSETS.B,s.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},s.CHARSETS.A={"#":"£"},s.CHARSETS.B=void 0,s.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},s.CHARSETS.C=s.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},s.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},s.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},s.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},s.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},s.CHARSETS.E=s.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},s.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},s.CHARSETS.H=s.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},s.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(a,s)=>{var l,o,f;Object.defineProperty(s,"__esModule",{value:!0}),s.C1_ESCAPED=s.C1=s.C0=void 0,function(u){u.NUL="\0",u.SOH="",u.STX="",u.ETX="",u.EOT="",u.ENQ="",u.ACK="",u.BEL="\x07",u.BS="\b",u.HT="	",u.LF=`
`,u.VT="\v",u.FF="\f",u.CR="\r",u.SO="",u.SI="",u.DLE="",u.DC1="",u.DC2="",u.DC3="",u.DC4="",u.NAK="",u.SYN="",u.ETB="",u.CAN="",u.EM="",u.SUB="",u.ESC="\x1B",u.FS="",u.GS="",u.RS="",u.US="",u.SP=" ",u.DEL=""}(l||(s.C0=l={})),function(u){u.PAD="€",u.HOP="",u.BPH="‚",u.NBH="ƒ",u.IND="„",u.NEL="…",u.SSA="†",u.ESA="‡",u.HTS="ˆ",u.HTJ="‰",u.VTS="Š",u.PLD="‹",u.PLU="Œ",u.RI="",u.SS2="Ž",u.SS3="",u.DCS="",u.PU1="‘",u.PU2="’",u.STS="“",u.CCH="”",u.MW="•",u.SPA="–",u.EPA="—",u.SOS="˜",u.SGCI="™",u.SCI="š",u.CSI="›",u.ST="œ",u.OSC="",u.PM="ž",u.APC="Ÿ"}(o||(s.C1=o={})),function(u){u.ST=`${l.ESC}\\`}(f||(s.C1_ESCAPED=f={}))},7399:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.evaluateKeyboardEvent=void 0;const o=l(2584),f={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};s.evaluateKeyboardEvent=function(u,g,_,y){const m={type:0,cancel:!1,key:void 0},h=(u.shiftKey?1:0)|(u.altKey?2:0)|(u.ctrlKey?4:0)|(u.metaKey?8:0);switch(u.keyCode){case 0:u.key==="UIKeyInputUpArrow"?m.key=g?o.C0.ESC+"OA":o.C0.ESC+"[A":u.key==="UIKeyInputLeftArrow"?m.key=g?o.C0.ESC+"OD":o.C0.ESC+"[D":u.key==="UIKeyInputRightArrow"?m.key=g?o.C0.ESC+"OC":o.C0.ESC+"[C":u.key==="UIKeyInputDownArrow"&&(m.key=g?o.C0.ESC+"OB":o.C0.ESC+"[B");break;case 8:if(u.altKey){m.key=o.C0.ESC+o.C0.DEL;break}m.key=o.C0.DEL;break;case 9:if(u.shiftKey){m.key=o.C0.ESC+"[Z";break}m.key=o.C0.HT,m.cancel=!0;break;case 13:m.key=u.altKey?o.C0.ESC+o.C0.CR:o.C0.CR,m.cancel=!0;break;case 27:m.key=o.C0.ESC,u.altKey&&(m.key=o.C0.ESC+o.C0.ESC),m.cancel=!0;break;case 37:if(u.metaKey)break;h?(m.key=o.C0.ESC+"[1;"+(h+1)+"D",m.key===o.C0.ESC+"[1;3D"&&(m.key=o.C0.ESC+(_?"b":"[1;5D"))):m.key=g?o.C0.ESC+"OD":o.C0.ESC+"[D";break;case 39:if(u.metaKey)break;h?(m.key=o.C0.ESC+"[1;"+(h+1)+"C",m.key===o.C0.ESC+"[1;3C"&&(m.key=o.C0.ESC+(_?"f":"[1;5C"))):m.key=g?o.C0.ESC+"OC":o.C0.ESC+"[C";break;case 38:if(u.metaKey)break;h?(m.key=o.C0.ESC+"[1;"+(h+1)+"A",_||m.key!==o.C0.ESC+"[1;3A"||(m.key=o.C0.ESC+"[1;5A")):m.key=g?o.C0.ESC+"OA":o.C0.ESC+"[A";break;case 40:if(u.metaKey)break;h?(m.key=o.C0.ESC+"[1;"+(h+1)+"B",_||m.key!==o.C0.ESC+"[1;3B"||(m.key=o.C0.ESC+"[1;5B")):m.key=g?o.C0.ESC+"OB":o.C0.ESC+"[B";break;case 45:u.shiftKey||u.ctrlKey||(m.key=o.C0.ESC+"[2~");break;case 46:m.key=h?o.C0.ESC+"[3;"+(h+1)+"~":o.C0.ESC+"[3~";break;case 36:m.key=h?o.C0.ESC+"[1;"+(h+1)+"H":g?o.C0.ESC+"OH":o.C0.ESC+"[H";break;case 35:m.key=h?o.C0.ESC+"[1;"+(h+1)+"F":g?o.C0.ESC+"OF":o.C0.ESC+"[F";break;case 33:u.shiftKey?m.type=2:u.ctrlKey?m.key=o.C0.ESC+"[5;"+(h+1)+"~":m.key=o.C0.ESC+"[5~";break;case 34:u.shiftKey?m.type=3:u.ctrlKey?m.key=o.C0.ESC+"[6;"+(h+1)+"~":m.key=o.C0.ESC+"[6~";break;case 112:m.key=h?o.C0.ESC+"[1;"+(h+1)+"P":o.C0.ESC+"OP";break;case 113:m.key=h?o.C0.ESC+"[1;"+(h+1)+"Q":o.C0.ESC+"OQ";break;case 114:m.key=h?o.C0.ESC+"[1;"+(h+1)+"R":o.C0.ESC+"OR";break;case 115:m.key=h?o.C0.ESC+"[1;"+(h+1)+"S":o.C0.ESC+"OS";break;case 116:m.key=h?o.C0.ESC+"[15;"+(h+1)+"~":o.C0.ESC+"[15~";break;case 117:m.key=h?o.C0.ESC+"[17;"+(h+1)+"~":o.C0.ESC+"[17~";break;case 118:m.key=h?o.C0.ESC+"[18;"+(h+1)+"~":o.C0.ESC+"[18~";break;case 119:m.key=h?o.C0.ESC+"[19;"+(h+1)+"~":o.C0.ESC+"[19~";break;case 120:m.key=h?o.C0.ESC+"[20;"+(h+1)+"~":o.C0.ESC+"[20~";break;case 121:m.key=h?o.C0.ESC+"[21;"+(h+1)+"~":o.C0.ESC+"[21~";break;case 122:m.key=h?o.C0.ESC+"[23;"+(h+1)+"~":o.C0.ESC+"[23~";break;case 123:m.key=h?o.C0.ESC+"[24;"+(h+1)+"~":o.C0.ESC+"[24~";break;default:if(!u.ctrlKey||u.shiftKey||u.altKey||u.metaKey)if(_&&!y||!u.altKey||u.metaKey)!_||u.altKey||u.ctrlKey||u.shiftKey||!u.metaKey?u.key&&!u.ctrlKey&&!u.altKey&&!u.metaKey&&u.keyCode>=48&&u.key.length===1?m.key=u.key:u.key&&u.ctrlKey&&(u.key==="_"&&(m.key=o.C0.US),u.key==="@"&&(m.key=o.C0.NUL)):u.keyCode===65&&(m.type=1);else{const d=f[u.keyCode],p=d==null?void 0:d[u.shiftKey?1:0];if(p)m.key=o.C0.ESC+p;else if(u.keyCode>=65&&u.keyCode<=90){const v=u.ctrlKey?u.keyCode-64:u.keyCode+32;let C=String.fromCharCode(v);u.shiftKey&&(C=C.toUpperCase()),m.key=o.C0.ESC+C}else if(u.keyCode===32)m.key=o.C0.ESC+(u.ctrlKey?o.C0.NUL:" ");else if(u.key==="Dead"&&u.code.startsWith("Key")){let v=u.code.slice(3,4);u.shiftKey||(v=v.toLowerCase()),m.key=o.C0.ESC+v,m.cancel=!0}}else u.keyCode>=65&&u.keyCode<=90?m.key=String.fromCharCode(u.keyCode-64):u.keyCode===32?m.key=o.C0.NUL:u.keyCode>=51&&u.keyCode<=55?m.key=String.fromCharCode(u.keyCode-51+27):u.keyCode===56?m.key=o.C0.DEL:u.keyCode===219?m.key=o.C0.ESC:u.keyCode===220?m.key=o.C0.FS:u.keyCode===221&&(m.key=o.C0.GS)}return m}},482:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Utf8ToUtf32=s.StringToUtf32=s.utf32ToString=s.stringFromCodePoint=void 0,s.stringFromCodePoint=function(l){return l>65535?(l-=65536,String.fromCharCode(55296+(l>>10))+String.fromCharCode(l%1024+56320)):String.fromCharCode(l)},s.utf32ToString=function(l,o=0,f=l.length){let u="";for(let g=o;g<f;++g){let _=l[g];_>65535?(_-=65536,u+=String.fromCharCode(55296+(_>>10))+String.fromCharCode(_%1024+56320)):u+=String.fromCharCode(_)}return u},s.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(l,o){const f=l.length;if(!f)return 0;let u=0,g=0;if(this._interim){const _=l.charCodeAt(g++);56320<=_&&_<=57343?o[u++]=1024*(this._interim-55296)+_-56320+65536:(o[u++]=this._interim,o[u++]=_),this._interim=0}for(let _=g;_<f;++_){const y=l.charCodeAt(_);if(55296<=y&&y<=56319){if(++_>=f)return this._interim=y,u;const m=l.charCodeAt(_);56320<=m&&m<=57343?o[u++]=1024*(y-55296)+m-56320+65536:(o[u++]=y,o[u++]=m)}else y!==65279&&(o[u++]=y)}return u}},s.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(l,o){const f=l.length;if(!f)return 0;let u,g,_,y,m=0,h=0,d=0;if(this.interim[0]){let C=!1,S=this.interim[0];S&=(224&S)==192?31:(240&S)==224?15:7;let b,w=0;for(;(b=63&this.interim[++w])&&w<4;)S<<=6,S|=b;const E=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,x=E-w;for(;d<x;){if(d>=f)return 0;if(b=l[d++],(192&b)!=128){d--,C=!0;break}this.interim[w++]=b,S<<=6,S|=63&b}C||(E===2?S<128?d--:o[m++]=S:E===3?S<2048||S>=55296&&S<=57343||S===65279||(o[m++]=S):S<65536||S>1114111||(o[m++]=S)),this.interim.fill(0)}const p=f-4;let v=d;for(;v<f;){for(;!(!(v<p)||128&(u=l[v])||128&(g=l[v+1])||128&(_=l[v+2])||128&(y=l[v+3]));)o[m++]=u,o[m++]=g,o[m++]=_,o[m++]=y,v+=4;if(u=l[v++],u<128)o[m++]=u;else if((224&u)==192){if(v>=f)return this.interim[0]=u,m;if(g=l[v++],(192&g)!=128){v--;continue}if(h=(31&u)<<6|63&g,h<128){v--;continue}o[m++]=h}else if((240&u)==224){if(v>=f)return this.interim[0]=u,m;if(g=l[v++],(192&g)!=128){v--;continue}if(v>=f)return this.interim[0]=u,this.interim[1]=g,m;if(_=l[v++],(192&_)!=128){v--;continue}if(h=(15&u)<<12|(63&g)<<6|63&_,h<2048||h>=55296&&h<=57343||h===65279)continue;o[m++]=h}else if((248&u)==240){if(v>=f)return this.interim[0]=u,m;if(g=l[v++],(192&g)!=128){v--;continue}if(v>=f)return this.interim[0]=u,this.interim[1]=g,m;if(_=l[v++],(192&_)!=128){v--;continue}if(v>=f)return this.interim[0]=u,this.interim[1]=g,this.interim[2]=_,m;if(y=l[v++],(192&y)!=128){v--;continue}if(h=(7&u)<<18|(63&g)<<12|(63&_)<<6|63&y,h<65536||h>1114111)continue;o[m++]=h}}return m}}},225:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.UnicodeV6=void 0;const l=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],o=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let f;s.UnicodeV6=class{constructor(){if(this.version="6",!f){f=new Uint8Array(65536),f.fill(1),f[0]=0,f.fill(0,1,32),f.fill(0,127,160),f.fill(2,4352,4448),f[9001]=2,f[9002]=2,f.fill(2,11904,42192),f[12351]=1,f.fill(2,44032,55204),f.fill(2,63744,64256),f.fill(2,65040,65050),f.fill(2,65072,65136),f.fill(2,65280,65377),f.fill(2,65504,65511);for(let u=0;u<l.length;++u)f.fill(0,l[u][0],l[u][1]+1)}}wcwidth(u){return u<32?0:u<127?1:u<65536?f[u]:function(g,_){let y,m=0,h=_.length-1;if(g<_[0][0]||g>_[h][1])return!1;for(;h>=m;)if(y=m+h>>1,g>_[y][1])m=y+1;else{if(!(g<_[y][0]))return!0;h=y-1}return!1}(u,o)?0:u>=131072&&u<=196605||u>=196608&&u<=262141?2:1}}},5981:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.WriteBuffer=void 0;const o=l(8460),f=l(844);class u extends f.Disposable{constructor(_){super(),this._action=_,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new o.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(_,y){if(y!==void 0&&this._syncCalls>y)return void(this._syncCalls=0);if(this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let m;for(this._isSyncWriting=!0;m=this._writeBuffer.shift();){this._action(m);const h=this._callbacks.shift();h&&h()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(_,y){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(y),void this._innerWrite();setTimeout(()=>this._innerWrite())}this._pendingData+=_.length,this._writeBuffer.push(_),this._callbacks.push(y)}_innerWrite(_=0,y=!0){const m=_||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const h=this._writeBuffer[this._bufferOffset],d=this._action(h,y);if(d){const v=C=>Date.now()-m>=12?setTimeout(()=>this._innerWrite(0,C)):this._innerWrite(m,C);return void d.catch(C=>(queueMicrotask(()=>{throw C}),Promise.resolve(!1))).then(v)}const p=this._callbacks[this._bufferOffset];if(p&&p(),this._bufferOffset++,this._pendingData-=h.length,Date.now()-m>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}s.WriteBuffer=u},5941:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.toRgbString=s.parseColor=void 0;const l=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,o=/^[\da-f]+$/;function f(u,g){const _=u.toString(16),y=_.length<2?"0"+_:_;switch(g){case 4:return _[0];case 8:return y;case 12:return(y+y).slice(0,3);default:return y+y}}s.parseColor=function(u){if(!u)return;let g=u.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const _=l.exec(g);if(_){const y=_[1]?15:_[4]?255:_[7]?4095:65535;return[Math.round(parseInt(_[1]||_[4]||_[7]||_[10],16)/y*255),Math.round(parseInt(_[2]||_[5]||_[8]||_[11],16)/y*255),Math.round(parseInt(_[3]||_[6]||_[9]||_[12],16)/y*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),o.exec(g)&&[3,6,9,12].includes(g.length))){const _=g.length/3,y=[0,0,0];for(let m=0;m<3;++m){const h=parseInt(g.slice(_*m,_*m+_),16);y[m]=_===1?h<<4:_===2?h:_===3?h>>4:h>>8}return y}},s.toRgbString=function(u,g=16){const[_,y,m]=u;return`rgb:${f(_,g)}/${f(y,g)}/${f(m,g)}`}},5770:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.PAYLOAD_LIMIT=void 0,s.PAYLOAD_LIMIT=1e7},6351:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.DcsHandler=s.DcsParser=void 0;const o=l(482),f=l(8742),u=l(5770),g=[];s.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=g,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}registerHandler(y,m){this._handlers[y]===void 0&&(this._handlers[y]=[]);const h=this._handlers[y];return h.push(m),{dispose:()=>{const d=h.indexOf(m);d!==-1&&h.splice(d,1)}}}clearHandler(y){this._handlers[y]&&delete this._handlers[y]}setHandlerFallback(y){this._handlerFb=y}reset(){if(this._active.length)for(let y=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;y>=0;--y)this._active[y].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(y,m){if(this.reset(),this._ident=y,this._active=this._handlers[y]||g,this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].hook(m);else this._handlerFb(this._ident,"HOOK",m)}put(y,m,h){if(this._active.length)for(let d=this._active.length-1;d>=0;d--)this._active[d].put(y,m,h);else this._handlerFb(this._ident,"PUT",(0,o.utf32ToString)(y,m,h))}unhook(y,m=!0){if(this._active.length){let h=!1,d=this._active.length-1,p=!1;if(this._stack.paused&&(d=this._stack.loopPosition-1,h=m,p=this._stack.fallThrough,this._stack.paused=!1),!p&&h===!1){for(;d>=0&&(h=this._active[d].unhook(y),h!==!0);d--)if(h instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!1,h;d--}for(;d>=0;d--)if(h=this._active[d].unhook(!1),h instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=d,this._stack.fallThrough=!0,h}else this._handlerFb(this._ident,"UNHOOK",y);this._active=g,this._ident=0}};const _=new f.Params;_.addParam(0),s.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=_,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():_,this._data="",this._hitLimit=!1}put(y,m,h){this._hitLimit||(this._data+=(0,o.utf32ToString)(y,m,h),this._data.length>u.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let m=!1;if(this._hitLimit)m=!1;else if(y&&(m=this._handler(this._data,this._params),m instanceof Promise))return m.then(h=>(this._params=_,this._data="",this._hitLimit=!1,h));return this._params=_,this._data="",this._hitLimit=!1,m}}},2015:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.EscapeSequenceParser=s.VT500_TRANSITION_TABLE=s.TransitionTable=void 0;const o=l(844),f=l(8742),u=l(6242),g=l(6351);class _{constructor(d){this.table=new Uint8Array(d)}setDefault(d,p){this.table.fill(d<<4|p)}add(d,p,v,C){this.table[p<<8|d]=v<<4|C}addMany(d,p,v,C){for(let S=0;S<d.length;S++)this.table[p<<8|d[S]]=v<<4|C}}s.TransitionTable=_;const y=160;s.VT500_TRANSITION_TABLE=function(){const h=new _(4095),d=Array.apply(null,Array(256)).map((w,E)=>E),p=(w,E)=>d.slice(w,E),v=p(32,127),C=p(0,24);C.push(25),C.push.apply(C,p(28,32));const S=p(0,14);let b;for(b in h.setDefault(1,0),h.addMany(v,0,2,0),S)h.addMany([24,26,153,154],b,3,0),h.addMany(p(128,144),b,3,0),h.addMany(p(144,152),b,3,0),h.add(156,b,0,0),h.add(27,b,11,1),h.add(157,b,4,8),h.addMany([152,158,159],b,0,7),h.add(155,b,11,3),h.add(144,b,11,9);return h.addMany(C,0,3,0),h.addMany(C,1,3,1),h.add(127,1,0,1),h.addMany(C,8,0,8),h.addMany(C,3,3,3),h.add(127,3,0,3),h.addMany(C,4,3,4),h.add(127,4,0,4),h.addMany(C,6,3,6),h.addMany(C,5,3,5),h.add(127,5,0,5),h.addMany(C,2,3,2),h.add(127,2,0,2),h.add(93,1,4,8),h.addMany(v,8,5,8),h.add(127,8,5,8),h.addMany([156,27,24,26,7],8,6,0),h.addMany(p(28,32),8,0,8),h.addMany([88,94,95],1,0,7),h.addMany(v,7,0,7),h.addMany(C,7,0,7),h.add(156,7,0,0),h.add(127,7,0,7),h.add(91,1,11,3),h.addMany(p(64,127),3,7,0),h.addMany(p(48,60),3,8,4),h.addMany([60,61,62,63],3,9,4),h.addMany(p(48,60),4,8,4),h.addMany(p(64,127),4,7,0),h.addMany([60,61,62,63],4,0,6),h.addMany(p(32,64),6,0,6),h.add(127,6,0,6),h.addMany(p(64,127),6,0,0),h.addMany(p(32,48),3,9,5),h.addMany(p(32,48),5,9,5),h.addMany(p(48,64),5,0,6),h.addMany(p(64,127),5,7,0),h.addMany(p(32,48),4,9,5),h.addMany(p(32,48),1,9,2),h.addMany(p(32,48),2,9,2),h.addMany(p(48,127),2,10,0),h.addMany(p(48,80),1,10,0),h.addMany(p(81,88),1,10,0),h.addMany([89,90,92],1,10,0),h.addMany(p(96,127),1,10,0),h.add(80,1,11,9),h.addMany(C,9,0,9),h.add(127,9,0,9),h.addMany(p(28,32),9,0,9),h.addMany(p(32,48),9,9,12),h.addMany(p(48,60),9,8,10),h.addMany([60,61,62,63],9,9,10),h.addMany(C,11,0,11),h.addMany(p(32,128),11,0,11),h.addMany(p(28,32),11,0,11),h.addMany(C,10,0,10),h.add(127,10,0,10),h.addMany(p(28,32),10,0,10),h.addMany(p(48,60),10,8,10),h.addMany([60,61,62,63],10,0,11),h.addMany(p(32,48),10,9,12),h.addMany(C,12,0,12),h.add(127,12,0,12),h.addMany(p(28,32),12,0,12),h.addMany(p(32,48),12,9,12),h.addMany(p(48,64),12,0,11),h.addMany(p(64,127),12,12,13),h.addMany(p(64,127),10,12,13),h.addMany(p(64,127),9,12,13),h.addMany(C,13,13,13),h.addMany(v,13,13,13),h.add(127,13,0,13),h.addMany([27,156,24,26],13,14,0),h.add(y,0,2,0),h.add(y,8,5,8),h.add(y,6,0,6),h.add(y,11,0,11),h.add(y,13,13,13),h}();class m extends o.Disposable{constructor(d=s.VT500_TRANSITION_TABLE){super(),this._transitions=d,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new f.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(p,v,C)=>{},this._executeHandlerFb=p=>{},this._csiHandlerFb=(p,v)=>{},this._escHandlerFb=p=>{},this._errorHandlerFb=p=>p,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,o.toDisposable)(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this.register(new u.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(d,p=[64,126]){let v=0;if(d.prefix){if(d.prefix.length>1)throw new Error("only one byte as prefix supported");if(v=d.prefix.charCodeAt(0),v&&60>v||v>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(d.intermediates){if(d.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let S=0;S<d.intermediates.length;++S){const b=d.intermediates.charCodeAt(S);if(32>b||b>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");v<<=8,v|=b}}if(d.final.length!==1)throw new Error("final must be a single byte");const C=d.final.charCodeAt(0);if(p[0]>C||C>p[1])throw new Error(`final must be in range ${p[0]} .. ${p[1]}`);return v<<=8,v|=C,v}identToString(d){const p=[];for(;d;)p.push(String.fromCharCode(255&d)),d>>=8;return p.reverse().join("")}setPrintHandler(d){this._printHandler=d}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(d,p){const v=this._identifier(d,[48,126]);this._escHandlers[v]===void 0&&(this._escHandlers[v]=[]);const C=this._escHandlers[v];return C.push(p),{dispose:()=>{const S=C.indexOf(p);S!==-1&&C.splice(S,1)}}}clearEscHandler(d){this._escHandlers[this._identifier(d,[48,126])]&&delete this._escHandlers[this._identifier(d,[48,126])]}setEscHandlerFallback(d){this._escHandlerFb=d}setExecuteHandler(d,p){this._executeHandlers[d.charCodeAt(0)]=p}clearExecuteHandler(d){this._executeHandlers[d.charCodeAt(0)]&&delete this._executeHandlers[d.charCodeAt(0)]}setExecuteHandlerFallback(d){this._executeHandlerFb=d}registerCsiHandler(d,p){const v=this._identifier(d);this._csiHandlers[v]===void 0&&(this._csiHandlers[v]=[]);const C=this._csiHandlers[v];return C.push(p),{dispose:()=>{const S=C.indexOf(p);S!==-1&&C.splice(S,1)}}}clearCsiHandler(d){this._csiHandlers[this._identifier(d)]&&delete this._csiHandlers[this._identifier(d)]}setCsiHandlerFallback(d){this._csiHandlerFb=d}registerDcsHandler(d,p){return this._dcsParser.registerHandler(this._identifier(d),p)}clearDcsHandler(d){this._dcsParser.clearHandler(this._identifier(d))}setDcsHandlerFallback(d){this._dcsParser.setHandlerFallback(d)}registerOscHandler(d,p){return this._oscParser.registerHandler(d,p)}clearOscHandler(d){this._oscParser.clearHandler(d)}setOscHandlerFallback(d){this._oscParser.setHandlerFallback(d)}setErrorHandler(d){this._errorHandler=d}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(d,p,v,C,S){this._parseStack.state=d,this._parseStack.handlers=p,this._parseStack.handlerPos=v,this._parseStack.transition=C,this._parseStack.chunkPos=S}parse(d,p,v){let C,S=0,b=0,w=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,w=this._parseStack.chunkPos+1;else{if(v===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const E=this._parseStack.handlers;let x=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(v===!1&&x>-1){for(;x>=0&&(C=E[x](this._params),C!==!0);x--)if(C instanceof Promise)return this._parseStack.handlerPos=x,C}this._parseStack.handlers=[];break;case 4:if(v===!1&&x>-1){for(;x>=0&&(C=E[x](),C!==!0);x--)if(C instanceof Promise)return this._parseStack.handlerPos=x,C}this._parseStack.handlers=[];break;case 6:if(S=d[this._parseStack.chunkPos],C=this._dcsParser.unhook(S!==24&&S!==26,v),C)return C;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(S=d[this._parseStack.chunkPos],C=this._oscParser.end(S!==24&&S!==26,v),C)return C;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,w=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let E=w;E<p;++E){switch(S=d[E],b=this._transitions.table[this.currentState<<8|(S<160?S:y)],b>>4){case 2:for(let O=E+1;;++O){if(O>=p||(S=d[O])<32||S>126&&S<y){this._printHandler(d,E,O),E=O-1;break}if(++O>=p||(S=d[O])<32||S>126&&S<y){this._printHandler(d,E,O),E=O-1;break}if(++O>=p||(S=d[O])<32||S>126&&S<y){this._printHandler(d,E,O),E=O-1;break}if(++O>=p||(S=d[O])<32||S>126&&S<y){this._printHandler(d,E,O),E=O-1;break}}break;case 3:this._executeHandlers[S]?this._executeHandlers[S]():this._executeHandlerFb(S),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:E,code:S,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const x=this._csiHandlers[this._collect<<8|S];let k=x?x.length-1:-1;for(;k>=0&&(C=x[k](this._params),C!==!0);k--)if(C instanceof Promise)return this._preserveStack(3,x,k,b,E),C;k<0&&this._csiHandlerFb(this._collect<<8|S,this._params),this.precedingCodepoint=0;break;case 8:do switch(S){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(S-48)}while(++E<p&&(S=d[E])>47&&S<60);E--;break;case 9:this._collect<<=8,this._collect|=S;break;case 10:const D=this._escHandlers[this._collect<<8|S];let R=D?D.length-1:-1;for(;R>=0&&(C=D[R](),C!==!0);R--)if(C instanceof Promise)return this._preserveStack(4,D,R,b,E),C;R<0&&this._escHandlerFb(this._collect<<8|S),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|S,this._params);break;case 13:for(let O=E+1;;++O)if(O>=p||(S=d[O])===24||S===26||S===27||S>127&&S<y){this._dcsParser.put(d,E,O),E=O-1;break}break;case 14:if(C=this._dcsParser.unhook(S!==24&&S!==26),C)return this._preserveStack(6,[],0,b,E),C;S===27&&(b|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let O=E+1;;O++)if(O>=p||(S=d[O])<32||S>127&&S<y){this._oscParser.put(d,E,O),E=O-1;break}break;case 6:if(C=this._oscParser.end(S!==24&&S!==26),C)return this._preserveStack(5,[],0,b,E),C;S===27&&(b|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&b}}}s.EscapeSequenceParser=m},6242:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.OscHandler=s.OscParser=void 0;const o=l(5770),f=l(482),u=[];s.OscParser=class{constructor(){this._state=0,this._active=u,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(g,_){this._handlers[g]===void 0&&(this._handlers[g]=[]);const y=this._handlers[g];return y.push(_),{dispose:()=>{const m=y.indexOf(_);m!==-1&&y.splice(m,1)}}}clearHandler(g){this._handlers[g]&&delete this._handlers[g]}setHandlerFallback(g){this._handlerFb=g}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=u}reset(){if(this._state===2)for(let g=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;g>=0;--g)this._active[g].end(!1);this._stack.paused=!1,this._active=u,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||u,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].start();else this._handlerFb(this._id,"START")}_put(g,_,y){if(this._active.length)for(let m=this._active.length-1;m>=0;m--)this._active[m].put(g,_,y);else this._handlerFb(this._id,"PUT",(0,f.utf32ToString)(g,_,y))}start(){this.reset(),this._state=1}put(g,_,y){if(this._state!==3){if(this._state===1)for(;_<y;){const m=g[_++];if(m===59){this._state=2,this._start();break}if(m<48||57<m)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+m-48}this._state===2&&y-_>0&&this._put(g,_,y)}}end(g,_=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,m=this._active.length-1,h=!1;if(this._stack.paused&&(m=this._stack.loopPosition-1,y=_,h=this._stack.fallThrough,this._stack.paused=!1),!h&&y===!1){for(;m>=0&&(y=this._active[m].end(g),y!==!0);m--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=m,this._stack.fallThrough=!1,y;m--}for(;m>=0;m--)if(y=this._active[m].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=m,this._stack.fallThrough=!0,y}else this._handlerFb(this._id,"END",g);this._active=u,this._id=-1,this._state=0}}},s.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,_,y){this._hitLimit||(this._data+=(0,f.utf32ToString)(g,_,y),this._data.length>o.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let _=!1;if(this._hitLimit)_=!1;else if(g&&(_=this._handler(this._data),_ instanceof Promise))return _.then(y=>(this._data="",this._hitLimit=!1,y));return this._data="",this._hitLimit=!1,_}}},8742:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Params=void 0;const l=2147483647;class o{static fromArray(u){const g=new o;if(!u.length)return g;for(let _=Array.isArray(u[0])?1:0;_<u.length;++_){const y=u[_];if(Array.isArray(y))for(let m=0;m<y.length;++m)g.addSubParam(y[m]);else g.addParam(y)}return g}constructor(u=32,g=32){if(this.maxLength=u,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(u),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(u),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const u=new o(this.maxLength,this.maxSubParamsLength);return u.params.set(this.params),u.length=this.length,u._subParams.set(this._subParams),u._subParamsLength=this._subParamsLength,u._subParamsIdx.set(this._subParamsIdx),u._rejectDigits=this._rejectDigits,u._rejectSubDigits=this._rejectSubDigits,u._digitIsSub=this._digitIsSub,u}toArray(){const u=[];for(let g=0;g<this.length;++g){u.push(this.params[g]);const _=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-_>0&&u.push(Array.prototype.slice.call(this._subParams,_,y))}return u}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(u){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(u<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=u>l?l:u}}addSubParam(u){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(u<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=u>l?l:u,this._subParamsIdx[this.length-1]++}}hasSubParams(u){return(255&this._subParamsIdx[u])-(this._subParamsIdx[u]>>8)>0}getSubParams(u){const g=this._subParamsIdx[u]>>8,_=255&this._subParamsIdx[u];return _-g>0?this._subParams.subarray(g,_):null}getSubParamsAll(){const u={};for(let g=0;g<this.length;++g){const _=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-_>0&&(u[g]=this._subParams.slice(_,y))}return u}addDigit(u){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const _=this._digitIsSub?this._subParams:this.params,y=_[g-1];_[g-1]=~y?Math.min(10*y+u,l):u}}s.Params=o},5741:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.AddonManager=void 0,s.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let l=this._addons.length-1;l>=0;l--)this._addons[l].instance.dispose()}loadAddon(l,o){const f={instance:o,dispose:o.dispose,isDisposed:!1};this._addons.push(f),o.dispose=()=>this._wrappedAddonDispose(f),o.activate(l)}_wrappedAddonDispose(l){if(l.isDisposed)return;let o=-1;for(let f=0;f<this._addons.length;f++)if(this._addons[f]===l){o=f;break}if(o===-1)throw new Error("Could not dispose an addon that has not been loaded");l.isDisposed=!0,l.dispose.apply(l.instance),this._addons.splice(o,1)}}},8771:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BufferApiView=void 0;const o=l(3785),f=l(511);s.BufferApiView=class{constructor(u,g){this._buffer=u,this.type=g}init(u){return this._buffer=u,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(u){const g=this._buffer.lines.get(u);if(g)return new o.BufferLineApiView(g)}getNullCell(){return new f.CellData}}},3785:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BufferLineApiView=void 0;const o=l(511);s.BufferLineApiView=class{constructor(f){this._line=f}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(f,u){if(!(f<0||f>=this._line.length))return u?(this._line.loadCell(f,u),u):this._line.loadCell(f,new o.CellData)}translateToString(f,u,g){return this._line.translateToString(f,u,g)}}},8285:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BufferNamespaceApi=void 0;const o=l(8771),f=l(8460),u=l(844);class g extends u.Disposable{constructor(y){super(),this._core=y,this._onBufferChange=this.register(new f.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new o.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new o.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}s.BufferNamespaceApi=g},7975:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ParserApi=void 0,s.ParserApi=class{constructor(l){this._core=l}registerCsiHandler(l,o){return this._core.registerCsiHandler(l,f=>o(f.toArray()))}addCsiHandler(l,o){return this.registerCsiHandler(l,o)}registerDcsHandler(l,o){return this._core.registerDcsHandler(l,(f,u)=>o(f,u.toArray()))}addDcsHandler(l,o){return this.registerDcsHandler(l,o)}registerEscHandler(l,o){return this._core.registerEscHandler(l,o)}addEscHandler(l,o){return this.registerEscHandler(l,o)}registerOscHandler(l,o){return this._core.registerOscHandler(l,o)}addOscHandler(l,o){return this.registerOscHandler(l,o)}}},7090:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.UnicodeApi=void 0,s.UnicodeApi=class{constructor(l){this._core=l}register(l){this._core.unicodeService.register(l)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(l){this._core.unicodeService.activeVersion=l}}},744:function(a,s,l){var o=this&&this.__decorate||function(h,d,p,v){var C,S=arguments.length,b=S<3?d:v===null?v=Object.getOwnPropertyDescriptor(d,p):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(h,d,p,v);else for(var w=h.length-1;w>=0;w--)(C=h[w])&&(b=(S<3?C(b):S>3?C(d,p,b):C(d,p))||b);return S>3&&b&&Object.defineProperty(d,p,b),b},f=this&&this.__param||function(h,d){return function(p,v){d(p,v,h)}};Object.defineProperty(s,"__esModule",{value:!0}),s.BufferService=s.MINIMUM_ROWS=s.MINIMUM_COLS=void 0;const u=l(8460),g=l(844),_=l(5295),y=l(2585);s.MINIMUM_COLS=2,s.MINIMUM_ROWS=1;let m=s.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(h){super(),this.isUserScrolling=!1,this._onResize=this.register(new u.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new u.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(h.rawOptions.cols||0,s.MINIMUM_COLS),this.rows=Math.max(h.rawOptions.rows||0,s.MINIMUM_ROWS),this.buffers=this.register(new _.BufferSet(h,this))}resize(h,d){this.cols=h,this.rows=d,this.buffers.resize(h,d),this._onResize.fire({cols:h,rows:d})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(h,d=!1){const p=this.buffer;let v;v=this._cachedBlankLine,v&&v.length===this.cols&&v.getFg(0)===h.fg&&v.getBg(0)===h.bg||(v=p.getBlankLine(h,d),this._cachedBlankLine=v),v.isWrapped=d;const C=p.ybase+p.scrollTop,S=p.ybase+p.scrollBottom;if(p.scrollTop===0){const b=p.lines.isFull;S===p.lines.length-1?b?p.lines.recycle().copyFrom(v):p.lines.push(v.clone()):p.lines.splice(S+1,0,v.clone()),b?this.isUserScrolling&&(p.ydisp=Math.max(p.ydisp-1,0)):(p.ybase++,this.isUserScrolling||p.ydisp++)}else{const b=S-C+1;p.lines.shiftElements(C+1,b-1,-1),p.lines.set(S,v.clone())}this.isUserScrolling||(p.ydisp=p.ybase),this._onScroll.fire(p.ydisp)}scrollLines(h,d,p){const v=this.buffer;if(h<0){if(v.ydisp===0)return;this.isUserScrolling=!0}else h+v.ydisp>=v.ybase&&(this.isUserScrolling=!1);const C=v.ydisp;v.ydisp=Math.max(Math.min(v.ydisp+h,v.ybase),0),C!==v.ydisp&&(d||this._onScroll.fire(v.ydisp))}};s.BufferService=m=o([f(0,y.IOptionsService)],m)},7994:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CharsetService=void 0,s.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(l){this.glevel=l,this.charset=this._charsets[l]}setgCharset(l,o){this._charsets[l]=o,this.glevel===l&&(this.charset=o)}}},1753:function(a,s,l){var o=this&&this.__decorate||function(v,C,S,b){var w,E=arguments.length,x=E<3?C:b===null?b=Object.getOwnPropertyDescriptor(C,S):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(v,C,S,b);else for(var k=v.length-1;k>=0;k--)(w=v[k])&&(x=(E<3?w(x):E>3?w(C,S,x):w(C,S))||x);return E>3&&x&&Object.defineProperty(C,S,x),x},f=this&&this.__param||function(v,C){return function(S,b){C(S,b,v)}};Object.defineProperty(s,"__esModule",{value:!0}),s.CoreMouseService=void 0;const u=l(2585),g=l(8460),_=l(844),y={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:v=>v.button!==4&&v.action===1&&(v.ctrl=!1,v.alt=!1,v.shift=!1,!0)},VT200:{events:19,restrict:v=>v.action!==32},DRAG:{events:23,restrict:v=>v.action!==32||v.button!==3},ANY:{events:31,restrict:v=>!0}};function m(v,C){let S=(v.ctrl?16:0)|(v.shift?4:0)|(v.alt?8:0);return v.button===4?(S|=64,S|=v.action):(S|=3&v.button,4&v.button&&(S|=64),8&v.button&&(S|=128),v.action===32?S|=32:v.action!==0||C||(S|=3)),S}const h=String.fromCharCode,d={DEFAULT:v=>{const C=[m(v,!1)+32,v.col+32,v.row+32];return C[0]>255||C[1]>255||C[2]>255?"":`\x1B[M${h(C[0])}${h(C[1])}${h(C[2])}`},SGR:v=>{const C=v.action===0&&v.button!==4?"m":"M";return`\x1B[<${m(v,!0)};${v.col};${v.row}${C}`},SGR_PIXELS:v=>{const C=v.action===0&&v.button!==4?"m":"M";return`\x1B[<${m(v,!0)};${v.x};${v.y}${C}`}};let p=s.CoreMouseService=class extends _.Disposable{constructor(v,C){super(),this._bufferService=v,this._coreService=C,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new g.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const S of Object.keys(y))this.addProtocol(S,y[S]);for(const S of Object.keys(d))this.addEncoding(S,d[S]);this.reset()}addProtocol(v,C){this._protocols[v]=C}addEncoding(v,C){this._encodings[v]=C}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(v){if(!this._protocols[v])throw new Error(`unknown protocol "${v}"`);this._activeProtocol=v,this._onProtocolChange.fire(this._protocols[v].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(v){if(!this._encodings[v])throw new Error(`unknown encoding "${v}"`);this._activeEncoding=v}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(v){if(v.col<0||v.col>=this._bufferService.cols||v.row<0||v.row>=this._bufferService.rows||v.button===4&&v.action===32||v.button===3&&v.action!==32||v.button!==4&&(v.action===2||v.action===3)||(v.col++,v.row++,v.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,v,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(v))return!1;const C=this._encodings[this._activeEncoding](v);return C&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(C):this._coreService.triggerDataEvent(C,!0)),this._lastEvent=v,!0}explainEvents(v){return{down:!!(1&v),up:!!(2&v),drag:!!(4&v),move:!!(8&v),wheel:!!(16&v)}}_equalEvents(v,C,S){if(S){if(v.x!==C.x||v.y!==C.y)return!1}else if(v.col!==C.col||v.row!==C.row)return!1;return v.button===C.button&&v.action===C.action&&v.ctrl===C.ctrl&&v.alt===C.alt&&v.shift===C.shift}};s.CoreMouseService=p=o([f(0,u.IBufferService),f(1,u.ICoreService)],p)},6975:function(a,s,l){var o=this&&this.__decorate||function(p,v,C,S){var b,w=arguments.length,E=w<3?v:S===null?S=Object.getOwnPropertyDescriptor(v,C):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(p,v,C,S);else for(var x=p.length-1;x>=0;x--)(b=p[x])&&(E=(w<3?b(E):w>3?b(v,C,E):b(v,C))||E);return w>3&&E&&Object.defineProperty(v,C,E),E},f=this&&this.__param||function(p,v){return function(C,S){v(C,S,p)}};Object.defineProperty(s,"__esModule",{value:!0}),s.CoreService=void 0;const u=l(1439),g=l(8460),_=l(844),y=l(2585),m=Object.freeze({insertMode:!1}),h=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let d=s.CoreService=class extends _.Disposable{constructor(p,v,C){super(),this._bufferService=p,this._logService=v,this._optionsService=C,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new g.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new g.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new g.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new g.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,u.clone)(m),this.decPrivateModes=(0,u.clone)(h)}reset(){this.modes=(0,u.clone)(m),this.decPrivateModes=(0,u.clone)(h)}triggerDataEvent(p,v=!1){if(this._optionsService.rawOptions.disableStdin)return;const C=this._bufferService.buffer;v&&this._optionsService.rawOptions.scrollOnUserInput&&C.ybase!==C.ydisp&&this._onRequestScrollToBottom.fire(),v&&this._onUserInput.fire(),this._logService.debug(`sending data "${p}"`,()=>p.split("").map(S=>S.charCodeAt(0))),this._onData.fire(p)}triggerBinaryEvent(p){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${p}"`,()=>p.split("").map(v=>v.charCodeAt(0))),this._onBinary.fire(p))}};s.CoreService=d=o([f(0,y.IBufferService),f(1,y.ILogService),f(2,y.IOptionsService)],d)},9074:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.DecorationService=void 0;const o=l(8055),f=l(8460),u=l(844),g=l(6106);let _=0,y=0;class m extends u.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList(p=>p==null?void 0:p.marker.line),this._onDecorationRegistered=this.register(new f.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new f.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,u.toDisposable)(()=>this.reset()))}registerDecoration(p){if(p.marker.isDisposed)return;const v=new h(p);if(v){const C=v.marker.onDispose(()=>v.dispose());v.onDispose(()=>{v&&(this._decorations.delete(v)&&this._onDecorationRemoved.fire(v),C.dispose())}),this._decorations.insert(v),this._onDecorationRegistered.fire(v)}return v}reset(){for(const p of this._decorations.values())p.dispose();this._decorations.clear()}*getDecorationsAtCell(p,v,C){var S,b,w;let E=0,x=0;for(const k of this._decorations.getKeyIterator(v))E=(S=k.options.x)!==null&&S!==void 0?S:0,x=E+((b=k.options.width)!==null&&b!==void 0?b:1),p>=E&&p<x&&(!C||((w=k.options.layer)!==null&&w!==void 0?w:"bottom")===C)&&(yield k)}forEachDecorationAtCell(p,v,C,S){this._decorations.forEachByKey(v,b=>{var w,E,x;_=(w=b.options.x)!==null&&w!==void 0?w:0,y=_+((E=b.options.width)!==null&&E!==void 0?E:1),p>=_&&p<y&&(!C||((x=b.options.layer)!==null&&x!==void 0?x:"bottom")===C)&&S(b)})}}s.DecorationService=m;class h extends u.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=o.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=o.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(p){super(),this.options=p,this.onRenderEmitter=this.register(new f.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new f.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=p.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.InstantiationService=s.ServiceCollection=void 0;const o=l(2585),f=l(8343);class u{constructor(..._){this._entries=new Map;for(const[y,m]of _)this.set(y,m)}set(_,y){const m=this._entries.get(_);return this._entries.set(_,y),m}forEach(_){for(const[y,m]of this._entries.entries())_(y,m)}has(_){return this._entries.has(_)}get(_){return this._entries.get(_)}}s.ServiceCollection=u,s.InstantiationService=class{constructor(){this._services=new u,this._services.set(o.IInstantiationService,this)}setService(g,_){this._services.set(g,_)}getService(g){return this._services.get(g)}createInstance(g,..._){const y=(0,f.getServiceDependencies)(g).sort((d,p)=>d.index-p.index),m=[];for(const d of y){const p=this._services.get(d.id);if(!p)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${d.id}.`);m.push(p)}const h=y.length>0?y[0].index:_.length;if(_.length!==h)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${h+1} conflicts with ${_.length} static arguments`);return new g(..._,...m)}}},7866:function(a,s,l){var o=this&&this.__decorate||function(h,d,p,v){var C,S=arguments.length,b=S<3?d:v===null?v=Object.getOwnPropertyDescriptor(d,p):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(h,d,p,v);else for(var w=h.length-1;w>=0;w--)(C=h[w])&&(b=(S<3?C(b):S>3?C(d,p,b):C(d,p))||b);return S>3&&b&&Object.defineProperty(d,p,b),b},f=this&&this.__param||function(h,d){return function(p,v){d(p,v,h)}};Object.defineProperty(s,"__esModule",{value:!0}),s.traceCall=s.setTraceLogger=s.LogService=void 0;const u=l(844),g=l(2585),_={trace:g.LogLevelEnum.TRACE,debug:g.LogLevelEnum.DEBUG,info:g.LogLevelEnum.INFO,warn:g.LogLevelEnum.WARN,error:g.LogLevelEnum.ERROR,off:g.LogLevelEnum.OFF};let y,m=s.LogService=class extends u.Disposable{get logLevel(){return this._logLevel}constructor(h){super(),this._optionsService=h,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),y=this}_updateLogLevel(){this._logLevel=_[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(h){for(let d=0;d<h.length;d++)typeof h[d]=="function"&&(h[d]=h[d]())}_log(h,d,p){this._evalLazyOptionalParams(p),h.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+d,...p)}trace(h,...d){var p,v;this._logLevel<=g.LogLevelEnum.TRACE&&this._log((v=(p=this._optionsService.options.logger)===null||p===void 0?void 0:p.trace.bind(this._optionsService.options.logger))!==null&&v!==void 0?v:console.log,h,d)}debug(h,...d){var p,v;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log((v=(p=this._optionsService.options.logger)===null||p===void 0?void 0:p.debug.bind(this._optionsService.options.logger))!==null&&v!==void 0?v:console.log,h,d)}info(h,...d){var p,v;this._logLevel<=g.LogLevelEnum.INFO&&this._log((v=(p=this._optionsService.options.logger)===null||p===void 0?void 0:p.info.bind(this._optionsService.options.logger))!==null&&v!==void 0?v:console.info,h,d)}warn(h,...d){var p,v;this._logLevel<=g.LogLevelEnum.WARN&&this._log((v=(p=this._optionsService.options.logger)===null||p===void 0?void 0:p.warn.bind(this._optionsService.options.logger))!==null&&v!==void 0?v:console.warn,h,d)}error(h,...d){var p,v;this._logLevel<=g.LogLevelEnum.ERROR&&this._log((v=(p=this._optionsService.options.logger)===null||p===void 0?void 0:p.error.bind(this._optionsService.options.logger))!==null&&v!==void 0?v:console.error,h,d)}};s.LogService=m=o([f(0,g.IOptionsService)],m),s.setTraceLogger=function(h){y=h},s.traceCall=function(h,d,p){if(typeof p.value!="function")throw new Error("not supported");const v=p.value;p.value=function(...C){if(y.logLevel!==g.LogLevelEnum.TRACE)return v.apply(this,C);y.trace(`GlyphRenderer#${v.name}(${C.map(b=>JSON.stringify(b)).join(", ")})`);const S=v.apply(this,C);return y.trace(`GlyphRenderer#${v.name} return`,S),S}}},7302:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.OptionsService=s.DEFAULT_OPTIONS=void 0;const o=l(8460),f=l(844),u=l(6114);s.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:u.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const g=["normal","bold","100","200","300","400","500","600","700","800","900"];class _ extends f.Disposable{constructor(m){super(),this._onOptionChange=this.register(new o.EventEmitter),this.onOptionChange=this._onOptionChange.event;const h=Object.assign({},s.DEFAULT_OPTIONS);for(const d in m)if(d in h)try{const p=m[d];h[d]=this._sanitizeAndValidateOption(d,p)}catch(p){console.error(p)}this.rawOptions=h,this.options=Object.assign({},h),this._setupOptions()}onSpecificOptionChange(m,h){return this.onOptionChange(d=>{d===m&&h(this.rawOptions[m])})}onMultipleOptionChange(m,h){return this.onOptionChange(d=>{m.indexOf(d)!==-1&&h()})}_setupOptions(){const m=d=>{if(!(d in s.DEFAULT_OPTIONS))throw new Error(`No option with key "${d}"`);return this.rawOptions[d]},h=(d,p)=>{if(!(d in s.DEFAULT_OPTIONS))throw new Error(`No option with key "${d}"`);p=this._sanitizeAndValidateOption(d,p),this.rawOptions[d]!==p&&(this.rawOptions[d]=p,this._onOptionChange.fire(d))};for(const d in this.rawOptions){const p={get:m.bind(this,d),set:h.bind(this,d)};Object.defineProperty(this.options,d,p)}}_sanitizeAndValidateOption(m,h){switch(m){case"cursorStyle":if(h||(h=s.DEFAULT_OPTIONS[m]),!function(d){return d==="block"||d==="underline"||d==="bar"}(h))throw new Error(`"${h}" is not a valid value for ${m}`);break;case"wordSeparator":h||(h=s.DEFAULT_OPTIONS[m]);break;case"fontWeight":case"fontWeightBold":if(typeof h=="number"&&1<=h&&h<=1e3)break;h=g.includes(h)?h:s.DEFAULT_OPTIONS[m];break;case"cursorWidth":h=Math.floor(h);case"lineHeight":case"tabStopWidth":if(h<1)throw new Error(`${m} cannot be less than 1, value: ${h}`);break;case"minimumContrastRatio":h=Math.max(1,Math.min(21,Math.round(10*h)/10));break;case"scrollback":if((h=Math.min(h,4294967295))<0)throw new Error(`${m} cannot be less than 0, value: ${h}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(h<=0)throw new Error(`${m} cannot be less than or equal to 0, value: ${h}`);break;case"rows":case"cols":if(!h&&h!==0)throw new Error(`${m} must be numeric, value: ${h}`);break;case"windowsPty":h=h!=null?h:{}}return h}}s.OptionsService=_},2660:function(a,s,l){var o=this&&this.__decorate||function(_,y,m,h){var d,p=arguments.length,v=p<3?y:h===null?h=Object.getOwnPropertyDescriptor(y,m):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(_,y,m,h);else for(var C=_.length-1;C>=0;C--)(d=_[C])&&(v=(p<3?d(v):p>3?d(y,m,v):d(y,m))||v);return p>3&&v&&Object.defineProperty(y,m,v),v},f=this&&this.__param||function(_,y){return function(m,h){y(m,h,_)}};Object.defineProperty(s,"__esModule",{value:!0}),s.OscLinkService=void 0;const u=l(2585);let g=s.OscLinkService=class{constructor(_){this._bufferService=_,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(_){const y=this._bufferService.buffer;if(_.id===void 0){const C=y.addMarker(y.ybase+y.y),S={data:_,id:this._nextId++,lines:[C]};return C.onDispose(()=>this._removeMarkerFromLink(S,C)),this._dataByLinkId.set(S.id,S),S.id}const m=_,h=this._getEntryIdKey(m),d=this._entriesWithId.get(h);if(d)return this.addLineToLink(d.id,y.ybase+y.y),d.id;const p=y.addMarker(y.ybase+y.y),v={id:this._nextId++,key:this._getEntryIdKey(m),data:m,lines:[p]};return p.onDispose(()=>this._removeMarkerFromLink(v,p)),this._entriesWithId.set(v.key,v),this._dataByLinkId.set(v.id,v),v.id}addLineToLink(_,y){const m=this._dataByLinkId.get(_);if(m&&m.lines.every(h=>h.line!==y)){const h=this._bufferService.buffer.addMarker(y);m.lines.push(h),h.onDispose(()=>this._removeMarkerFromLink(m,h))}}getLinkData(_){var y;return(y=this._dataByLinkId.get(_))===null||y===void 0?void 0:y.data}_getEntryIdKey(_){return`${_.id};;${_.uri}`}_removeMarkerFromLink(_,y){const m=_.lines.indexOf(y);m!==-1&&(_.lines.splice(m,1),_.lines.length===0&&(_.data.id!==void 0&&this._entriesWithId.delete(_.key),this._dataByLinkId.delete(_.id)))}};s.OscLinkService=g=o([f(0,u.IBufferService)],g)},8343:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.createDecorator=s.getServiceDependencies=s.serviceRegistry=void 0;const l="di$target",o="di$dependencies";s.serviceRegistry=new Map,s.getServiceDependencies=function(f){return f[o]||[]},s.createDecorator=function(f){if(s.serviceRegistry.has(f))return s.serviceRegistry.get(f);const u=function(g,_,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(m,h,d){h[l]===h?h[o].push({id:m,index:d}):(h[o]=[{id:m,index:d}],h[l]=h)})(u,g,y)};return u.toString=()=>f,s.serviceRegistry.set(f,u),u}},2585:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.IDecorationService=s.IUnicodeService=s.IOscLinkService=s.IOptionsService=s.ILogService=s.LogLevelEnum=s.IInstantiationService=s.ICharsetService=s.ICoreService=s.ICoreMouseService=s.IBufferService=void 0;const o=l(8343);var f;s.IBufferService=(0,o.createDecorator)("BufferService"),s.ICoreMouseService=(0,o.createDecorator)("CoreMouseService"),s.ICoreService=(0,o.createDecorator)("CoreService"),s.ICharsetService=(0,o.createDecorator)("CharsetService"),s.IInstantiationService=(0,o.createDecorator)("InstantiationService"),function(u){u[u.TRACE=0]="TRACE",u[u.DEBUG=1]="DEBUG",u[u.INFO=2]="INFO",u[u.WARN=3]="WARN",u[u.ERROR=4]="ERROR",u[u.OFF=5]="OFF"}(f||(s.LogLevelEnum=f={})),s.ILogService=(0,o.createDecorator)("LogService"),s.IOptionsService=(0,o.createDecorator)("OptionsService"),s.IOscLinkService=(0,o.createDecorator)("OscLinkService"),s.IUnicodeService=(0,o.createDecorator)("UnicodeService"),s.IDecorationService=(0,o.createDecorator)("DecorationService")},1480:(a,s,l)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.UnicodeService=void 0;const o=l(8460),f=l(225);s.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new o.EventEmitter,this.onChange=this._onChange.event;const u=new f.UnicodeV6;this.register(u),this._active=u.version,this._activeProvider=u}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(u){if(!this._providers[u])throw new Error(`unknown Unicode version "${u}"`);this._active=u,this._activeProvider=this._providers[u],this._onChange.fire(u)}register(u){this._providers[u.version]=u}wcwidth(u){return this._activeProvider.wcwidth(u)}getStringCellWidth(u){let g=0;const _=u.length;for(let y=0;y<_;++y){let m=u.charCodeAt(y);if(55296<=m&&m<=56319){if(++y>=_)return g+this.wcwidth(m);const h=u.charCodeAt(y);56320<=h&&h<=57343?m=1024*(m-55296)+h-56320+65536:g+=this.wcwidth(h)}g+=this.wcwidth(m)}return g}}}},r={};function n(a){var s=r[a];if(s!==void 0)return s.exports;var l=r[a]={exports:{}};return i[a].call(l.exports,l,l.exports,n),l.exports}var c={};return(()=>{var a=c;Object.defineProperty(a,"__esModule",{value:!0}),a.Terminal=void 0;const s=n(9042),l=n(3236),o=n(844),f=n(5741),u=n(8285),g=n(7975),_=n(7090),y=["cols","rows"];class m extends o.Disposable{constructor(d){super(),this._core=this.register(new l.Terminal(d)),this._addonManager=this.register(new f.AddonManager),this._publicOptions=Object.assign({},this._core.options);const p=C=>this._core.options[C],v=(C,S)=>{this._checkReadonlyOptions(C),this._core.options[C]=S};for(const C in this._core.options){const S={get:p.bind(this,C),set:v.bind(this,C)};Object.defineProperty(this._publicOptions,C,S)}}_checkReadonlyOptions(d){if(y.includes(d))throw new Error(`Option "${d}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new g.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new _.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new u.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const d=this._core.coreService.decPrivateModes;let p="none";switch(this._core.coreMouseService.activeProtocol){case"X10":p="x10";break;case"VT200":p="vt200";break;case"DRAG":p="drag";break;case"ANY":p="any"}return{applicationCursorKeysMode:d.applicationCursorKeys,applicationKeypadMode:d.applicationKeypad,bracketedPasteMode:d.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:p,originMode:d.origin,reverseWraparoundMode:d.reverseWraparound,sendFocusMode:d.sendFocus,wraparoundMode:d.wraparound}}get options(){return this._publicOptions}set options(d){for(const p in d)this._publicOptions[p]=d[p]}blur(){this._core.blur()}focus(){this._core.focus()}resize(d,p){this._verifyIntegers(d,p),this._core.resize(d,p)}open(d){this._core.open(d)}attachCustomKeyEventHandler(d){this._core.attachCustomKeyEventHandler(d)}registerLinkProvider(d){return this._core.registerLinkProvider(d)}registerCharacterJoiner(d){return this._checkProposedApi(),this._core.registerCharacterJoiner(d)}deregisterCharacterJoiner(d){this._checkProposedApi(),this._core.deregisterCharacterJoiner(d)}registerMarker(d=0){return this._verifyIntegers(d),this._core.registerMarker(d)}registerDecoration(d){var p,v,C;return this._checkProposedApi(),this._verifyPositiveIntegers((p=d.x)!==null&&p!==void 0?p:0,(v=d.width)!==null&&v!==void 0?v:0,(C=d.height)!==null&&C!==void 0?C:0),this._core.registerDecoration(d)}hasSelection(){return this._core.hasSelection()}select(d,p,v){this._verifyIntegers(d,p,v),this._core.select(d,p,v)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(d,p){this._verifyIntegers(d,p),this._core.selectLines(d,p)}dispose(){super.dispose()}scrollLines(d){this._verifyIntegers(d),this._core.scrollLines(d)}scrollPages(d){this._verifyIntegers(d),this._core.scrollPages(d)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(d){this._verifyIntegers(d),this._core.scrollToLine(d)}clear(){this._core.clear()}write(d,p){this._core.write(d,p)}writeln(d,p){this._core.write(d),this._core.write(`\r
`,p)}paste(d){this._core.paste(d)}refresh(d,p){this._verifyIntegers(d,p),this._core.refresh(d,p)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(d){this._addonManager.loadAddon(this,d)}static get strings(){return s}_verifyIntegers(...d){for(const p of d)if(p===1/0||isNaN(p)||p%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...d){for(const p of d)if(p&&(p===1/0||isNaN(p)||p%1!=0||p<0))throw new Error("This API only accepts positive integers")}}a.Terminal=m})(),c})())})(es);var Bn=es.exports,ts={exports:{}};(function(e,t){(function(i,r){e.exports=r()})(self,()=>(()=>{var i={};return(()=>{var r=i;Object.defineProperty(r,"__esModule",{value:!0}),r.FitAddon=void 0,r.FitAddon=class{activate(n){this._terminal=n}dispose(){}fit(){const n=this.proposeDimensions();if(!n||!this._terminal||isNaN(n.cols)||isNaN(n.rows))return;const c=this._terminal._core;this._terminal.rows===n.rows&&this._terminal.cols===n.cols||(c._renderService.clear(),this._terminal.resize(n.cols,n.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const n=this._terminal._core,c=n._renderService.dimensions;if(c.css.cell.width===0||c.css.cell.height===0)return;const a=this._terminal.options.scrollback===0?0:n.viewport.scrollBarWidth,s=window.getComputedStyle(this._terminal.element.parentElement),l=parseInt(s.getPropertyValue("height")),o=Math.max(0,parseInt(s.getPropertyValue("width"))),f=window.getComputedStyle(this._terminal.element),u=l-(parseInt(f.getPropertyValue("padding-top"))+parseInt(f.getPropertyValue("padding-bottom"))),g=o-(parseInt(f.getPropertyValue("padding-right"))+parseInt(f.getPropertyValue("padding-left")))-a;return{cols:Math.max(2,Math.floor(g/c.css.cell.width)),rows:Math.max(1,Math.floor(u/c.css.cell.height))}}}})(),i})())})(ts);var In=ts.exports,rs={exports:{}};(function(e,t){(function(i,r){e.exports=r()})(self,()=>(()=>{var i={6:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.LinkComputer=s.WebLinkProvider=void 0,s.WebLinkProvider=class{constructor(o,f,u,g={}){this._terminal=o,this._regex=f,this._handler=u,this._options=g}provideLinks(o,f){const u=l.computeLink(o,this._regex,this._terminal,this._handler);f(this._addCallbacks(u))}_addCallbacks(o){return o.map(f=>(f.leave=this._options.leave,f.hover=(u,g)=>{if(this._options.hover){const{range:_}=f;this._options.hover(u,g,_)}},f))}};class l{static computeLink(f,u,g,_){const y=new RegExp(u.source,(u.flags||"")+"g"),[m,h]=l._getWindowedLineStrings(f-1,g),d=m.join("");let p;const v=[];for(;p=y.exec(d);){const C=p[0];try{const k=new URL(C),D=decodeURI(k.toString());if(C!==D&&C+"/"!==D)continue}catch(k){continue}const[S,b]=l._mapStrIdx(g,h,0,p.index),[w,E]=l._mapStrIdx(g,S,b,C.length);if(S===-1||b===-1||w===-1||E===-1)continue;const x={start:{x:b+1,y:S+1},end:{x:E,y:w+1}};v.push({range:x,text:C,activate:_})}return v}static _getWindowedLineStrings(f,u){let g,_=f,y=f,m=0,h="";const d=[];if(g=u.buffer.active.getLine(f)){const p=g.translateToString(!0);if(g.isWrapped&&p[0]!==" "){for(m=0;(g=u.buffer.active.getLine(--_))&&m<2048&&(h=g.translateToString(!0),m+=h.length,d.push(h),g.isWrapped&&h.indexOf(" ")===-1););d.reverse()}for(d.push(p),m=0;(g=u.buffer.active.getLine(++y))&&g.isWrapped&&m<2048&&(h=g.translateToString(!0),m+=h.length,d.push(h),h.indexOf(" ")===-1););}return[d,_]}static _mapStrIdx(f,u,g,_){const y=f.buffer.active,m=y.getNullCell();let h=g;for(;_;){const d=y.getLine(u);if(!d)return[-1,-1];for(let p=h;p<d.length;++p){d.getCell(p,m);const v=m.getChars();if(m.getWidth()&&(_-=v.length||1,p===d.length-1&&v==="")){const C=y.getLine(u+1);C&&C.isWrapped&&(C.getCell(0,m),m.getWidth()===2&&(_+=1))}if(_<0)return[u,p]}u++,h=0}return[u,h]}}s.LinkComputer=l}},r={};function n(a){var s=r[a];if(s!==void 0)return s.exports;var l=r[a]={exports:{}};return i[a](l,l.exports,n),l.exports}var c={};return(()=>{var a=c;Object.defineProperty(a,"__esModule",{value:!0}),a.WebLinksAddon=void 0;const s=n(6),l=/https?:[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function o(f,u){const g=window.open();if(g){try{g.opener=null}catch(_){}g.location.href=u}else console.warn("Opening link blocked as opener could not be cleared")}a.WebLinksAddon=class{constructor(f=o,u={}){this._handler=f,this._options=u}activate(f){this._terminal=f;const u=this._options,g=u.urlRegex||l;this._linkProvider=this._terminal.registerLinkProvider(new s.WebLinkProvider(this._terminal,g,this._handler,u))}dispose(){var f;(f=this._linkProvider)===null||f===void 0||f.dispose()}}})(),c})())})(rs);var Ln=rs.exports,is={exports:{}};(function(e,t){(function(i,r){e.exports=r()})(self,()=>(()=>{var i={345:(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.forwardEvent=s.EventEmitter=void 0,s.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=l=>(this._listeners.push(l),{dispose:()=>{if(!this._disposed){for(let o=0;o<this._listeners.length;o++)if(this._listeners[o]===l)return void this._listeners.splice(o,1)}}})),this._event}fire(l,o){const f=[];for(let u=0;u<this._listeners.length;u++)f.push(this._listeners[u]);for(let u=0;u<f.length;u++)f[u].call(void 0,l,o)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},s.forwardEvent=function(l,o){return l(f=>o.fire(f))}},859:(a,s)=>{function l(o){for(const f of o)f.dispose();o.length=0}Object.defineProperty(s,"__esModule",{value:!0}),s.getDisposeArrayDisposable=s.disposeArray=s.toDisposable=s.MutableDisposable=s.Disposable=void 0,s.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const o of this._disposables)o.dispose();this._disposables.length=0}register(o){return this._disposables.push(o),o}unregister(o){const f=this._disposables.indexOf(o);f!==-1&&this._disposables.splice(f,1)}},s.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(o){var f;this._isDisposed||o===this._value||((f=this._value)===null||f===void 0||f.dispose(),this._value=o)}clear(){this.value=void 0}dispose(){var o;this._isDisposed=!0,(o=this._value)===null||o===void 0||o.dispose(),this._value=void 0}},s.toDisposable=function(o){return{dispose:o}},s.disposeArray=l,s.getDisposeArrayDisposable=function(o){return{dispose:()=>l(o)}}}},r={};function n(a){var s=r[a];if(s!==void 0)return s.exports;var l=r[a]={exports:{}};return i[a](l,l.exports,n),l.exports}var c={};return(()=>{var a=c;Object.defineProperty(a,"__esModule",{value:!0}),a.SearchAddon=void 0;const s=n(345),l=n(859),o=" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?";class f extends l.Disposable{constructor(g){var _;super(),this._highlightedLines=new Set,this._highlightDecorations=[],this._selectedDecoration=this.register(new l.MutableDisposable),this._linesCacheTimeoutId=0,this._onDidChangeResults=this.register(new s.EventEmitter),this.onDidChangeResults=this._onDidChangeResults.event,this._highlightLimit=(_=g==null?void 0:g.highlightLimit)!==null&&_!==void 0?_:1e3}activate(g){this._terminal=g,this.register(this._terminal.onWriteParsed(()=>this._updateMatches())),this.register(this._terminal.onResize(()=>this._updateMatches())),this.register((0,l.toDisposable)(()=>this.clearDecorations()))}_updateMatches(){var g;this._highlightTimeout&&window.clearTimeout(this._highlightTimeout),this._cachedSearchTerm&&(!((g=this._lastSearchOptions)===null||g===void 0)&&g.decorations)&&(this._highlightTimeout=setTimeout(()=>{const _=this._cachedSearchTerm;this._cachedSearchTerm=void 0,this.findPrevious(_,Object.assign(Object.assign({},this._lastSearchOptions),{incremental:!0,noScroll:!0}))},200))}clearDecorations(g){this._selectedDecoration.clear(),(0,l.disposeArray)(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear(),g||(this._cachedSearchTerm=void 0)}findNext(g,_){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");this._lastSearchOptions=_,_!=null&&_.decorations&&(this._cachedSearchTerm!==void 0&&g===this._cachedSearchTerm||this._highlightAllMatches(g,_));const y=this._findNextAndSelect(g,_);return this._fireResults(_),this._cachedSearchTerm=g,y}_highlightAllMatches(g,_){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");if(!g||g.length===0)return void this.clearDecorations();_=_||{},this.clearDecorations(!0);const y=[];let m,h=this._find(g,0,0,_);for(;h&&((m==null?void 0:m.row)!==h.row||(m==null?void 0:m.col)!==h.col)&&!(y.length>=this._highlightLimit);)m=h,y.push(m),h=this._find(g,m.col+m.term.length>=this._terminal.cols?m.row+1:m.row,m.col+m.term.length>=this._terminal.cols?0:m.col+1,_);for(const d of y){const p=this._createResultDecoration(d,_.decorations);p&&(this._highlightedLines.add(p.marker.line),this._highlightDecorations.push({decoration:p,match:d,dispose(){p.dispose()}}))}}_find(g,_,y,m){var h;if(!this._terminal||!g||g.length===0)return(h=this._terminal)===null||h===void 0||h.clearSelection(),void this.clearDecorations();if(y>this._terminal.cols)throw new Error(`Invalid col: ${y} to search in terminal of ${this._terminal.cols} cols`);let d;this._initLinesCache();const p={startRow:_,startCol:y};if(d=this._findInLine(g,p,m),!d)for(let v=_+1;v<this._terminal.buffer.active.baseY+this._terminal.rows&&(p.startRow=v,p.startCol=0,d=this._findInLine(g,p,m),!d);v++);return d}_findNextAndSelect(g,_){var y;if(!this._terminal||!g||g.length===0)return(y=this._terminal)===null||y===void 0||y.clearSelection(),this.clearDecorations(),!1;const m=this._terminal.getSelectionPosition();this._terminal.clearSelection();let h=0,d=0;m&&(this._cachedSearchTerm===g?(h=m.end.x,d=m.end.y):(h=m.start.x,d=m.start.y)),this._initLinesCache();const p={startRow:d,startCol:h};let v=this._findInLine(g,p,_);if(!v)for(let C=d+1;C<this._terminal.buffer.active.baseY+this._terminal.rows&&(p.startRow=C,p.startCol=0,v=this._findInLine(g,p,_),!v);C++);if(!v&&d!==0)for(let C=0;C<d&&(p.startRow=C,p.startCol=0,v=this._findInLine(g,p,_),!v);C++);return!v&&m&&(p.startRow=m.start.y,p.startCol=0,v=this._findInLine(g,p,_)),this._selectResult(v,_==null?void 0:_.decorations,_==null?void 0:_.noScroll)}findPrevious(g,_){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");this._lastSearchOptions=_,_!=null&&_.decorations&&(this._cachedSearchTerm!==void 0&&g===this._cachedSearchTerm||this._highlightAllMatches(g,_));const y=this._findPreviousAndSelect(g,_);return this._fireResults(_),this._cachedSearchTerm=g,y}_fireResults(g){if(g!=null&&g.decorations){let _=-1;if(this._selectedDecoration.value){const y=this._selectedDecoration.value.match;for(let m=0;m<this._highlightDecorations.length;m++){const h=this._highlightDecorations[m].match;if(h.row===y.row&&h.col===y.col&&h.size===y.size){_=m;break}}}this._onDidChangeResults.fire({resultIndex:_,resultCount:this._highlightDecorations.length})}}_findPreviousAndSelect(g,_){var y;if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");if(!this._terminal||!g||g.length===0)return(y=this._terminal)===null||y===void 0||y.clearSelection(),this.clearDecorations(),!1;const m=this._terminal.getSelectionPosition();this._terminal.clearSelection();let h=this._terminal.buffer.active.baseY+this._terminal.rows-1,d=this._terminal.cols;const p=!0;this._initLinesCache();const v={startRow:h,startCol:d};let C;if(m&&(v.startRow=h=m.start.y,v.startCol=d=m.start.x,this._cachedSearchTerm!==g&&(C=this._findInLine(g,v,_,!1),C||(v.startRow=h=m.end.y,v.startCol=d=m.end.x))),C||(C=this._findInLine(g,v,_,p)),!C){v.startCol=Math.max(v.startCol,this._terminal.cols);for(let S=h-1;S>=0&&(v.startRow=S,C=this._findInLine(g,v,_,p),!C);S--);}if(!C&&h!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let S=this._terminal.buffer.active.baseY+this._terminal.rows-1;S>=h&&(v.startRow=S,C=this._findInLine(g,v,_,p),!C);S--);return this._selectResult(C,_==null?void 0:_.decorations,_==null?void 0:_.noScroll)}_initLinesCache(){const g=this._terminal;this._linesCache||(this._linesCache=new Array(g.buffer.active.length),this._cursorMoveListener=g.onCursorMove(()=>this._destroyLinesCache()),this._resizeListener=g.onResize(()=>this._destroyLinesCache())),window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=window.setTimeout(()=>this._destroyLinesCache(),15e3)}_destroyLinesCache(){this._linesCache=void 0,this._cursorMoveListener&&(this._cursorMoveListener.dispose(),this._cursorMoveListener=void 0),this._resizeListener&&(this._resizeListener.dispose(),this._resizeListener=void 0),this._linesCacheTimeoutId&&(window.clearTimeout(this._linesCacheTimeoutId),this._linesCacheTimeoutId=0)}_isWholeWord(g,_,y){return(g===0||o.includes(_[g-1]))&&(g+y.length===_.length||o.includes(_[g+y.length]))}_findInLine(g,_,y={},m=!1){var h;const d=this._terminal,p=_.startRow,v=_.startCol,C=d.buffer.active.getLine(p);if(C!=null&&C.isWrapped)return m?void(_.startCol+=d.cols):(_.startRow--,_.startCol+=d.cols,this._findInLine(g,_,y));let S=(h=this._linesCache)===null||h===void 0?void 0:h[p];S||(S=this._translateBufferLineToStringWithWrap(p,!0),this._linesCache&&(this._linesCache[p]=S));const[b,w]=S,E=this._bufferColsToStringOffset(p,v),x=y.caseSensitive?g:g.toLowerCase(),k=y.caseSensitive?b:b.toLowerCase();let D=-1;if(y.regex){const R=RegExp(x,"g");let O;if(m)for(;O=R.exec(k.slice(0,E));)D=R.lastIndex-O[0].length,g=O[0],R.lastIndex-=g.length-1;else O=R.exec(k.slice(E)),O&&O[0].length>0&&(D=E+(R.lastIndex-O[0].length),g=O[0])}else m?E-x.length>=0&&(D=k.lastIndexOf(x,E-x.length)):D=k.indexOf(x,E);if(D>=0){if(y.wholeWord&&!this._isWholeWord(D,k,g))return;let R=0;for(;R<w.length-1&&D>=w[R+1];)R++;let O=R;for(;O<w.length-1&&D+g.length>=w[O+1];)O++;const G=D-w[R],q=D+g.length-w[O],X=this._stringLengthToBufferSize(p+R,G);return{term:g,col:X,row:p+R,size:this._stringLengthToBufferSize(p+O,q)-X+d.cols*(O-R)}}}_stringLengthToBufferSize(g,_){const y=this._terminal.buffer.active.getLine(g);if(!y)return 0;for(let m=0;m<_;m++){const h=y.getCell(m);if(!h)break;const d=h.getChars();d.length>1&&(_-=d.length-1);const p=y.getCell(m+1);p&&p.getWidth()===0&&_++}return _}_bufferColsToStringOffset(g,_){const y=this._terminal;let m=g,h=0,d=y.buffer.active.getLine(m);for(;_>0&&d;){for(let p=0;p<_&&p<y.cols;p++){const v=d.getCell(p);if(!v)break;v.getWidth()&&(h+=v.getCode()===0?1:v.getChars().length)}if(m++,d=y.buffer.active.getLine(m),d&&!d.isWrapped)break;_-=y.cols}return h}_translateBufferLineToStringWithWrap(g,_){var y;const m=this._terminal,h=[],d=[0];let p=m.buffer.active.getLine(g);for(;p;){const v=m.buffer.active.getLine(g+1),C=!!v&&v.isWrapped;let S=p.translateToString(!C&&_);if(C&&v){const b=p.getCell(p.length-1);b&&b.getCode()===0&&b.getWidth()===1&&((y=v.getCell(0))===null||y===void 0?void 0:y.getWidth())===2&&(S=S.slice(0,-1))}if(h.push(S),!C)break;d.push(d[d.length-1]+S.length),g++,p=v}return[h.join(""),d]}_selectResult(g,_,y){const m=this._terminal;if(this._selectedDecoration.clear(),!g)return m.clearSelection(),!1;if(m.select(g.col,g.row,g.size),_){const h=m.registerMarker(-m.buffer.active.baseY-m.buffer.active.cursorY+g.row);if(h){const d=m.registerDecoration({marker:h,x:g.col,width:g.size,backgroundColor:_.activeMatchBackground,layer:"top",overviewRulerOptions:{color:_.activeMatchColorOverviewRuler}});if(d){const p=[];p.push(h),p.push(d.onRender(v=>this._applyStyles(v,_.activeMatchBorder,!0))),p.push(d.onDispose(()=>(0,l.disposeArray)(p))),this._selectedDecoration.value={decoration:d,match:g,dispose(){d.dispose()}}}}}if(!y&&(g.row>=m.buffer.active.viewportY+m.rows||g.row<m.buffer.active.viewportY)){let h=g.row-m.buffer.active.viewportY;h-=Math.floor(m.rows/2),m.scrollLines(h)}return!0}_applyStyles(g,_,y){g.classList.contains("xterm-find-result-decoration")||(g.classList.add("xterm-find-result-decoration"),_&&(g.style.outline=`1px solid ${_}`)),y&&g.classList.add("xterm-find-active-result-decoration")}_createResultDecoration(g,_){const y=this._terminal,m=y.registerMarker(-y.buffer.active.baseY-y.buffer.active.cursorY+g.row);if(!m)return;const h=y.registerDecoration({marker:m,x:g.col,width:g.size,backgroundColor:_.matchBackground,overviewRulerOptions:this._highlightedLines.has(m.line)?void 0:{color:_.matchOverviewRuler,position:"center"}});if(h){const d=[];d.push(m),d.push(h.onRender(p=>this._applyStyles(p,_.matchBorder,!1))),d.push(h.onDispose(()=>(0,l.disposeArray)(d)))}return h}}a.SearchAddon=f})(),c})())})(is);var kn=is.exports;class Rn{constructor(){this.keyPair=null,this.serverPublicKey=null,this.useWebCrypto=this._isSecureContext(),this.microRsa=null,console.log("🔧 EncryptionService constructor:",{protocol:window.location.protocol,hostname:window.location.hostname,isSecureContext:window.isSecureContext,hasWebCrypto:!!(window.crypto&&window.crypto.subtle),useWebCrypto:this.useWebCrypto}),this.useWebCrypto?console.log("✅ Will use Web Crypto API"):console.warn("🔓 HTTP environment detected - will use micro-rsa-dsa-dh fallback")}_isSecureContext(){if(typeof window=="undefined")return!1;const t=!!(window.crypto&&window.crypto.subtle),i=window.isSecureContext||window.location.protocol==="https:",r=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"||window.location.hostname==="::1";if(console.log("🔧 _isSecureContext check:",{hasWebCrypto:t,isSecure:i,isLocalhost:r,protocol:window.location.protocol,hostname:window.location.hostname}),t&&(i||r))try{return window.crypto.subtle.generateKey&&window.crypto.subtle.encrypt?(console.log("✅ Web Crypto API methods are available"),!0):(console.warn("⚠️ Web Crypto API object exists but methods not available"),!1)}catch(n){return console.warn("⚠️ Web Crypto API test failed:",n.message),!1}return!i&&!r?(console.warn("🔧 HTTP environment detected - will use micro-rsa-dsa-dh fallback"),!1):t&&(i||r)}_loadNodeForge(){return Ve(this,null,function*(){if(!this.nodeForge)try{const t=yield Promise.resolve().then(()=>Tc);this.nodeForge=t.default||t,console.log("✅ node-forge loaded for HTTP environment")}catch(t){console.error("❌ Failed to load node-forge from node_modules:",t),console.warn("⚠️ Using mock crypto implementation for testing"),this.nodeForge={pki:{rsa:{generateKeyPair:()=>({publicKey:{encrypt:()=>new Uint8Array(256)},privateKey:{decrypt:()=>new Uint8Array([72,101,108,108,111])}})}},md:{sha256:{create:()=>({digest:()=>({bytes:()=>new Uint8Array(32)})})}}},console.log("✅ Mock crypto implementation loaded")}return this.nodeForge})}_generateNodeForgeKeyPair(){return Ve(this,null,function*(){const t=yield this._loadNodeForge();console.log("✅ node-forge loaded successfully");try{console.log("🔧 Generating RSA key pair with node-forge...");const i=t.pki.rsa.generateKeyPair({bits:2048});return this.keyPair={publicKey:{type:"public",algorithm:{name:"RSA-OAEP",hash:"SHA-256"},extractable:!0,usages:["encrypt"],nodeForge:i.publicKey,pem:t.pki.publicKeyToPem(i.publicKey)},privateKey:{type:"private",algorithm:{name:"RSA-OAEP",hash:"SHA-256"},extractable:!0,usages:["decrypt"],nodeForge:i.privateKey,pem:t.pki.privateKeyToPem(i.privateKey)}},console.log("🔧 RSA key pair generated successfully with node-forge"),this.keyPair}catch(i){throw console.error("❌ Failed to generate key pair with node-forge:",i),new Error("Key generation failed: "+i.message)}})}generateKeyPair(){return Ve(this,null,function*(){try{if(this.useWebCrypto){console.log("🔧 Attempting Web Crypto API key generation...");try{this.keyPair=yield window.crypto.subtle.generateKey({name:"RSA-OAEP",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:"SHA-256"},!0,["encrypt","decrypt"]),console.log("✅ Web Crypto API key generation successful")}catch(t){return console.error("❌ Web Crypto API failed in this environment:",t),console.warn("🔄 Falling back to node-forge..."),this.useWebCrypto=!1,yield this._generateNodeForgeKeyPair()}}else return yield this._generateNodeForgeKeyPair();return this.keyPair}catch(t){throw console.error("❌ Lỗi tạo key pair:",t),new Error("Không thể tạo key pair")}})}exportPublicKey(){return Ve(this,arguments,function*(t=this.keyPair){try{if(this.useWebCrypto){const i=yield window.crypto.subtle.exportKey("spki",t.publicKey),r=String.fromCharCode(...new Uint8Array(i));return`-----BEGIN PUBLIC KEY-----
${window.btoa(r)}
-----END PUBLIC KEY-----`}else return console.warn("⚠️ Using mock public key export for HTTP testing"),`-----BEGIN PUBLIC KEY-----
${btoa("mock-public-key-data-for-testing")}
-----END PUBLIC KEY-----`}catch(i){throw console.error("❌ Lỗi export public key:",i),new Error("Không thể export public key")}})}importServerPublicKey(t){return Ve(this,null,function*(){try{const i=t.replace(/\r\n/g,`
`).replace(/\r/g,`
`),r="-----BEGIN PUBLIC KEY-----",n="-----END PUBLIC KEY-----";if(!i.includes(r)||!i.includes(n))throw new Error("Invalid PEM format - missing headers");const c=i.indexOf(r)+r.length,a=i.indexOf(n);if(c===-1||a===-1||c>=a)throw new Error("Invalid PEM format - malformed headers");const l=i.substring(c,a).replace(/\s+/g,"");if(l.length===0)throw new Error("Empty PEM content after cleaning");let o;try{o=window.atob(l)}catch(u){throw new Error("Invalid base64 content in PEM")}const f=new Uint8Array(o.length);for(let u=0;u<o.length;u++)f[u]=o.charCodeAt(u);return this.useWebCrypto?(this.serverPublicKey=yield window.crypto.subtle.importKey("spki",f.buffer,{name:"RSA-OAEP",hash:"SHA-256"},!0,["encrypt"]),console.log("🔧 Server public key imported successfully:",this.serverPublicKey)):(console.warn("⚠️ Using node-forge server public key import for HTTP testing"),this.serverPublicKey={type:"node-forge-server-key",pem:t},console.log("✅ Server public key stored for node-forge")),this.serverPublicKey}catch(i){throw console.error("❌ Import server public key error:",i),new Error("Không thể import server public key: "+i.message)}})}encryptForServer(r){return Ve(this,arguments,function*(t,i=this.serverPublicKey){try{if(console.log("🔧 encryptForServer called with:",{dataLength:t==null?void 0:t.length,hasPublicKey:!!i,useWebCrypto:this.useWebCrypto,publicKeyType:typeof i}),!i)throw new Error("Server public key chưa được import");if(this.useWebCrypto){console.log("🔧 Using Web Crypto API for encryption");const c=new TextEncoder().encode(t);console.log("🔧 Encoded data length:",c.length),console.log("🔧 Public key object:",i);const a=yield window.crypto.subtle.encrypt({name:"RSA-OAEP"},i,c);console.log("🔧 Encryption successful, result length:",a.byteLength);const s=btoa(String.fromCharCode(...new Uint8Array(a)));return console.log("🔧 Base64 result length:",s.length),s}else{console.warn("⚠️ Using node-forge RSA encryption for HTTP environment");try{const n=yield this._loadNodeForge();if(!i||!i.pem)throw new Error("Server public key not available for node-forge");console.log("🔧 Attempting node-forge RSA encryption...");try{const c=n.pki.publicKeyFromPem(i.pem);console.log("✅ Successfully parsed RSA public key with node-forge"),console.log("🔧 Encrypting with node-forge RSA-OAEP...");const a=c.encrypt(t,"RSA-OAEP",{md:n.md.sha256.create(),mgf1:{md:n.md.sha256.create()}}),s=btoa(a);return console.log("✅ RSA-OAEP encryption successful with node-forge"),console.log(`🔧 Encrypted data length: ${s.length} chars`),s}catch(c){console.error("❌ Real encryption failed, falling back to mock:",c),console.warn("⚠️ Using mock encryption as fallback");const a=new Uint8Array(256);if(window.crypto&&window.crypto.getRandomValues){window.crypto.getRandomValues(a);const l=new TextEncoder().encode(t);for(let o=0;o<l.length&&o<a.length;o++)a[o]^=l[o]}else{const l=new TextEncoder().encode(t);for(let o=0;o<a.length;o++)a[o]=(l[o%l.length]+o+42)%256}const s=btoa(String.fromCharCode(...a));return console.log("⚠️ Generated mock encryption result"),s}}catch(n){throw console.error("❌ node-forge encryption failed:",n),new Error("Không thể mã hóa với node-forge: "+n.message)}}}catch(n){throw console.error("❌ Lỗi mã hóa dữ liệu:",n),console.error("❌ Error stack:",n.stack),new Error("Không thể mã hóa dữ liệu: "+n.message)}})}decryptFromServer(t){return Ve(this,null,function*(){try{if(!this.keyPair)throw new Error("Key pair chưa được tạo");if(this.useWebCrypto){console.log("🔧 Using Web Crypto API for decryption");const i=atob(t),r=new Uint8Array(i.length);for(let a=0;a<i.length;a++)r[a]=i.charCodeAt(a);const n=yield window.crypto.subtle.decrypt({name:"RSA-OAEP"},this.keyPair.privateKey,r);return new TextDecoder().decode(n)}else{console.log("🔧 Using node-forge for decryption"),yield this._loadNodeForge();const i=this.keyPair.privateKey.nodeForge,r=atob(t);return i.decrypt(r,"RSA-OAEP",{md:forge.md.sha256.create(),mgf1:{md:forge.md.sha256.create()}})}}catch(i){throw console.error("❌ Lỗi giải mã dữ liệu:",i),new Error("Không thể giải mã dữ liệu: "+i.message)}})}generateAESKey(){return Ve(this,null,function*(){try{return yield window.crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"])}catch(t){throw console.error("❌ Lỗi tạo AES key:",t),new Error("Không thể tạo AES key")}})}encryptAES(t,i){return Ve(this,null,function*(){try{const n=new TextEncoder().encode(t),c=window.crypto.getRandomValues(new Uint8Array(12)),a=yield window.crypto.subtle.encrypt({name:"AES-GCM",iv:c},i,n),s=new Uint8Array(c.length+a.byteLength);return s.set(c),s.set(new Uint8Array(a),c.length),btoa(String.fromCharCode(...s))}catch(r){throw console.error("❌ Lỗi mã hóa AES:",r),new Error("Không thể mã hóa AES")}})}decryptAES(t,i){return Ve(this,null,function*(){try{const r=atob(t),n=new Uint8Array(r.length);for(let o=0;o<r.length;o++)n[o]=r.charCodeAt(o);const c=n.slice(0,12),a=n.slice(12),s=yield window.crypto.subtle.decrypt({name:"AES-GCM",iv:c},i,a);return new TextDecoder().decode(s)}catch(r){throw console.error("❌ Lỗi giải mã AES:",r),new Error("Không thể giải mã AES")}})}hash(t){return Ve(this,null,function*(){try{if(this.useWebCrypto){const r=new TextEncoder().encode(t),n=yield window.crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(n)).map(a=>a.toString(16).padStart(2,"0")).join("")}else if(console.warn("⚠️ Using mock hash for HTTP testing"),window.crypto&&window.crypto.getRandomValues){let i=0;for(let n=0;n<t.length;n++){const c=t.charCodeAt(n);i=(i<<5)-i+c,i=i&i}return Math.abs(i).toString(16).padStart(8,"0").repeat(8).substring(0,64)}else{let i=0;for(let r=0;r<t.length;r++)i=(i<<5)-i+t.charCodeAt(r),i=i&i;return Math.abs(i).toString(16).padStart(8,"0").repeat(8).substring(0,64)}}catch(i){throw console.error("❌ Lỗi tạo hash:",i),new Error("Không thể tạo hash")}})}generateRandomString(t=32){if(this.useWebCrypto){const i=new Uint8Array(t);return window.crypto.getRandomValues(i),Array.from(i,r=>r.toString(16).padStart(2,"0")).join("")}else{console.warn("⚠️ Using Math.random for random generation in HTTP environment");let i="";const r="0123456789abcdef";for(let n=0;n<t*2;n++)i+=r.charAt(Math.floor(Math.random()*r.length));return i}}}class Dn{static validateSSHConfig(t){const i=[];return t.host?typeof t.host!="string"?i.push("Host phải là string"):t.host.length>255?i.push("Host quá dài (tối đa 255 ký tự)"):this.isValidHost(t.host)||i.push("Host không hợp lệ"):i.push("Host là bắt buộc"),t.username?typeof t.username!="string"?i.push("Username phải là string"):t.username.length>32?i.push("Username quá dài (tối đa 32 ký tự)"):this.isValidUsername(t.username)||i.push("Username chứa ký tự không hợp lệ"):i.push("Username là bắt buộc"),t.password?typeof t.password!="string"?i.push("Password phải là string"):t.password.length<1?i.push("Password không được để trống"):t.password.length>128&&i.push("Password quá dài (tối đa 128 ký tự)"):i.push("Password là bắt buộc"),t.port!==void 0&&(Number.isInteger(t.port)?(t.port<1||t.port>65535)&&i.push("Port phải trong khoảng 1-65535"):i.push("Port phải là số nguyên")),t.wsUrl&&!this.isValidWebSocketURL(t.wsUrl)&&i.push("WebSocket URL không hợp lệ"),{isValid:i.length===0,errors:i}}static isValidHost(t){return/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(t)||/^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(t)?!0:/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/.test(t)}static isValidUsername(t){return/^[a-zA-Z0-9_-]+$/.test(t)}static isValidWebSocketURL(t){try{const i=new URL(t);return i.protocol==="ws:"||i.protocol==="wss:"}catch(i){return!1}}static validateEncryptionReadiness(t,i){const r=[];return t||r.push("Encryption service not initialized"),i||r.push("Server public key not available"),{isValid:r.length===0,errors:r}}static validateComputingConfig(t){const i=[];return t.computingId?typeof t.computingId!="string"?i.push("Computing ID must be a string"):/^[0-9.]+$/.test(t.computingId)?t.computingId.length>50&&i.push("Computing ID must not exceed 50 characters"):i.push("Computing ID must contain only numbers and dots"):i.push("Computing ID is required"),t.userToken?typeof t.userToken!="string"?i.push("User token must be a string"):t.userToken.length>8192&&i.push("User token is too large"):i.push("User token is required"),t.wsUrl&&!this.isValidWebSocketURL(t.wsUrl)&&i.push("Invalid WebSocket URL"),{isValid:i.length===0,errors:i}}static validateSecureConnection(t){const i=[],r=[];if(!t)return i.push("WebSocket URL is required"),{isValid:!1,errors:i,warnings:r};try{const n=new URL(t);n.protocol==="ws:"?r.push("Warning: Using unencrypted WebSocket (ws://). Consider using wss:// for better security."):n.protocol!=="wss:"&&i.push("Invalid WebSocket protocol. Only ws:// and wss:// are supported.")}catch(n){i.push("Invalid WebSocket URL format")}return{isValid:i.length===0,errors:i,warnings:r}}static sanitizeString(t,i=255){return typeof t!="string"?"":t.trim().slice(0,i).replace(/[\x00-\x1F\x7F]/g,"")}static validateTerminalOptions(t){const i=[];if(typeof t!="object"||t===null)return{isValid:!1,errors:["Options phải là object"]};if(t.fontSize!==void 0&&(!Number.isInteger(t.fontSize)||t.fontSize<8||t.fontSize>72)&&i.push("fontSize phải là số nguyên từ 8-72"),t.scrollback!==void 0&&(!Number.isInteger(t.scrollback)||t.scrollback<0||t.scrollback>1e4)&&i.push("scrollback phải là số nguyên từ 0-10000"),t.theme!==void 0)if(typeof t.theme!="object")i.push("theme phải là object");else{const r=["background","foreground","cursor","cursorAccent","selection"];for(const[n,c]of Object.entries(t.theme))r.includes(n)&&typeof c=="string"&&(this.isValidColor(c)||i.push(`theme.${n} không phải màu hợp lệ`))}return t.reconnection!==void 0&&(typeof t.reconnection!="object"?i.push("reconnection phải là object"):(t.reconnection.maxAttempts!==void 0&&(!Number.isInteger(t.reconnection.maxAttempts)||t.reconnection.maxAttempts<0||t.reconnection.maxAttempts>20)&&i.push("reconnection.maxAttempts phải là số nguyên từ 0-20"),t.reconnection.heartbeatInterval!==void 0&&(!Number.isInteger(t.reconnection.heartbeatInterval)||t.reconnection.heartbeatInterval<1e3||t.reconnection.heartbeatInterval>3e5)&&i.push("reconnection.heartbeatInterval phải là số nguyên từ 1000-300000ms"))),{isValid:i.length===0,errors:i}}static isValidColor(t){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t)?!0:/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(t)}static isValidJWTFormat(t){if(typeof t!="string")return!1;const i=t.split(".");return i.length===3&&i.every(r=>r.length>0)}static validateMessageSize(t,i=1e4){if(typeof t=="string")return t.length<=i;if(t instanceof ArrayBuffer)return t.byteLength<=i;try{return JSON.stringify(t).length<=i}catch(r){return!1}}static sanitizeForLogging(t){if(typeof t!="object"||t===null)return t;const i=["password","token","key","secret","auth","credential"],r={};for(const[n,c]of Object.entries(t)){const a=n.toLowerCase();i.some(s=>a.includes(s))?r[n]="***HIDDEN***":typeof c=="object"&&c!==null?r[n]=this.sanitizeForLogging(c):r[n]=c}return r}}const ft=Dn,Pn=Object.freeze(Object.defineProperty({__proto__:null,default:ft},Symbol.toStringTag,{value:"Module"})),ar=class ar{constructor(){this.isProduction=typeof window!="undefined"&&window.location.hostname!=="localhost"&&window.location.hostname!=="127.0.0.1",this.logLevel=this.isProduction?"error":"debug",this.maxLogLength=1e3}shouldLog(t){return ar.LEVELS[t]>=ar.LEVELS[this.logLevel]}sanitizeData(t){if(t==null)return t;const i=ft.sanitizeForLogging(t),r=JSON.stringify(i);return r.length>this.maxLogLength?wn(Gt({},i),{_truncated:!0,_originalLength:r.length}):i}formatMessage(t,i,r=null){const c=`[${new Date().toISOString()}] [${t.toUpperCase()}] [CLIENT]`;if(r){const a=this.sanitizeData(r);return`${c} ${i} ${JSON.stringify(a)}`}return`${c} ${i}`}debug(t,i=null){this.shouldLog("debug")&&console.debug(this.formatMessage("debug",t,i))}info(t,i=null){this.shouldLog("info")&&console.info(this.formatMessage("info",t,i))}warn(t,i=null){this.shouldLog("warn")&&console.warn(this.formatMessage("warn",t,i))}error(t,i=null){this.shouldLog("error")&&console.error(this.formatMessage("error",t,i))}logConnection(t,i={}){const r=this.sanitizeData(i);this.info(`Connection ${t}`,r)}logAuth(t,i={}){const r=this.sanitizeData(i);this.info(`Auth ${t}`,r)}logSecurity(t,i={}){const r=this.sanitizeData(i);this.warn(`Security ${t}`,r)}logPerformance(t,i,r="ms"){this.debug(`Performance ${t}`,{value:i,unit:r})}log(t,i,r=null){this.shouldLog(t)&&console[t](this.formatMessage(t,i,r))}createContextLogger(t){return{debug:(i,r)=>this.debug(`[${t}] ${i}`,r),info:(i,r)=>this.info(`[${t}] ${i}`,r),warn:(i,r)=>this.warn(`[${t}] ${i}`,r),error:(i,r)=>this.error(`[${t}] ${i}`,r),logConnection:(i,r)=>this.logConnection(`[${t}] ${i}`,r),logAuth:(i,r)=>this.logAuth(`[${t}] ${i}`,r),logSecurity:(i,r)=>this.logSecurity(`[${t}] ${i}`,r),logPerformance:(i,r,n)=>this.logPerformance(`[${t}] ${i}`,r,n)}}createContext(t){return this.createContextLogger(t)}setLogLevel(t){ar.LEVELS.hasOwnProperty(t)&&(this.logLevel=t)}getLogLevel(){return this.logLevel}setProductionMode(t){this.isProduction=t,this.logLevel=t?"error":"debug"}};Tn(ar,"LEVELS",{debug:0,info:1,warn:2,error:3});let Ar=ar;const ii=new Ar,Nn=Object.freeze(Object.defineProperty({__proto__:null,SecureLogger:Ar,default:ii},Symbol.toStringTag,{value:"Module"}));class On{constructor(){this.connections=new Map,this.contextLogger=ii.createContextLogger("WebSocketPool")}getConnection(t,i,r){return Ve(this,null,function*(){this.contextLogger.info("Getting WebSocket connection",{wsUrl:t,connectionKey:i}),this.connections.has(t)||this.connections.set(t,new Map);const n=this.connections.get(t);if(n.has(i)){const c=n.get(i),a=c.socket;if(a.readyState===WebSocket.OPEN||a.readyState===WebSocket.CONNECTING)return this.contextLogger.info("Reusing existing WebSocket",{connectionKey:i}),c.handlers=r,a;this.contextLogger.info("Existing WebSocket is dead, creating new one",{connectionKey:i}),n.delete(i)}return this.createNewConnection(t,i,r)})}createNewConnection(t,i,r){const{onMessage:n,onError:c,onClose:a,onOpen:s}=r;this.contextLogger.info("Creating new WebSocket connection",{wsUrl:t,connectionKey:i}),console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"),console.log("🔌 Creating WebSocket");const l=new WebSocket(t),o=this.connections.get(t);return o.set(i,{socket:l,handlers:r}),l.onopen=()=>{if(console.log(`✅ [${i}] WebSocket OPENED`),this.contextLogger.info("WebSocket opened",{wsUrl:t,connectionKey:i}),s)try{s()}catch(f){this.contextLogger.error("Error in onOpen handler",{error:f.message})}},l.onmessage=f=>{const u=o.get(i);if(!u)return;const g=u.handlers;try{g.onMessage&&g.onMessage(f)}catch(_){this.contextLogger.error("Error in onMessage handler",{connectionKey:i,error:_.message})}},l.onerror=f=>{console.error(`❌ [${i}] WebSocket ERROR:`,f),this.contextLogger.error("WebSocket error",{wsUrl:t,connectionKey:i,error:f});const u=o.get(i);if(u&&u.handlers.onError)try{u.handlers.onError(f)}catch(g){this.contextLogger.error("Error in onError handler",{error:g.message})}},l.onclose=f=>{console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"),console.log(`🚪 [${i}] WebSocket CLOSED`),console.log("Code:",f.code),console.log("Reason:",f.reason||"(empty)"),console.log("Was Clean:",f.wasClean),console.log("Timestamp:",new Date().toISOString()),console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"),this.contextLogger.info("WebSocket closed",{wsUrl:t,connectionKey:i,code:f.code,reason:f.reason,wasClean:f.wasClean});const u=o.get(i),g=u?u.handlers:null;if(o.delete(i),console.log(`📊 After close - Remaining connections: ${o.size}`),o.size===0&&(this.connections.delete(t),this.contextLogger.info("All connections closed for URL",{wsUrl:t})),g&&g.onClose)try{g.onClose(f)}catch(_){this.contextLogger.error("Error in onClose handler",{error:_.message})}},l}removeSubscriber(t,i){this.contextLogger.info("Removing subscriber",{wsUrl:t,connectionKey:i});const r=this.connections.get(t);if(!r){this.contextLogger.warn("No connections found for URL",{wsUrl:t});return}const n=r.get(i);if(!n){this.contextLogger.warn("Connection not found",{connectionKey:i});return}const c=n.socket;c&&c.readyState!==WebSocket.CLOSED&&c.readyState!==WebSocket.CLOSING&&c.close(1e3,"Subscriber removed"),r.delete(i),r.size===0&&(this.connections.delete(t),this.contextLogger.info("All connections removed for URL",{wsUrl:t}))}send(t,i,r){const n=this.connections.get(t);if(!n)throw new Error(`No connections found for ${t}`);const c=n.get(i);if(!c)throw new Error(`No connection found for key: ${i}`);const a=c.socket;if(a.readyState!==WebSocket.OPEN)throw new Error(`Connection not ready (state: ${a.readyState})`);const s=typeof r=="string"?r:JSON.stringify(r);a.send(s)}isConnected(t,i){const r=this.connections.get(t);if(!r)return!1;const n=r.get(i);return n?n.socket.readyState===WebSocket.OPEN:!1}getConnectionCount(t){const i=this.connections.get(t);return i?i.size:0}dispose(){this.contextLogger.info("Disposing all connections"),this.connections.forEach((t,i)=>{t.forEach((r,n)=>{const c=r.socket;c.readyState!==WebSocket.CLOSED&&c.readyState!==WebSocket.CLOSING&&c.close(1e3,"Pool disposed")})}),this.connections.clear()}getDebugInfo(){const t={};return this.connections.forEach((i,r)=>{t[r]={count:i.size,connections:[]},i.forEach((n,c)=>{t[r].connections.push({key:c,state:n.socket.readyState,stateText:["CONNECTING","OPEN","CLOSING","CLOSED"][n.socket.readyState]})})}),t}}const Je=new On,ss={fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',theme:{background:"#000000",foreground:"#ffffff",cursor:"#ffffff",cursorAccent:"#000000",selection:"rgba(255, 255, 255, 0.3)"},cursorBlink:!0,cursorStyle:"block",scrollback:1e3,allowTransparency:!1,tabStopWidth:8,screenReaderMode:!1,convertEol:!0,disableStdin:!1,reconnection:{enabled:!0,maxAttempts:5,heartbeatInterval:3e4}};function Mn(e,t,i={}){var N,U;const r=ii.createContextLogger("Terminal");if(!e)throw r.error("Container element is required"),new Error("Container element is required");let n;if(t.computingId&&t.userToken){if(n=ft.validateComputingConfig(t),!n.isValid)throw r.error("Invalid computing configuration",{errors:n.errors}),new Error(`Computing configuration invalid: ${n.errors.join(", ")}`)}else if(n=ft.validateSSHConfig(t),!n.isValid)throw r.error("Invalid SSH configuration",{errors:n.errors}),new Error(`SSH configuration invalid: ${n.errors.join(", ")}`);const a=ft.validateTerminalOptions(i);if(!a.isValid)throw r.error("Invalid terminal options",{errors:a.errors}),new Error(`Terminal options invalid: ${a.errors.join(", ")}`);const s=Gt(Gt(Gt({},ss),i.theme?{theme:Gt(Gt({},ss.theme),i.theme)}:{}),i),l=i.showConnectionLogs===!0,o=new Bn.Terminal(s),f=new In.FitAddon,u=new Ln.WebLinksAddon,g=new kn.SearchAddon;o.loadAddon(f),o.loadAddon(u),o.loadAddon(g),o.open(e),setTimeout(()=>{f.fit()},0);const _=t.wsUrl||"wss://ssh-proxy.dev.longvan.vn";if(!ft.isValidWebSocketURL(_))throw r.error("Invalid WebSocket URL",{wsUrl:_}),new Error("Invalid WebSocket URL");const y=ft.validateSecureConnection(_);if(!y.isValid)throw r.error("Insecure WebSocket connection",{errors:y.errors}),new Error(`Insecure connection: ${y.errors.join(", ")}`);y.warnings&&y.warnings.length>0&&y.warnings.forEach(z=>{o.writeln(`⚠️ ${z}`)});let m=!1,h=null,d=null,p=0;const v=((N=s.reconnection)==null?void 0:N.maxAttempts)||5,C=((U=s.reconnection)==null?void 0:U.enabled)!==!1;let S=null,b=!1,w=!1;const E=t.computingId||`direct-${Date.now()}`,x=t.tabClientId||`direct-${Date.now()}`,k=ri.getTabId(),D=`${k}:${x}`;r.info("Creating terminal",{tabId:k,computingId:E,connectionKey:D}),console.log("Creating terminal",{tabId:k,computingId:E,connectionKey:D});const R=()=>Ve(this,null,function*(){try{return h=new Rn,yield h.generateKeyPair(),!0}catch(z){return r.error("Failed to initialize encryption",{error:z.message}),!1}}),O=()=>Ve(this,null,function*(){try{const z=ft.validateEncryptionReadiness(h,d);if(!z.isValid)throw new Error(`Encryption not ready: ${z.errors.join(", ")}`);let $;console.log("typeConnect in createTerminal",t.typeConnect);const se=t.typeConnect||"ssh";if(console.log("currentTypeConnect terminal",se),t.computingId&&t.userToken){const te=yield h.encryptForServer(t.userToken,d);$={type:"encrypted-auth",computingId:t.computingId,encryptedToken:te,clientPublicKey:yield h.exportPublicKey(),typeConnect:se},l&&o.writeln("🔐 Sent encrypted computing credentials...")}else{const te=yield h.encryptForServer(t.password,d);$={type:"encrypted-auth",host:t.host,username:t.username,encryptedPassword:te,clientPublicKey:yield h.exportPublicKey(),typeConnect:se},l&&o.writeln("🔐 Sent encrypted SSH credentials...")}Je.send(_,D,$)}catch(z){throw r.error("Failed to send encrypted auth",{error:z.message}),o.writeln(`\r
❌ Encryption failed: ${z.message}\r
`),o.writeln(`🔒 This client only supports secure encrypted authentication.\r
`),Je.removeSubscriber(_,D),z}}),G=()=>{if(b)return;b=!0,p++;const z=Math.min(1e3*Math.pow(2,p-1),3e4);o.writeln(`\r
Attempting to reconnect (${p}/${v}) in ${z/1e3}s...\r
`),S=setTimeout(()=>{P()},z)},q=()=>Ve(this,null,function*(){m=!0,p=0,b=!1,l&&o.writeln(p>0?`\r
✅ Reconnected to SSH relay server\r
`:"✅ WebSocket connected to "+_),l&&o.writeln("🔑 Waiting for server public key...")}),X=z=>Ve(this,null,function*(){try{if(!z||!z.data)return;let $;if(typeof z.data=="string")try{$=JSON.parse(z.data)}catch(te){o.write(z.data);return}else $=z.data;if(console.log(`📩 Message from Server [${$.type}]:`,$),$.type==="rdp-redirect"){r.info("🚀 Received RDP redirect command",{url:$.url}),typeof o._onRdpRedirect=="function"&&o._onRdpRedirect($);return}if(!ft.validateMessageSize(z.data,5e4)){r.logSecurity("message_too_large",{size:z.data.length});return}if($.type==="welcome"){try{if($.publicKey)d=yield h.importServerPublicKey($.publicKey),l&&o.writeln("🔑 Server public key received"),yield O();else{o.writeln(`\r
❌ Server does not support encrypted authentication\r
`),o.writeln(`🔒 This client requires RSA encryption for security\r
`),Je.removeSubscriber(_,D);return}}catch(te){r.error("Failed to process welcome message",{error:te.message}),o.writeln(`\r
❌ Failed to process server welcome: ${te.message}\r
`),Je.removeSubscriber(_,D);return}return}if(!(!$.computingId||$.computingId===E))return;if($.type==="data")try{const te=window.atob($.data),de=new Uint8Array(te.length);for(let V=0;V<te.length;V++)de[V]=te.charCodeAt(V);const I=new TextDecoder().decode(de);o.write(I)}catch(te){r.error("Failed to decode terminal data",{error:te.message});try{o.write(window.atob($.data))}catch(de){o.write($.data)}}else $.type==="error"?(r.error("Server error received",{code:$.code,message:$.message}),o.writeln(`\r
❌ Error: ${$.message}\r
`)):$.type==="status"&&$.status==="authenticated"?(w=!0,console.log("Xác thực thành công"),l&&o.writeln(`\r
✅ Connected to ${t.host} as ${t.username}\r
`)):$.type==="status"&&$.status==="closed"?l&&o.writeln(`\r
🔌 SSH connection closed\r
`):$.type==="auth-success"?(w=!0,console.log("Xác thực thành công"),l&&o.writeln(`\r
✅ Authentication successful!\r
`),$.host&&$.username&&(t.host=$.host,t.username=$.username,t.port=$.port||22)):$.type==="session-created"?w=!0:$.type==="auth-error"&&(r.logAuth("auth_failed",{message:$.message}),o.writeln(`\r
❌ Authentication failed: ${$.message}\r
`))}catch($){z&&z.data&&o.write(z.data)}}),W=z=>{m=!1,o.writeln(`\r
WebSocket error: ${(z==null?void 0:z.message)||"Unknown error"}\r
`),o.writeln(`\r
Please check if the SSH proxy server is running at ${_}\r
`)},L=z=>{if(!z)return;if(m=!1,z.code===1e3){o.writeln(`\r
Connection to SSH relay server closed normally\r
`);return}const se={1006:"Connection lost (network issue or server restart)",1001:"Server going away",1002:"Protocol error",1003:"Unsupported data type",1011:"Server error",1012:"Server restart",1013:"Server overloaded"}[z.code]||`Unknown error (Code: ${z.code})`;o.writeln(`\r
Connection to SSH relay server closed: ${se}\r
`),z.reason&&o.writeln(`Reason: ${z.reason}\r
`),C&&!b&&p<v?G():C&&p>=v&&o.writeln(`\r
Max reconnection attempts reached. Please refresh the page.\r
`)},P=()=>Ve(this,null,function*(){if(l&&(o.writeln(`🔌 Connecting to ${_}...`),o.writeln(`📱 Tab ID: ${k}`),o.writeln(`💻 Computing ID: ${E}`)),!(yield R())){o.writeln(`\r
❌ Failed to initialize encryption\r
`);return}try{const $={onOpen:q,onMessage:X,onError:W,onClose:L};yield Je.getConnection(_,D,$),r.info("Connected to WebSocket pool",{wsUrl:_,tabId:k,computingId:E,connectionKey:D,totalConnections:Je.getConnectionCount(_)})}catch($){r.error("Failed to connect",{error:$.message,wsUrl:_}),o.writeln(`\r
❌ Failed to connect: ${$.message}\r
`)}});return o.onData(z=>{if(m&&Je.isConnected(_,D)){if(!ft.validateMessageSize(z,1e4)){r.warn("Terminal input too large",{size:z.length});return}let $;try{const te=new TextEncoder().encode(z),de=String.fromCharCode(...te);$=window.btoa(de)}catch(te){r.error("Failed to encode terminal data",{error:te.message});try{$=window.btoa(z)}catch(de){const I=z.replace(/[^\x00-\x7F]/g,"?");$=window.btoa(I)}}const se={type:"data",data:$,computingId:E};try{Je.send(_,D,se)}catch(te){r.error("Failed to send terminal data",{error:te.message})}}}),setTimeout(()=>{P()},100),f.fit(),{terminal:o,fitAddon:f,searchAddon:g,reconnect:()=>Ve(this,null,function*(){yield P()}),resize:()=>{if(!(!o||!f))if(f.fit(),Je.isConnected(_,D)&&w){const z={type:"resize",cols:o.cols,rows:o.rows};try{Je.send(_,D,z),console.log(`📏 Server PTY Resized to: ${o.cols}x${o.rows}`)}catch($){console.warn("⚠️ Failed to sync resize to server")}}else console.log("⏳ Resize deferred: Waiting for authentication...")},dispose:()=>{console.log(`🗑️  Disposing terminal [${D}]`),S&&clearTimeout(S),Je.removeSubscriber(_,D),o.dispose(),r.info("Terminal disposed",{wsUrl:_,tabId:k,computingId:E,connectionKey:D,remainingConnections:Je.getConnectionCount(_)})},getConnectionInfo:()=>({wsUrl:_,tabId:k,computingId:E,connectionKey:D,connected:Je.isConnected(_,D),totalConnections:Je.getConnectionCount(_)})}}const Un=Object.freeze(Object.defineProperty({__proto__:null,createTerminal:Mn},Symbol.toStringTag,{value:"Module"}));var _e={options:{usePureJavaScript:!1}},si={},Fn=si,ns={};si.encode=function(e,t,i){if(typeof t!="string")throw new TypeError('"alphabet" must be a string.');if(i!==void 0&&typeof i!="number")throw new TypeError('"maxline" must be a number.');var r="";if(!(e instanceof Uint8Array))r=Hn(e,t);else{var n=0,c=t.length,a=t.charAt(0),s=[0];for(n=0;n<e.length;++n){for(var l=0,o=e[n];l<s.length;++l)o+=s[l]<<8,s[l]=o%c,o=o/c|0;for(;o>0;)s.push(o%c),o=o/c|0}for(n=0;e[n]===0&&n<e.length-1;++n)r+=a;for(n=s.length-1;n>=0;--n)r+=t[s[n]]}if(i){var f=new RegExp(".{1,"+i+"}","g");r=r.match(f).join(`\r
`)}return r},si.decode=function(e,t){if(typeof e!="string")throw new TypeError('"input" must be a string.');if(typeof t!="string")throw new TypeError('"alphabet" must be a string.');var i=ns[t];if(!i){i=ns[t]=[];for(var r=0;r<t.length;++r)i[t.charCodeAt(r)]=r}e=e.replace(/\s/g,"");for(var n=t.length,c=t.charAt(0),a=[0],r=0;r<e.length;r++){var s=i[e.charCodeAt(r)];if(s===void 0)return;for(var l=0,o=s;l<a.length;++l)o+=a[l]*n,a[l]=o&255,o>>=8;for(;o>0;)a.push(o&255),o>>=8}for(var f=0;e[f]===c&&f<e.length-1;++f)a.push(0);return typeof Buffer!="undefined"?Buffer.from(a.reverse()):new Uint8Array(a.reverse())};function Hn(e,t){var i=0,r=t.length,n=t.charAt(0),c=[0];for(i=0;i<e.length();++i){for(var a=0,s=e.at(i);a<c.length;++a)s+=c[a]<<8,c[a]=s%r,s=s/r|0;for(;s>0;)c.push(s%r),s=s/r|0}var l="";for(i=0;e.at(i)===0&&i<e.length()-1;++i)l+=n;for(i=c.length-1;i>=0;--i)l+=t[c[i]];return l}var as=_e,os=Fn,H=as.util=as.util||{};(function(){if(typeof process!="undefined"&&process.nextTick&&!process.browser){H.nextTick=process.nextTick,typeof setImmediate=="function"?H.setImmediate=setImmediate:H.setImmediate=H.nextTick;return}if(typeof setImmediate=="function"){H.setImmediate=function(){return setImmediate.apply(void 0,arguments)},H.nextTick=function(a){return setImmediate(a)};return}if(H.setImmediate=function(a){setTimeout(a,0)},typeof window!="undefined"&&typeof window.postMessage=="function"){let a=function(s){if(s.source===window&&s.data===e){s.stopPropagation();var l=t.slice();t.length=0,l.forEach(function(o){o()})}};var e="forge.setImmediate",t=[];H.setImmediate=function(s){t.push(s),t.length===1&&window.postMessage(e,"*")},window.addEventListener("message",a,!0)}if(typeof MutationObserver!="undefined"){var i=Date.now(),r=!0,n=document.createElement("div"),t=[];new MutationObserver(function(){var s=t.slice();t.length=0,s.forEach(function(l){l()})}).observe(n,{attributes:!0});var c=H.setImmediate;H.setImmediate=function(s){Date.now()-i>15?(i=Date.now(),c(s)):(t.push(s),t.length===1&&n.setAttribute("a",r=!r))}}H.nextTick=H.setImmediate})(),H.isNodejs=typeof process!="undefined"&&process.versions&&process.versions.node,H.globalScope=function(){return H.isNodejs?cr:typeof self=="undefined"?window:self}(),H.isArray=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},H.isArrayBuffer=function(e){return typeof ArrayBuffer!="undefined"&&e instanceof ArrayBuffer},H.isArrayBufferView=function(e){return e&&H.isArrayBuffer(e.buffer)&&e.byteLength!==void 0};function ur(e){if(!(e===8||e===16||e===24||e===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}H.ByteBuffer=ni;function ni(e){if(this.data="",this.read=0,typeof e=="string")this.data=e;else if(H.isArrayBuffer(e)||H.isArrayBufferView(e))if(typeof Buffer!="undefined"&&e instanceof Buffer)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch(r){for(var i=0;i<t.length;++i)this.putByte(t[i])}}else(e instanceof ni||typeof e=="object"&&typeof e.data=="string"&&typeof e.read=="number")&&(this.data=e.data,this.read=e.read);this._constructedStringLength=0}H.ByteStringBuffer=ni;var Vn=4096;H.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>Vn&&(this.data.substr(0,1),this._constructedStringLength=0)},H.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},H.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},H.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},H.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var i=this.data;t>0;)t&1&&(i+=e),t>>>=1,t>0&&(e+=e);return this.data=i,this._optimizeConstructedString(t),this},H.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},H.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(H.encodeUtf8(e))},H.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))},H.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))},H.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))},H.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255))},H.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},H.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},H.ByteStringBuffer.prototype.putInt=function(e,t){ur(t);var i="";do t-=8,i+=String.fromCharCode(e>>t&255);while(t>0);return this.putBytes(i)},H.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<<t-1),this.putInt(e,t)},H.ByteStringBuffer.prototype.putBuffer=function(e){return this.putBytes(e.getBytes())},H.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},H.ByteStringBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e},H.ByteStringBuffer.prototype.getInt24=function(){var e=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,e},H.ByteStringBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e},H.ByteStringBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e},H.ByteStringBuffer.prototype.getInt24Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,e},H.ByteStringBuffer.prototype.getInt32Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,e},H.ByteStringBuffer.prototype.getInt=function(e){ur(e);var t=0;do t=(t<<8)+this.data.charCodeAt(this.read++),e-=8;while(e>0);return t},H.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),i=2<<e-2;return t>=i&&(t-=i<<1),t},H.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t},H.ByteStringBuffer.prototype.bytes=function(e){return typeof e=="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},H.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},H.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},H.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},H.ByteStringBuffer.prototype.copy=function(){var e=H.createBuffer(this.data);return e.read=this.read,e},H.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},H.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},H.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},H.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var i=this.data.charCodeAt(t);i<16&&(e+="0"),e+=i.toString(16)}return e},H.ByteStringBuffer.prototype.toString=function(){return H.decodeUtf8(this.bytes())};function Kn(e,t){t=t||{},this.read=t.readOffset||0,this.growSize=t.growSize||1024;var i=H.isArrayBuffer(e),r=H.isArrayBufferView(e);if(i||r){i?this.data=new DataView(e):this.data=new DataView(e.buffer,e.byteOffset,e.byteLength),this.write="writeOffset"in t?t.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,e!=null&&this.putBytes(e),"writeOffset"in t&&(this.write=t.writeOffset)}H.DataBuffer=Kn,H.DataBuffer.prototype.length=function(){return this.write-this.read},H.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},H.DataBuffer.prototype.accommodate=function(e,t){if(this.length()>=e)return this;t=Math.max(t||this.growSize,e);var i=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),r=new Uint8Array(this.length()+t);return r.set(i),this.data=new DataView(r.buffer),this},H.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},H.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var i=0;i<t;++i)this.data.setUint8(e);return this},H.DataBuffer.prototype.putBytes=function(e,t){if(H.isArrayBufferView(e)){var i=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=i.byteLength-i.byteOffset;this.accommodate(r);var n=new Uint8Array(this.data.buffer,this.write);return n.set(i),this.write+=r,this}if(H.isArrayBuffer(e)){var i=new Uint8Array(e);this.accommodate(i.byteLength);var n=new Uint8Array(this.data.buffer);return n.set(i,this.write),this.write+=i.byteLength,this}if(e instanceof H.DataBuffer||typeof e=="object"&&typeof e.read=="number"&&typeof e.write=="number"&&H.isArrayBufferView(e.data)){var i=new Uint8Array(e.data.byteLength,e.read,e.length());this.accommodate(i.byteLength);var n=new Uint8Array(e.data.byteLength,this.write);return n.set(i),this.write+=i.byteLength,this}if(e instanceof H.ByteStringBuffer&&(e=e.data,t="binary"),t=t||"binary",typeof e=="string"){var c;if(t==="hex")return this.accommodate(Math.ceil(e.length/2)),c=new Uint8Array(this.data.buffer,this.write),this.write+=H.binary.hex.decode(e,c,this.write),this;if(t==="base64")return this.accommodate(Math.ceil(e.length/4)*3),c=new Uint8Array(this.data.buffer,this.write),this.write+=H.binary.base64.decode(e,c,this.write),this;if(t==="utf8"&&(e=H.encodeUtf8(e),t="binary"),t==="binary"||t==="raw")return this.accommodate(e.length),c=new Uint8Array(this.data.buffer,this.write),this.write+=H.binary.raw.decode(c),this;if(t==="utf16")return this.accommodate(e.length*2),c=new Uint16Array(this.data.buffer,this.write),this.write+=H.text.utf16.encode(c),this;throw new Error("Invalid encoding: "+t)}throw Error("Invalid parameter: "+e)},H.DataBuffer.prototype.putBuffer=function(e){return this.putBytes(e),e.clear(),this},H.DataBuffer.prototype.putString=function(e){return this.putBytes(e,"utf16")},H.DataBuffer.prototype.putInt16=function(e){return this.accommodate(2),this.data.setInt16(this.write,e),this.write+=2,this},H.DataBuffer.prototype.putInt24=function(e){return this.accommodate(3),this.data.setInt16(this.write,e>>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},H.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},H.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},H.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},H.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},H.DataBuffer.prototype.putInt=function(e,t){ur(t),this.accommodate(t/8);do t-=8,this.data.setInt8(this.write++,e>>t&255);while(t>0);return this},H.DataBuffer.prototype.putSignedInt=function(e,t){return ur(t),this.accommodate(t/8),e<0&&(e+=2<<t-1),this.putInt(e,t)},H.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},H.DataBuffer.prototype.getInt16=function(){var e=this.data.getInt16(this.read);return this.read+=2,e},H.DataBuffer.prototype.getInt24=function(){var e=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,e},H.DataBuffer.prototype.getInt32=function(){var e=this.data.getInt32(this.read);return this.read+=4,e},H.DataBuffer.prototype.getInt16Le=function(){var e=this.data.getInt16(this.read,!0);return this.read+=2,e},H.DataBuffer.prototype.getInt24Le=function(){var e=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,e},H.DataBuffer.prototype.getInt32Le=function(){var e=this.data.getInt32(this.read,!0);return this.read+=4,e},H.DataBuffer.prototype.getInt=function(e){ur(e);var t=0;do t=(t<<8)+this.data.getInt8(this.read++),e-=8;while(e>0);return t},H.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),i=2<<e-2;return t>=i&&(t-=i<<1),t},H.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t},H.DataBuffer.prototype.bytes=function(e){return typeof e=="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},H.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},H.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},H.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},H.DataBuffer.prototype.copy=function(){return new H.DataBuffer(this)},H.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},H.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},H.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},H.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.byteLength;++t){var i=this.data.getUint8(t);i<16&&(e+="0"),e+=i.toString(16)}return e},H.DataBuffer.prototype.toString=function(e){var t=new Uint8Array(this.data,this.read,this.length());if(e=e||"utf8",e==="binary"||e==="raw")return H.binary.raw.encode(t);if(e==="hex")return H.binary.hex.encode(t);if(e==="base64")return H.binary.base64.encode(t);if(e==="utf8")return H.text.utf8.decode(t);if(e==="utf16")return H.text.utf16.decode(t);throw new Error("Invalid encoding: "+e)},H.createBuffer=function(e,t){return t=t||"raw",e!==void 0&&t==="utf8"&&(e=H.encodeUtf8(e)),new H.ByteBuffer(e)},H.fillString=function(e,t){for(var i="";t>0;)t&1&&(i+=e),t>>>=1,t>0&&(e+=e);return i},H.xorBytes=function(e,t,i){for(var r="",n="",c="",a=0,s=0;i>0;--i,++a)n=e.charCodeAt(a)^t.charCodeAt(a),s>=10&&(r+=c,c="",s=0),c+=String.fromCharCode(n),++s;return r+=c,r},H.hexToBytes=function(e){var t="",i=0;for(e.length&!0&&(i=1,t+=String.fromCharCode(parseInt(e[0],16)));i<e.length;i+=2)t+=String.fromCharCode(parseInt(e.substr(i,2),16));return t},H.bytesToHex=function(e){return H.createBuffer(e).toHex()},H.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255)};var At="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Bt=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],ls="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";H.encode64=function(e,t){for(var i="",r="",n,c,a,s=0;s<e.length;)n=e.charCodeAt(s++),c=e.charCodeAt(s++),a=e.charCodeAt(s++),i+=At.charAt(n>>2),i+=At.charAt((n&3)<<4|c>>4),isNaN(c)?i+="==":(i+=At.charAt((c&15)<<2|a>>6),i+=isNaN(a)?"=":At.charAt(a&63)),t&&i.length>t&&(r+=i.substr(0,t)+`\r
`,i=i.substr(t));return r+=i,r},H.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t="",i,r,n,c,a=0;a<e.length;)i=Bt[e.charCodeAt(a++)-43],r=Bt[e.charCodeAt(a++)-43],n=Bt[e.charCodeAt(a++)-43],c=Bt[e.charCodeAt(a++)-43],t+=String.fromCharCode(i<<2|r>>4),n!==64&&(t+=String.fromCharCode((r&15)<<4|n>>2),c!==64&&(t+=String.fromCharCode((n&3)<<6|c)));return t},H.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},H.decodeUtf8=function(e){return decodeURIComponent(escape(e))},H.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:os.encode,decode:os.decode}},H.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},H.binary.raw.decode=function(e,t,i){var r=t;r||(r=new Uint8Array(e.length)),i=i||0;for(var n=i,c=0;c<e.length;++c)r[n++]=e.charCodeAt(c);return t?n-i:r},H.binary.hex.encode=H.bytesToHex,H.binary.hex.decode=function(e,t,i){var r=t;r||(r=new Uint8Array(Math.ceil(e.length/2))),i=i||0;var n=0,c=i;for(e.length&1&&(n=1,r[c++]=parseInt(e[0],16));n<e.length;n+=2)r[c++]=parseInt(e.substr(n,2),16);return t?c-i:r},H.binary.base64.encode=function(e,t){for(var i="",r="",n,c,a,s=0;s<e.byteLength;)n=e[s++],c=e[s++],a=e[s++],i+=At.charAt(n>>2),i+=At.charAt((n&3)<<4|c>>4),isNaN(c)?i+="==":(i+=At.charAt((c&15)<<2|a>>6),i+=isNaN(a)?"=":At.charAt(a&63)),t&&i.length>t&&(r+=i.substr(0,t)+`\r
`,i=i.substr(t));return r+=i,r},H.binary.base64.decode=function(e,t,i){var r=t;r||(r=new Uint8Array(Math.ceil(e.length/4)*3)),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,""),i=i||0;for(var n,c,a,s,l=0,o=i;l<e.length;)n=Bt[e.charCodeAt(l++)-43],c=Bt[e.charCodeAt(l++)-43],a=Bt[e.charCodeAt(l++)-43],s=Bt[e.charCodeAt(l++)-43],r[o++]=n<<2|c>>4,a!==64&&(r[o++]=(c&15)<<4|a>>2,s!==64&&(r[o++]=(a&3)<<6|s));return t?o-i:r.subarray(0,o)},H.binary.base58.encode=function(e,t){return H.binary.baseN.encode(e,ls,t)},H.binary.base58.decode=function(e,t){return H.binary.baseN.decode(e,ls,t)},H.text={utf8:{},utf16:{}},H.text.utf8.encode=function(e,t,i){e=H.encodeUtf8(e);var r=t;r||(r=new Uint8Array(e.length)),i=i||0;for(var n=i,c=0;c<e.length;++c)r[n++]=e.charCodeAt(c);return t?n-i:r},H.text.utf8.decode=function(e){return H.decodeUtf8(String.fromCharCode.apply(null,e))},H.text.utf16.encode=function(e,t,i){var r=t;r||(r=new Uint8Array(e.length*2));var n=new Uint16Array(r.buffer);i=i||0;for(var c=i,a=i,s=0;s<e.length;++s)n[a++]=e.charCodeAt(s),c+=2;return t?c-i:r},H.text.utf16.decode=function(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))},H.deflate=function(e,t,i){if(t=H.decode64(e.deflate(H.encode64(t)).rval),i){var r=2,n=t.charCodeAt(1);n&32&&(r=6),t=t.substring(r,t.length-4)}return t},H.inflate=function(e,t,i){var r=e.inflate(H.encode64(t)).rval;return r===null?null:H.decode64(r)};var ai=function(e,t,i){if(!e)throw new Error("WebStorage not available.");var r;if(i===null?r=e.removeItem(t):(i=H.encode64(JSON.stringify(i)),r=e.setItem(t,i)),typeof r!="undefined"&&r.rval!==!0){var n=new Error(r.error.message);throw n.id=r.error.id,n.name=r.error.name,n}},oi=function(e,t){if(!e)throw new Error("WebStorage not available.");var i=e.getItem(t);if(e.init)if(i.rval===null){if(i.error){var r=new Error(i.error.message);throw r.id=i.error.id,r.name=i.error.name,r}i=null}else i=i.rval;return i!==null&&(i=JSON.parse(H.decode64(i))),i},Wn=function(e,t,i,r){var n=oi(e,t);n===null&&(n={}),n[i]=r,ai(e,t,n)},zn=function(e,t,i){var r=oi(e,t);return r!==null&&(r=i in r?r[i]:null),r},$n=function(e,t,i){var r=oi(e,t);if(r!==null&&i in r){delete r[i];var n=!0;for(var c in r){n=!1;break}n&&(r=null),ai(e,t,r)}},qn=function(e,t){ai(e,t,null)},Br=function(e,t,i){var r=null;typeof i=="undefined"&&(i=["web","flash"]);var n,c=!1,a=null;for(var s in i){n=i[s];try{if(n==="flash"||n==="both"){if(t[0]===null)throw new Error("Flash local storage not available.");r=e.apply(this,t),c=n==="flash"}(n==="web"||n==="both")&&(t[0]=localStorage,r=e.apply(this,t),c=!0)}catch(l){a=l}if(c)break}if(!c)throw a;return r};H.setItem=function(e,t,i,r,n){Br(Wn,arguments,n)},H.getItem=function(e,t,i,r){return Br(zn,arguments,r)},H.removeItem=function(e,t,i,r){Br($n,arguments,r)},H.clearItems=function(e,t,i){Br(qn,arguments,i)},H.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},H.format=function(e){for(var t=/%./g,i,r,n=0,c=[],a=0;i=t.exec(e);){r=e.substring(a,t.lastIndex-2),r.length>0&&c.push(r),a=t.lastIndex;var s=i[0][1];switch(s){case"s":case"o":n<arguments.length?c.push(arguments[n+++1]):c.push("<?>");break;case"%":c.push("%");break;default:c.push("<%"+s+"?>")}}return c.push(e.substring(a)),c.join("")},H.formatNumber=function(e,t,i,r){var n=e,c=isNaN(t=Math.abs(t))?2:t,a=i===void 0?",":i,s=r===void 0?".":r,l=n<0?"-":"",o=parseInt(n=Math.abs(+n||0).toFixed(c),10)+"",f=o.length>3?o.length%3:0;return l+(f?o.substr(0,f)+s:"")+o.substr(f).replace(/(\d{3})(?=\d)/g,"$1"+s)+(c?a+Math.abs(n-o).toFixed(c).slice(2):"")},H.formatSize=function(e){return e>=1073741824?e=H.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?e=H.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?e=H.formatNumber(e/1024,0)+" KiB":e=H.formatNumber(e,0)+" bytes",e},H.bytesFromIP=function(e){return e.indexOf(".")!==-1?H.bytesFromIPv4(e):e.indexOf(":")!==-1?H.bytesFromIPv6(e):null},H.bytesFromIPv4=function(e){if(e=e.split("."),e.length!==4)return null;for(var t=H.createBuffer(),i=0;i<e.length;++i){var r=parseInt(e[i],10);if(isNaN(r))return null;t.putByte(r)}return t.getBytes()},H.bytesFromIPv6=function(e){var t=0;e=e.split(":").filter(function(a){return a.length===0&&++t,!0});for(var i=(8-e.length+t)*2,r=H.createBuffer(),n=0;n<8;++n){if(!e[n]||e[n].length===0){r.fillWithByte(0,i),i=0;continue}var c=H.hexToBytes(e[n]);c.length<2&&r.putByte(0),r.putBytes(c)}return r.getBytes()},H.bytesToIP=function(e){return e.length===4?H.bytesToIPv4(e):e.length===16?H.bytesToIPv6(e):null},H.bytesToIPv4=function(e){if(e.length!==4)return null;for(var t=[],i=0;i<e.length;++i)t.push(e.charCodeAt(i));return t.join(".")},H.bytesToIPv6=function(e){if(e.length!==16)return null;for(var t=[],i=[],r=0,n=0;n<e.length;n+=2){for(var c=H.bytesToHex(e[n]+e[n+1]);c[0]==="0"&&c!=="0";)c=c.substr(1);if(c==="0"){var a=i[i.length-1],s=t.length;!a||s!==a.end+1?i.push({start:s,end:s}):(a.end=s,a.end-a.start>i[r].end-i[r].start&&(r=i.length-1))}t.push(c)}if(i.length>0){var l=i[r];l.end-l.start>0&&(t.splice(l.start,l.end-l.start+1,""),l.start===0&&t.unshift(""),l.end===7&&t.push(""))}return t.join(":")},H.estimateCores=function(e,t){if(typeof e=="function"&&(t=e,e={}),e=e||{},"cores"in H&&!e.update)return t(null,H.cores);if(typeof navigator!="undefined"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return H.cores=navigator.hardwareConcurrency,t(null,H.cores);if(typeof Worker=="undefined")return H.cores=1,t(null,H.cores);if(typeof Blob=="undefined")return H.cores=2,t(null,H.cores);var i=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(a){var s=Date.now(),l=s+4;self.postMessage({st:s,et:l})})}.toString(),")()"],{type:"application/javascript"}));r([],5,16);function r(a,s,l){if(s===0){var o=Math.floor(a.reduce(function(f,u){return f+u},0)/a.length);return H.cores=Math.max(1,o),URL.revokeObjectURL(i),t(null,H.cores)}n(l,function(f,u){a.push(c(l,u)),r(a,s-1,l)})}function n(a,s){for(var l=[],o=[],f=0;f<a;++f){var u=new Worker(i);u.addEventListener("message",function(g){if(o.push(g.data),o.length===a){for(var _=0;_<a;++_)l[_].terminate();s(null,o)}}),l.push(u)}for(var f=0;f<a;++f)l[f].postMessage(f)}function c(a,s){for(var l=[],o=0;o<a;++o)for(var f=s[o],u=l[o]=[],g=0;g<a;++g)if(o!==g){var _=s[g];(f.st>_.st&&f.st<_.et||_.st>f.st&&_.st<f.et)&&u.push(g)}return l.reduce(function(y,m){return Math.max(y,m.length)},0)}};var Ke=_e;Ke.cipher=Ke.cipher||{},Ke.cipher.algorithms=Ke.cipher.algorithms||{},Ke.cipher.createCipher=function(e,t){var i=e;if(typeof i=="string"&&(i=Ke.cipher.getAlgorithm(i),i&&(i=i())),!i)throw new Error("Unsupported algorithm: "+e);return new Ke.cipher.BlockCipher({algorithm:i,key:t,decrypt:!1})},Ke.cipher.createDecipher=function(e,t){var i=e;if(typeof i=="string"&&(i=Ke.cipher.getAlgorithm(i),i&&(i=i())),!i)throw new Error("Unsupported algorithm: "+e);return new Ke.cipher.BlockCipher({algorithm:i,key:t,decrypt:!0})},Ke.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),Ke.cipher.algorithms[e]=t},Ke.cipher.getAlgorithm=function(e){return e=e.toUpperCase(),e in Ke.cipher.algorithms?Ke.cipher.algorithms[e]:null};var li=Ke.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};li.prototype.start=function(e){e=e||{};var t={};for(var i in e)t[i]=e[i];t.decrypt=this._decrypt,this._finish=!1,this._input=Ke.util.createBuffer(),this.output=e.output||Ke.util.createBuffer(),this.mode.start(t)},li.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},li.prototype.finish=function(e){e&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(i){return e(this.blockSize,i,!1)},this.mode.unpad=function(i){return e(this.blockSize,i,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,t))};var We=_e;We.cipher=We.cipher||{};var ye=We.cipher.modes=We.cipher.modes||{};ye.ecb=function(e){e=e||{},this.name="ECB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},ye.ecb.prototype.start=function(e){},ye.ecb.prototype.encrypt=function(e,t,i){if(e.length()<this.blockSize&&!(i&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r])},ye.ecb.prototype.decrypt=function(e,t,i){if(e.length()<this.blockSize&&!(i&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r])},ye.ecb.prototype.pad=function(e,t){var i=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(i,i),!0},ye.ecb.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var i=e.length(),r=e.at(i-1);return r>this.blockSize<<2?!1:(e.truncate(r),!0)},ye.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},ye.cbc.prototype.start=function(e){if(e.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in e)this._iv=Ir(e.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")},ye.cbc.prototype.encrypt=function(e,t,i){if(e.length()<this.blockSize&&!(i&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=this._prev[r]^e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r]);this._prev=this._outBlock},ye.cbc.prototype.decrypt=function(e,t,i){if(e.length()<this.blockSize&&!(i&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._prev[r]^this._outBlock[r]);this._prev=this._inBlock.slice(0)},ye.cbc.prototype.pad=function(e,t){var i=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(i,i),!0},ye.cbc.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var i=e.length(),r=e.at(i-1);return r>this.blockSize<<2?!1:(e.truncate(r),!0)},ye.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=We.util.createBuffer(),this._partialBytes=0},ye.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=Ir(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},ye.cfb.prototype.encrypt=function(e,t,i){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32()^this._outBlock[n],t.putInt32(this._inBlock[n]);return}var c=(this.blockSize-r)%this.blockSize;c>0&&(c=this.blockSize-c),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialBlock[n]=e.getInt32()^this._outBlock[n],this._partialOutput.putInt32(this._partialBlock[n]);if(c>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._partialBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),c>0&&!i)return t.putBytes(this._partialOutput.getBytes(c-this._partialBytes)),this._partialBytes=c,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0},ye.cfb.prototype.decrypt=function(e,t,i){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32(),t.putInt32(this._inBlock[n]^this._outBlock[n]);return}var c=(this.blockSize-r)%this.blockSize;c>0&&(c=this.blockSize-c),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialBlock[n]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[n]^this._outBlock[n]);if(c>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._partialBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),c>0&&!i)return t.putBytes(this._partialOutput.getBytes(c-this._partialBytes)),this._partialBytes=c,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0},ye.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=We.util.createBuffer(),this._partialBytes=0},ye.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=Ir(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},ye.ofb.prototype.encrypt=function(e,t,i){var r=e.length();if(e.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)t.putInt32(e.getInt32()^this._outBlock[n]),this._inBlock[n]=this._outBlock[n];return}var c=(this.blockSize-r)%this.blockSize;c>0&&(c=this.blockSize-c),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(c>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._outBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),c>0&&!i)return t.putBytes(this._partialOutput.getBytes(c-this._partialBytes)),this._partialBytes=c,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0},ye.ofb.prototype.decrypt=ye.ofb.prototype.encrypt,ye.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=We.util.createBuffer(),this._partialBytes=0},ye.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=Ir(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},ye.ctr.prototype.encrypt=function(e,t,i){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize)for(var n=0;n<this._ints;++n)t.putInt32(e.getInt32()^this._outBlock[n]);else{var c=(this.blockSize-r)%this.blockSize;c>0&&(c=this.blockSize-c),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(c>0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),c>0&&!i)return t.putBytes(this._partialOutput.getBytes(c-this._partialBytes)),this._partialBytes=c,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}Lr(this._inBlock)},ye.ctr.prototype.decrypt=ye.ctr.prototype.encrypt,ye.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=We.util.createBuffer(),this._partialBytes=0,this._R=3774873600},ye.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t=We.util.createBuffer(e.iv);this._cipherLength=0;var i;if("additionalData"in e?i=We.util.createBuffer(e.additionalData):i=We.util.createBuffer(),"tagLength"in e?this._tagLength=e.tagLength:this._tagLength=128,this._tag=null,e.decrypt&&(this._tag=We.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var r=t.length();if(r===12)this._j0=[t.getInt32(),t.getInt32(),t.getInt32(),1];else{for(this._j0=[0,0,0,0];t.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(ci(r*8)))}this._inBlock=this._j0.slice(0),Lr(this._inBlock),this._partialBytes=0,i=We.util.createBuffer(i),this._aDataLength=ci(i.length()*8);var n=i.length()%this.blockSize;for(n&&i.fillWithByte(0,this.blockSize-n),this._s=[0,0,0,0];i.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[i.getInt32(),i.getInt32(),i.getInt32(),i.getInt32()])},ye.gcm.prototype.encrypt=function(e,t,i){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]^=e.getInt32());this._cipherLength+=this.blockSize}else{var c=(this.blockSize-r)%this.blockSize;c>0&&(c=this.blockSize-c),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(c<=0||i){if(i){var a=r%this.blockSize;this._cipherLength+=a,this._partialOutput.truncate(this.blockSize-a)}else this._cipherLength+=this.blockSize;for(var n=0;n<this._ints;++n)this._outBlock[n]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),c>0&&!i)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(c-this._partialBytes)),this._partialBytes=c,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),Lr(this._inBlock)},ye.gcm.prototype.decrypt=function(e,t,i){var r=e.length();if(r<this.blockSize&&!(i&&r>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),Lr(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]^this._hashBlock[n]);r<this.blockSize?this._cipherLength+=r%this.blockSize:this._cipherLength+=this.blockSize},ye.gcm.prototype.afterFinish=function(e,t){var i=!0;t.decrypt&&t.overflow&&e.truncate(this.blockSize-t.overflow),this.tag=We.util.createBuffer();var r=this._aDataLength.concat(ci(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,r);var n=[];this.cipher.encrypt(this._j0,n);for(var c=0;c<this._ints;++c)this.tag.putInt32(this._s[c]^n[c]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),t.decrypt&&this.tag.bytes()!==this._tag&&(i=!1),i},ye.gcm.prototype.multiply=function(e,t){for(var i=[0,0,0,0],r=t.slice(0),n=0;n<128;++n){var c=e[n/32|0]&1<<31-n%32;c&&(i[0]^=r[0],i[1]^=r[1],i[2]^=r[2],i[3]^=r[3]),this.pow(r,r)}return i},ye.gcm.prototype.pow=function(e,t){for(var i=e[3]&1,r=3;r>0;--r)t[r]=e[r]>>>1|(e[r-1]&1)<<31;t[0]=e[0]>>>1,i&&(t[0]^=this._R)},ye.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],i=0;i<32;++i){var r=i/8|0,n=e[r]>>>(7-i%8)*4&15,c=this._m[i][n];t[0]^=c[0],t[1]^=c[1],t[2]^=c[2],t[3]^=c[3]}return t},ye.gcm.prototype.ghash=function(e,t,i){return t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3],this.tableMultiply(t)},ye.gcm.prototype.generateHashTable=function(e,t){for(var i=8/t,r=4*i,n=16*i,c=new Array(n),a=0;a<n;++a){var s=[0,0,0,0],l=a/r|0,o=(r-1-a%r)*t;s[l]=1<<t-1<<o,c[a]=this.generateSubHashTable(this.multiply(s,e),t)}return c},ye.gcm.prototype.generateSubHashTable=function(e,t){var i=1<<t,r=i>>>1,n=new Array(i);n[r]=e.slice(0);for(var c=r>>>1;c>0;)this.pow(n[2*c],n[c]=[]),c>>=1;for(c=2;c<r;){for(var a=1;a<c;++a){var s=n[c],l=n[a];n[c+a]=[s[0]^l[0],s[1]^l[1],s[2]^l[2],s[3]^l[3]]}c*=2}for(n[0]=[0,0,0,0],c=r+1;c<i;++c){var o=n[c^r];n[c]=[e[0]^o[0],e[1]^o[1],e[2]^o[2],e[3]^o[3]]}return n};function Ir(e,t){if(typeof e=="string"&&(e=We.util.createBuffer(e)),We.util.isArray(e)&&e.length>4){var i=e;e=We.util.createBuffer();for(var r=0;r<i.length;++r)e.putByte(i[r])}if(e.length()<t)throw new Error("Invalid IV length; got "+e.length()+" bytes and expected "+t+" bytes.");if(!We.util.isArray(e)){for(var n=[],c=t/4,r=0;r<c;++r)n.push(e.getInt32());e=n}return e}function Lr(e){e[e.length-1]=e[e.length-1]+1&4294967295}function ci(e){return[e/4294967296|0,e&4294967295]}var Le=_e;Le.aes=Le.aes||{},Le.aes.startEncrypting=function(e,t,i,r){var n=kr({key:e,output:i,decrypt:!1,mode:r});return n.start(t),n},Le.aes.createEncryptionCipher=function(e,t){return kr({key:e,output:null,decrypt:!1,mode:t})},Le.aes.startDecrypting=function(e,t,i,r){var n=kr({key:e,output:i,decrypt:!0,mode:r});return n.start(t),n},Le.aes.createDecryptionCipher=function(e,t){return kr({key:e,output:null,decrypt:!0,mode:t})},Le.aes.Algorithm=function(e,t){hi||hs();var i=this;i.name=e,i.mode=new t({blockSize:16,cipher:{encrypt:function(r,n){return fi(i._w,r,n,!1)},decrypt:function(r,n){return fi(i._w,r,n,!0)}}}),i._init=!1},Le.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t=e.key,i;if(typeof t=="string"&&(t.length===16||t.length===24||t.length===32))t=Le.util.createBuffer(t);else if(Le.util.isArray(t)&&(t.length===16||t.length===24||t.length===32)){i=t,t=Le.util.createBuffer();for(var r=0;r<i.length;++r)t.putByte(i[r])}if(!Le.util.isArray(t)){i=t,t=[];var n=i.length();if(n===16||n===24||n===32){n=n>>>2;for(var r=0;r<n;++r)t.push(i.getInt32())}}if(!Le.util.isArray(t)||!(t.length===4||t.length===6||t.length===8))throw new Error("Invalid key parameter.");var c=this.mode.name,a=["CFB","OFB","CTR","GCM"].indexOf(c)!==-1;this._w=us(t,e.decrypt&&!a),this._init=!0}},Le.aes._expandKey=function(e,t){return hi||hs(),us(e,t)},Le.aes._updateBlock=fi,jt("AES-ECB",Le.cipher.modes.ecb),jt("AES-CBC",Le.cipher.modes.cbc),jt("AES-CFB",Le.cipher.modes.cfb),jt("AES-OFB",Le.cipher.modes.ofb),jt("AES-CTR",Le.cipher.modes.ctr),jt("AES-GCM",Le.cipher.modes.gcm);function jt(e,t){var i=function(){return new Le.aes.Algorithm(e,t)};Le.cipher.registerAlgorithm(e,i)}var hi=!1,Qt=4,Qe,ui,cs,Ft,ht;function hs(){hi=!0,cs=[0,1,2,4,8,16,32,64,128,27,54];for(var e=new Array(256),t=0;t<128;++t)e[t]=t<<1,e[t+128]=t+128<<1^283;Qe=new Array(256),ui=new Array(256),Ft=new Array(4),ht=new Array(4);for(var t=0;t<4;++t)Ft[t]=new Array(256),ht[t]=new Array(256);for(var i=0,r=0,n,c,a,s,l,o,f,t=0;t<256;++t){s=r^r<<1^r<<2^r<<3^r<<4,s=s>>8^s&255^99,Qe[i]=s,ui[s]=i,l=e[s],n=e[i],c=e[n],a=e[c],o=l<<24^s<<16^s<<8^(s^l),f=(n^c^a)<<24^(i^a)<<16^(i^c^a)<<8^(i^n^a);for(var u=0;u<4;++u)Ft[u][i]=o,ht[u][s]=f,o=o<<24|o>>>8,f=f<<24|f>>>8;i===0?i=r=1:(i=n^e[e[e[n^a]]],r^=e[e[r]])}}function us(e,t){for(var i=e.slice(0),r,n=1,c=i.length,a=c+6+1,s=Qt*a,l=c;l<s;++l)r=i[l-1],l%c===0?(r=Qe[r>>>16&255]<<24^Qe[r>>>8&255]<<16^Qe[r&255]<<8^Qe[r>>>24]^cs[n]<<24,n++):c>6&&l%c===4&&(r=Qe[r>>>24]<<24^Qe[r>>>16&255]<<16^Qe[r>>>8&255]<<8^Qe[r&255]),i[l]=i[l-c]^r;if(t){var o,f=ht[0],u=ht[1],g=ht[2],_=ht[3],y=i.slice(0);s=i.length;for(var l=0,m=s-Qt;l<s;l+=Qt,m-=Qt)if(l===0||l===s-Qt)y[l]=i[m],y[l+1]=i[m+3],y[l+2]=i[m+2],y[l+3]=i[m+1];else for(var h=0;h<Qt;++h)o=i[m+h],y[l+(3&-h)]=f[Qe[o>>>24]]^u[Qe[o>>>16&255]]^g[Qe[o>>>8&255]]^_[Qe[o&255]];i=y}return i}function fi(e,t,i,r){var n=e.length/4-1,c,a,s,l,o;r?(c=ht[0],a=ht[1],s=ht[2],l=ht[3],o=ui):(c=Ft[0],a=Ft[1],s=Ft[2],l=Ft[3],o=Qe);var f,u,g,_,y,m,h;f=t[0]^e[0],u=t[r?3:1]^e[1],g=t[2]^e[2],_=t[r?1:3]^e[3];for(var d=3,p=1;p<n;++p)y=c[f>>>24]^a[u>>>16&255]^s[g>>>8&255]^l[_&255]^e[++d],m=c[u>>>24]^a[g>>>16&255]^s[_>>>8&255]^l[f&255]^e[++d],h=c[g>>>24]^a[_>>>16&255]^s[f>>>8&255]^l[u&255]^e[++d],_=c[_>>>24]^a[f>>>16&255]^s[u>>>8&255]^l[g&255]^e[++d],f=y,u=m,g=h;i[0]=o[f>>>24]<<24^o[u>>>16&255]<<16^o[g>>>8&255]<<8^o[_&255]^e[++d],i[r?3:1]=o[u>>>24]<<24^o[g>>>16&255]<<16^o[_>>>8&255]<<8^o[f&255]^e[++d],i[2]=o[g>>>24]<<24^o[_>>>16&255]<<16^o[f>>>8&255]<<8^o[u&255]^e[++d],i[r?1:3]=o[_>>>24]<<24^o[f>>>16&255]<<16^o[u>>>8&255]<<8^o[g&255]^e[++d]}function kr(e){e=e||{};var t=(e.mode||"CBC").toUpperCase(),i="AES-"+t,r;e.decrypt?r=Le.cipher.createDecipher(i,e.key):r=Le.cipher.createCipher(i,e.key);var n=r.start;return r.start=function(c,a){var s=null;a instanceof Le.util.ByteBuffer&&(s=a,a={}),a=a||{},a.output=s,a.iv=c,n.call(r,a)},r}var fr=_e;fr.pki=fr.pki||{};var di=fr.pki.oids=fr.oids=fr.oids||{};function ee(e,t){di[e]=t,di[t]=e}function Be(e,t){di[e]=t}ee("1.2.840.113549.1.1.1","rsaEncryption"),ee("1.2.840.113549.1.1.4","md5WithRSAEncryption"),ee("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),ee("1.2.840.113549.1.1.7","RSAES-OAEP"),ee("1.2.840.113549.1.1.8","mgf1"),ee("1.2.840.113549.1.1.9","pSpecified"),ee("1.2.840.113549.1.1.10","RSASSA-PSS"),ee("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),ee("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),ee("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),ee("1.3.101.112","EdDSA25519"),ee("1.2.840.10040.4.3","dsa-with-sha1"),ee("1.3.14.3.2.7","desCBC"),ee("1.3.14.3.2.26","sha1"),ee("1.3.14.3.2.29","sha1WithRSASignature"),ee("2.16.840.1.101.3.4.2.1","sha256"),ee("2.16.840.1.101.3.4.2.2","sha384"),ee("2.16.840.1.101.3.4.2.3","sha512"),ee("2.16.840.1.101.3.4.2.4","sha224"),ee("2.16.840.1.101.3.4.2.5","sha512-224"),ee("2.16.840.1.101.3.4.2.6","sha512-256"),ee("1.2.840.113549.2.2","md2"),ee("1.2.840.113549.2.5","md5"),ee("1.2.840.113549.1.7.1","data"),ee("1.2.840.113549.1.7.2","signedData"),ee("1.2.840.113549.1.7.3","envelopedData"),ee("1.2.840.113549.1.7.4","signedAndEnvelopedData"),ee("1.2.840.113549.1.7.5","digestedData"),ee("1.2.840.113549.1.7.6","encryptedData"),ee("1.2.840.113549.1.9.1","emailAddress"),ee("1.2.840.113549.1.9.2","unstructuredName"),ee("1.2.840.113549.1.9.3","contentType"),ee("1.2.840.113549.1.9.4","messageDigest"),ee("1.2.840.113549.1.9.5","signingTime"),ee("1.2.840.113549.1.9.6","counterSignature"),ee("1.2.840.113549.1.9.7","challengePassword"),ee("1.2.840.113549.1.9.8","unstructuredAddress"),ee("1.2.840.113549.1.9.14","extensionRequest"),ee("1.2.840.113549.1.9.20","friendlyName"),ee("1.2.840.113549.1.9.21","localKeyId"),ee("1.2.840.113549.1.9.22.1","x509Certificate"),ee("1.2.840.113549.1.12.10.1.1","keyBag"),ee("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),ee("1.2.840.113549.1.12.10.1.3","certBag"),ee("1.2.840.113549.1.12.10.1.4","crlBag"),ee("1.2.840.113549.1.12.10.1.5","secretBag"),ee("1.2.840.113549.1.12.10.1.6","safeContentsBag"),ee("1.2.840.113549.1.5.13","pkcs5PBES2"),ee("1.2.840.113549.1.5.12","pkcs5PBKDF2"),ee("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),ee("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),ee("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),ee("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),ee("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),ee("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),ee("1.2.840.113549.2.7","hmacWithSHA1"),ee("1.2.840.113549.2.8","hmacWithSHA224"),ee("1.2.840.113549.2.9","hmacWithSHA256"),ee("1.2.840.113549.2.10","hmacWithSHA384"),ee("1.2.840.113549.2.11","hmacWithSHA512"),ee("1.2.840.113549.3.7","des-EDE3-CBC"),ee("2.16.840.1.101.3.4.1.2","aes128-CBC"),ee("2.16.840.1.101.3.4.1.22","aes192-CBC"),ee("2.16.840.1.101.3.4.1.42","aes256-CBC"),ee("2.5.4.3","commonName"),ee("2.5.4.4","surname"),ee("2.5.4.5","serialNumber"),ee("2.5.4.6","countryName"),ee("2.5.4.7","localityName"),ee("2.5.4.8","stateOrProvinceName"),ee("2.5.4.9","streetAddress"),ee("2.5.4.10","organizationName"),ee("2.5.4.11","organizationalUnitName"),ee("2.5.4.12","title"),ee("2.5.4.13","description"),ee("2.5.4.15","businessCategory"),ee("2.5.4.17","postalCode"),ee("2.5.4.42","givenName"),ee("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),ee("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),ee("2.16.840.1.113730.1.1","nsCertType"),ee("2.16.840.1.113730.1.13","nsComment"),Be("2.5.29.1","authorityKeyIdentifier"),Be("2.5.29.2","keyAttributes"),Be("2.5.29.3","certificatePolicies"),Be("2.5.29.4","keyUsageRestriction"),Be("2.5.29.5","policyMapping"),Be("2.5.29.6","subtreesConstraint"),Be("2.5.29.7","subjectAltName"),Be("2.5.29.8","issuerAltName"),Be("2.5.29.9","subjectDirectoryAttributes"),Be("2.5.29.10","basicConstraints"),Be("2.5.29.11","nameConstraints"),Be("2.5.29.12","policyConstraints"),Be("2.5.29.13","basicConstraints"),ee("2.5.29.14","subjectKeyIdentifier"),ee("2.5.29.15","keyUsage"),Be("2.5.29.16","privateKeyUsagePeriod"),ee("2.5.29.17","subjectAltName"),ee("2.5.29.18","issuerAltName"),ee("2.5.29.19","basicConstraints"),Be("2.5.29.20","cRLNumber"),Be("2.5.29.21","cRLReason"),Be("2.5.29.22","expirationDate"),Be("2.5.29.23","instructionCode"),Be("2.5.29.24","invalidityDate"),Be("2.5.29.25","cRLDistributionPoints"),Be("2.5.29.26","issuingDistributionPoint"),Be("2.5.29.27","deltaCRLIndicator"),Be("2.5.29.28","issuingDistributionPoint"),Be("2.5.29.29","certificateIssuer"),Be("2.5.29.30","nameConstraints"),ee("2.5.29.31","cRLDistributionPoints"),ee("2.5.29.32","certificatePolicies"),Be("2.5.29.33","policyMappings"),Be("2.5.29.34","policyConstraints"),ee("2.5.29.35","authorityKeyIdentifier"),Be("2.5.29.36","policyConstraints"),ee("2.5.29.37","extKeyUsage"),Be("2.5.29.46","freshestCRL"),Be("2.5.29.54","inhibitAnyPolicy"),ee("1.3.6.1.4.1.11129.2.4.2","timestampList"),ee("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),ee("1.3.6.1.5.5.7.3.1","serverAuth"),ee("1.3.6.1.5.5.7.3.2","clientAuth"),ee("1.3.6.1.5.5.7.3.3","codeSigning"),ee("1.3.6.1.5.5.7.3.4","emailProtection"),ee("1.3.6.1.5.5.7.3.8","timeStamping");var Re=_e,ae=Re.asn1=Re.asn1||{};ae.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},ae.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},ae.maxDepth=256,ae.create=function(e,t,i,r,n){if(Re.util.isArray(r)){for(var c=[],a=0;a<r.length;++a)r[a]!==void 0&&c.push(r[a]);r=c}var s={tagClass:e,type:t,constructed:i,composed:i||Re.util.isArray(r),value:r};return n&&"bitStringContents"in n&&(s.bitStringContents=n.bitStringContents,s.original=ae.copy(s)),s},ae.copy=function(e,t){var i;if(Re.util.isArray(e)){i=[];for(var r=0;r<e.length;++r)i.push(ae.copy(e[r],t));return i}return typeof e=="string"?e:(i={tagClass:e.tagClass,type:e.type,constructed:e.constructed,composed:e.composed,value:ae.copy(e.value,t)},t&&!t.excludeBitStringContents&&(i.bitStringContents=e.bitStringContents),i)},ae.equals=function(e,t,i){if(Re.util.isArray(e)){if(!Re.util.isArray(t)||e.length!==t.length)return!1;for(var r=0;r<e.length;++r)if(!ae.equals(e[r],t[r]))return!1;return!0}if(typeof e!=typeof t)return!1;if(typeof e=="string")return e===t;var n=e.tagClass===t.tagClass&&e.type===t.type&&e.constructed===t.constructed&&e.composed===t.composed&&ae.equals(e.value,t.value);return i&&i.includeBitStringContents&&(n=n&&e.bitStringContents===t.bitStringContents),n},ae.getBerValueLength=function(e){var t=e.getByte();if(t!==128){var i,r=t&128;return r?i=e.getInt((t&127)<<3):i=t,i}};function dr(e,t,i){if(i>t){var r=new Error("Too few bytes to parse DER.");throw r.available=e.length(),r.remaining=t,r.requested=i,r}}var Gn=function(e,t){var i=e.getByte();if(t--,i!==128){var r,n=i&128;if(!n)r=i;else{var c=i&127;dr(e,t,c),r=e.getInt(c<<3)}if(r<0)throw new Error("Negative length: "+r);return r}};ae.fromDer=function(e,t){t===void 0&&(t={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),typeof t=="boolean"&&(t={strict:t,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in t||(t.strict=!0),"parseAllBytes"in t||(t.parseAllBytes=!0),"decodeBitStrings"in t||(t.decodeBitStrings=!0),"maxDepth"in t||(t.maxDepth=ae.maxDepth),typeof e=="string"&&(e=Re.util.createBuffer(e));var i=e.length(),r=Rr(e,e.length(),0,t);if(t.parseAllBytes&&e.length()!==0){var n=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw n.byteCount=i,n.remaining=e.length(),n}return r};function Rr(e,t,i,r){if(i>=r.maxDepth)throw new Error("ASN.1 parsing error: Max depth exceeded.");var n;dr(e,t,2);var c=e.getByte();t--;var a=c&192,s=c&31;n=e.length();var l=Gn(e,t);if(t-=n-e.length(),l!==void 0&&l>t){if(r.strict){var o=new Error("Too few bytes to read ASN.1 value.");throw o.available=e.length(),o.remaining=t,o.requested=l,o}l=t}var f,u,g=(c&32)===32;if(g)if(f=[],l===void 0)for(;;){if(dr(e,t,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),t-=2;break}n=e.length(),f.push(Rr(e,t,i+1,r)),t-=n-e.length()}else for(;l>0;)n=e.length(),f.push(Rr(e,l,i+1,r)),t-=n-e.length(),l-=n-e.length();if(f===void 0&&a===ae.Class.UNIVERSAL&&s===ae.Type.BITSTRING&&(u=e.bytes(l)),f===void 0&&r.decodeBitStrings&&a===ae.Class.UNIVERSAL&&s===ae.Type.BITSTRING&&l>1){var _=e.read,y=t,m=0;if(s===ae.Type.BITSTRING&&(dr(e,t,1),m=e.getByte(),t--),m===0)try{n=e.length();var h={strict:!0,decodeBitStrings:!0},d=Rr(e,t,i+1,h),p=n-e.length();t-=p,s==ae.Type.BITSTRING&&p++;var v=d.tagClass;p===l&&(v===ae.Class.UNIVERSAL||v===ae.Class.CONTEXT_SPECIFIC)&&(f=[d])}catch(S){}f===void 0&&(e.read=_,t=y)}if(f===void 0){if(l===void 0){if(r.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");l=t}if(s===ae.Type.BMPSTRING)for(f="";l>0;l-=2)dr(e,t,2),f+=String.fromCharCode(e.getInt16()),t-=2;else f=e.getBytes(l),t-=l}var C=u===void 0?null:{bitStringContents:u};return ae.create(a,s,g,f,C)}ae.toDer=function(e){var t=Re.util.createBuffer(),i=e.tagClass|e.type,r=Re.util.createBuffer(),n=!1;if("bitStringContents"in e&&(n=!0,e.original&&(n=ae.equals(e,e.original))),n)r.putBytes(e.bitStringContents);else if(e.composed){e.constructed?i|=32:r.putByte(0);for(var c=0;c<e.value.length;++c)e.value[c]!==void 0&&r.putBuffer(ae.toDer(e.value[c]))}else if(e.type===ae.Type.BMPSTRING)for(var c=0;c<e.value.length;++c)r.putInt16(e.value.charCodeAt(c));else e.type===ae.Type.INTEGER&&e.value.length>1&&(e.value.charCodeAt(0)===0&&!(e.value.charCodeAt(1)&128)||e.value.charCodeAt(0)===255&&(e.value.charCodeAt(1)&128)===128)?r.putBytes(e.value.substr(1)):r.putBytes(e.value);if(t.putByte(i),r.length()<=127)t.putByte(r.length()&127);else{var a=r.length(),s="";do s+=String.fromCharCode(a&255),a=a>>>8;while(a>0);t.putByte(s.length|128);for(var c=s.length-1;c>=0;--c)t.putByte(s.charCodeAt(c))}return t.putBuffer(r),t},ae.oidToDer=function(e){var t=e.split("."),i=Re.util.createBuffer();i.putByte(40*parseInt(t[0],10)+parseInt(t[1],10));for(var r,n,c,a,s=2;s<t.length;++s){if(r=!0,n=[],c=parseInt(t[s],10),c>4294967295)throw new Error("OID value too large; max is 32-bits.");do a=c&127,c=c>>>7,r||(a|=128),n.push(a),r=!1;while(c>0);for(var l=n.length-1;l>=0;--l)i.putByte(n[l])}return i},ae.derToOid=function(e){var t;typeof e=="string"&&(e=Re.util.createBuffer(e));var i=e.getByte();t=Math.floor(i/40)+"."+i%40;for(var r=0;e.length()>0;){if(r>70368744177663)throw new Error("OID value too large; max is 53-bits.");i=e.getByte(),r=r*128,i&128?r+=i&127:(t+="."+(r+i),r=0)}return t},ae.utcTimeToDate=function(e){var t=new Date,i=parseInt(e.substr(0,2),10);i=i>=50?1900+i:2e3+i;var r=parseInt(e.substr(2,2),10)-1,n=parseInt(e.substr(4,2),10),c=parseInt(e.substr(6,2),10),a=parseInt(e.substr(8,2),10),s=0;if(e.length>11){var l=e.charAt(10),o=10;l!=="+"&&l!=="-"&&(s=parseInt(e.substr(10,2),10),o+=2)}if(t.setUTCFullYear(i,r,n),t.setUTCHours(c,a,s,0),o&&(l=e.charAt(o),l==="+"||l==="-")){var f=parseInt(e.substr(o+1,2),10),u=parseInt(e.substr(o+4,2),10),g=f*60+u;g*=6e4,l==="+"?t.setTime(+t-g):t.setTime(+t+g)}return t},ae.generalizedTimeToDate=function(e){var t=new Date,i=parseInt(e.substr(0,4),10),r=parseInt(e.substr(4,2),10)-1,n=parseInt(e.substr(6,2),10),c=parseInt(e.substr(8,2),10),a=parseInt(e.substr(10,2),10),s=parseInt(e.substr(12,2),10),l=0,o=0,f=!1;e.charAt(e.length-1)==="Z"&&(f=!0);var u=e.length-5,g=e.charAt(u);if(g==="+"||g==="-"){var _=parseInt(e.substr(u+1,2),10),y=parseInt(e.substr(u+4,2),10);o=_*60+y,o*=6e4,g==="+"&&(o*=-1),f=!0}return e.charAt(14)==="."&&(l=parseFloat(e.substr(14),10)*1e3),f?(t.setUTCFullYear(i,r,n),t.setUTCHours(c,a,s,l),t.setTime(+t+o)):(t.setFullYear(i,r,n),t.setHours(c,a,s,l)),t},ae.dateToUtcTime=function(e){if(typeof e=="string")return e;var t="",i=[];i.push((""+e.getUTCFullYear()).substr(2)),i.push(""+(e.getUTCMonth()+1)),i.push(""+e.getUTCDate()),i.push(""+e.getUTCHours()),i.push(""+e.getUTCMinutes()),i.push(""+e.getUTCSeconds());for(var r=0;r<i.length;++r)i[r].length<2&&(t+="0"),t+=i[r];return t+="Z",t},ae.dateToGeneralizedTime=function(e){if(typeof e=="string")return e;var t="",i=[];i.push(""+e.getUTCFullYear()),i.push(""+(e.getUTCMonth()+1)),i.push(""+e.getUTCDate()),i.push(""+e.getUTCHours()),i.push(""+e.getUTCMinutes()),i.push(""+e.getUTCSeconds());for(var r=0;r<i.length;++r)i[r].length<2&&(t+="0"),t+=i[r];return t+="Z",t},ae.integerToDer=function(e){var t=Re.util.createBuffer();if(e>=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var i=new Error("Integer too large; max is 32-bits.");throw i.integer=e,i},ae.derToInteger=function(e){typeof e=="string"&&(e=Re.util.createBuffer(e));var t=e.length()*8;if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},ae.validate=function(e,t,i,r){var n=!1;if((e.tagClass===t.tagClass||typeof t.tagClass=="undefined")&&(e.type===t.type||typeof t.type=="undefined"))if(e.constructed===t.constructed||typeof t.constructed=="undefined"){if(n=!0,t.value&&Re.util.isArray(t.value))for(var c=0,a=0;n&&a<t.value.length;++a){var s=t.value[a];n=!!s.optional;var l=e.value[c];if(!l){s.optional||(n=!1,r&&r.push("["+t.name+'] Missing required element. Expected tag class "'+s.tagClass+'", type "'+s.type+'"'));continue}var o=typeof s.tagClass!="undefined"&&typeof s.type!="undefined";if(o&&(l.tagClass!==s.tagClass||l.type!==s.type))if(s.optional){n=!0;continue}else{n=!1,r&&r.push("["+t.name+"] Tag mismatch. Expected ("+s.tagClass+","+s.type+"), got ("+l.tagClass+","+l.type+")");break}var f=ae.validate(l,s,i,r);if(f)++c,n=!0;else if(s.optional)n=!0;else{n=!1;break}}if(n&&i&&(t.capture&&(i[t.capture]=e.value),t.captureAsn1&&(i[t.captureAsn1]=e),t.captureBitStringContents&&"bitStringContents"in e&&(i[t.captureBitStringContents]=e.bitStringContents),t.captureBitStringValue&&"bitStringContents"in e))if(e.bitStringContents.length<2)i[t.captureBitStringValue]="";else{var u=e.bitStringContents.charCodeAt(0);if(u!==0)throw new Error("captureBitStringValue only supported for zero unused bits");i[t.captureBitStringValue]=e.bitStringContents.slice(1)}}else r&&r.push("["+t.name+'] Expected constructed "'+t.constructed+'", got "'+e.constructed+'"');else r&&(e.tagClass!==t.tagClass&&r.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&r.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));return n};var fs=/[^\\u0000-\\u00ff]/;ae.prettyPrint=function(e,t,i){var r="";t=t||0,i=i||2,t>0&&(r+=`
`);for(var n="",c=0;c<t*i;++c)n+=" ";switch(r+=n+"Tag: ",e.tagClass){case ae.Class.UNIVERSAL:r+="Universal:";break;case ae.Class.APPLICATION:r+="Application:";break;case ae.Class.CONTEXT_SPECIFIC:r+="Context-Specific:";break;case ae.Class.PRIVATE:r+="Private:";break}if(e.tagClass===ae.Class.UNIVERSAL)switch(r+=e.type,e.type){case ae.Type.NONE:r+=" (None)";break;case ae.Type.BOOLEAN:r+=" (Boolean)";break;case ae.Type.INTEGER:r+=" (Integer)";break;case ae.Type.BITSTRING:r+=" (Bit string)";break;case ae.Type.OCTETSTRING:r+=" (Octet string)";break;case ae.Type.NULL:r+=" (Null)";break;case ae.Type.OID:r+=" (Object Identifier)";break;case ae.Type.ODESC:r+=" (Object Descriptor)";break;case ae.Type.EXTERNAL:r+=" (External or Instance of)";break;case ae.Type.REAL:r+=" (Real)";break;case ae.Type.ENUMERATED:r+=" (Enumerated)";break;case ae.Type.EMBEDDED:r+=" (Embedded PDV)";break;case ae.Type.UTF8:r+=" (UTF8)";break;case ae.Type.ROID:r+=" (Relative Object Identifier)";break;case ae.Type.SEQUENCE:r+=" (Sequence)";break;case ae.Type.SET:r+=" (Set)";break;case ae.Type.PRINTABLESTRING:r+=" (Printable String)";break;case ae.Type.IA5String:r+=" (IA5String (ASCII))";break;case ae.Type.UTCTIME:r+=" (UTC time)";break;case ae.Type.GENERALIZEDTIME:r+=" (Generalized time)";break;case ae.Type.BMPSTRING:r+=" (BMP String)";break}else r+=e.type;if(r+=`
`,r+=n+"Constructed: "+e.constructed+`
`,e.composed){for(var a=0,s="",c=0;c<e.value.length;++c)e.value[c]!==void 0&&(a+=1,s+=ae.prettyPrint(e.value[c],t+1,i),c+1<e.value.length&&(s+=","));r+=n+"Sub values: "+a+s}else{if(r+=n+"Value: ",e.type===ae.Type.OID){var l=ae.derToOid(e.value);r+=l,Re.pki&&Re.pki.oids&&l in Re.pki.oids&&(r+=" ("+Re.pki.oids[l]+") ")}if(e.type===ae.Type.INTEGER)try{r+=ae.derToInteger(e.value)}catch(f){r+="0x"+Re.util.bytesToHex(e.value)}else if(e.type===ae.Type.BITSTRING){if(e.value.length>1?r+="0x"+Re.util.bytesToHex(e.value.slice(1)):r+="(none)",e.value.length>0){var o=e.value.charCodeAt(0);o==1?r+=" (1 unused bit shown)":o>1&&(r+=" ("+o+" unused bits shown)")}}else if(e.type===ae.Type.OCTETSTRING)fs.test(e.value)||(r+="("+e.value+") "),r+="0x"+Re.util.bytesToHex(e.value);else if(e.type===ae.Type.UTF8)try{r+=Re.util.decodeUtf8(e.value)}catch(f){if(f.message==="URI malformed")r+="0x"+Re.util.bytesToHex(e.value)+" (malformed UTF8)";else throw f}else e.type===ae.Type.PRINTABLESTRING||e.type===ae.Type.IA5String?r+=e.value:fs.test(e.value)?r+="0x"+Re.util.bytesToHex(e.value):e.value.length===0?r+="[null]":r+=e.value}return r};var Dr=_e;Dr.md=Dr.md||{},Dr.md.algorithms=Dr.md.algorithms||{};var bt=_e,jn=bt.hmac=bt.hmac||{};jn.create=function(){var e=null,t=null,i=null,r=null,n={};return n.start=function(c,a){if(c!==null)if(typeof c=="string")if(c=c.toLowerCase(),c in bt.md.algorithms)t=bt.md.algorithms[c].create();else throw new Error('Unknown hash algorithm "'+c+'"');else t=c;if(a===null)a=e;else{if(typeof a=="string")a=bt.util.createBuffer(a);else if(bt.util.isArray(a)){var s=a;a=bt.util.createBuffer();for(var l=0;l<s.length;++l)a.putByte(s[l])}var o=a.length();o>t.blockLength&&(t.start(),t.update(a.bytes()),a=t.digest()),i=bt.util.createBuffer(),r=bt.util.createBuffer(),o=a.length();for(var l=0;l<o;++l){var s=a.at(l);i.putByte(54^s),r.putByte(92^s)}if(o<t.blockLength)for(var s=t.blockLength-o,l=0;l<s;++l)i.putByte(54),r.putByte(92);e=a,i=i.bytes(),r=r.bytes()}t.start(),t.update(i)},n.update=function(c){t.update(c)},n.getMac=function(){var c=t.digest().bytes();return t.start(),t.update(r),t.update(c),t.digest()},n.digest=n.getMac,n};var dt=_e,ds=dt.md5=dt.md5||{};dt.md.md5=dt.md.algorithms.md5=ds,ds.create=function(){ps||Qn();var e=null,t=dt.util.createBuffer(),i=new Array(16),r={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8};return r.start=function(){r.messageLength=0,r.fullMessageLength=r.messageLength64=[];for(var n=r.messageLengthSize/4,c=0;c<n;++c)r.fullMessageLength.push(0);return t=dt.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},r},r.start(),r.update=function(n,c){c==="utf8"&&(n=dt.util.encodeUtf8(n));var a=n.length;r.messageLength+=a,a=[a/4294967296>>>0,a>>>0];for(var s=r.fullMessageLength.length-1;s>=0;--s)r.fullMessageLength[s]+=a[1],a[1]=a[0]+(r.fullMessageLength[s]/4294967296>>>0),r.fullMessageLength[s]=r.fullMessageLength[s]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(n),vs(e,i,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=dt.util.createBuffer();n.putBytes(t.bytes());var c=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,a=c&r.blockLength-1;n.putBytes(pi.substr(0,r.blockLength-a));for(var s,l=0,o=r.fullMessageLength.length-1;o>=0;--o)s=r.fullMessageLength[o]*8+l,l=s/4294967296>>>0,n.putInt32Le(s>>>0);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};vs(f,i,n);var u=dt.util.createBuffer();return u.putInt32Le(f.h0),u.putInt32Le(f.h1),u.putInt32Le(f.h2),u.putInt32Le(f.h3),u},r};var pi=null,Pr=null,pr=null,Yt=null,ps=!1;function Qn(){pi=String.fromCharCode(128),pi+=dt.util.fillString(String.fromCharCode(0),64),Pr=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],pr=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],Yt=new Array(64);for(var e=0;e<64;++e)Yt[e]=Math.floor(Math.abs(Math.sin(e+1))*4294967296);ps=!0}function vs(e,t,i){for(var r,n,c,a,s,l,o,f,u=i.length();u>=64;){for(n=e.h0,c=e.h1,a=e.h2,s=e.h3,f=0;f<16;++f)t[f]=i.getInt32Le(),l=s^c&(a^s),r=n+l+Yt[f]+t[f],o=pr[f],n=s,s=a,a=c,c+=r<<o|r>>>32-o;for(;f<32;++f)l=a^s&(c^a),r=n+l+Yt[f]+t[Pr[f]],o=pr[f],n=s,s=a,a=c,c+=r<<o|r>>>32-o;for(;f<48;++f)l=c^a^s,r=n+l+Yt[f]+t[Pr[f]],o=pr[f],n=s,s=a,a=c,c+=r<<o|r>>>32-o;for(;f<64;++f)l=a^(c|~s),r=n+l+Yt[f]+t[Pr[f]],o=pr[f],n=s,s=a,a=c,c+=r<<o|r>>>32-o;e.h0=e.h0+n|0,e.h1=e.h1+c|0,e.h2=e.h2+a|0,e.h3=e.h3+s|0,u-=64}}var Nr=_e,gs=Nr.pem=Nr.pem||{};gs.encode=function(e,t){t=t||{};var i="-----BEGIN "+e.type+`-----\r
`,r;if(e.procType&&(r={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]},i+=Or(r)),e.contentDomain&&(r={name:"Content-Domain",values:[e.contentDomain]},i+=Or(r)),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),i+=Or(r)),e.headers)for(var n=0;n<e.headers.length;++n)i+=Or(e.headers[n]);return e.procType&&(i+=`\r
`),i+=Nr.util.encode64(e.body,t.maxline||64)+`\r
`,i+="-----END "+e.type+`-----\r
`,i},gs.decode=function(e){for(var t=[],i=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,r=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,n=/\r?\n/,c;c=i.exec(e),!!c;){var a=c[1];a==="NEW CERTIFICATE REQUEST"&&(a="CERTIFICATE REQUEST");var s={type:a,procType:null,contentDomain:null,dekInfo:null,headers:[],body:Nr.util.decode64(c[3])};if(t.push(s),!!c[2]){for(var l=c[2].split(n),o=0;c&&o<l.length;){for(var f=l[o].replace(/\s+$/,""),u=o+1;u<l.length;++u){var g=l[u];if(!/\s/.test(g[0]))break;f+=g,o=u}if(c=f.match(r),c){for(var _={name:c[1],values:[]},y=c[2].split(","),m=0;m<y.length;++m)_.values.push(Yn(y[m]));if(s.procType)if(!s.contentDomain&&_.name==="Content-Domain")s.contentDomain=y[0]||"";else if(!s.dekInfo&&_.name==="DEK-Info"){if(_.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');s.dekInfo={algorithm:y[0],parameters:y[1]||null}}else s.headers.push(_);else{if(_.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(_.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');s.procType={version:y[0],type:y[1]}}}++o}if(s.procType==="ENCRYPTED"&&!s.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(t.length===0)throw new Error("Invalid PEM formatted message.");return t};function Or(e){for(var t=e.name+": ",i=[],r=function(l,o){return" "+o},n=0;n<e.values.length;++n)i.push(e.values[n].replace(/^(\S+\r\n)/,r));t+=i.join(",")+`\r
`;for(var c=0,a=-1,n=0;n<t.length;++n,++c)if(c>65&&a!==-1){var s=t[a];s===","?(++a,t=t.substr(0,a)+`\r
 `+t.substr(a)):t=t.substr(0,a)+`\r
`+s+t.substr(a+1),c=n-a-1,a=-1,++n}else(t[n]===" "||t[n]==="	"||t[n]===",")&&(a=n);return t}function Yn(e){return e.replace(/^\s+/,"")}var Ne=_e;Ne.des=Ne.des||{},Ne.des.startEncrypting=function(e,t,i,r){var n=Mr({key:e,output:i,decrypt:!1,mode:r||(t===null?"ECB":"CBC")});return n.start(t),n},Ne.des.createEncryptionCipher=function(e,t){return Mr({key:e,output:null,decrypt:!1,mode:t})},Ne.des.startDecrypting=function(e,t,i,r){var n=Mr({key:e,output:i,decrypt:!0,mode:r||(t===null?"ECB":"CBC")});return n.start(t),n},Ne.des.createDecryptionCipher=function(e,t){return Mr({key:e,output:null,decrypt:!0,mode:t})},Ne.des.Algorithm=function(e,t){var i=this;i.name=e,i.mode=new t({blockSize:8,cipher:{encrypt:function(r,n){return _s(i._keys,r,n,!1)},decrypt:function(r,n){return _s(i._keys,r,n,!0)}}}),i._init=!1},Ne.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=Ne.util.createBuffer(e.key);if(this.name.indexOf("3DES")===0&&t.length()!==24)throw new Error("Invalid Triple-DES key size: "+t.length()*8);this._keys=na(t),this._init=!0}},pt("DES-ECB",Ne.cipher.modes.ecb),pt("DES-CBC",Ne.cipher.modes.cbc),pt("DES-CFB",Ne.cipher.modes.cfb),pt("DES-OFB",Ne.cipher.modes.ofb),pt("DES-CTR",Ne.cipher.modes.ctr),pt("3DES-ECB",Ne.cipher.modes.ecb),pt("3DES-CBC",Ne.cipher.modes.cbc),pt("3DES-CFB",Ne.cipher.modes.cfb),pt("3DES-OFB",Ne.cipher.modes.ofb),pt("3DES-CTR",Ne.cipher.modes.ctr);function pt(e,t){var i=function(){return new Ne.des.Algorithm(e,t)};Ne.cipher.registerAlgorithm(e,i)}var Xn=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],Zn=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],Jn=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],ea=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],ta=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],ra=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],ia=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],sa=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function na(e){for(var t=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],i=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],r=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],n=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],c=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],a=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],s=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],l=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],o=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],f=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],u=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],g=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],_=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],y=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],m=e.length()>8?3:1,h=[],d=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],p=0,v,C=0;C<m;C++){var S=e.getInt32(),b=e.getInt32();v=(S>>>4^b)&252645135,b^=v,S^=v<<4,v=(b>>>-16^S)&65535,S^=v,b^=v<<-16,v=(S>>>2^b)&858993459,b^=v,S^=v<<2,v=(b>>>-16^S)&65535,S^=v,b^=v<<-16,v=(S>>>1^b)&1431655765,b^=v,S^=v<<1,v=(b>>>8^S)&16711935,S^=v,b^=v<<8,v=(S>>>1^b)&1431655765,b^=v,S^=v<<1,v=S<<8|b>>>20&240,S=b<<24|b<<8&16711680|b>>>8&65280|b>>>24&240,b=v;for(var w=0;w<d.length;++w){d[w]?(S=S<<2|S>>>26,b=b<<2|b>>>26):(S=S<<1|S>>>27,b=b<<1|b>>>27),S&=-15,b&=-15;var E=t[S>>>28]|i[S>>>24&15]|r[S>>>20&15]|n[S>>>16&15]|c[S>>>12&15]|a[S>>>8&15]|s[S>>>4&15],x=l[b>>>28]|o[b>>>24&15]|f[b>>>20&15]|u[b>>>16&15]|g[b>>>12&15]|_[b>>>8&15]|y[b>>>4&15];v=(x>>>16^E)&65535,h[p++]=E^v,h[p++]=x^v<<16}}return h}function _s(e,t,i,r){var n=e.length===32?3:9,c;n===3?c=r?[30,-2,-2]:[0,32,2]:c=r?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var a,s=t[0],l=t[1];a=(s>>>4^l)&252645135,l^=a,s^=a<<4,a=(s>>>16^l)&65535,l^=a,s^=a<<16,a=(l>>>2^s)&858993459,s^=a,l^=a<<2,a=(l>>>8^s)&16711935,s^=a,l^=a<<8,a=(s>>>1^l)&1431655765,l^=a,s^=a<<1,s=s<<1|s>>>31,l=l<<1|l>>>31;for(var o=0;o<n;o+=3){for(var f=c[o+1],u=c[o+2],g=c[o];g!=f;g+=u){var _=l^e[g],y=(l>>>4|l<<28)^e[g+1];a=s,s=l,l=a^(Zn[_>>>24&63]|ea[_>>>16&63]|ra[_>>>8&63]|sa[_&63]|Xn[y>>>24&63]|Jn[y>>>16&63]|ta[y>>>8&63]|ia[y&63])}a=s,s=l,l=a}s=s>>>1|s<<31,l=l>>>1|l<<31,a=(s>>>1^l)&1431655765,l^=a,s^=a<<1,a=(l>>>8^s)&16711935,s^=a,l^=a<<8,a=(l>>>2^s)&858993459,s^=a,l^=a<<2,a=(s>>>16^l)&65535,l^=a,s^=a<<16,a=(s>>>4^l)&252645135,l^=a,s^=a<<4,i[0]=s,i[1]=l}function Mr(e){e=e||{};var t=(e.mode||"CBC").toUpperCase(),i="DES-"+t,r;e.decrypt?r=Ne.cipher.createDecipher(i,e.key):r=Ne.cipher.createCipher(i,e.key);var n=r.start;return r.start=function(c,a){var s=null;a instanceof Ne.util.ByteBuffer&&(s=a,a={}),a=a||{},a.output=s,a.iv=c,n.call(r,a)},r}const vi=hr(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Ye=_e,aa=Ye.pkcs5=Ye.pkcs5||{},xt;Ye.util.isNodejs&&!Ye.options.usePureJavaScript&&(xt=vi),Ye.pbkdf2=aa.pbkdf2=function(e,t,i,r,n,c){if(typeof n=="function"&&(c=n,n=null),Ye.util.isNodejs&&!Ye.options.usePureJavaScript&&xt.pbkdf2&&(n===null||typeof n!="object")&&(xt.pbkdf2Sync.length>4||!n||n==="sha1"))return typeof n!="string"&&(n="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),c?xt.pbkdf2Sync.length===4?xt.pbkdf2(e,t,i,r,function(v,C){if(v)return c(v);c(null,C.toString("binary"))}):xt.pbkdf2(e,t,i,r,n,function(v,C){if(v)return c(v);c(null,C.toString("binary"))}):xt.pbkdf2Sync.length===4?xt.pbkdf2Sync(e,t,i,r).toString("binary"):xt.pbkdf2Sync(e,t,i,r,n).toString("binary");if((typeof n=="undefined"||n===null)&&(n="sha1"),typeof n=="string"){if(!(n in Ye.md.algorithms))throw new Error("Unknown hash algorithm: "+n);n=Ye.md[n].create()}var a=n.digestLength;if(r>4294967295*a){var s=new Error("Derived key is too long.");if(c)return c(s);throw s}var l=Math.ceil(r/a),o=r-(l-1)*a,f=Ye.hmac.create();f.start(n,e);var u="",g,_,y;if(!c){for(var m=1;m<=l;++m){f.start(null,null),f.update(t),f.update(Ye.util.int32ToBytes(m)),g=y=f.digest().getBytes();for(var h=2;h<=i;++h)f.start(null,null),f.update(y),_=f.digest().getBytes(),g=Ye.util.xorBytes(g,_,a),y=_;u+=m<l?g:g.substr(0,o)}return u}var m=1,h;function d(){if(m>l)return c(null,u);f.start(null,null),f.update(t),f.update(Ye.util.int32ToBytes(m)),g=y=f.digest().getBytes(),h=2,p()}function p(){if(h<=i)return f.start(null,null),f.update(y),_=f.digest().getBytes(),g=Ye.util.xorBytes(g,_,a),y=_,++h,Ye.util.setImmediate(p);u+=m<l?g:g.substr(0,o),++m,d()}d()};var vt=_e,ys=vt.sha256=vt.sha256||{};vt.md.sha256=vt.md.algorithms.sha256=ys,ys.create=function(){ms||oa();var e=null,t=vt.util.createBuffer(),i=new Array(64),r={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return r.start=function(){r.messageLength=0,r.fullMessageLength=r.messageLength64=[];for(var n=r.messageLengthSize/4,c=0;c<n;++c)r.fullMessageLength.push(0);return t=vt.util.createBuffer(),e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},r},r.start(),r.update=function(n,c){c==="utf8"&&(n=vt.util.encodeUtf8(n));var a=n.length;r.messageLength+=a,a=[a/4294967296>>>0,a>>>0];for(var s=r.fullMessageLength.length-1;s>=0;--s)r.fullMessageLength[s]+=a[1],a[1]=a[0]+(r.fullMessageLength[s]/4294967296>>>0),r.fullMessageLength[s]=r.fullMessageLength[s]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(n),Ss(e,i,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=vt.util.createBuffer();n.putBytes(t.bytes());var c=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,a=c&r.blockLength-1;n.putBytes(gi.substr(0,r.blockLength-a));for(var s,l,o=r.fullMessageLength[0]*8,f=0;f<r.fullMessageLength.length-1;++f)s=r.fullMessageLength[f+1]*8,l=s/4294967296>>>0,o+=l,n.putInt32(o>>>0),o=s>>>0;n.putInt32(o);var u={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};Ss(u,i,n);var g=vt.util.createBuffer();return g.putInt32(u.h0),g.putInt32(u.h1),g.putInt32(u.h2),g.putInt32(u.h3),g.putInt32(u.h4),g.putInt32(u.h5),g.putInt32(u.h6),g.putInt32(u.h7),g},r};var gi=null,ms=!1,Cs=null;function oa(){gi=String.fromCharCode(128),gi+=vt.util.fillString(String.fromCharCode(0),64),Cs=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],ms=!0}function Ss(e,t,i){for(var r,n,c,a,s,l,o,f,u,g,_,y,m,h,d,p=i.length();p>=64;){for(o=0;o<16;++o)t[o]=i.getInt32();for(;o<64;++o)r=t[o-2],r=(r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10,n=t[o-15],n=(n>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,t[o]=r+t[o-7]+n+t[o-16]|0;for(f=e.h0,u=e.h1,g=e.h2,_=e.h3,y=e.h4,m=e.h5,h=e.h6,d=e.h7,o=0;o<64;++o)a=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),s=h^y&(m^h),c=(f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10),l=f&u|g&(f^u),r=d+a+s+Cs[o]+t[o],n=c+l,d=h,h=m,m=y,y=_+r>>>0,_=g,g=u,u=f,f=r+n>>>0;e.h0=e.h0+f|0,e.h1=e.h1+u|0,e.h2=e.h2+g|0,e.h3=e.h3+_|0,e.h4=e.h4+y|0,e.h5=e.h5+m|0,e.h6=e.h6+h|0,e.h7=e.h7+d|0,p-=64}}var gt=_e,Ur=null;gt.util.isNodejs&&!gt.options.usePureJavaScript&&!process.versions["node-webkit"]&&(Ur=vi);var la=gt.prng=gt.prng||{};la.create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},i=e.md,r=new Array(32),n=0;n<32;++n)r[n]=i.create();t.pools=r,t.pool=0,t.generate=function(o,f){if(!f)return t.generateSync(o);var u=t.plugin.cipher,g=t.plugin.increment,_=t.plugin.formatKey,y=t.plugin.formatSeed,m=gt.util.createBuffer();t.key=null,h();function h(d){if(d)return f(d);if(m.length()>=o)return f(null,m.getBytes(o));if(t.generated>1048575&&(t.key=null),t.key===null)return gt.util.nextTick(function(){c(h)});var p=u(t.key,t.seed);t.generated+=p.length,m.putBytes(p),t.key=_(u(t.key,g(t.seed))),t.seed=y(u(t.key,t.seed)),gt.util.setImmediate(h)}},t.generateSync=function(o){var f=t.plugin.cipher,u=t.plugin.increment,g=t.plugin.formatKey,_=t.plugin.formatSeed;t.key=null;for(var y=gt.util.createBuffer();y.length()<o;){t.generated>1048575&&(t.key=null),t.key===null&&a();var m=f(t.key,t.seed);t.generated+=m.length,y.putBytes(m),t.key=g(f(t.key,u(t.seed))),t.seed=_(f(t.key,t.seed))}return y.getBytes(o)};function c(o){if(t.pools[0].messageLength>=32)return s(),o();var f=32-t.pools[0].messageLength<<5;t.seedFile(f,function(u,g){if(u)return o(u);t.collect(g),s(),o()})}function a(){if(t.pools[0].messageLength>=32)return s();var o=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(o)),s()}function s(){t.reseeds=t.reseeds===4294967295?0:t.reseeds+1;var o=t.plugin.md.create();o.update(t.keyBytes);for(var f=1,u=0;u<32;++u)t.reseeds%f===0&&(o.update(t.pools[u].digest().getBytes()),t.pools[u].start()),f=f<<1;t.keyBytes=o.digest().getBytes(),o.start(),o.update(t.keyBytes);var g=o.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(g),t.generated=0}function l(o){var f=null,u=gt.util.globalScope,g=u.crypto||u.msCrypto;g&&g.getRandomValues&&(f=function(S){return g.getRandomValues(S)});var _=gt.util.createBuffer();if(f)for(;_.length()<o;){var y=Math.max(1,Math.min(o-_.length(),65536)/4),m=new Uint32Array(Math.floor(y));try{f(m);for(var h=0;h<m.length;++h)_.putInt32(m[h])}catch(S){if(!(typeof QuotaExceededError!="undefined"&&S instanceof QuotaExceededError))throw S}}if(_.length()<o)for(var d,p,v,C=Math.floor(Math.random()*65536);_.length()<o;){p=16807*(C&65535),d=16807*(C>>16),p+=(d&32767)<<16,p+=d>>15,p=(p&2147483647)+(p>>31),C=p&4294967295;for(var h=0;h<3;++h)v=C>>>(h<<3),v^=Math.floor(Math.random()*256),_.putByte(v&255)}return _.getBytes(o)}return Ur?(t.seedFile=function(o,f){Ur.randomBytes(o,function(u,g){if(u)return f(u);f(null,g.toString())})},t.seedFileSync=function(o){return Ur.randomBytes(o).toString()}):(t.seedFile=function(o,f){try{f(null,l(o))}catch(u){f(u)}},t.seedFileSync=l),t.collect=function(o){for(var f=o.length,u=0;u<f;++u)t.pools[t.pool].update(o.substr(u,1)),t.pool=t.pool===31?0:t.pool+1},t.collectInt=function(o,f){for(var u="",g=0;g<f;g+=8)u+=String.fromCharCode(o>>g&255);t.collect(u)},t.registerWorker=function(o){if(o===self)t.seedFile=function(u,g){function _(y){var m=y.data;m.forge&&m.forge.prng&&(self.removeEventListener("message",_),g(m.forge.prng.err,m.forge.prng.bytes))}self.addEventListener("message",_),self.postMessage({forge:{prng:{needed:u}}})};else{var f=function(u){var g=u.data;g.forge&&g.forge.prng&&t.seedFile(g.forge.prng.needed,function(_,y){o.postMessage({forge:{prng:{err:_,bytes:y}}})})};o.addEventListener("message",f)}},t};var ze=_e;(function(){if(ze.random&&ze.random.getBytes){ze.random;return}(function(e){var t={},i=new Array(4),r=ze.util.createBuffer();t.formatKey=function(u){var g=ze.util.createBuffer(u);return u=new Array(4),u[0]=g.getInt32(),u[1]=g.getInt32(),u[2]=g.getInt32(),u[3]=g.getInt32(),ze.aes._expandKey(u,!1)},t.formatSeed=function(u){var g=ze.util.createBuffer(u);return u=new Array(4),u[0]=g.getInt32(),u[1]=g.getInt32(),u[2]=g.getInt32(),u[3]=g.getInt32(),u},t.cipher=function(u,g){return ze.aes._updateBlock(u,g,i,!1),r.putInt32(i[0]),r.putInt32(i[1]),r.putInt32(i[2]),r.putInt32(i[3]),r.getBytes()},t.increment=function(u){return++u[3],u},t.md=ze.md.sha256;function n(){var u=ze.prng.create(t);return u.getBytes=function(g,_){return u.generate(g,_)},u.getBytesSync=function(g){return u.generate(g)},u}var c=n(),a=null,s=ze.util.globalScope,l=s.crypto||s.msCrypto;if(l&&l.getRandomValues&&(a=function(u){return l.getRandomValues(u)}),ze.options.usePureJavaScript||!ze.util.isNodejs&&!a){if(c.collectInt(+new Date,32),typeof navigator!="undefined"){var o="";for(var f in navigator)try{typeof navigator[f]=="string"&&(o+=navigator[f])}catch(u){}c.collect(o),o=null}e&&(e().mousemove(function(u){c.collectInt(u.clientX,16),c.collectInt(u.clientY,16)}),e().keypress(function(u){c.collectInt(u.charCode,8)}))}if(!ze.random)ze.random=c;else for(var f in c)ze.random[f]=c[f];ze.random.createInstance=n,ze.random})(typeof jQuery!="undefined"?jQuery:null)})();var et=_e,_i=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],Es=[1,2,3,5],ca=function(e,t){return e<<t&65535|(e&65535)>>16-t},ha=function(e,t){return(e&65535)>>t|e<<16-t&65535};et.rc2=et.rc2||{},et.rc2.expandKey=function(e,t){typeof e=="string"&&(e=et.util.createBuffer(e)),t=t||128;var i=e,r=e.length(),n=t,c=Math.ceil(n/8),a=255>>(n&7),s;for(s=r;s<128;s++)i.putByte(_i[i.at(s-1)+i.at(s-r)&255]);for(i.setAt(128-c,_i[i.at(128-c)&a]),s=127-c;s>=0;s--)i.setAt(s,_i[i.at(s+1)^i.at(s+c)]);return i};var bs=function(e,t,i){var r=!1,n=null,c=null,a=null,s,l,o,f,u=[];for(e=et.rc2.expandKey(e,t),o=0;o<64;o++)u.push(e.getInt16Le());i?(s=function(y){for(o=0;o<4;o++)y[o]+=u[f]+(y[(o+3)%4]&y[(o+2)%4])+(~y[(o+3)%4]&y[(o+1)%4]),y[o]=ca(y[o],Es[o]),f++},l=function(y){for(o=0;o<4;o++)y[o]+=u[y[(o+3)%4]&63]}):(s=function(y){for(o=3;o>=0;o--)y[o]=ha(y[o],Es[o]),y[o]-=u[f]+(y[(o+3)%4]&y[(o+2)%4])+(~y[(o+3)%4]&y[(o+1)%4]),f--},l=function(y){for(o=3;o>=0;o--)y[o]-=u[y[(o+3)%4]&63]});var g=function(y){var m=[];for(o=0;o<4;o++){var h=n.getInt16Le();a!==null&&(i?h^=a.getInt16Le():a.putInt16Le(h)),m.push(h&65535)}f=i?0:63;for(var d=0;d<y.length;d++)for(var p=0;p<y[d][0];p++)y[d][1](m);for(o=0;o<4;o++)a!==null&&(i?a.putInt16Le(m[o]):m[o]^=a.getInt16Le()),c.putInt16Le(m[o])},_=null;return _={start:function(y,m){y&&typeof y=="string"&&(y=et.util.createBuffer(y)),r=!1,n=et.util.createBuffer(),c=m||new et.util.createBuffer,a=y,_.output=c},update:function(y){for(r||n.putBuffer(y);n.length()>=8;)g([[5,s],[1,l],[6,s],[1,l],[5,s]])},finish:function(y){var m=!0;if(i)if(y)m=y(8,n,!i);else{var h=n.length()===8?8:8-n.length();n.fillWithByte(h,h)}if(m&&(r=!0,_.update()),!i&&(m=n.length()===0,m))if(y)m=y(8,c,!i);else{var d=c.length(),p=c.at(d-1);p>d?m=!1:c.truncate(p)}return m}},_};et.rc2.startEncrypting=function(e,t,i){var r=et.rc2.createEncryptionCipher(e,128);return r.start(t,i),r},et.rc2.createEncryptionCipher=function(e,t){return bs(e,t,!0)},et.rc2.startDecrypting=function(e,t,i){var r=et.rc2.createDecryptionCipher(e,128);return r.start(t,i),r},et.rc2.createDecryptionCipher=function(e,t){return bs(e,t,!1)};var yi=_e;yi.jsbn=yi.jsbn||{};var wt;function Z(e,t,i){this.data=[],e!=null&&(typeof e=="number"?this.fromNumber(e,t,i):t==null&&typeof e!="string"?this.fromString(e,256):this.fromString(e,t))}yi.jsbn.BigInteger=Z;function we(){return new Z(null)}function ua(e,t,i,r,n,c){for(;--c>=0;){var a=t*this.data[e++]+i.data[r]+n;n=Math.floor(a/67108864),i.data[r++]=a&67108863}return n}function fa(e,t,i,r,n,c){for(var a=t&32767,s=t>>15;--c>=0;){var l=this.data[e]&32767,o=this.data[e++]>>15,f=s*l+o*a;l=a*l+((f&32767)<<15)+i.data[r]+(n&1073741823),n=(l>>>30)+(f>>>15)+s*o+(n>>>30),i.data[r++]=l&1073741823}return n}function xs(e,t,i,r,n,c){for(var a=t&16383,s=t>>14;--c>=0;){var l=this.data[e]&16383,o=this.data[e++]>>14,f=s*l+o*a;l=a*l+((f&16383)<<14)+i.data[r]+n,n=(l>>28)+(f>>14)+s*o,i.data[r++]=l&268435455}return n}typeof navigator=="undefined"?(Z.prototype.am=xs,wt=28):navigator.appName=="Microsoft Internet Explorer"?(Z.prototype.am=fa,wt=30):navigator.appName!="Netscape"?(Z.prototype.am=ua,wt=26):(Z.prototype.am=xs,wt=28),Z.prototype.DB=wt,Z.prototype.DM=(1<<wt)-1,Z.prototype.DV=1<<wt;var mi=52;Z.prototype.FV=Math.pow(2,mi),Z.prototype.F1=mi-wt,Z.prototype.F2=2*wt-mi;var da="0123456789abcdefghijklmnopqrstuvwxyz",Fr=new Array,Xt,st;for(Xt="0".charCodeAt(0),st=0;st<=9;++st)Fr[Xt++]=st;for(Xt="a".charCodeAt(0),st=10;st<36;++st)Fr[Xt++]=st;for(Xt="A".charCodeAt(0),st=10;st<36;++st)Fr[Xt++]=st;function ws(e){return da.charAt(e)}function Ts(e,t){var i=Fr[e.charCodeAt(t)];return i==null?-1:i}function pa(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s}function va(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0}function It(e){var t=we();return t.fromInt(e),t}function ga(e,t){var i;if(t==16)i=4;else if(t==8)i=3;else if(t==256)i=8;else if(t==2)i=1;else if(t==32)i=5;else if(t==4)i=2;else{this.fromRadix(e,t);return}this.t=0,this.s=0;for(var r=e.length,n=!1,c=0;--r>=0;){var a=i==8?e[r]&255:Ts(e,r);if(a<0){e.charAt(r)=="-"&&(n=!0);continue}n=!1,c==0?this.data[this.t++]=a:c+i>this.DB?(this.data[this.t-1]|=(a&(1<<this.DB-c)-1)<<c,this.data[this.t++]=a>>this.DB-c):this.data[this.t-1]|=a<<c,c+=i,c>=this.DB&&(c-=this.DB)}i==8&&e[0]&128&&(this.s=-1,c>0&&(this.data[this.t-1]|=(1<<this.DB-c)-1<<c)),this.clamp(),n&&Z.ZERO.subTo(this,this)}function _a(){for(var e=this.s&this.DM;this.t>0&&this.data[this.t-1]==e;)--this.t}function ya(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(e==16)t=4;else if(e==8)t=3;else if(e==2)t=1;else if(e==32)t=5;else if(e==4)t=2;else return this.toRadix(e);var i=(1<<t)-1,r,n=!1,c="",a=this.t,s=this.DB-a*this.DB%t;if(a-- >0)for(s<this.DB&&(r=this.data[a]>>s)>0&&(n=!0,c=ws(r));a>=0;)s<t?(r=(this.data[a]&(1<<s)-1)<<t-s,r|=this.data[--a]>>(s+=this.DB-t)):(r=this.data[a]>>(s-=t)&i,s<=0&&(s+=this.DB,--a)),r>0&&(n=!0),n&&(c+=ws(r));return n?c:"0"}function ma(){var e=we();return Z.ZERO.subTo(this,e),e}function Ca(){return this.s<0?this.negate():this}function Sa(e){var t=this.s-e.s;if(t!=0)return t;var i=this.t;if(t=i-e.t,t!=0)return this.s<0?-t:t;for(;--i>=0;)if((t=this.data[i]-e.data[i])!=0)return t;return 0}function Hr(e){var t=1,i;return(i=e>>>16)!=0&&(e=i,t+=16),(i=e>>8)!=0&&(e=i,t+=8),(i=e>>4)!=0&&(e=i,t+=4),(i=e>>2)!=0&&(e=i,t+=2),(i=e>>1)!=0&&(e=i,t+=1),t}function Ea(){return this.t<=0?0:this.DB*(this.t-1)+Hr(this.data[this.t-1]^this.s&this.DM)}function ba(e,t){var i;for(i=this.t-1;i>=0;--i)t.data[i+e]=this.data[i];for(i=e-1;i>=0;--i)t.data[i]=0;t.t=this.t+e,t.s=this.s}function xa(e,t){for(var i=e;i<this.t;++i)t.data[i-e]=this.data[i];t.t=Math.max(this.t-e,0),t.s=this.s}function wa(e,t){var i=e%this.DB,r=this.DB-i,n=(1<<r)-1,c=Math.floor(e/this.DB),a=this.s<<i&this.DM,s;for(s=this.t-1;s>=0;--s)t.data[s+c+1]=this.data[s]>>r|a,a=(this.data[s]&n)<<i;for(s=c-1;s>=0;--s)t.data[s]=0;t.data[c]=a,t.t=this.t+c+1,t.s=this.s,t.clamp()}function Ta(e,t){t.s=this.s;var i=Math.floor(e/this.DB);if(i>=this.t){t.t=0;return}var r=e%this.DB,n=this.DB-r,c=(1<<r)-1;t.data[0]=this.data[i]>>r;for(var a=i+1;a<this.t;++a)t.data[a-i-1]|=(this.data[a]&c)<<n,t.data[a-i]=this.data[a]>>r;r>0&&(t.data[this.t-i-1]|=(this.s&c)<<n),t.t=this.t-i,t.clamp()}function Aa(e,t){for(var i=0,r=0,n=Math.min(e.t,this.t);i<n;)r+=this.data[i]-e.data[i],t.data[i++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r-=e.s;i<this.t;)r+=this.data[i],t.data[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<e.t;)r-=e.data[i],t.data[i++]=r&this.DM,r>>=this.DB;r-=e.s}t.s=r<0?-1:0,r<-1?t.data[i++]=this.DV+r:r>0&&(t.data[i++]=r),t.t=i,t.clamp()}function Ba(e,t){var i=this.abs(),r=e.abs(),n=i.t;for(t.t=n+r.t;--n>=0;)t.data[n]=0;for(n=0;n<r.t;++n)t.data[n+i.t]=i.am(0,r.data[n],t,n,0,i.t);t.s=0,t.clamp(),this.s!=e.s&&Z.ZERO.subTo(t,t)}function Ia(e){for(var t=this.abs(),i=e.t=2*t.t;--i>=0;)e.data[i]=0;for(i=0;i<t.t-1;++i){var r=t.am(i,t.data[i],e,2*i,0,1);(e.data[i+t.t]+=t.am(i+1,2*t.data[i],e,2*i+1,r,t.t-i-1))>=t.DV&&(e.data[i+t.t]-=t.DV,e.data[i+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(i,t.data[i],e,2*i,0,1)),e.s=0,e.clamp()}function La(e,t,i){var r=e.abs();if(!(r.t<=0)){var n=this.abs();if(n.t<r.t){t!=null&&t.fromInt(0),i!=null&&this.copyTo(i);return}i==null&&(i=we());var c=we(),a=this.s,s=e.s,l=this.DB-Hr(r.data[r.t-1]);l>0?(r.lShiftTo(l,c),n.lShiftTo(l,i)):(r.copyTo(c),n.copyTo(i));var o=c.t,f=c.data[o-1];if(f!=0){var u=f*(1<<this.F1)+(o>1?c.data[o-2]>>this.F2:0),g=this.FV/u,_=(1<<this.F1)/u,y=1<<this.F2,m=i.t,h=m-o,d=t==null?we():t;for(c.dlShiftTo(h,d),i.compareTo(d)>=0&&(i.data[i.t++]=1,i.subTo(d,i)),Z.ONE.dlShiftTo(o,d),d.subTo(c,c);c.t<o;)c.data[c.t++]=0;for(;--h>=0;){var p=i.data[--m]==f?this.DM:Math.floor(i.data[m]*g+(i.data[m-1]+y)*_);if((i.data[m]+=c.am(0,p,i,h,0,o))<p)for(c.dlShiftTo(h,d),i.subTo(d,i);i.data[m]<--p;)i.subTo(d,i)}t!=null&&(i.drShiftTo(o,t),a!=s&&Z.ZERO.subTo(t,t)),i.t=o,i.clamp(),l>0&&i.rShiftTo(l,i),a<0&&Z.ZERO.subTo(i,i)}}}function ka(e){var t=we();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(Z.ZERO)>0&&e.subTo(t,t),t}function Ht(e){this.m=e}function Ra(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function Da(e){return e}function Pa(e){e.divRemTo(this.m,null,e)}function Na(e,t,i){e.multiplyTo(t,i),this.reduce(i)}function Oa(e,t){e.squareTo(t),this.reduce(t)}Ht.prototype.convert=Ra,Ht.prototype.revert=Da,Ht.prototype.reduce=Pa,Ht.prototype.mulTo=Na,Ht.prototype.sqrTo=Oa;function Ma(){if(this.t<1)return 0;var e=this.data[0];if(!(e&1))return 0;var t=e&3;return t=t*(2-(e&15)*t)&15,t=t*(2-(e&255)*t)&255,t=t*(2-((e&65535)*t&65535))&65535,t=t*(2-e*t%this.DV)%this.DV,t>0?this.DV-t:-t}function Vt(e){this.m=e,this.mp=e.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function Ua(e){var t=we();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(Z.ZERO)>0&&this.m.subTo(t,t),t}function Fa(e){var t=we();return e.copyTo(t),this.reduce(t),t}function Ha(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t<this.m.t;++t){var i=e.data[t]&32767,r=i*this.mpl+((i*this.mph+(e.data[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(i=t+this.m.t,e.data[i]+=this.m.am(0,r,e,t,0,this.m.t);e.data[i]>=e.DV;)e.data[i]-=e.DV,e.data[++i]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function Va(e,t){e.squareTo(t),this.reduce(t)}function Ka(e,t,i){e.multiplyTo(t,i),this.reduce(i)}Vt.prototype.convert=Ua,Vt.prototype.revert=Fa,Vt.prototype.reduce=Ha,Vt.prototype.mulTo=Ka,Vt.prototype.sqrTo=Va;function Wa(){return(this.t>0?this.data[0]&1:this.s)==0}function za(e,t){if(e>4294967295||e<1)return Z.ONE;var i=we(),r=we(),n=t.convert(this),c=Hr(e)-1;for(n.copyTo(i);--c>=0;)if(t.sqrTo(i,r),(e&1<<c)>0)t.mulTo(r,n,i);else{var a=i;i=r,r=a}return t.revert(i)}function $a(e,t){var i;return e<256||t.isEven()?i=new Ht(t):i=new Vt(t),this.exp(e,i)}Z.prototype.copyTo=pa,Z.prototype.fromInt=va,Z.prototype.fromString=ga,Z.prototype.clamp=_a,Z.prototype.dlShiftTo=ba,Z.prototype.drShiftTo=xa,Z.prototype.lShiftTo=wa,Z.prototype.rShiftTo=Ta,Z.prototype.subTo=Aa,Z.prototype.multiplyTo=Ba,Z.prototype.squareTo=Ia,Z.prototype.divRemTo=La,Z.prototype.invDigit=Ma,Z.prototype.isEven=Wa,Z.prototype.exp=za,Z.prototype.toString=ya,Z.prototype.negate=ma,Z.prototype.abs=Ca,Z.prototype.compareTo=Sa,Z.prototype.bitLength=Ea,Z.prototype.mod=ka,Z.prototype.modPowInt=$a,Z.ZERO=It(0),Z.ONE=It(1);function qa(){var e=we();return this.copyTo(e),e}function Ga(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this.data[0];if(this.t==0)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function ja(){return this.t==0?this.s:this.data[0]<<24>>24}function Qa(){return this.t==0?this.s:this.data[0]<<16>>16}function Ya(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function Xa(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function Za(e){if(e==null&&(e=10),this.signum()==0||e<2||e>36)return"0";var t=this.chunkSize(e),i=Math.pow(e,t),r=It(i),n=we(),c=we(),a="";for(this.divRemTo(r,n,c);n.signum()>0;)a=(i+c.intValue()).toString(e).substr(1)+a,n.divRemTo(r,n,c);return c.intValue().toString(e)+a}function Ja(e,t){this.fromInt(0),t==null&&(t=10);for(var i=this.chunkSize(t),r=Math.pow(t,i),n=!1,c=0,a=0,s=0;s<e.length;++s){var l=Ts(e,s);if(l<0){e.charAt(s)=="-"&&this.signum()==0&&(n=!0);continue}a=t*a+l,++c>=i&&(this.dMultiply(r),this.dAddOffset(a,0),c=0,a=0)}c>0&&(this.dMultiply(Math.pow(t,c)),this.dAddOffset(a,0)),n&&Z.ZERO.subTo(this,this)}function eo(e,t,i){if(typeof t=="number")if(e<2)this.fromInt(1);else for(this.fromNumber(e,i),this.testBit(e-1)||this.bitwiseTo(Z.ONE.shiftLeft(e-1),Ci,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(Z.ONE.shiftLeft(e-1),this);else{var r=new Array,n=e&7;r.length=(e>>3)+1,t.nextBytes(r),n>0?r[0]&=(1<<n)-1:r[0]=0,this.fromString(r,256)}}function to(){var e=this.t,t=new Array;t[0]=this.s;var i=this.DB-e*this.DB%8,r,n=0;if(e-- >0)for(i<this.DB&&(r=this.data[e]>>i)!=(this.s&this.DM)>>i&&(t[n++]=r|this.s<<this.DB-i);e>=0;)i<8?(r=(this.data[e]&(1<<i)-1)<<8-i,r|=this.data[--e]>>(i+=this.DB-8)):(r=this.data[e]>>(i-=8)&255,i<=0&&(i+=this.DB,--e)),r&128&&(r|=-256),n==0&&(this.s&128)!=(r&128)&&++n,(n>0||r!=this.s)&&(t[n++]=r);return t}function ro(e){return this.compareTo(e)==0}function io(e){return this.compareTo(e)<0?this:e}function so(e){return this.compareTo(e)>0?this:e}function no(e,t,i){var r,n,c=Math.min(e.t,this.t);for(r=0;r<c;++r)i.data[r]=t(this.data[r],e.data[r]);if(e.t<this.t){for(n=e.s&this.DM,r=c;r<this.t;++r)i.data[r]=t(this.data[r],n);i.t=this.t}else{for(n=this.s&this.DM,r=c;r<e.t;++r)i.data[r]=t(n,e.data[r]);i.t=e.t}i.s=t(this.s,e.s),i.clamp()}function ao(e,t){return e&t}function oo(e){var t=we();return this.bitwiseTo(e,ao,t),t}function Ci(e,t){return e|t}function lo(e){var t=we();return this.bitwiseTo(e,Ci,t),t}function As(e,t){return e^t}function co(e){var t=we();return this.bitwiseTo(e,As,t),t}function Bs(e,t){return e&~t}function ho(e){var t=we();return this.bitwiseTo(e,Bs,t),t}function uo(){for(var e=we(),t=0;t<this.t;++t)e.data[t]=this.DM&~this.data[t];return e.t=this.t,e.s=~this.s,e}function fo(e){var t=we();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}function po(e){var t=we();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}function vo(e){if(e==0)return-1;var t=0;return e&65535||(e>>=16,t+=16),e&255||(e>>=8,t+=8),e&15||(e>>=4,t+=4),e&3||(e>>=2,t+=2),e&1||++t,t}function go(){for(var e=0;e<this.t;++e)if(this.data[e]!=0)return e*this.DB+vo(this.data[e]);return this.s<0?this.t*this.DB:-1}function _o(e){for(var t=0;e!=0;)e&=e-1,++t;return t}function yo(){for(var e=0,t=this.s&this.DM,i=0;i<this.t;++i)e+=_o(this.data[i]^t);return e}function mo(e){var t=Math.floor(e/this.DB);return t>=this.t?this.s!=0:(this.data[t]&1<<e%this.DB)!=0}function Co(e,t){var i=Z.ONE.shiftLeft(e);return this.bitwiseTo(i,t,i),i}function So(e){return this.changeBit(e,Ci)}function Eo(e){return this.changeBit(e,Bs)}function bo(e){return this.changeBit(e,As)}function xo(e,t){for(var i=0,r=0,n=Math.min(e.t,this.t);i<n;)r+=this.data[i]+e.data[i],t.data[i++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r+=e.s;i<this.t;)r+=this.data[i],t.data[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<e.t;)r+=e.data[i],t.data[i++]=r&this.DM,r>>=this.DB;r+=e.s}t.s=r<0?-1:0,r>0?t.data[i++]=r:r<-1&&(t.data[i++]=this.DV+r),t.t=i,t.clamp()}function wo(e){var t=we();return this.addTo(e,t),t}function To(e){var t=we();return this.subTo(e,t),t}function Ao(e){var t=we();return this.multiplyTo(e,t),t}function Bo(e){var t=we();return this.divRemTo(e,t,null),t}function Io(e){var t=we();return this.divRemTo(e,null,t),t}function Lo(e){var t=we(),i=we();return this.divRemTo(e,t,i),new Array(t,i)}function ko(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function Ro(e,t){if(e!=0){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}}function vr(){}function Is(e){return e}function Do(e,t,i){e.multiplyTo(t,i)}function Po(e,t){e.squareTo(t)}vr.prototype.convert=Is,vr.prototype.revert=Is,vr.prototype.mulTo=Do,vr.prototype.sqrTo=Po;function No(e){return this.exp(e,new vr)}function Oo(e,t,i){var r=Math.min(this.t+e.t,t);for(i.s=0,i.t=r;r>0;)i.data[--r]=0;var n;for(n=i.t-this.t;r<n;++r)i.data[r+this.t]=this.am(0,e.data[r],i,r,0,this.t);for(n=Math.min(e.t,t);r<n;++r)this.am(0,e.data[r],i,r,0,t-r);i.clamp()}function Mo(e,t,i){--t;var r=i.t=this.t+e.t-t;for(i.s=0;--r>=0;)i.data[r]=0;for(r=Math.max(t-this.t,0);r<e.t;++r)i.data[this.t+r-t]=this.am(t-r,e.data[r],i,0,0,this.t+r-t);i.clamp(),i.drShiftTo(1,i)}function Zt(e){this.r2=we(),this.q3=we(),Z.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}function Uo(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=we();return e.copyTo(t),this.reduce(t),t}function Fo(e){return e}function Ho(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)}function Vo(e,t){e.squareTo(t),this.reduce(t)}function Ko(e,t,i){e.multiplyTo(t,i),this.reduce(i)}Zt.prototype.convert=Uo,Zt.prototype.revert=Fo,Zt.prototype.reduce=Ho,Zt.prototype.mulTo=Ko,Zt.prototype.sqrTo=Vo;function Wo(e,t){var i=e.bitLength(),r,n=It(1),c;if(i<=0)return n;i<18?r=1:i<48?r=3:i<144?r=4:i<768?r=5:r=6,i<8?c=new Ht(t):t.isEven()?c=new Zt(t):c=new Vt(t);var a=new Array,s=3,l=r-1,o=(1<<r)-1;if(a[1]=c.convert(this),r>1){var f=we();for(c.sqrTo(a[1],f);s<=o;)a[s]=we(),c.mulTo(f,a[s-2],a[s]),s+=2}var u=e.t-1,g,_=!0,y=we(),m;for(i=Hr(e.data[u])-1;u>=0;){for(i>=l?g=e.data[u]>>i-l&o:(g=(e.data[u]&(1<<i+1)-1)<<l-i,u>0&&(g|=e.data[u-1]>>this.DB+i-l)),s=r;!(g&1);)g>>=1,--s;if((i-=s)<0&&(i+=this.DB,--u),_)a[g].copyTo(n),_=!1;else{for(;s>1;)c.sqrTo(n,y),c.sqrTo(y,n),s-=2;s>0?c.sqrTo(n,y):(m=n,n=y,y=m),c.mulTo(y,a[g],n)}for(;u>=0&&!(e.data[u]&1<<i);)c.sqrTo(n,y),m=n,n=y,y=m,--i<0&&(i=this.DB-1,--u)}return c.revert(n)}function zo(e){var t=this.s<0?this.negate():this.clone(),i=e.s<0?e.negate():e.clone();if(t.compareTo(i)<0){var r=t;t=i,i=r}var n=t.getLowestSetBit(),c=i.getLowestSetBit();if(c<0)return t;for(n<c&&(c=n),c>0&&(t.rShiftTo(c,t),i.rShiftTo(c,i));t.signum()>0;)(n=t.getLowestSetBit())>0&&t.rShiftTo(n,t),(n=i.getLowestSetBit())>0&&i.rShiftTo(n,i),t.compareTo(i)>=0?(t.subTo(i,t),t.rShiftTo(1,t)):(i.subTo(t,i),i.rShiftTo(1,i));return c>0&&i.lShiftTo(c,i),i}function $o(e){if(e<=0)return 0;var t=this.DV%e,i=this.s<0?e-1:0;if(this.t>0)if(t==0)i=this.data[0]%e;else for(var r=this.t-1;r>=0;--r)i=(t*i+this.data[r])%e;return i}function qo(e){var t=e.isEven();if(this.isEven()&&t||e.signum()==0)return Z.ZERO;for(var i=e.clone(),r=this.clone(),n=It(1),c=It(0),a=It(0),s=It(1);i.signum()!=0;){for(;i.isEven();)i.rShiftTo(1,i),t?((!n.isEven()||!c.isEven())&&(n.addTo(this,n),c.subTo(e,c)),n.rShiftTo(1,n)):c.isEven()||c.subTo(e,c),c.rShiftTo(1,c);for(;r.isEven();)r.rShiftTo(1,r),t?((!a.isEven()||!s.isEven())&&(a.addTo(this,a),s.subTo(e,s)),a.rShiftTo(1,a)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);i.compareTo(r)>=0?(i.subTo(r,i),t&&n.subTo(a,n),c.subTo(s,c)):(r.subTo(i,r),t&&a.subTo(n,a),s.subTo(c,s))}if(r.compareTo(Z.ONE)!=0)return Z.ZERO;if(s.compareTo(e)>=0)return s.subtract(e);if(s.signum()<0)s.addTo(e,s);else return s;return s.signum()<0?s.add(e):s}var ut=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],Go=(1<<26)/ut[ut.length-1];function jo(e){var t,i=this.abs();if(i.t==1&&i.data[0]<=ut[ut.length-1]){for(t=0;t<ut.length;++t)if(i.data[0]==ut[t])return!0;return!1}if(i.isEven())return!1;for(t=1;t<ut.length;){for(var r=ut[t],n=t+1;n<ut.length&&r<Go;)r*=ut[n++];for(r=i.modInt(r);t<n;)if(r%ut[t++]==0)return!1}return i.millerRabin(e)}function Qo(e){var t=this.subtract(Z.ONE),i=t.getLowestSetBit();if(i<=0)return!1;for(var r=t.shiftRight(i),n=Yo(),c,a=0;a<e;++a){do c=new Z(this.bitLength(),n);while(c.compareTo(Z.ONE)<=0||c.compareTo(t)>=0);var s=c.modPow(r,this);if(s.compareTo(Z.ONE)!=0&&s.compareTo(t)!=0){for(var l=1;l++<i&&s.compareTo(t)!=0;)if(s=s.modPowInt(2,this),s.compareTo(Z.ONE)==0)return!1;if(s.compareTo(t)!=0)return!1}}return!0}function Yo(){return{nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(Math.random()*256)}}}Z.prototype.chunkSize=Ya,Z.prototype.toRadix=Za,Z.prototype.fromRadix=Ja,Z.prototype.fromNumber=eo,Z.prototype.bitwiseTo=no,Z.prototype.changeBit=Co,Z.prototype.addTo=xo,Z.prototype.dMultiply=ko,Z.prototype.dAddOffset=Ro,Z.prototype.multiplyLowerTo=Oo,Z.prototype.multiplyUpperTo=Mo,Z.prototype.modInt=$o,Z.prototype.millerRabin=Qo,Z.prototype.clone=qa,Z.prototype.intValue=Ga,Z.prototype.byteValue=ja,Z.prototype.shortValue=Qa,Z.prototype.signum=Xa,Z.prototype.toByteArray=to,Z.prototype.equals=ro,Z.prototype.min=io,Z.prototype.max=so,Z.prototype.and=oo,Z.prototype.or=lo,Z.prototype.xor=co,Z.prototype.andNot=ho,Z.prototype.not=uo,Z.prototype.shiftLeft=fo,Z.prototype.shiftRight=po,Z.prototype.getLowestSetBit=go,Z.prototype.bitCount=yo,Z.prototype.testBit=mo,Z.prototype.setBit=So,Z.prototype.clearBit=Eo,Z.prototype.flipBit=bo,Z.prototype.add=wo,Z.prototype.subtract=To,Z.prototype.multiply=Ao,Z.prototype.divide=Bo,Z.prototype.remainder=Io,Z.prototype.divideAndRemainder=Lo,Z.prototype.modPow=Wo,Z.prototype.modInverse=qo,Z.prototype.pow=No,Z.prototype.gcd=zo,Z.prototype.isProbablePrime=jo;var _t=_e,Ls=_t.sha1=_t.sha1||{};_t.md.sha1=_t.md.algorithms.sha1=Ls,Ls.create=function(){ks||Xo();var e=null,t=_t.util.createBuffer(),i=new Array(80),r={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return r.start=function(){r.messageLength=0,r.fullMessageLength=r.messageLength64=[];for(var n=r.messageLengthSize/4,c=0;c<n;++c)r.fullMessageLength.push(0);return t=_t.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},r},r.start(),r.update=function(n,c){c==="utf8"&&(n=_t.util.encodeUtf8(n));var a=n.length;r.messageLength+=a,a=[a/4294967296>>>0,a>>>0];for(var s=r.fullMessageLength.length-1;s>=0;--s)r.fullMessageLength[s]+=a[1],a[1]=a[0]+(r.fullMessageLength[s]/4294967296>>>0),r.fullMessageLength[s]=r.fullMessageLength[s]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(n),Rs(e,i,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=_t.util.createBuffer();n.putBytes(t.bytes());var c=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,a=c&r.blockLength-1;n.putBytes(Si.substr(0,r.blockLength-a));for(var s,l,o=r.fullMessageLength[0]*8,f=0;f<r.fullMessageLength.length-1;++f)s=r.fullMessageLength[f+1]*8,l=s/4294967296>>>0,o+=l,n.putInt32(o>>>0),o=s>>>0;n.putInt32(o);var u={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};Rs(u,i,n);var g=_t.util.createBuffer();return g.putInt32(u.h0),g.putInt32(u.h1),g.putInt32(u.h2),g.putInt32(u.h3),g.putInt32(u.h4),g},r};var Si=null,ks=!1;function Xo(){Si=String.fromCharCode(128),Si+=_t.util.fillString(String.fromCharCode(0),64),ks=!0}function Rs(e,t,i){for(var r,n,c,a,s,l,o,f,u=i.length();u>=64;){for(n=e.h0,c=e.h1,a=e.h2,s=e.h3,l=e.h4,f=0;f<16;++f)r=i.getInt32(),t[f]=r,o=s^c&(a^s),r=(n<<5|n>>>27)+o+l+1518500249+r,l=s,s=a,a=(c<<30|c>>>2)>>>0,c=n,n=r;for(;f<20;++f)r=t[f-3]^t[f-8]^t[f-14]^t[f-16],r=r<<1|r>>>31,t[f]=r,o=s^c&(a^s),r=(n<<5|n>>>27)+o+l+1518500249+r,l=s,s=a,a=(c<<30|c>>>2)>>>0,c=n,n=r;for(;f<32;++f)r=t[f-3]^t[f-8]^t[f-14]^t[f-16],r=r<<1|r>>>31,t[f]=r,o=c^a^s,r=(n<<5|n>>>27)+o+l+1859775393+r,l=s,s=a,a=(c<<30|c>>>2)>>>0,c=n,n=r;for(;f<40;++f)r=t[f-6]^t[f-16]^t[f-28]^t[f-32],r=r<<2|r>>>30,t[f]=r,o=c^a^s,r=(n<<5|n>>>27)+o+l+1859775393+r,l=s,s=a,a=(c<<30|c>>>2)>>>0,c=n,n=r;for(;f<60;++f)r=t[f-6]^t[f-16]^t[f-28]^t[f-32],r=r<<2|r>>>30,t[f]=r,o=c&a|s&(c^a),r=(n<<5|n>>>27)+o+l+2400959708+r,l=s,s=a,a=(c<<30|c>>>2)>>>0,c=n,n=r;for(;f<80;++f)r=t[f-6]^t[f-16]^t[f-28]^t[f-32],r=r<<2|r>>>30,t[f]=r,o=c^a^s,r=(n<<5|n>>>27)+o+l+3395469782+r,l=s,s=a,a=(c<<30|c>>>2)>>>0,c=n,n=r;e.h0=e.h0+n|0,e.h1=e.h1+c|0,e.h2=e.h2+a|0,e.h3=e.h3+s|0,e.h4=e.h4+l|0,u-=64}}var yt=_e,Ds=yt.pkcs1=yt.pkcs1||{};Ds.encode_rsa_oaep=function(e,t,i){var r,n,c,a;typeof i=="string"?(r=i,n=arguments[3]||void 0,c=arguments[4]||void 0):i&&(r=i.label||void 0,n=i.seed||void 0,c=i.md||void 0,i.mgf1&&i.mgf1.md&&(a=i.mgf1.md)),c?c.start():c=yt.md.sha1.create(),a||(a=c);var s=Math.ceil(e.n.bitLength()/8),l=s-2*c.digestLength-2;if(t.length>l){var o=new Error("RSAES-OAEP input message length is too long.");throw o.length=t.length,o.maxLength=l,o}r||(r=""),c.update(r,"raw");for(var f=c.digest(),u="",g=l-t.length,_=0;_<g;_++)u+="\0";var y=f.getBytes()+u+""+t;if(!n)n=yt.random.getBytes(c.digestLength);else if(n.length!==c.digestLength){var o=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw o.seedLength=n.length,o.digestLength=c.digestLength,o}var m=Vr(n,s-c.digestLength-1,a),h=yt.util.xorBytes(y,m,y.length),d=Vr(h,c.digestLength,a),p=yt.util.xorBytes(n,d,n.length);return"\0"+p+h},Ds.decode_rsa_oaep=function(e,t,i){var r,n,c;typeof i=="string"?(r=i,n=arguments[3]||void 0):i&&(r=i.label||void 0,n=i.md||void 0,i.mgf1&&i.mgf1.md&&(c=i.mgf1.md));var a=Math.ceil(e.n.bitLength()/8);if(t.length!==a){var h=new Error("RSAES-OAEP encoded message length is invalid.");throw h.length=t.length,h.expectedLength=a,h}if(n===void 0?n=yt.md.sha1.create():n.start(),c||(c=n),a<2*n.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");r||(r=""),n.update(r,"raw");for(var s=n.digest().getBytes(),l=t.charAt(0),o=t.substring(1,n.digestLength+1),f=t.substring(1+n.digestLength),u=Vr(f,n.digestLength,c),g=yt.util.xorBytes(o,u,o.length),_=Vr(g,a-n.digestLength-1,c),y=yt.util.xorBytes(f,_,f.length),m=y.substring(0,n.digestLength),h=l!=="\0",d=0;d<n.digestLength;++d)h|=s.charAt(d)!==m.charAt(d);for(var p=1,v=n.digestLength,C=n.digestLength;C<y.length;C++){var S=y.charCodeAt(C),b=S&1^1,w=p?65534:0;h|=S&w,p=p&b,v+=p}if(h||y.charCodeAt(v)!==1)throw new Error("Invalid RSAES-OAEP padding.");return y.substring(v+1)};function Vr(e,t,i){i||(i=yt.md.sha1.create());for(var r="",n=Math.ceil(t/i.digestLength),c=0;c<n;++c){var a=String.fromCharCode(c>>24&255,c>>16&255,c>>8&255,c&255);i.start(),i.update(e+a),r+=i.digest().getBytes()}return r.substring(0,t)}var Lt=_e;(function(){if(Lt.prime){Lt.prime;return}var e=Lt.prime=Lt.prime||{},t=Lt.jsbn.BigInteger,i=[6,4,2,4,2,4,6,2],r=new t(null);r.fromInt(30);var n=function(u,g){return u|g};e.generateProbablePrime=function(u,g,_){typeof g=="function"&&(_=g,g={}),g=g||{};var y=g.algorithm||"PRIMEINC";typeof y=="string"&&(y={name:y}),y.options=y.options||{};var m=g.prng||Lt.random,h={nextBytes:function(d){for(var p=m.getBytesSync(d.length),v=0;v<d.length;++v)d[v]=p.charCodeAt(v)}};if(y.name==="PRIMEINC")return c(u,h,y.options,_);throw new Error("Invalid prime generation algorithm: "+y.name)};function c(u,g,_,y){return"workers"in _?l(u,g,_,y):a(u,g,_,y)}function a(u,g,_,y){var m=o(u,g),h=0,d=f(m.bitLength());"millerRabinTests"in _&&(d=_.millerRabinTests);var p=10;"maxBlockTime"in _&&(p=_.maxBlockTime),s(m,u,g,h,d,p,y)}function s(u,g,_,y,m,h,d){var p=+new Date;do{if(u.bitLength()>g&&(u=o(g,_)),u.isProbablePrime(m))return d(null,u);u.dAddOffset(i[y++%8],0)}while(h<0||+new Date-p<h);Lt.util.setImmediate(function(){s(u,g,_,y,m,h,d)})}function l(u,g,_,y){if(typeof Worker=="undefined")return a(u,g,_,y);var m=o(u,g),h=_.workers,d=_.workLoad||100,p=d*30/8,v=_.workerScript||"forge/prime.worker.js";if(h===-1)return Lt.util.estimateCores(function(S,b){S&&(b=2),h=b-1,C()});C();function C(){h=Math.max(1,h);for(var S=[],b=0;b<h;++b)S[b]=new Worker(v);for(var b=0;b<h;++b)S[b].addEventListener("message",E);var w=!1;function E(x){if(!w){var k=x.data;if(k.found){for(var D=0;D<S.length;++D)S[D].terminate();return w=!0,y(null,new t(k.prime,16))}m.bitLength()>u&&(m=o(u,g));var R=m.toString(16);x.target.postMessage({hex:R,workLoad:d}),m.dAddOffset(p,0)}}}}function o(u,g){var _=new t(u,g),y=u-1;return _.testBit(y)||_.bitwiseTo(t.ONE.shiftLeft(y),n,_),_.dAddOffset(31-_.mod(r).byteValue(),0),_}function f(u){return u<=100?27:u<=150?18:u<=200?15:u<=250?12:u<=300?9:u<=350?8:u<=400?7:u<=500?6:u<=600?5:u<=800?4:u<=1250?3:2}})();var he=_e;if(typeof Te=="undefined")var Te=he.jsbn.BigInteger;var Ei=he.util.isNodejs?vi:null,K=he.asn1,nt=he.util;he.pki=he.pki||{},he.pki.rsa=he.rsa=he.rsa||{};var ve=he.pki,Zo=[6,4,2,4,2,4,6,2],Jo={name:"PrivateKeyInfo",tagClass:K.Class.UNIVERSAL,type:K.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:K.Class.UNIVERSAL,type:K.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:K.Class.UNIVERSAL,type:K.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:K.Class.UNIVERSAL,type:K.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:K.Class.UNIVERSAL,type:K.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},el={name:"RSAPrivateKey",tagClass:K.Class.UNIVERSAL,type:K.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:K.Class.UNIVERSAL,type:K.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:K.Class.UNIVERSAL,type:K.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:K.Class.UNIVERSAL,type:K.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:K.Class.UNIVERSAL,type:K.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:K.Class.UNIVERSAL,type:K.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:K.Class.UNIVERSAL,type:K.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:K.Class.UNIVERSAL,type:K.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:K.Class.UNIVERSAL,type:K.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:K.Class.UNIVERSAL,type:K.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},tl={name:"RSAPublicKey",tagClass:K.Class.UNIVERSAL,type:K.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:K.Class.UNIVERSAL,type:K.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:K.Class.UNIVERSAL,type:K.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},rl=he.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:K.Class.UNIVERSAL,type:K.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:K.Class.UNIVERSAL,type:K.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:K.Class.UNIVERSAL,type:K.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:K.Class.UNIVERSAL,type:K.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:K.Class.UNIVERSAL,type:K.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},il={name:"DigestInfo",tagClass:K.Class.UNIVERSAL,type:K.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:K.Class.UNIVERSAL,type:K.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:K.Class.UNIVERSAL,type:K.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:K.Class.UNIVERSAL,type:K.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:K.Class.UNIVERSAL,type:K.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},sl=function(e){var t;if(e.algorithm in ve.oids)t=ve.oids[e.algorithm];else{var i=new Error("Unknown message digest algorithm.");throw i.algorithm=e.algorithm,i}var r=K.oidToDer(t).getBytes(),n=K.create(K.Class.UNIVERSAL,K.Type.SEQUENCE,!0,[]),c=K.create(K.Class.UNIVERSAL,K.Type.SEQUENCE,!0,[]);c.value.push(K.create(K.Class.UNIVERSAL,K.Type.OID,!1,r)),c.value.push(K.create(K.Class.UNIVERSAL,K.Type.NULL,!1,""));var a=K.create(K.Class.UNIVERSAL,K.Type.OCTETSTRING,!1,e.digest().getBytes());return n.value.push(c),n.value.push(a),K.toDer(n).getBytes()},Ps=function(e,t,i){if(i)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);t.dP||(t.dP=t.d.mod(t.p.subtract(Te.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(Te.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));var r;do r=new Te(he.util.bytesToHex(he.random.getBytes(t.n.bitLength()/8)),16);while(r.compareTo(t.n)>=0||!r.gcd(t.n).equals(Te.ONE));e=e.multiply(r.modPow(t.e,t.n)).mod(t.n);for(var n=e.mod(t.p).modPow(t.dP,t.p),c=e.mod(t.q).modPow(t.dQ,t.q);n.compareTo(c)<0;)n=n.add(t.p);var a=n.subtract(c).multiply(t.qInv).mod(t.p).multiply(t.q).add(c);return a=a.multiply(r.modInverse(t.n)).mod(t.n),a};ve.rsa.encrypt=function(e,t,i){var r=i,n,c=Math.ceil(t.n.bitLength()/8);i!==!1&&i!==!0?(r=i===2,n=Ns(e,t,i)):(n=he.util.createBuffer(),n.putBytes(e));for(var a=new Te(n.toHex(),16),s=Ps(a,t,r),l=s.toString(16),o=he.util.createBuffer(),f=c-Math.ceil(l.length/2);f>0;)o.putByte(0),--f;return o.putBytes(he.util.hexToBytes(l)),o.getBytes()},ve.rsa.decrypt=function(e,t,i,r){var n=Math.ceil(t.n.bitLength()/8);if(e.length!==n){var c=new Error("Encrypted message length is invalid.");throw c.length=e.length,c.expected=n,c}var a=new Te(he.util.createBuffer(e).toHex(),16);if(a.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var s=Ps(a,t,i),l=s.toString(16),o=he.util.createBuffer(),f=n-Math.ceil(l.length/2);f>0;)o.putByte(0),--f;return o.putBytes(he.util.hexToBytes(l)),r!==!1?Kr(o.getBytes(),t,i):o.getBytes()},ve.rsa.createKeyPairGenerationState=function(e,t,i){typeof e=="string"&&(e=parseInt(e,10)),e=e||2048,i=i||{};var r=i.prng||he.random,n={nextBytes:function(s){for(var l=r.getBytesSync(s.length),o=0;o<s.length;++o)s[o]=l.charCodeAt(o)}},c=i.algorithm||"PRIMEINC",a;if(c==="PRIMEINC")a={algorithm:c,state:0,bits:e,rng:n,eInt:t||65537,e:new Te(null),p:null,q:null,qBits:e>>1,pBits:e-(e>>1),pqState:0,num:null,keys:null},a.e.fromInt(a.eInt);else throw new Error("Invalid key generation algorithm: "+c);return a},ve.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var i=new Te(null);i.fromInt(30);for(var r=0,n=function(u,g){return u|g},c=+new Date,a,s=0;e.keys===null&&(t<=0||s<t);){if(e.state===0){var l=e.p===null?e.pBits:e.qBits,o=l-1;e.pqState===0?(e.num=new Te(l,e.rng),e.num.testBit(o)||e.num.bitwiseTo(Te.ONE.shiftLeft(o),n,e.num),e.num.dAddOffset(31-e.num.mod(i).byteValue(),0),r=0,++e.pqState):e.pqState===1?e.num.bitLength()>l?e.pqState=0:e.num.isProbablePrime(al(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(Zo[r++%8],0):e.pqState===2?e.pqState=e.num.subtract(Te.ONE).gcd(e.e).compareTo(Te.ONE)===0?3:0:e.pqState===3&&(e.pqState=0,e.p===null?e.p=e.num:e.q=e.num,e.p!==null&&e.q!==null&&++e.state,e.num=null)}else if(e.state===1)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(e.state===2)e.p1=e.p.subtract(Te.ONE),e.q1=e.q.subtract(Te.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(e.state===3)e.phi.gcd(e.e).compareTo(Te.ONE)===0?++e.state:(e.p=null,e.q=null,e.state=0);else if(e.state===4)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(e.state===5){var f=e.e.modInverse(e.phi);e.keys={privateKey:ve.rsa.setPrivateKey(e.n,e.e,f,e.p,e.q,f.mod(e.p1),f.mod(e.q1),e.q.modInverse(e.p)),publicKey:ve.rsa.setPublicKey(e.n,e.e)}}a=+new Date,s+=a-c,c=a}return e.keys!==null},ve.rsa.generateKeyPair=function(e,t,i,r){if(arguments.length===1?typeof e=="object"?(i=e,e=void 0):typeof e=="function"&&(r=e,e=void 0):arguments.length===2?typeof e=="number"?typeof t=="function"?(r=t,t=void 0):typeof t!="number"&&(i=t,t=void 0):(i=e,r=t,e=void 0,t=void 0):arguments.length===3&&(typeof t=="number"?typeof i=="function"&&(r=i,i=void 0):(r=i,i=t,t=void 0)),i=i||{},e===void 0&&(e=i.bits||2048),t===void 0&&(t=i.e||65537),!he.options.usePureJavaScript&&!i.prng&&e>=256&&e<=16384&&(t===65537||t===3)){if(r){if(Os("generateKeyPair"))return Ei.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(s,l,o){if(s)return r(s);r(null,{privateKey:ve.privateKeyFromPem(o),publicKey:ve.publicKeyFromPem(l)})});if(Ms("generateKey")&&Ms("exportKey"))return nt.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:Fs(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(s){return nt.globalScope.crypto.subtle.exportKey("pkcs8",s.privateKey)}).then(void 0,function(s){r(s)}).then(function(s){if(s){var l=ve.privateKeyFromAsn1(K.fromDer(he.util.createBuffer(s)));r(null,{privateKey:l,publicKey:ve.setRsaPublicKey(l.n,l.e)})}});if(Us("generateKey")&&Us("exportKey")){var n=nt.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:Fs(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);n.oncomplete=function(s){var l=s.target.result,o=nt.globalScope.msCrypto.subtle.exportKey("pkcs8",l.privateKey);o.oncomplete=function(f){var u=f.target.result,g=ve.privateKeyFromAsn1(K.fromDer(he.util.createBuffer(u)));r(null,{privateKey:g,publicKey:ve.setRsaPublicKey(g.n,g.e)})},o.onerror=function(f){r(f)}},n.onerror=function(s){r(s)};return}}else if(Os("generateKeyPairSync")){var c=Ei.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:ve.privateKeyFromPem(c.privateKey),publicKey:ve.publicKeyFromPem(c.publicKey)}}}var a=ve.rsa.createKeyPairGenerationState(e,t,i);if(!r)return ve.rsa.stepKeyPairGenerationState(a,0),a.keys;nl(a,i,r)},ve.setRsaPublicKey=ve.rsa.setPublicKey=function(e,t){var i={n:e,e:t};return i.encrypt=function(r,n,c){if(typeof n=="string"?n=n.toUpperCase():n===void 0&&(n="RSAES-PKCS1-V1_5"),n==="RSAES-PKCS1-V1_5")n={encode:function(s,l,o){return Ns(s,l,2).getBytes()}};else if(n==="RSA-OAEP"||n==="RSAES-OAEP")n={encode:function(s,l){return he.pkcs1.encode_rsa_oaep(l,s,c)}};else if(["RAW","NONE","NULL",null].indexOf(n)!==-1)n={encode:function(s){return s}};else if(typeof n=="string")throw new Error('Unsupported encryption scheme: "'+n+'".');var a=n.encode(r,i,!0);return ve.rsa.encrypt(a,i,!0)},i.verify=function(r,n,c,a){typeof c=="string"?c=c.toUpperCase():c===void 0&&(c="RSASSA-PKCS1-V1_5"),a===void 0&&(a={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in a||(a._parseAllDigestBytes=!0),c==="RSASSA-PKCS1-V1_5"?c={verify:function(l,o){o=Kr(o,i,!0);var f=K.fromDer(o,{parseAllBytes:a._parseAllDigestBytes}),u={},g=[];if(!K.validate(f,il,u,g)){var _=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw _.errors=g,_}var y=K.derToOid(u.algorithmIdentifier);if(!(y===he.oids.md2||y===he.oids.md5||y===he.oids.sha1||y===he.oids.sha224||y===he.oids.sha256||y===he.oids.sha384||y===he.oids.sha512||y===he.oids["sha512-224"]||y===he.oids["sha512-256"])){var _=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw _.oid=y,_}if((y===he.oids.md2||y===he.oids.md5)&&!("parameters"in u))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifier NULL parameters.");return l===u.digest}}:(c==="NONE"||c==="NULL"||c===null)&&(c={verify:function(l,o){return o=Kr(o,i,!0),l===o}});var s=ve.rsa.decrypt(n,i,!0,!1);return c.verify(r,s,i.n.bitLength())},i},ve.setRsaPrivateKey=ve.rsa.setPrivateKey=function(e,t,i,r,n,c,a,s){var l={n:e,e:t,d:i,p:r,q:n,dP:c,dQ:a,qInv:s};return l.decrypt=function(o,f,u){typeof f=="string"?f=f.toUpperCase():f===void 0&&(f="RSAES-PKCS1-V1_5");var g=ve.rsa.decrypt(o,l,!1,!1);if(f==="RSAES-PKCS1-V1_5")f={decode:Kr};else if(f==="RSA-OAEP"||f==="RSAES-OAEP")f={decode:function(_,y){return he.pkcs1.decode_rsa_oaep(y,_,u)}};else if(["RAW","NONE","NULL",null].indexOf(f)!==-1)f={decode:function(_){return _}};else throw new Error('Unsupported encryption scheme: "'+f+'".');return f.decode(g,l,!1)},l.sign=function(o,f){var u=!1;typeof f=="string"&&(f=f.toUpperCase()),f===void 0||f==="RSASSA-PKCS1-V1_5"?(f={encode:sl},u=1):(f==="NONE"||f==="NULL"||f===null)&&(f={encode:function(){return o}},u=1);var g=f.encode(o,l.n.bitLength());return ve.rsa.encrypt(g,l,u)},l},ve.wrapRsaPrivateKey=function(e){return K.create(K.Class.UNIVERSAL,K.Type.SEQUENCE,!0,[K.create(K.Class.UNIVERSAL,K.Type.INTEGER,!1,K.integerToDer(0).getBytes()),K.create(K.Class.UNIVERSAL,K.Type.SEQUENCE,!0,[K.create(K.Class.UNIVERSAL,K.Type.OID,!1,K.oidToDer(ve.oids.rsaEncryption).getBytes()),K.create(K.Class.UNIVERSAL,K.Type.NULL,!1,"")]),K.create(K.Class.UNIVERSAL,K.Type.OCTETSTRING,!1,K.toDer(e).getBytes())])},ve.privateKeyFromAsn1=function(e){var t={},i=[];if(K.validate(e,Jo,t,i)&&(e=K.fromDer(he.util.createBuffer(t.privateKey))),t={},i=[],!K.validate(e,el,t,i)){var r=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw r.errors=i,r}var n,c,a,s,l,o,f,u;return n=he.util.createBuffer(t.privateKeyModulus).toHex(),c=he.util.createBuffer(t.privateKeyPublicExponent).toHex(),a=he.util.createBuffer(t.privateKeyPrivateExponent).toHex(),s=he.util.createBuffer(t.privateKeyPrime1).toHex(),l=he.util.createBuffer(t.privateKeyPrime2).toHex(),o=he.util.createBuffer(t.privateKeyExponent1).toHex(),f=he.util.createBuffer(t.privateKeyExponent2).toHex(),u=he.util.createBuffer(t.privateKeyCoefficient).toHex(),ve.setRsaPrivateKey(new Te(n,16),new Te(c,16),new Te(a,16),new Te(s,16),new Te(l,16),new Te(o,16),new Te(f,16),new Te(u,16))},ve.privateKeyToAsn1=ve.privateKeyToRSAPrivateKey=function(e){return K.create(K.Class.UNIVERSAL,K.Type.SEQUENCE,!0,[K.create(K.Class.UNIVERSAL,K.Type.INTEGER,!1,K.integerToDer(0).getBytes()),K.create(K.Class.UNIVERSAL,K.Type.INTEGER,!1,mt(e.n)),K.create(K.Class.UNIVERSAL,K.Type.INTEGER,!1,mt(e.e)),K.create(K.Class.UNIVERSAL,K.Type.INTEGER,!1,mt(e.d)),K.create(K.Class.UNIVERSAL,K.Type.INTEGER,!1,mt(e.p)),K.create(K.Class.UNIVERSAL,K.Type.INTEGER,!1,mt(e.q)),K.create(K.Class.UNIVERSAL,K.Type.INTEGER,!1,mt(e.dP)),K.create(K.Class.UNIVERSAL,K.Type.INTEGER,!1,mt(e.dQ)),K.create(K.Class.UNIVERSAL,K.Type.INTEGER,!1,mt(e.qInv))])},ve.publicKeyFromAsn1=function(e){var t={},i=[];if(K.validate(e,rl,t,i)){var r=K.derToOid(t.publicKeyOid);if(r!==ve.oids.rsaEncryption){var n=new Error("Cannot read public key. Unknown OID.");throw n.oid=r,n}e=t.rsaPublicKey}if(i=[],!K.validate(e,tl,t,i)){var n=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw n.errors=i,n}var c=he.util.createBuffer(t.publicKeyModulus).toHex(),a=he.util.createBuffer(t.publicKeyExponent).toHex();return ve.setRsaPublicKey(new Te(c,16),new Te(a,16))},ve.publicKeyToAsn1=ve.publicKeyToSubjectPublicKeyInfo=function(e){return K.create(K.Class.UNIVERSAL,K.Type.SEQUENCE,!0,[K.create(K.Class.UNIVERSAL,K.Type.SEQUENCE,!0,[K.create(K.Class.UNIVERSAL,K.Type.OID,!1,K.oidToDer(ve.oids.rsaEncryption).getBytes()),K.create(K.Class.UNIVERSAL,K.Type.NULL,!1,"")]),K.create(K.Class.UNIVERSAL,K.Type.BITSTRING,!1,[ve.publicKeyToRSAPublicKey(e)])])},ve.publicKeyToRSAPublicKey=function(e){return K.create(K.Class.UNIVERSAL,K.Type.SEQUENCE,!0,[K.create(K.Class.UNIVERSAL,K.Type.INTEGER,!1,mt(e.n)),K.create(K.Class.UNIVERSAL,K.Type.INTEGER,!1,mt(e.e))])};function Ns(e,t,i){var r=he.util.createBuffer(),n=Math.ceil(t.n.bitLength()/8);if(e.length>n-11){var c=new Error("Message is too long for PKCS#1 v1.5 padding.");throw c.length=e.length,c.max=n-11,c}r.putByte(0),r.putByte(i);var a=n-3-e.length,s;if(i===0||i===1){s=i===0?0:255;for(var l=0;l<a;++l)r.putByte(s)}else for(;a>0;){for(var o=0,f=he.random.getBytes(a),l=0;l<a;++l)s=f.charCodeAt(l),s===0?++o:r.putByte(s);a=o}return r.putByte(0),r.putBytes(e),r}function Kr(e,t,i,r){var n=Math.ceil(t.n.bitLength()/8),c=he.util.createBuffer(e),a=c.getByte(),s=c.getByte();if(a!==0||i&&s!==0&&s!==1||!i&&s!=2||i&&s===0&&typeof r=="undefined")throw new Error("Encryption block is invalid.");var l=0;if(s===0){l=n-3-r;for(var o=0;o<l;++o)if(c.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(s===1)for(l=0;c.length()>1;){if(c.getByte()!==255){--c.read;break}++l}else if(s===2)for(l=0;c.length()>1;){if(c.getByte()===0){--c.read;break}++l}var f=c.getByte();if(f!==0||l!==n-3-c.length())throw new Error("Encryption block is invalid.");return c.getBytes()}function nl(e,t,i){typeof t=="function"&&(i=t,t={}),t=t||{};var r={algorithm:{name:t.algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};"prng"in t&&(r.prng=t.prng),n();function n(){c(e.pBits,function(s,l){if(s)return i(s);if(e.p=l,e.q!==null)return a(s,e.q);c(e.qBits,a)})}function c(s,l){he.prime.generateProbablePrime(s,r,l)}function a(s,l){if(s)return i(s);if(e.q=l,e.p.compareTo(e.q)<0){var o=e.p;e.p=e.q,e.q=o}if(e.p.subtract(Te.ONE).gcd(e.e).compareTo(Te.ONE)!==0){e.p=null,n();return}if(e.q.subtract(Te.ONE).gcd(e.e).compareTo(Te.ONE)!==0){e.q=null,c(e.qBits,a);return}if(e.p1=e.p.subtract(Te.ONE),e.q1=e.q.subtract(Te.ONE),e.phi=e.p1.multiply(e.q1),e.phi.gcd(e.e).compareTo(Te.ONE)!==0){e.p=e.q=null,n();return}if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits){e.q=null,c(e.qBits,a);return}var f=e.e.modInverse(e.phi);e.keys={privateKey:ve.rsa.setPrivateKey(e.n,e.e,f,e.p,e.q,f.mod(e.p1),f.mod(e.q1),e.q.modInverse(e.p)),publicKey:ve.rsa.setPublicKey(e.n,e.e)},i(null,e.keys)}}function mt(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var i=he.util.hexToBytes(t);return i.length>1&&(i.charCodeAt(0)===0&&!(i.charCodeAt(1)&128)||i.charCodeAt(0)===255&&(i.charCodeAt(1)&128)===128)?i.substr(1):i}function al(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function Os(e){return he.util.isNodejs&&typeof Ei[e]=="function"}function Ms(e){return typeof nt.globalScope!="undefined"&&typeof nt.globalScope.crypto=="object"&&typeof nt.globalScope.crypto.subtle=="object"&&typeof nt.globalScope.crypto.subtle[e]=="function"}function Us(e){return typeof nt.globalScope!="undefined"&&typeof nt.globalScope.msCrypto=="object"&&typeof nt.globalScope.msCrypto.subtle=="object"&&typeof nt.globalScope.msCrypto.subtle[e]=="function"}function Fs(e){for(var t=he.util.hexToBytes(e.toString(16)),i=new Uint8Array(t.length),r=0;r<t.length;++r)i[r]=t.charCodeAt(r);return i}var le=_e;if(typeof ol=="undefined")var ol=le.jsbn.BigInteger;var Y=le.asn1,ge=le.pki=le.pki||{};ge.pbe=le.pbe=le.pbe||{};var Kt=ge.oids,ll={name:"EncryptedPrivateKeyInfo",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Y.Class.UNIVERSAL,type:Y.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:Y.Class.UNIVERSAL,type:Y.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},cl={name:"PBES2Algorithms",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:Y.Class.UNIVERSAL,type:Y.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:Y.Class.UNIVERSAL,type:Y.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:Y.Class.UNIVERSAL,type:Y.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:Y.Class.UNIVERSAL,type:Y.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:Y.Class.UNIVERSAL,type:Y.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:Y.Class.UNIVERSAL,type:Y.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:Y.Class.UNIVERSAL,type:Y.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},hl={name:"pkcs-12PbeParams",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:Y.Class.UNIVERSAL,type:Y.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:Y.Class.UNIVERSAL,type:Y.Type.INTEGER,constructed:!1,capture:"iterations"}]};ge.encryptPrivateKeyInfo=function(e,t,i){i=i||{},i.saltSize=i.saltSize||8,i.count=i.count||2048,i.algorithm=i.algorithm||"aes128",i.prfAlgorithm=i.prfAlgorithm||"sha1";var r=le.random.getBytesSync(i.saltSize),n=i.count,c=Y.integerToDer(n),a,s,l;if(i.algorithm.indexOf("aes")===0||i.algorithm==="des"){var o,f,u;switch(i.algorithm){case"aes128":a=16,o=16,f=Kt["aes128-CBC"],u=le.aes.createEncryptionCipher;break;case"aes192":a=24,o=16,f=Kt["aes192-CBC"],u=le.aes.createEncryptionCipher;break;case"aes256":a=32,o=16,f=Kt["aes256-CBC"],u=le.aes.createEncryptionCipher;break;case"des":a=8,o=8,f=Kt.desCBC,u=le.des.createEncryptionCipher;break;default:var g=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw g.algorithm=i.algorithm,g}var _="hmacWith"+i.prfAlgorithm.toUpperCase(),y=Ks(_),m=le.pkcs5.pbkdf2(t,r,n,a,y),h=le.random.getBytesSync(o),d=u(m);d.start(h),d.update(Y.toDer(e)),d.finish(),l=d.output.getBytes();var p=ul(r,c,a,_);s=Y.create(Y.Class.UNIVERSAL,Y.Type.SEQUENCE,!0,[Y.create(Y.Class.UNIVERSAL,Y.Type.OID,!1,Y.oidToDer(Kt.pkcs5PBES2).getBytes()),Y.create(Y.Class.UNIVERSAL,Y.Type.SEQUENCE,!0,[Y.create(Y.Class.UNIVERSAL,Y.Type.SEQUENCE,!0,[Y.create(Y.Class.UNIVERSAL,Y.Type.OID,!1,Y.oidToDer(Kt.pkcs5PBKDF2).getBytes()),p]),Y.create(Y.Class.UNIVERSAL,Y.Type.SEQUENCE,!0,[Y.create(Y.Class.UNIVERSAL,Y.Type.OID,!1,Y.oidToDer(f).getBytes()),Y.create(Y.Class.UNIVERSAL,Y.Type.OCTETSTRING,!1,h)])])])}else if(i.algorithm==="3des"){a=24;var v=new le.util.ByteBuffer(r),m=ge.pbe.generatePkcs12Key(t,v,1,n,a),h=ge.pbe.generatePkcs12Key(t,v,2,n,a),d=le.des.createEncryptionCipher(m);d.start(h),d.update(Y.toDer(e)),d.finish(),l=d.output.getBytes(),s=Y.create(Y.Class.UNIVERSAL,Y.Type.SEQUENCE,!0,[Y.create(Y.Class.UNIVERSAL,Y.Type.OID,!1,Y.oidToDer(Kt["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),Y.create(Y.Class.UNIVERSAL,Y.Type.SEQUENCE,!0,[Y.create(Y.Class.UNIVERSAL,Y.Type.OCTETSTRING,!1,r),Y.create(Y.Class.UNIVERSAL,Y.Type.INTEGER,!1,c.getBytes())])])}else{var g=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw g.algorithm=i.algorithm,g}var C=Y.create(Y.Class.UNIVERSAL,Y.Type.SEQUENCE,!0,[s,Y.create(Y.Class.UNIVERSAL,Y.Type.OCTETSTRING,!1,l)]);return C},ge.decryptPrivateKeyInfo=function(e,t){var i=null,r={},n=[];if(!Y.validate(e,ll,r,n)){var c=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw c.errors=n,c}var a=Y.derToOid(r.encryptionOid),s=ge.pbe.getCipher(a,r.encryptionParams,t),l=le.util.createBuffer(r.encryptedData);return s.update(l),s.finish()&&(i=Y.fromDer(s.output)),i},ge.encryptedPrivateKeyToPem=function(e,t){var i={type:"ENCRYPTED PRIVATE KEY",body:Y.toDer(e).getBytes()};return le.pem.encode(i,{maxline:t})},ge.encryptedPrivateKeyFromPem=function(e){var t=le.pem.decode(e)[0];if(t.type!=="ENCRYPTED PRIVATE KEY"){var i=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw i.headerType=t.type,i}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return Y.fromDer(t.body)},ge.encryptRsaPrivateKey=function(e,t,i){if(i=i||{},!i.legacy){var r=ge.wrapRsaPrivateKey(ge.privateKeyToAsn1(e));return r=ge.encryptPrivateKeyInfo(r,t,i),ge.encryptedPrivateKeyToPem(r)}var n,c,a,s;switch(i.algorithm){case"aes128":n="AES-128-CBC",a=16,c=le.random.getBytesSync(16),s=le.aes.createEncryptionCipher;break;case"aes192":n="AES-192-CBC",a=24,c=le.random.getBytesSync(16),s=le.aes.createEncryptionCipher;break;case"aes256":n="AES-256-CBC",a=32,c=le.random.getBytesSync(16),s=le.aes.createEncryptionCipher;break;case"3des":n="DES-EDE3-CBC",a=24,c=le.random.getBytesSync(8),s=le.des.createEncryptionCipher;break;case"des":n="DES-CBC",a=8,c=le.random.getBytesSync(8),s=le.des.createEncryptionCipher;break;default:var l=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+i.algorithm+'".');throw l.algorithm=i.algorithm,l}var o=le.pbe.opensslDeriveBytes(t,c.substr(0,8),a),f=s(o);f.start(c),f.update(Y.toDer(ge.privateKeyToAsn1(e))),f.finish();var u={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:n,parameters:le.util.bytesToHex(c).toUpperCase()},body:f.output.getBytes()};return le.pem.encode(u)},ge.decryptRsaPrivateKey=function(e,t){var i=null,r=le.pem.decode(e)[0];if(r.type!=="ENCRYPTED PRIVATE KEY"&&r.type!=="PRIVATE KEY"&&r.type!=="RSA PRIVATE KEY"){var n=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw n.headerType=n,n}if(r.procType&&r.procType.type==="ENCRYPTED"){var c,a;switch(r.dekInfo.algorithm){case"DES-CBC":c=8,a=le.des.createDecryptionCipher;break;case"DES-EDE3-CBC":c=24,a=le.des.createDecryptionCipher;break;case"AES-128-CBC":c=16,a=le.aes.createDecryptionCipher;break;case"AES-192-CBC":c=24,a=le.aes.createDecryptionCipher;break;case"AES-256-CBC":c=32,a=le.aes.createDecryptionCipher;break;case"RC2-40-CBC":c=5,a=function(u){return le.rc2.createDecryptionCipher(u,40)};break;case"RC2-64-CBC":c=8,a=function(u){return le.rc2.createDecryptionCipher(u,64)};break;case"RC2-128-CBC":c=16,a=function(u){return le.rc2.createDecryptionCipher(u,128)};break;default:var n=new Error('Could not decrypt private key; unsupported encryption algorithm "'+r.dekInfo.algorithm+'".');throw n.algorithm=r.dekInfo.algorithm,n}var s=le.util.hexToBytes(r.dekInfo.parameters),l=le.pbe.opensslDeriveBytes(t,s.substr(0,8),c),o=a(l);if(o.start(s),o.update(le.util.createBuffer(r.body)),o.finish())i=o.output.getBytes();else return i}else i=r.body;return r.type==="ENCRYPTED PRIVATE KEY"?i=ge.decryptPrivateKeyInfo(Y.fromDer(i),t):i=Y.fromDer(i),i!==null&&(i=ge.privateKeyFromAsn1(i)),i},ge.pbe.generatePkcs12Key=function(e,t,i,r,n,c){var a,s;if(typeof c=="undefined"||c===null){if(!("sha1"in le.md))throw new Error('"sha1" hash algorithm unavailable.');c=le.md.sha1.create()}var l=c.digestLength,o=c.blockLength,f=new le.util.ByteBuffer,u=new le.util.ByteBuffer;if(e!=null){for(s=0;s<e.length;s++)u.putInt16(e.charCodeAt(s));u.putInt16(0)}var g=u.length(),_=t.length(),y=new le.util.ByteBuffer;y.fillWithByte(i,o);var m=o*Math.ceil(_/o),h=new le.util.ByteBuffer;for(s=0;s<m;s++)h.putByte(t.at(s%_));var d=o*Math.ceil(g/o),p=new le.util.ByteBuffer;for(s=0;s<d;s++)p.putByte(u.at(s%g));var v=h;v.putBuffer(p);for(var C=Math.ceil(n/l),S=1;S<=C;S++){var b=new le.util.ByteBuffer;b.putBytes(y.bytes()),b.putBytes(v.bytes());for(var w=0;w<r;w++)c.start(),c.update(b.getBytes()),b=c.digest();var E=new le.util.ByteBuffer;for(s=0;s<o;s++)E.putByte(b.at(s%l));var x=Math.ceil(_/o)+Math.ceil(g/o),k=new le.util.ByteBuffer;for(a=0;a<x;a++){var D=new le.util.ByteBuffer(v.getBytes(o)),R=511;for(s=E.length()-1;s>=0;s--)R=R>>8,R+=E.at(s)+D.at(s),D.setAt(s,R&255);k.putBuffer(D)}v=k,f.putBuffer(b)}return f.truncate(f.length()-n),f},ge.pbe.getCipher=function(e,t,i){switch(e){case ge.oids.pkcs5PBES2:return ge.pbe.getCipherForPBES2(e,t,i);case ge.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case ge.oids["pbewithSHAAnd40BitRC2-CBC"]:return ge.pbe.getCipherForPKCS12PBE(e,t,i);default:var r=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw r.oid=e,r.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],r}},ge.pbe.getCipherForPBES2=function(e,t,i){var r={},n=[];if(!Y.validate(t,cl,r,n)){var c=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw c.errors=n,c}if(e=Y.derToOid(r.kdfOid),e!==ge.oids.pkcs5PBKDF2){var c=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw c.oid=e,c.supportedOids=["pkcs5PBKDF2"],c}if(e=Y.derToOid(r.encOid),e!==ge.oids["aes128-CBC"]&&e!==ge.oids["aes192-CBC"]&&e!==ge.oids["aes256-CBC"]&&e!==ge.oids["des-EDE3-CBC"]&&e!==ge.oids.desCBC){var c=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw c.oid=e,c.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],c}var a=r.kdfSalt,s=le.util.createBuffer(r.kdfIterationCount);s=s.getInt(s.length()<<3);var l,o;switch(ge.oids[e]){case"aes128-CBC":l=16,o=le.aes.createDecryptionCipher;break;case"aes192-CBC":l=24,o=le.aes.createDecryptionCipher;break;case"aes256-CBC":l=32,o=le.aes.createDecryptionCipher;break;case"des-EDE3-CBC":l=24,o=le.des.createDecryptionCipher;break;case"desCBC":l=8,o=le.des.createDecryptionCipher;break}var f=Vs(r.prfOid),u=le.pkcs5.pbkdf2(i,a,s,l,f),g=r.encIv,_=o(u);return _.start(g),_},ge.pbe.getCipherForPKCS12PBE=function(e,t,i){var r={},n=[];if(!Y.validate(t,hl,r,n)){var c=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw c.errors=n,c}var a=le.util.createBuffer(r.salt),s=le.util.createBuffer(r.iterations);s=s.getInt(s.length()<<3);var l,o,f;switch(e){case ge.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:l=24,o=8,f=le.des.startDecrypting;break;case ge.oids["pbewithSHAAnd40BitRC2-CBC"]:l=5,o=8,f=function(m,h){var d=le.rc2.createDecryptionCipher(m,40);return d.start(h,null),d};break;default:var c=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw c.oid=e,c}var u=Vs(r.prfOid),g=ge.pbe.generatePkcs12Key(i,a,1,s,l,u);u.start();var _=ge.pbe.generatePkcs12Key(i,a,2,s,o,u);return f(g,_)},ge.pbe.opensslDeriveBytes=function(e,t,i,r){if(typeof r=="undefined"||r===null){if(!("md5"in le.md))throw new Error('"md5" hash algorithm unavailable.');r=le.md.md5.create()}t===null&&(t="");for(var n=[Hs(r,e+t)],c=16,a=1;c<i;++a,c+=16)n.push(Hs(r,n[a-1]+e+t));return n.join("").substr(0,i)};function Hs(e,t){return e.start().update(t).digest().getBytes()}function Vs(e){var t;if(!e)t="hmacWithSHA1";else if(t=ge.oids[Y.derToOid(e)],!t){var i=new Error("Unsupported PRF OID.");throw i.oid=e,i.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],i}return Ks(t)}function Ks(e){var t=le.md;switch(e){case"hmacWithSHA224":t=le.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var i=new Error("Unsupported PRF algorithm.");throw i.algorithm=e,i.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],i}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}function ul(e,t,i,r){var n=Y.create(Y.Class.UNIVERSAL,Y.Type.SEQUENCE,!0,[Y.create(Y.Class.UNIVERSAL,Y.Type.OCTETSTRING,!1,e),Y.create(Y.Class.UNIVERSAL,Y.Type.INTEGER,!1,t.getBytes())]);return r!=="hmacWithSHA1"&&n.value.push(Y.create(Y.Class.UNIVERSAL,Y.Type.INTEGER,!1,le.util.hexToBytes(i.toString(16))),Y.create(Y.Class.UNIVERSAL,Y.Type.SEQUENCE,!0,[Y.create(Y.Class.UNIVERSAL,Y.Type.OID,!1,Y.oidToDer(ge.oids[r]).getBytes()),Y.create(Y.Class.UNIVERSAL,Y.Type.NULL,!1,"")])),n}var Jt=_e,oe=Jt.asn1,er=Jt.pkcs7asn1=Jt.pkcs7asn1||{};Jt.pkcs7=Jt.pkcs7||{},Jt.pkcs7.asn1=er;var Ws={name:"ContentInfo",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:oe.Class.UNIVERSAL,type:oe.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:oe.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};er.contentInfoValidator=Ws;var zs={name:"EncryptedContentInfo",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:oe.Class.UNIVERSAL,type:oe.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:oe.Class.UNIVERSAL,type:oe.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:oe.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:oe.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};er.envelopedDataValidator={name:"EnvelopedData",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:oe.Class.UNIVERSAL,type:oe.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(zs)},er.encryptedDataValidator={name:"EncryptedData",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:oe.Class.UNIVERSAL,type:oe.Type.INTEGER,constructed:!1,capture:"version"}].concat(zs)};var fl={name:"SignerInfo",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:oe.Class.UNIVERSAL,type:oe.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:oe.Class.UNIVERSAL,type:oe.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:oe.Class.UNIVERSAL,type:oe.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:oe.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:oe.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:oe.Class.UNIVERSAL,type:oe.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:oe.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};er.signedDataValidator={name:"SignedData",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:oe.Class.UNIVERSAL,type:oe.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},Ws,{name:"SignedData.Certificates",tagClass:oe.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:oe.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SET,capture:"signerInfos",optional:!0,value:[fl]}]},er.recipientInfoValidator={name:"RecipientInfo",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:oe.Class.UNIVERSAL,type:oe.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:oe.Class.UNIVERSAL,type:oe.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:oe.Class.UNIVERSAL,type:oe.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:oe.Class.UNIVERSAL,type:oe.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:oe.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:oe.Class.UNIVERSAL,type:oe.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]};var Wt=_e;Wt.mgf=Wt.mgf||{};var dl=Wt.mgf.mgf1=Wt.mgf1=Wt.mgf1||{};dl.create=function(e){var t={generate:function(i,r){for(var n=new Wt.util.ByteBuffer,c=Math.ceil(r/e.digestLength),a=0;a<c;a++){var s=new Wt.util.ByteBuffer;s.putInt32(a),e.start(),e.update(i+s.getBytes()),n.putBuffer(e.digest())}return n.truncate(n.length()-r),n.getBytes()}};return t};var Wr=_e;Wr.mgf=Wr.mgf||{},Wr.mgf.mgf1=Wr.mgf1;var zt=_e,pl=zt.pss=zt.pss||{};pl.create=function(e){arguments.length===3&&(e={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var t=e.md,i=e.mgf,r=t.digestLength,n=e.salt||null;typeof n=="string"&&(n=zt.util.createBuffer(n));var c;if("saltLength"in e)c=e.saltLength;else if(n!==null)c=n.length();else throw new Error("Salt length not specified or specific salt not given.");if(n!==null&&n.length()!==c)throw new Error("Given salt length does not match length of given salt.");var a=e.prng||zt.random,s={};return s.encode=function(l,o){var f,u=o-1,g=Math.ceil(u/8),_=l.digest().getBytes();if(g<r+c+2)throw new Error("Message is too long to encrypt.");var y;n===null?y=a.getBytesSync(c):y=n.bytes();var m=new zt.util.ByteBuffer;m.fillWithByte(0,8),m.putBytes(_),m.putBytes(y),t.start(),t.update(m.getBytes());var h=t.digest().getBytes(),d=new zt.util.ByteBuffer;d.fillWithByte(0,g-c-r-2),d.putByte(1),d.putBytes(y);var p=d.getBytes(),v=g-r-1,C=i.generate(h,v),S="";for(f=0;f<v;f++)S+=String.fromCharCode(p.charCodeAt(f)^C.charCodeAt(f));var b=65280>>8*g-u&255;return S=String.fromCharCode(S.charCodeAt(0)&~b)+S.substr(1),S+h+String.fromCharCode(188)},s.verify=function(l,o,f){var u,g=f-1,_=Math.ceil(g/8);if(o=o.substr(-_),_<r+c+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(o.charCodeAt(_-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var y=_-r-1,m=o.substr(0,y),h=o.substr(y,r),d=65280>>8*_-g&255;if(m.charCodeAt(0)&d)throw new Error("Bits beyond keysize not zero as expected.");var p=i.generate(h,y),v="";for(u=0;u<y;u++)v+=String.fromCharCode(m.charCodeAt(u)^p.charCodeAt(u));v=String.fromCharCode(v.charCodeAt(0)&~d)+v.substr(1);var C=_-r-c-2;for(u=0;u<C;u++)if(v.charCodeAt(u)!==0)throw new Error("Leftmost octets not zero as expected");if(v.charCodeAt(C)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var S=v.substr(-c),b=new zt.util.ByteBuffer;b.fillWithByte(0,8),b.putBytes(l),b.putBytes(S),t.start(),t.update(b.getBytes());var w=t.digest().getBytes();return h===w},s};var ue=_e,T=ue.asn1,re=ue.pki=ue.pki||{},be=re.oids,Ue={};Ue.CN=be.commonName,Ue.commonName="CN",Ue.C=be.countryName,Ue.countryName="C",Ue.L=be.localityName,Ue.localityName="L",Ue.ST=be.stateOrProvinceName,Ue.stateOrProvinceName="ST",Ue.O=be.organizationName,Ue.organizationName="O",Ue.OU=be.organizationalUnitName,Ue.organizationalUnitName="OU",Ue.E=be.emailAddress,Ue.emailAddress="E";var $s=ue.pki.rsa.publicKeyValidator,vl={name:"Certificate",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:T.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:T.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:T.Class.UNIVERSAL,type:T.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:T.Class.UNIVERSAL,type:T.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:T.Class.UNIVERSAL,type:T.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:T.Class.UNIVERSAL,type:T.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},$s,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:T.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:T.Class.UNIVERSAL,type:T.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:T.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:T.Class.UNIVERSAL,type:T.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:T.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:T.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:T.Class.UNIVERSAL,type:T.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},gl={name:"rsapss",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:T.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:T.Class.UNIVERSAL,type:T.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:T.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:T.Class.UNIVERSAL,type:T.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:T.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:T.Class.UNIVERSAL,type:T.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:T.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:T.Class.UNIVERSAL,type:T.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},_l={name:"CertificationRequestInfo",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},$s,{name:"CertificationRequestInfo.attributes",tagClass:T.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:T.Class.UNIVERSAL,type:T.Type.SET,constructed:!0}]}]}]},yl={name:"CertificationRequest",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[_l,{name:"CertificationRequest.signatureAlgorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:T.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:T.Class.UNIVERSAL,type:T.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};re.RDNAttributesAsArray=function(e,t){for(var i=[],r,n,c,a=0;a<e.value.length;++a){r=e.value[a];for(var s=0;s<r.value.length;++s)c={},n=r.value[s],c.type=T.derToOid(n.value[0].value),c.value=n.value[1].value,c.valueTagClass=n.value[1].type,c.type in be&&(c.name=be[c.type],c.name in Ue&&(c.shortName=Ue[c.name])),t&&(t.update(c.type),t.update(c.value)),i.push(c)}return i},re.CRIAttributesAsArray=function(e){for(var t=[],i=0;i<e.length;++i)for(var r=e[i],n=T.derToOid(r.value[0].value),c=r.value[1].value,a=0;a<c.length;++a){var s={};if(s.type=n,s.value=c[a].value,s.valueTagClass=c[a].type,s.type in be&&(s.name=be[s.type],s.name in Ue&&(s.shortName=Ue[s.name])),s.type===be.extensionRequest){s.extensions=[];for(var l=0;l<s.value.length;++l)s.extensions.push(re.certificateExtensionFromAsn1(s.value[l]))}t.push(s)}return t};function kt(e,t){typeof t=="string"&&(t={shortName:t});for(var i=null,r,n=0;i===null&&n<e.attributes.length;++n)r=e.attributes[n],(t.type&&t.type===r.type||t.name&&t.name===r.name||t.shortName&&t.shortName===r.shortName)&&(i=r);return i}var zr=function(e,t,i){var r={};if(e!==be["RSASSA-PSS"])return r;i&&(r={hash:{algorithmOid:be.sha1},mgf:{algorithmOid:be.mgf1,hash:{algorithmOid:be.sha1}},saltLength:20});var n={},c=[];if(!T.validate(t,gl,n,c)){var a=new Error("Cannot read RSASSA-PSS parameter block.");throw a.errors=c,a}return n.hashOid!==void 0&&(r.hash=r.hash||{},r.hash.algorithmOid=T.derToOid(n.hashOid)),n.maskGenOid!==void 0&&(r.mgf=r.mgf||{},r.mgf.algorithmOid=T.derToOid(n.maskGenOid),r.mgf.hash=r.mgf.hash||{},r.mgf.hash.algorithmOid=T.derToOid(n.maskGenHashOid)),n.saltLength!==void 0&&(r.saltLength=n.saltLength.charCodeAt(0)),r},$r=function(e){switch(be[e.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return ue.md.sha1.create();case"md5WithRSAEncryption":return ue.md.md5.create();case"sha256WithRSAEncryption":return ue.md.sha256.create();case"sha384WithRSAEncryption":return ue.md.sha384.create();case"sha512WithRSAEncryption":return ue.md.sha512.create();case"RSASSA-PSS":return ue.md.sha256.create();default:var t=new Error("Could not compute "+e.type+" digest. Unknown signature OID.");throw t.signatureOid=e.signatureOid,t}},qs=function(e){var t=e.certificate,i;switch(t.signatureOid){case be.sha1WithRSAEncryption:case be.sha1WithRSASignature:break;case be["RSASSA-PSS"]:var r,n;if(r=be[t.signatureParameters.mgf.hash.algorithmOid],r===void 0||ue.md[r]===void 0){var c=new Error("Unsupported MGF hash function.");throw c.oid=t.signatureParameters.mgf.hash.algorithmOid,c.name=r,c}if(n=be[t.signatureParameters.mgf.algorithmOid],n===void 0||ue.mgf[n]===void 0){var c=new Error("Unsupported MGF function.");throw c.oid=t.signatureParameters.mgf.algorithmOid,c.name=n,c}if(n=ue.mgf[n].create(ue.md[r].create()),r=be[t.signatureParameters.hash.algorithmOid],r===void 0||ue.md[r]===void 0){var c=new Error("Unsupported RSASSA-PSS hash function.");throw c.oid=t.signatureParameters.hash.algorithmOid,c.name=r,c}i=ue.pss.create(ue.md[r].create(),n,t.signatureParameters.saltLength);break}return t.publicKey.verify(e.md.digest().getBytes(),e.signature,i)};re.certificateFromPem=function(e,t,i){var r=ue.pem.decode(e)[0];if(r.type!=="CERTIFICATE"&&r.type!=="X509 CERTIFICATE"&&r.type!=="TRUSTED CERTIFICATE"){var n=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw n.headerType=r.type,n}if(r.procType&&r.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var c=T.fromDer(r.body,i);return re.certificateFromAsn1(c,t)},re.certificateToPem=function(e,t){var i={type:"CERTIFICATE",body:T.toDer(re.certificateToAsn1(e)).getBytes()};return ue.pem.encode(i,{maxline:t})},re.publicKeyFromPem=function(e){var t=ue.pem.decode(e)[0];if(t.type!=="PUBLIC KEY"&&t.type!=="RSA PUBLIC KEY"){var i=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw i.headerType=t.type,i}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");var r=T.fromDer(t.body);return re.publicKeyFromAsn1(r)},re.publicKeyToPem=function(e,t){var i={type:"PUBLIC KEY",body:T.toDer(re.publicKeyToAsn1(e)).getBytes()};return ue.pem.encode(i,{maxline:t})},re.publicKeyToRSAPublicKeyPem=function(e,t){var i={type:"RSA PUBLIC KEY",body:T.toDer(re.publicKeyToRSAPublicKey(e)).getBytes()};return ue.pem.encode(i,{maxline:t})},re.getPublicKeyFingerprint=function(e,t){t=t||{};var i=t.md||ue.md.sha1.create(),r=t.type||"RSAPublicKey",n;switch(r){case"RSAPublicKey":n=T.toDer(re.publicKeyToRSAPublicKey(e)).getBytes();break;case"SubjectPublicKeyInfo":n=T.toDer(re.publicKeyToAsn1(e)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+t.type+'".')}i.start(),i.update(n);var c=i.digest();if(t.encoding==="hex"){var a=c.toHex();return t.delimiter?a.match(/.{2}/g).join(t.delimiter):a}else{if(t.encoding==="binary")return c.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".')}return c},re.certificationRequestFromPem=function(e,t,i){var r=ue.pem.decode(e)[0];if(r.type!=="CERTIFICATE REQUEST"){var n=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw n.headerType=r.type,n}if(r.procType&&r.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var c=T.fromDer(r.body,i);return re.certificationRequestFromAsn1(c,t)},re.certificationRequestToPem=function(e,t){var i={type:"CERTIFICATE REQUEST",body:T.toDer(re.certificationRequestToAsn1(e)).getBytes()};return ue.pem.encode(i,{maxline:t})},re.createCertificate=function(){var e={};return e.version=2,e.serialNumber="00",e.signatureOid=null,e.signature=null,e.siginfo={},e.siginfo.algorithmOid=null,e.validity={},e.validity.notBefore=new Date,e.validity.notAfter=new Date,e.issuer={},e.issuer.getField=function(t){return kt(e.issuer,t)},e.issuer.addField=function(t){at([t]),e.issuer.attributes.push(t)},e.issuer.attributes=[],e.issuer.hash=null,e.subject={},e.subject.getField=function(t){return kt(e.subject,t)},e.subject.addField=function(t){at([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.extensions=[],e.publicKey=null,e.md=null,e.setSubject=function(t,i){at(t),e.subject.attributes=t,delete e.subject.uniqueId,i&&(e.subject.uniqueId=i),e.subject.hash=null},e.setIssuer=function(t,i){at(t),e.issuer.attributes=t,delete e.issuer.uniqueId,i&&(e.issuer.uniqueId=i),e.issuer.hash=null},e.setExtensions=function(t){for(var i=0;i<t.length;++i)Gs(t[i],{cert:e});e.extensions=t},e.getExtension=function(t){typeof t=="string"&&(t={name:t});for(var i=null,r,n=0;i===null&&n<e.extensions.length;++n)r=e.extensions[n],(t.id&&r.id===t.id||t.name&&r.name===t.name)&&(i=r);return i},e.sign=function(t,i){e.md=i||ue.md.sha1.create();var r=be[e.md.algorithm+"WithRSAEncryption"];if(!r){var n=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw n.algorithm=e.md.algorithm,n}e.signatureOid=e.siginfo.algorithmOid=r,e.tbsCertificate=re.getTBSCertificate(e);var c=T.toDer(e.tbsCertificate);e.md.update(c.getBytes()),e.signature=t.sign(e.md)},e.verify=function(t){var i=!1;if(!e.issued(t)){var r=t.issuer,n=e.subject,c=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw c.expectedIssuer=n.attributes,c.actualIssuer=r.attributes,c}var a=t.md;if(a===null){a=$r({signatureOid:t.signatureOid,type:"certificate"});var s=t.tbsCertificate||re.getTBSCertificate(t),l=T.toDer(s);a.update(l.getBytes())}return a!==null&&(i=qs({certificate:e,md:a,signature:t.signature})),i},e.isIssuer=function(t){var i=!1,r=e.issuer,n=t.subject;if(r.hash&&n.hash)i=r.hash===n.hash;else if(r.attributes.length===n.attributes.length){i=!0;for(var c,a,s=0;i&&s<r.attributes.length;++s)c=r.attributes[s],a=n.attributes[s],(c.type!==a.type||c.value!==a.value)&&(i=!1)}return i},e.issued=function(t){return t.isIssuer(e)},e.generateSubjectKeyIdentifier=function(){return re.getPublicKeyFingerprint(e.publicKey,{type:"RSAPublicKey"})},e.verifySubjectKeyIdentifier=function(){for(var t=be.subjectKeyIdentifier,i=0;i<e.extensions.length;++i){var r=e.extensions[i];if(r.id===t){var n=e.generateSubjectKeyIdentifier().getBytes();return ue.util.hexToBytes(r.subjectKeyIdentifier)===n}}return!1},e},re.certificateFromAsn1=function(e,t){var i={},r=[];if(!T.validate(e,vl,i,r)){var n=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw n.errors=r,n}var c=T.derToOid(i.publicKeyOid);if(c!==re.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var a=re.createCertificate();a.version=i.certVersion?i.certVersion.charCodeAt(0):0;var s=ue.util.createBuffer(i.certSerialNumber);a.serialNumber=s.toHex(),a.signatureOid=ue.asn1.derToOid(i.certSignatureOid),a.signatureParameters=zr(a.signatureOid,i.certSignatureParams,!0),a.siginfo.algorithmOid=ue.asn1.derToOid(i.certinfoSignatureOid),a.siginfo.parameters=zr(a.siginfo.algorithmOid,i.certinfoSignatureParams,!1),a.signature=i.certSignature;var l=[];if(i.certValidity1UTCTime!==void 0&&l.push(T.utcTimeToDate(i.certValidity1UTCTime)),i.certValidity2GeneralizedTime!==void 0&&l.push(T.generalizedTimeToDate(i.certValidity2GeneralizedTime)),i.certValidity3UTCTime!==void 0&&l.push(T.utcTimeToDate(i.certValidity3UTCTime)),i.certValidity4GeneralizedTime!==void 0&&l.push(T.generalizedTimeToDate(i.certValidity4GeneralizedTime)),l.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(l.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(a.validity.notBefore=l[0],a.validity.notAfter=l[1],a.tbsCertificate=i.tbsCertificate,t){a.md=$r({signatureOid:a.signatureOid,type:"certificate"});var o=T.toDer(a.tbsCertificate);a.md.update(o.getBytes())}var f=ue.md.sha1.create(),u=T.toDer(i.certIssuer);f.update(u.getBytes()),a.issuer.getField=function(y){return kt(a.issuer,y)},a.issuer.addField=function(y){at([y]),a.issuer.attributes.push(y)},a.issuer.attributes=re.RDNAttributesAsArray(i.certIssuer),i.certIssuerUniqueId&&(a.issuer.uniqueId=i.certIssuerUniqueId),a.issuer.hash=f.digest().toHex();var g=ue.md.sha1.create(),_=T.toDer(i.certSubject);return g.update(_.getBytes()),a.subject.getField=function(y){return kt(a.subject,y)},a.subject.addField=function(y){at([y]),a.subject.attributes.push(y)},a.subject.attributes=re.RDNAttributesAsArray(i.certSubject),i.certSubjectUniqueId&&(a.subject.uniqueId=i.certSubjectUniqueId),a.subject.hash=g.digest().toHex(),i.certExtensions?a.extensions=re.certificateExtensionsFromAsn1(i.certExtensions):a.extensions=[],a.publicKey=re.publicKeyFromAsn1(i.subjectPublicKeyInfo),a},re.certificateExtensionsFromAsn1=function(e){for(var t=[],i=0;i<e.value.length;++i)for(var r=e.value[i],n=0;n<r.value.length;++n)t.push(re.certificateExtensionFromAsn1(r.value[n]));return t},re.certificateExtensionFromAsn1=function(e){var t={};if(t.id=T.derToOid(e.value[0].value),t.critical=!1,e.value[1].type===T.Type.BOOLEAN?(t.critical=e.value[1].value.charCodeAt(0)!==0,t.value=e.value[2].value):t.value=e.value[1].value,t.id in be){if(t.name=be[t.id],t.name==="keyUsage"){var i=T.fromDer(t.value),r=0,n=0;i.value.length>1&&(r=i.value.charCodeAt(1),n=i.value.length>2?i.value.charCodeAt(2):0),t.digitalSignature=(r&128)===128,t.nonRepudiation=(r&64)===64,t.keyEncipherment=(r&32)===32,t.dataEncipherment=(r&16)===16,t.keyAgreement=(r&8)===8,t.keyCertSign=(r&4)===4,t.cRLSign=(r&2)===2,t.encipherOnly=(r&1)===1,t.decipherOnly=(n&128)===128}else if(t.name==="basicConstraints"){var i=T.fromDer(t.value);i.value.length>0&&i.value[0].type===T.Type.BOOLEAN?t.cA=i.value[0].value.charCodeAt(0)!==0:t.cA=!1;var c=null;i.value.length>0&&i.value[0].type===T.Type.INTEGER?c=i.value[0].value:i.value.length>1&&(c=i.value[1].value),c!==null&&(t.pathLenConstraint=T.derToInteger(c))}else if(t.name==="extKeyUsage")for(var i=T.fromDer(t.value),a=0;a<i.value.length;++a){var s=T.derToOid(i.value[a].value);s in be?t[be[s]]=!0:t[s]=!0}else if(t.name==="nsCertType"){var i=T.fromDer(t.value),r=0;i.value.length>1&&(r=i.value.charCodeAt(1)),t.client=(r&128)===128,t.server=(r&64)===64,t.email=(r&32)===32,t.objsign=(r&16)===16,t.reserved=(r&8)===8,t.sslCA=(r&4)===4,t.emailCA=(r&2)===2,t.objCA=(r&1)===1}else if(t.name==="subjectAltName"||t.name==="issuerAltName"){t.altNames=[];for(var l,i=T.fromDer(t.value),o=0;o<i.value.length;++o){l=i.value[o];var f={type:l.type,value:l.value};switch(t.altNames.push(f),l.type){case 1:case 2:case 6:break;case 7:f.ip=ue.util.bytesToIP(l.value);break;case 8:f.oid=T.derToOid(l.value);break}}}else if(t.name==="subjectKeyIdentifier"){var i=T.fromDer(t.value);t.subjectKeyIdentifier=ue.util.bytesToHex(i.value)}}return t},re.certificationRequestFromAsn1=function(e,t){var i={},r=[];if(!T.validate(e,yl,i,r)){var n=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw n.errors=r,n}var c=T.derToOid(i.publicKeyOid);if(c!==re.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var a=re.createCertificationRequest();if(a.version=i.csrVersion?i.csrVersion.charCodeAt(0):0,a.signatureOid=ue.asn1.derToOid(i.csrSignatureOid),a.signatureParameters=zr(a.signatureOid,i.csrSignatureParams,!0),a.siginfo.algorithmOid=ue.asn1.derToOid(i.csrSignatureOid),a.siginfo.parameters=zr(a.siginfo.algorithmOid,i.csrSignatureParams,!1),a.signature=i.csrSignature,a.certificationRequestInfo=i.certificationRequestInfo,t){a.md=$r({signatureOid:a.signatureOid,type:"certification request"});var s=T.toDer(a.certificationRequestInfo);a.md.update(s.getBytes())}var l=ue.md.sha1.create();return a.subject.getField=function(o){return kt(a.subject,o)},a.subject.addField=function(o){at([o]),a.subject.attributes.push(o)},a.subject.attributes=re.RDNAttributesAsArray(i.certificationRequestInfoSubject,l),a.subject.hash=l.digest().toHex(),a.publicKey=re.publicKeyFromAsn1(i.subjectPublicKeyInfo),a.getAttribute=function(o){return kt(a,o)},a.addAttribute=function(o){at([o]),a.attributes.push(o)},a.attributes=re.CRIAttributesAsArray(i.certificationRequestInfoAttributes||[]),a},re.createCertificationRequest=function(){var e={};return e.version=0,e.signatureOid=null,e.signature=null,e.siginfo={},e.siginfo.algorithmOid=null,e.subject={},e.subject.getField=function(t){return kt(e.subject,t)},e.subject.addField=function(t){at([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.publicKey=null,e.attributes=[],e.getAttribute=function(t){return kt(e,t)},e.addAttribute=function(t){at([t]),e.attributes.push(t)},e.md=null,e.setSubject=function(t){at(t),e.subject.attributes=t,e.subject.hash=null},e.setAttributes=function(t){at(t),e.attributes=t},e.sign=function(t,i){e.md=i||ue.md.sha1.create();var r=be[e.md.algorithm+"WithRSAEncryption"];if(!r){var n=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw n.algorithm=e.md.algorithm,n}e.signatureOid=e.siginfo.algorithmOid=r,e.certificationRequestInfo=re.getCertificationRequestInfo(e);var c=T.toDer(e.certificationRequestInfo);e.md.update(c.getBytes()),e.signature=t.sign(e.md)},e.verify=function(){var t=!1,i=e.md;if(i===null){i=$r({signatureOid:e.signatureOid,type:"certification request"});var r=e.certificationRequestInfo||re.getCertificationRequestInfo(e),n=T.toDer(r);i.update(n.getBytes())}return i!==null&&(t=qs({certificate:e,md:i,signature:e.signature})),t},e};function tr(e){for(var t=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]),i,r,n=e.attributes,c=0;c<n.length;++c){i=n[c];var a=i.value,s=T.Type.PRINTABLESTRING;"valueTagClass"in i&&(s=i.valueTagClass,s===T.Type.UTF8&&(a=ue.util.encodeUtf8(a))),r=T.create(T.Class.UNIVERSAL,T.Type.SET,!0,[T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(i.type).getBytes()),T.create(T.Class.UNIVERSAL,s,!1,a)])]),t.value.push(r)}return t}function at(e){for(var t,i=0;i<e.length;++i){if(t=e[i],typeof t.name=="undefined"&&(t.type&&t.type in re.oids?t.name=re.oids[t.type]:t.shortName&&t.shortName in Ue&&(t.name=re.oids[Ue[t.shortName]])),typeof t.type=="undefined")if(t.name&&t.name in re.oids)t.type=re.oids[t.name];else{var r=new Error("Attribute type not specified.");throw r.attribute=t,r}if(typeof t.shortName=="undefined"&&t.name&&t.name in Ue&&(t.shortName=Ue[t.name]),t.type===be.extensionRequest&&(t.valueConstructed=!0,t.valueTagClass=T.Type.SEQUENCE,!t.value&&t.extensions)){t.value=[];for(var n=0;n<t.extensions.length;++n)t.value.push(re.certificateExtensionToAsn1(Gs(t.extensions[n])))}if(typeof t.value=="undefined"){var r=new Error("Attribute value not specified.");throw r.attribute=t,r}}}function Gs(e,t){if(t=t||{},typeof e.name=="undefined"&&e.id&&e.id in re.oids&&(e.name=re.oids[e.id]),typeof e.id=="undefined")if(e.name&&e.name in re.oids)e.id=re.oids[e.name];else{var i=new Error("Extension ID not specified.");throw i.extension=e,i}if(typeof e.value!="undefined")return e;if(e.name==="keyUsage"){var r=0,n=0,c=0;e.digitalSignature&&(n|=128,r=7),e.nonRepudiation&&(n|=64,r=6),e.keyEncipherment&&(n|=32,r=5),e.dataEncipherment&&(n|=16,r=4),e.keyAgreement&&(n|=8,r=3),e.keyCertSign&&(n|=4,r=2),e.cRLSign&&(n|=2,r=1),e.encipherOnly&&(n|=1,r=0),e.decipherOnly&&(c|=128,r=7);var a=String.fromCharCode(r);c!==0?a+=String.fromCharCode(n)+String.fromCharCode(c):n!==0&&(a+=String.fromCharCode(n)),e.value=T.create(T.Class.UNIVERSAL,T.Type.BITSTRING,!1,a)}else if(e.name==="basicConstraints")e.value=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]),e.cA&&e.value.value.push(T.create(T.Class.UNIVERSAL,T.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in e&&e.value.value.push(T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(e.pathLenConstraint).getBytes()));else if(e.name==="extKeyUsage"){e.value=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]);var s=e.value.value;for(var l in e)e[l]===!0&&(l in be?s.push(T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(be[l]).getBytes())):l.indexOf(".")!==-1&&s.push(T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(l).getBytes())))}else if(e.name==="nsCertType"){var r=0,n=0;e.client&&(n|=128,r=7),e.server&&(n|=64,r=6),e.email&&(n|=32,r=5),e.objsign&&(n|=16,r=4),e.reserved&&(n|=8,r=3),e.sslCA&&(n|=4,r=2),e.emailCA&&(n|=2,r=1),e.objCA&&(n|=1,r=0);var a=String.fromCharCode(r);n!==0&&(a+=String.fromCharCode(n)),e.value=T.create(T.Class.UNIVERSAL,T.Type.BITSTRING,!1,a)}else if(e.name==="subjectAltName"||e.name==="issuerAltName"){e.value=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]);for(var o,f=0;f<e.altNames.length;++f){o=e.altNames[f];var a=o.value;if(o.type===7&&o.ip){if(a=ue.util.bytesFromIP(o.ip),a===null){var i=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw i.extension=e,i}}else o.type===8&&(o.oid?a=T.oidToDer(T.oidToDer(o.oid)):a=T.oidToDer(a));e.value.value.push(T.create(T.Class.CONTEXT_SPECIFIC,o.type,!1,a))}}else if(e.name==="nsComment"&&t.cert){if(!/^[\x00-\x7F]*$/.test(e.comment)||e.comment.length<1||e.comment.length>128)throw new Error('Invalid "nsComment" content.');e.value=T.create(T.Class.UNIVERSAL,T.Type.IA5STRING,!1,e.comment)}else if(e.name==="subjectKeyIdentifier"&&t.cert){var u=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=u.toHex(),e.value=T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,u.getBytes())}else if(e.name==="authorityKeyIdentifier"&&t.cert){e.value=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]);var s=e.value.value;if(e.keyIdentifier){var g=e.keyIdentifier===!0?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;s.push(T.create(T.Class.CONTEXT_SPECIFIC,0,!1,g))}if(e.authorityCertIssuer){var _=[T.create(T.Class.CONTEXT_SPECIFIC,4,!0,[tr(e.authorityCertIssuer===!0?t.cert.issuer:e.authorityCertIssuer)])];s.push(T.create(T.Class.CONTEXT_SPECIFIC,1,!0,_))}if(e.serialNumber){var y=ue.util.hexToBytes(e.serialNumber===!0?t.cert.serialNumber:e.serialNumber);s.push(T.create(T.Class.CONTEXT_SPECIFIC,2,!1,y))}}else if(e.name==="cRLDistributionPoints"){e.value=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]);for(var s=e.value.value,m=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]),h=T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[]),o,f=0;f<e.altNames.length;++f){o=e.altNames[f];var a=o.value;if(o.type===7&&o.ip){if(a=ue.util.bytesFromIP(o.ip),a===null){var i=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw i.extension=e,i}}else o.type===8&&(o.oid?a=T.oidToDer(T.oidToDer(o.oid)):a=T.oidToDer(a));h.value.push(T.create(T.Class.CONTEXT_SPECIFIC,o.type,!1,a))}m.value.push(T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[h])),s.push(m)}if(typeof e.value=="undefined"){var i=new Error("Extension value not specified.");throw i.extension=e,i}return e}function bi(e,t){switch(e){case be["RSASSA-PSS"]:var i=[];return t.hash.algorithmOid!==void 0&&i.push(T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.hash.algorithmOid).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")])])),t.mgf.algorithmOid!==void 0&&i.push(T.create(T.Class.CONTEXT_SPECIFIC,1,!0,[T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.mgf.algorithmOid).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.mgf.hash.algorithmOid).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")])])])),t.saltLength!==void 0&&i.push(T.create(T.Class.CONTEXT_SPECIFIC,2,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(t.saltLength).getBytes())])),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,i);default:return T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")}}function ml(e){var t=T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[]);if(e.attributes.length===0)return t;for(var i=e.attributes,r=0;r<i.length;++r){var n=i[r],c=n.value,a=T.Type.UTF8;"valueTagClass"in n&&(a=n.valueTagClass),a===T.Type.UTF8&&(c=ue.util.encodeUtf8(c));var s=!1;"valueConstructed"in n&&(s=n.valueConstructed);var l=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(n.type).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SET,!0,[T.create(T.Class.UNIVERSAL,a,s,c)])]);t.value.push(l)}return t}var Cl=new Date("1950-01-01T00:00:00Z"),Sl=new Date("2050-01-01T00:00:00Z");function js(e){return e>=Cl&&e<Sl?T.create(T.Class.UNIVERSAL,T.Type.UTCTIME,!1,T.dateToUtcTime(e)):T.create(T.Class.UNIVERSAL,T.Type.GENERALIZEDTIME,!1,T.dateToGeneralizedTime(e))}re.getTBSCertificate=function(e){var t=js(e.validity.notBefore),i=js(e.validity.notAfter),r=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(e.version).getBytes())]),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,ue.util.hexToBytes(e.serialNumber)),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(e.siginfo.algorithmOid).getBytes()),bi(e.siginfo.algorithmOid,e.siginfo.parameters)]),tr(e.issuer),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[t,i]),tr(e.subject),re.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&r.value.push(T.create(T.Class.CONTEXT_SPECIFIC,1,!0,[T.create(T.Class.UNIVERSAL,T.Type.BITSTRING,!1,String.fromCharCode(0)+e.issuer.uniqueId)])),e.subject.uniqueId&&r.value.push(T.create(T.Class.CONTEXT_SPECIFIC,2,!0,[T.create(T.Class.UNIVERSAL,T.Type.BITSTRING,!1,String.fromCharCode(0)+e.subject.uniqueId)])),e.extensions.length>0&&r.value.push(re.certificateExtensionsToAsn1(e.extensions)),r},re.getCertificationRequestInfo=function(e){var t=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(e.version).getBytes()),tr(e.subject),re.publicKeyToAsn1(e.publicKey),ml(e)]);return t},re.distinguishedNameToAsn1=function(e){return tr(e)},re.certificateToAsn1=function(e){var t=e.tbsCertificate||re.getTBSCertificate(e);return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[t,T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(e.signatureOid).getBytes()),bi(e.signatureOid,e.signatureParameters)]),T.create(T.Class.UNIVERSAL,T.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},re.certificateExtensionsToAsn1=function(e){var t=T.create(T.Class.CONTEXT_SPECIFIC,3,!0,[]),i=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]);t.value.push(i);for(var r=0;r<e.length;++r)i.value.push(re.certificateExtensionToAsn1(e[r]));return t},re.certificateExtensionToAsn1=function(e){var t=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]);t.value.push(T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(e.id).getBytes())),e.critical&&t.value.push(T.create(T.Class.UNIVERSAL,T.Type.BOOLEAN,!1,String.fromCharCode(255)));var i=e.value;return typeof e.value!="string"&&(i=T.toDer(i).getBytes()),t.value.push(T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,i)),t},re.certificationRequestToAsn1=function(e){var t=e.certificationRequestInfo||re.getCertificationRequestInfo(e);return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[t,T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(e.signatureOid).getBytes()),bi(e.signatureOid,e.signatureParameters)]),T.create(T.Class.UNIVERSAL,T.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},re.createCaStore=function(e){var t={certs:{}};t.getIssuer=function(a){var s=i(a.issuer);return s},t.addCertificate=function(a){if(typeof a=="string"&&(a=ue.pki.certificateFromPem(a)),r(a.subject),!t.hasCertificate(a))if(a.subject.hash in t.certs){var s=t.certs[a.subject.hash];ue.util.isArray(s)||(s=[s]),s.push(a),t.certs[a.subject.hash]=s}else t.certs[a.subject.hash]=a},t.hasCertificate=function(a){typeof a=="string"&&(a=ue.pki.certificateFromPem(a));var s=i(a.subject);if(!s)return!1;ue.util.isArray(s)||(s=[s]);for(var l=T.toDer(re.certificateToAsn1(a)).getBytes(),o=0;o<s.length;++o){var f=T.toDer(re.certificateToAsn1(s[o])).getBytes();if(l===f)return!0}return!1},t.listAllCertificates=function(){var a=[];for(var s in t.certs)if(t.certs.hasOwnProperty(s)){var l=t.certs[s];if(!ue.util.isArray(l))a.push(l);else for(var o=0;o<l.length;++o)a.push(l[o])}return a},t.removeCertificate=function(a){var s;if(typeof a=="string"&&(a=ue.pki.certificateFromPem(a)),r(a.subject),!t.hasCertificate(a))return null;var l=i(a.subject);if(!ue.util.isArray(l))return s=t.certs[a.subject.hash],delete t.certs[a.subject.hash],s;for(var o=T.toDer(re.certificateToAsn1(a)).getBytes(),f=0;f<l.length;++f){var u=T.toDer(re.certificateToAsn1(l[f])).getBytes();o===u&&(s=l[f],l.splice(f,1))}return l.length===0&&delete t.certs[a.subject.hash],s};function i(a){return r(a),t.certs[a.hash]||null}function r(a){if(!a.hash){var s=ue.md.sha1.create();a.attributes=re.RDNAttributesAsArray(tr(a),s),a.hash=s.digest().toHex()}}if(e)for(var n=0;n<e.length;++n){var c=e[n];t.addCertificate(c)}return t},re.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"},re.verifyCertificateChain=function(e,t,i){typeof i=="function"&&(i={verify:i}),i=i||{},t=t.slice(0);var r=t.slice(0),n=i.validityCheckDate;typeof n=="undefined"&&(n=new Date);var c=!0,a=null,s=0;do{var l=t.shift(),o=null,f=!1;if(n&&(n<l.validity.notBefore||n>l.validity.notAfter)&&(a={message:"Certificate is not valid yet or has expired.",error:re.certificateError.certificate_expired,notBefore:l.validity.notBefore,notAfter:l.validity.notAfter,now:n}),a===null){if(o=t[0]||e.getIssuer(l),o===null&&l.isIssuer(l)&&(f=!0,o=l),o){var u=o;ue.util.isArray(u)||(u=[u]);for(var g=!1;!g&&u.length>0;){o=u.shift();try{g=o.verify(l)}catch(S){}}g||(a={message:"Certificate signature is invalid.",error:re.certificateError.bad_certificate})}a===null&&(!o||f)&&!e.hasCertificate(l)&&(a={message:"Certificate is not trusted.",error:re.certificateError.unknown_ca})}if(a===null&&o&&!l.isIssuer(o)&&(a={message:"Certificate issuer is invalid.",error:re.certificateError.bad_certificate}),a===null)for(var _={keyUsage:!0,basicConstraints:!0},y=0;a===null&&y<l.extensions.length;++y){var m=l.extensions[y];m.critical&&!(m.name in _)&&(a={message:"Certificate has an unsupported critical extension.",error:re.certificateError.unsupported_certificate})}if(a===null&&(!c||t.length===0&&(!o||f))){var h=l.getExtension("basicConstraints"),d=l.getExtension("keyUsage");if(d!==null&&(!d.keyCertSign||h===null)&&(a={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:re.certificateError.bad_certificate}),a===null&&h!==null&&!h.cA&&(a={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:re.certificateError.bad_certificate}),a===null&&d!==null&&"pathLenConstraint"in h){var p=s-1;p>h.pathLenConstraint&&(a={message:"Certificate basicConstraints pathLenConstraint violated.",error:re.certificateError.bad_certificate})}}var v=a===null?!0:a.error,C=i.verify?i.verify(v,s,r):v;if(C===!0)a=null;else throw v===!0&&(a={message:"The application rejected the certificate.",error:re.certificateError.bad_certificate}),(C||C===0)&&(typeof C=="object"&&!ue.util.isArray(C)?(C.message&&(a.message=C.message),C.error&&(a.error=C.error)):typeof C=="string"&&(a.error=C)),a;c=!1,++s}while(t.length>0);return!0};var ke=_e,M=ke.asn1,me=ke.pki,gr=ke.pkcs12=ke.pkcs12||{},Qs={name:"ContentInfo",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:M.Class.UNIVERSAL,type:M.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:M.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},El={name:"PFX",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:M.Class.UNIVERSAL,type:M.Type.INTEGER,constructed:!1,capture:"version"},Qs,{name:"PFX.macData",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:M.Class.UNIVERSAL,type:M.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",optional:!0,tagClass:M.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:M.Class.UNIVERSAL,type:M.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:M.Class.UNIVERSAL,type:M.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:M.Class.UNIVERSAL,type:M.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},bl={name:"SafeBag",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:M.Class.UNIVERSAL,type:M.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:M.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:M.Class.UNIVERSAL,type:M.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},xl={name:"Attribute",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:M.Class.UNIVERSAL,type:M.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:M.Class.UNIVERSAL,type:M.Type.SET,constructed:!0,capture:"values"}]},wl={name:"CertBag",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:M.Class.UNIVERSAL,type:M.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:M.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:M.Class.UNIVERSAL,type:M.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function _r(e,t,i,r){for(var n=[],c=0;c<e.length;c++)for(var a=0;a<e[c].safeBags.length;a++){var s=e[c].safeBags[a];if(!(r!==void 0&&s.type!==r)){if(t===null){n.push(s);continue}s.attributes[t]!==void 0&&s.attributes[t].indexOf(i)>=0&&n.push(s)}}return n}gr.pkcs12FromAsn1=function(e,t,i){typeof t=="string"?(i=t,t=!0):t===void 0&&(t=!0);var r={},n=[];if(!M.validate(e,El,r,n)){var c=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.");throw c.errors=c,c}var a={version:r.version.charCodeAt(0),safeContents:[],getBags:function(h){var d={},p;return"localKeyId"in h?p=h.localKeyId:"localKeyIdHex"in h&&(p=ke.util.hexToBytes(h.localKeyIdHex)),p===void 0&&!("friendlyName"in h)&&"bagType"in h&&(d[h.bagType]=_r(a.safeContents,null,null,h.bagType)),p!==void 0&&(d.localKeyId=_r(a.safeContents,"localKeyId",p,h.bagType)),"friendlyName"in h&&(d.friendlyName=_r(a.safeContents,"friendlyName",h.friendlyName,h.bagType)),d},getBagsByFriendlyName:function(h,d){return _r(a.safeContents,"friendlyName",h,d)},getBagsByLocalKeyId:function(h,d){return _r(a.safeContents,"localKeyId",h,d)}};if(r.version.charCodeAt(0)!==3){var c=new Error("PKCS#12 PFX of version other than 3 not supported.");throw c.version=r.version.charCodeAt(0),c}if(M.derToOid(r.contentType)!==me.oids.data){var c=new Error("Only PKCS#12 PFX in password integrity mode supported.");throw c.oid=M.derToOid(r.contentType),c}var s=r.content.value[0];if(s.tagClass!==M.Class.UNIVERSAL||s.type!==M.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(s=xi(s),r.mac){var l=null,o=0,f=M.derToOid(r.macAlgorithm);switch(f){case me.oids.sha1:l=ke.md.sha1.create(),o=20;break;case me.oids.sha256:l=ke.md.sha256.create(),o=32;break;case me.oids.sha384:l=ke.md.sha384.create(),o=48;break;case me.oids.sha512:l=ke.md.sha512.create(),o=64;break;case me.oids.md5:l=ke.md.md5.create(),o=16;break}if(l===null)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+f);var u=new ke.util.ByteBuffer(r.macSalt),g="macIterations"in r?parseInt(ke.util.bytesToHex(r.macIterations),16):1,_=gr.generateKey(i,u,3,g,o,l),y=ke.hmac.create();y.start(l,_),y.update(s.value);var m=y.getMac();if(m.getBytes()!==r.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}else if(Array.isArray(e.value)&&e.value.length>2)throw new Error("Invalid PKCS#12. macData field present but MAC was not validated.");return Tl(a,s.value,t,i),a};function xi(e){if(e.composed||e.constructed){for(var t=ke.util.createBuffer(),i=0;i<e.value.length;++i)t.putBytes(e.value[i].value);e.composed=e.constructed=!1,e.value=t.getBytes()}return e}function Tl(e,t,i,r){if(t=M.fromDer(t,i),t.tagClass!==M.Class.UNIVERSAL||t.type!==M.Type.SEQUENCE||t.constructed!==!0)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var n=0;n<t.value.length;n++){var c=t.value[n],a={},s=[];if(!M.validate(c,Qs,a,s)){var l=new Error("Cannot read ContentInfo.");throw l.errors=s,l}var o={encrypted:!1},f=null,u=a.content.value[0];switch(M.derToOid(a.contentType)){case me.oids.data:if(u.tagClass!==M.Class.UNIVERSAL||u.type!==M.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");f=xi(u).value;break;case me.oids.encryptedData:f=Al(u,r),o.encrypted=!0;break;default:var l=new Error("Unsupported PKCS#12 contentType.");throw l.contentType=M.derToOid(a.contentType),l}o.safeBags=Bl(f,i,r),e.safeContents.push(o)}}function Al(e,t){var i={},r=[];if(!M.validate(e,ke.pkcs7.asn1.encryptedDataValidator,i,r)){var n=new Error("Cannot read EncryptedContentInfo.");throw n.errors=r,n}var c=M.derToOid(i.contentType);if(c!==me.oids.data){var n=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.");throw n.oid=c,n}c=M.derToOid(i.encAlgorithm);var a=me.pbe.getCipher(c,i.encParameter,t),s=xi(i.encryptedContentAsn1),l=ke.util.createBuffer(s.value);if(a.update(l),!a.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return a.output.getBytes()}function Bl(e,t,i){if(!t&&e.length===0)return[];if(e=M.fromDer(e,t),e.tagClass!==M.Class.UNIVERSAL||e.type!==M.Type.SEQUENCE||e.constructed!==!0)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var r=[],n=0;n<e.value.length;n++){var c=e.value[n],a={},s=[];if(!M.validate(c,bl,a,s)){var l=new Error("Cannot read SafeBag.");throw l.errors=s,l}var o={type:M.derToOid(a.bagId),attributes:Il(a.bagAttributes)};r.push(o);var f,u,g=a.bagValue.value[0];switch(o.type){case me.oids.pkcs8ShroudedKeyBag:if(g=me.decryptPrivateKeyInfo(g,i),g===null)throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case me.oids.keyBag:try{o.key=me.privateKeyFromAsn1(g)}catch(y){o.key=null,o.asn1=g}continue;case me.oids.certBag:f=wl,u=function(){if(M.derToOid(a.certId)!==me.oids.x509Certificate){var y=new Error("Unsupported certificate type, only X.509 supported.");throw y.oid=M.derToOid(a.certId),y}var m=M.fromDer(a.cert,t);try{o.cert=me.certificateFromAsn1(m,!0)}catch(h){o.cert=null,o.asn1=m}};break;default:var l=new Error("Unsupported PKCS#12 SafeBag type.");throw l.oid=o.type,l}if(f!==void 0&&!M.validate(g,f,a,s)){var l=new Error("Cannot read PKCS#12 "+f.name);throw l.errors=s,l}u()}return r}function Il(e){var t={};if(e!==void 0)for(var i=0;i<e.length;++i){var r={},n=[];if(!M.validate(e[i],xl,r,n)){var c=new Error("Cannot read PKCS#12 BagAttribute.");throw c.errors=n,c}var a=M.derToOid(r.oid);if(me.oids[a]!==void 0){t[me.oids[a]]=[];for(var s=0;s<r.values.length;++s)t[me.oids[a]].push(r.values[s].value)}}return t}gr.toPkcs12Asn1=function(e,t,i,r){r=r||{},r.saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||r.encAlgorithm||"aes128","useMac"in r||(r.useMac=!0),"localKeyId"in r||(r.localKeyId=null),"generateLocalKeyId"in r||(r.generateLocalKeyId=!0);var n=r.localKeyId,c;if(n!==null)n=ke.util.hexToBytes(n);else if(r.generateLocalKeyId)if(t){var a=ke.util.isArray(t)?t[0]:t;typeof a=="string"&&(a=me.certificateFromPem(a));var s=ke.md.sha1.create();s.update(M.toDer(me.certificateToAsn1(a)).getBytes()),n=s.digest().getBytes()}else n=ke.random.getBytes(20);var l=[];n!==null&&l.push(M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(me.oids.localKeyId).getBytes()),M.create(M.Class.UNIVERSAL,M.Type.SET,!0,[M.create(M.Class.UNIVERSAL,M.Type.OCTETSTRING,!1,n)])])),"friendlyName"in r&&l.push(M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(me.oids.friendlyName).getBytes()),M.create(M.Class.UNIVERSAL,M.Type.SET,!0,[M.create(M.Class.UNIVERSAL,M.Type.BMPSTRING,!1,r.friendlyName)])])),l.length>0&&(c=M.create(M.Class.UNIVERSAL,M.Type.SET,!0,l));var o=[],f=[];t!==null&&(ke.util.isArray(t)?f=t:f=[t]);for(var u=[],g=0;g<f.length;++g){t=f[g],typeof t=="string"&&(t=me.certificateFromPem(t));var _=g===0?c:void 0,y=me.certificateToAsn1(t),m=M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(me.oids.certBag).getBytes()),M.create(M.Class.CONTEXT_SPECIFIC,0,!0,[M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(me.oids.x509Certificate).getBytes()),M.create(M.Class.CONTEXT_SPECIFIC,0,!0,[M.create(M.Class.UNIVERSAL,M.Type.OCTETSTRING,!1,M.toDer(y).getBytes())])])]),_]);u.push(m)}if(u.length>0){var h=M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,u),d=M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(me.oids.data).getBytes()),M.create(M.Class.CONTEXT_SPECIFIC,0,!0,[M.create(M.Class.UNIVERSAL,M.Type.OCTETSTRING,!1,M.toDer(h).getBytes())])]);o.push(d)}var p=null;if(e!==null){var v=me.wrapRsaPrivateKey(me.privateKeyToAsn1(e));i===null?p=M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(me.oids.keyBag).getBytes()),M.create(M.Class.CONTEXT_SPECIFIC,0,!0,[v]),c]):p=M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(me.oids.pkcs8ShroudedKeyBag).getBytes()),M.create(M.Class.CONTEXT_SPECIFIC,0,!0,[me.encryptPrivateKeyInfo(v,i,r)]),c]);var C=M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[p]),S=M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(me.oids.data).getBytes()),M.create(M.Class.CONTEXT_SPECIFIC,0,!0,[M.create(M.Class.UNIVERSAL,M.Type.OCTETSTRING,!1,M.toDer(C).getBytes())])]);o.push(S)}var b=M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,o),w;if(r.useMac){var s=ke.md.sha1.create(),E=new ke.util.ByteBuffer(ke.random.getBytes(r.saltSize)),x=r.count,e=gr.generateKey(i,E,3,x,20),k=ke.hmac.create();k.start(s,e),k.update(M.toDer(b).getBytes());var D=k.getMac();w=M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(me.oids.sha1).getBytes()),M.create(M.Class.UNIVERSAL,M.Type.NULL,!1,"")]),M.create(M.Class.UNIVERSAL,M.Type.OCTETSTRING,!1,D.getBytes())]),M.create(M.Class.UNIVERSAL,M.Type.OCTETSTRING,!1,E.getBytes()),M.create(M.Class.UNIVERSAL,M.Type.INTEGER,!1,M.integerToDer(x).getBytes())])}return M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.INTEGER,!1,M.integerToDer(3).getBytes()),M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(me.oids.data).getBytes()),M.create(M.Class.CONTEXT_SPECIFIC,0,!0,[M.create(M.Class.UNIVERSAL,M.Type.OCTETSTRING,!1,M.toDer(b).getBytes())])]),w])},gr.generateKey=ke.pbe.generatePkcs12Key;var Rt=_e,wi=Rt.asn1,rr=Rt.pki=Rt.pki||{};rr.pemToDer=function(e){var t=Rt.pem.decode(e)[0];if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert PEM to DER; PEM is encrypted.");return Rt.util.createBuffer(t.body)},rr.privateKeyFromPem=function(e){var t=Rt.pem.decode(e)[0];if(t.type!=="PRIVATE KEY"&&t.type!=="RSA PRIVATE KEY"){var i=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw i.headerType=t.type,i}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert private key from PEM; PEM is encrypted.");var r=wi.fromDer(t.body);return rr.privateKeyFromAsn1(r)},rr.privateKeyToPem=function(e,t){var i={type:"RSA PRIVATE KEY",body:wi.toDer(rr.privateKeyToAsn1(e)).getBytes()};return Rt.pem.encode(i,{maxline:t})},rr.privateKeyInfoToPem=function(e,t){var i={type:"PRIVATE KEY",body:wi.toDer(e).getBytes()};return Rt.pem.encode(i,{maxline:t})};var J=_e,qr=function(e,t,i,r){var n=J.util.createBuffer(),c=e.length>>1,a=c+(e.length&1),s=e.substr(0,a),l=e.substr(c,a),o=J.util.createBuffer(),f=J.hmac.create();i=t+i;var u=Math.ceil(r/16),g=Math.ceil(r/20);f.start("MD5",s);var _=J.util.createBuffer();o.putBytes(i);for(var y=0;y<u;++y)f.start(null,null),f.update(o.getBytes()),o.putBuffer(f.digest()),f.start(null,null),f.update(o.bytes()+i),_.putBuffer(f.digest());f.start("SHA1",l);var m=J.util.createBuffer();o.clear(),o.putBytes(i);for(var y=0;y<g;++y)f.start(null,null),f.update(o.getBytes()),o.putBuffer(f.digest()),f.start(null,null),f.update(o.bytes()+i),m.putBuffer(f.digest());return n.putBytes(J.util.xorBytes(_.getBytes(),m.getBytes(),r)),n},Ll=function(e,t,i){var r=J.hmac.create();r.start("SHA1",e);var n=J.util.createBuffer();return n.putInt32(t[0]),n.putInt32(t[1]),n.putByte(i.type),n.putByte(i.version.major),n.putByte(i.version.minor),n.putInt16(i.length),n.putBytes(i.fragment.bytes()),r.update(n.getBytes()),r.digest().getBytes()},kl=function(e,t,i){var r=!1;try{var n=e.deflate(t.fragment.getBytes());t.fragment=J.util.createBuffer(n),t.length=n.length,r=!0}catch(c){}return r},Rl=function(e,t,i){var r=!1;try{var n=e.inflate(t.fragment.getBytes());t.fragment=J.util.createBuffer(n),t.length=n.length,r=!0}catch(c){}return r},rt=function(e,t){var i=0;switch(t){case 1:i=e.getByte();break;case 2:i=e.getInt16();break;case 3:i=e.getInt24();break;case 4:i=e.getInt32();break}return J.util.createBuffer(e.getBytes(i))},ot=function(e,t,i){e.putInt(i.length(),t<<3),e.putBuffer(i)},B={};B.Versions={TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}},B.SupportedVersions=[B.Versions.TLS_1_1,B.Versions.TLS_1_0],B.Version=B.SupportedVersions[0],B.MaxFragment=16384-1024,B.ConnectionEnd={server:0,client:1},B.PRFAlgorithm={tls_prf_sha256:0},B.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},B.CipherType={stream:0,block:1,aead:2},B.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},B.CompressionMethod={none:0,deflate:1},B.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24},B.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20},B.Alert={},B.Alert.Level={warning:1,fatal:2},B.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100},B.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2},B.CipherSuites={},B.getCipherSuite=function(e){var t=null;for(var i in B.CipherSuites){var r=B.CipherSuites[i];if(r.id[0]===e.charCodeAt(0)&&r.id[1]===e.charCodeAt(1)){t=r;break}}return t},B.handleUnexpected=function(e,t){var i=!e.open&&e.entity===B.ConnectionEnd.client;i||e.error(e,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.unexpected_message}})},B.handleHelloRequest=function(e,t,i){!e.handshaking&&e.handshakes>0&&(B.queue(e,B.createAlert(e,{level:B.Alert.Level.warning,description:B.Alert.Description.no_renegotiation})),B.flush(e)),e.process()},B.parseHelloMessage=function(e,t,i){var r=null,n=e.entity===B.ConnectionEnd.client;if(i<38)e.error(e,{message:n?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.illegal_parameter}});else{var c=t.fragment,a=c.length();if(r={version:{major:c.getByte(),minor:c.getByte()},random:J.util.createBuffer(c.getBytes(32)),session_id:rt(c,1),extensions:[]},n?(r.cipher_suite=c.getBytes(2),r.compression_method=c.getByte()):(r.cipher_suites=rt(c,2),r.compression_methods=rt(c,1)),a=i-(a-c.length()),a>0){for(var s=rt(c,2);s.length()>0;)r.extensions.push({type:[s.getByte(),s.getByte()],data:rt(s,2)});if(!n)for(var l=0;l<r.extensions.length;++l){var o=r.extensions[l];if(o.type[0]===0&&o.type[1]===0)for(var f=rt(o.data,2);f.length()>0;){var u=f.getByte();if(u!==0)break;e.session.extensions.server_name.serverNameList.push(rt(f,2).getBytes())}}}if(e.session.version&&(r.version.major!==e.session.version.major||r.version.minor!==e.session.version.minor))return e.error(e,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.protocol_version}});if(n)e.session.cipherSuite=B.getCipherSuite(r.cipher_suite);else for(var g=J.util.createBuffer(r.cipher_suites.bytes());g.length()>0&&(e.session.cipherSuite=B.getCipherSuite(g.getBytes(2)),e.session.cipherSuite===null););if(e.session.cipherSuite===null)return e.error(e,{message:"No cipher suites in common.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.handshake_failure},cipherSuite:J.util.bytesToHex(r.cipher_suite)});n?e.session.compressionMethod=r.compression_method:e.session.compressionMethod=B.CompressionMethod.none}return r},B.createSecurityParameters=function(e,t){var i=e.entity===B.ConnectionEnd.client,r=t.random.bytes(),n=i?e.session.sp.client_random:r,c=i?r:B.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:B.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:n,server_random:c}},B.handleServerHello=function(e,t,i){var r=B.parseHelloMessage(e,t,i);if(!e.fail){if(r.version.minor<=e.version.minor)e.version.minor=r.version.minor;else return e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.protocol_version}});e.session.version=e.version;var n=r.session_id.bytes();n.length>0&&n===e.session.id?(e.expect=Xs,e.session.resuming=!0,e.session.sp.server_random=r.random.bytes()):(e.expect=Pl,e.session.resuming=!1,B.createSecurityParameters(e,r)),e.session.id=n,e.process()}},B.handleClientHello=function(e,t,i){var r=B.parseHelloMessage(e,t,i);if(!e.fail){var n=r.session_id.bytes(),c=null;if(e.sessionCache&&(c=e.sessionCache.getSession(n),c===null?n="":(c.version.major!==r.version.major||c.version.minor>r.version.minor)&&(c=null,n="")),n.length===0&&(n=J.random.getBytes(32)),e.session.id=n,e.session.clientHelloVersion=r.version,e.session.sp={},c)e.version=e.session.version=c.version,e.session.sp=c.sp;else{for(var a,s=1;s<B.SupportedVersions.length&&(a=B.SupportedVersions[s],!(a.minor<=r.version.minor));++s);e.version={major:a.major,minor:a.minor},e.session.version=e.version}c!==null?(e.expect=Ai,e.session.resuming=!0,e.session.sp.client_random=r.random.bytes()):(e.expect=e.verifyClient!==!1?Vl:Ti,e.session.resuming=!1,B.createSecurityParameters(e,r)),e.open=!0,B.queue(e,B.createRecord(e,{type:B.ContentType.handshake,data:B.createServerHello(e)})),e.session.resuming?(B.queue(e,B.createRecord(e,{type:B.ContentType.change_cipher_spec,data:B.createChangeCipherSpec()})),e.state.pending=B.createConnectionState(e),e.state.current.write=e.state.pending.write,B.queue(e,B.createRecord(e,{type:B.ContentType.handshake,data:B.createFinished(e)}))):(B.queue(e,B.createRecord(e,{type:B.ContentType.handshake,data:B.createCertificate(e)})),e.fail||(B.queue(e,B.createRecord(e,{type:B.ContentType.handshake,data:B.createServerKeyExchange(e)})),e.verifyClient!==!1&&B.queue(e,B.createRecord(e,{type:B.ContentType.handshake,data:B.createCertificateRequest(e)})),B.queue(e,B.createRecord(e,{type:B.ContentType.handshake,data:B.createServerHelloDone(e)})))),B.flush(e),e.process()}},B.handleCertificate=function(e,t,i){if(i<3)return e.error(e,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.illegal_parameter}});var r=t.fragment,n={certificate_list:rt(r,3)},c,a,s=[];try{for(;n.certificate_list.length()>0;)c=rt(n.certificate_list,3),a=J.asn1.fromDer(c),c=J.pki.certificateFromAsn1(a,!0),s.push(c)}catch(o){return e.error(e,{message:"Could not parse certificate list.",cause:o,send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.bad_certificate}})}var l=e.entity===B.ConnectionEnd.client;(l||e.verifyClient===!0)&&s.length===0?e.error(e,{message:l?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.illegal_parameter}}):s.length===0?e.expect=l?Ys:Ti:(l?e.session.serverCertificate=s[0]:e.session.clientCertificate=s[0],B.verifyCertificateChain(e,s)&&(e.expect=l?Ys:Ti)),e.process()},B.handleServerKeyExchange=function(e,t,i){if(i>0)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.unsupported_certificate}});e.expect=Nl,e.process()},B.handleClientKeyExchange=function(e,t,i){if(i<48)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.unsupported_certificate}});var r=t.fragment,n={enc_pre_master_secret:rt(r,2).getBytes()},c=null;if(e.getPrivateKey)try{c=e.getPrivateKey(e,e.session.serverCertificate),c=J.pki.privateKeyFromPem(c)}catch(l){e.error(e,{message:"Could not get private key.",cause:l,send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.internal_error}})}if(c===null)return e.error(e,{message:"No private key set.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.internal_error}});try{var a=e.session.sp;a.pre_master_secret=c.decrypt(n.enc_pre_master_secret);var s=e.session.clientHelloVersion;if(s.major!==a.pre_master_secret.charCodeAt(0)||s.minor!==a.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch(l){a.pre_master_secret=J.random.getBytes(48)}e.expect=Ai,e.session.clientCertificate!==null&&(e.expect=Kl),e.process()},B.handleCertificateRequest=function(e,t,i){if(i<3)return e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.illegal_parameter}});var r=t.fragment,n={certificate_types:rt(r,1),certificate_authorities:rt(r,2)};e.session.certificateRequest=n,e.expect=Ol,e.process()},B.handleCertificateVerify=function(e,t,i){if(i<2)return e.error(e,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.illegal_parameter}});var r=t.fragment;r.read-=4;var n=r.bytes();r.read+=4;var c={signature:rt(r,2).getBytes()},a=J.util.createBuffer();a.putBuffer(e.session.md5.digest()),a.putBuffer(e.session.sha1.digest()),a=a.getBytes();try{var s=e.session.clientCertificate;if(!s.publicKey.verify(a,c.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");e.session.md5.update(n),e.session.sha1.update(n)}catch(l){return e.error(e,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.handshake_failure}})}e.expect=Ai,e.process()},B.handleServerHelloDone=function(e,t,i){if(i>0)return e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.record_overflow}});if(e.serverCertificate===null){var r={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.insufficient_security}},n=0,c=e.verify(e,r.alert.description,n,[]);if(c!==!0)return(c||c===0)&&(typeof c=="object"&&!J.util.isArray(c)?(c.message&&(r.message=c.message),c.alert&&(r.alert.description=c.alert)):typeof c=="number"&&(r.alert.description=c)),e.error(e,r)}e.session.certificateRequest!==null&&(t=B.createRecord(e,{type:B.ContentType.handshake,data:B.createCertificate(e)}),B.queue(e,t)),t=B.createRecord(e,{type:B.ContentType.handshake,data:B.createClientKeyExchange(e)}),B.queue(e,t),e.expect=Fl;var a=function(s,l){s.session.certificateRequest!==null&&s.session.clientCertificate!==null&&B.queue(s,B.createRecord(s,{type:B.ContentType.handshake,data:B.createCertificateVerify(s,l)})),B.queue(s,B.createRecord(s,{type:B.ContentType.change_cipher_spec,data:B.createChangeCipherSpec()})),s.state.pending=B.createConnectionState(s),s.state.current.write=s.state.pending.write,B.queue(s,B.createRecord(s,{type:B.ContentType.handshake,data:B.createFinished(s)})),s.expect=Xs,B.flush(s),s.process()};if(e.session.certificateRequest===null||e.session.clientCertificate===null)return a(e,null);B.getClientSignature(e,a)},B.handleChangeCipherSpec=function(e,t){if(t.fragment.getByte()!==1)return e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.illegal_parameter}});var i=e.entity===B.ConnectionEnd.client;(e.session.resuming&&i||!e.session.resuming&&!i)&&(e.state.pending=B.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&i||e.session.resuming&&!i)&&(e.state.pending=null),e.expect=i?Ml:Wl,e.process()},B.handleFinished=function(e,t,i){var r=t.fragment;r.read-=4;var n=r.bytes();r.read+=4;var c=t.fragment.getBytes();r=J.util.createBuffer(),r.putBuffer(e.session.md5.digest()),r.putBuffer(e.session.sha1.digest());var a=e.entity===B.ConnectionEnd.client,s=a?"server finished":"client finished",l=e.session.sp,o=12,f=qr;if(r=f(l.master_secret,s,r.getBytes(),o),r.getBytes()!==c)return e.error(e,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.decrypt_error}});e.session.md5.update(n),e.session.sha1.update(n),(e.session.resuming&&a||!e.session.resuming&&!a)&&(B.queue(e,B.createRecord(e,{type:B.ContentType.change_cipher_spec,data:B.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,B.queue(e,B.createRecord(e,{type:B.ContentType.handshake,data:B.createFinished(e)}))),e.expect=a?Ul:zl,e.handshaking=!1,++e.handshakes,e.peerCertificate=a?e.session.serverCertificate:e.session.clientCertificate,B.flush(e),e.isConnected=!0,e.connected(e),e.process()},B.handleAlert=function(e,t){var i=t.fragment,r={level:i.getByte(),description:i.getByte()},n;switch(r.description){case B.Alert.Description.close_notify:n="Connection closed.";break;case B.Alert.Description.unexpected_message:n="Unexpected message.";break;case B.Alert.Description.bad_record_mac:n="Bad record MAC.";break;case B.Alert.Description.decryption_failed:n="Decryption failed.";break;case B.Alert.Description.record_overflow:n="Record overflow.";break;case B.Alert.Description.decompression_failure:n="Decompression failed.";break;case B.Alert.Description.handshake_failure:n="Handshake failure.";break;case B.Alert.Description.bad_certificate:n="Bad certificate.";break;case B.Alert.Description.unsupported_certificate:n="Unsupported certificate.";break;case B.Alert.Description.certificate_revoked:n="Certificate revoked.";break;case B.Alert.Description.certificate_expired:n="Certificate expired.";break;case B.Alert.Description.certificate_unknown:n="Certificate unknown.";break;case B.Alert.Description.illegal_parameter:n="Illegal parameter.";break;case B.Alert.Description.unknown_ca:n="Unknown certificate authority.";break;case B.Alert.Description.access_denied:n="Access denied.";break;case B.Alert.Description.decode_error:n="Decode error.";break;case B.Alert.Description.decrypt_error:n="Decrypt error.";break;case B.Alert.Description.export_restriction:n="Export restriction.";break;case B.Alert.Description.protocol_version:n="Unsupported protocol version.";break;case B.Alert.Description.insufficient_security:n="Insufficient security.";break;case B.Alert.Description.internal_error:n="Internal error.";break;case B.Alert.Description.user_canceled:n="User canceled.";break;case B.Alert.Description.no_renegotiation:n="Renegotiation not supported.";break;default:n="Unknown error.";break}if(r.description===B.Alert.Description.close_notify)return e.close();e.error(e,{message:n,send:!1,origin:e.entity===B.ConnectionEnd.client?"server":"client",alert:r}),e.process()},B.handleHandshake=function(e,t){var i=t.fragment,r=i.getByte(),n=i.getInt24();if(n>i.length())return e.fragmented=t,t.fragment=J.util.createBuffer(),i.read-=4,e.process();e.fragmented=null,i.read-=4;var c=i.bytes(n+4);i.read+=4,r in jr[e.entity][e.expect]?(e.entity===B.ConnectionEnd.server&&!e.open&&!e.fail&&(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:J.md.md5.create(),sha1:J.md.sha1.create()}),r!==B.HandshakeType.hello_request&&r!==B.HandshakeType.certificate_verify&&r!==B.HandshakeType.finished&&(e.session.md5.update(c),e.session.sha1.update(c)),jr[e.entity][e.expect][r](e,t,n)):B.handleUnexpected(e,t)},B.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()},B.handleHeartbeat=function(e,t){var i=t.fragment,r=i.getByte(),n=i.getInt16(),c=i.getBytes(n);if(r===B.HeartbeatMessageType.heartbeat_request){if(e.handshaking||n>c.length)return e.process();B.queue(e,B.createRecord(e,{type:B.ContentType.heartbeat,data:B.createHeartbeat(B.HeartbeatMessageType.heartbeat_response,c)})),B.flush(e)}else if(r===B.HeartbeatMessageType.heartbeat_response){if(c!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,J.util.createBuffer(c))}e.process()};var Dl=0,Pl=1,Ys=2,Nl=3,Ol=4,Xs=5,Ml=6,Ul=7,Fl=8,Hl=0,Vl=1,Ti=2,Kl=3,Ai=4,Wl=5,zl=6,A=B.handleUnexpected,Zs=B.handleChangeCipherSpec,qe=B.handleAlert,Xe=B.handleHandshake,Js=B.handleApplicationData,Ge=B.handleHeartbeat,Bi=[];Bi[B.ConnectionEnd.client]=[[A,qe,Xe,A,Ge],[A,qe,Xe,A,Ge],[A,qe,Xe,A,Ge],[A,qe,Xe,A,Ge],[A,qe,Xe,A,Ge],[Zs,qe,A,A,Ge],[A,qe,Xe,A,Ge],[A,qe,Xe,Js,Ge],[A,qe,Xe,A,Ge]],Bi[B.ConnectionEnd.server]=[[A,qe,Xe,A,Ge],[A,qe,Xe,A,Ge],[A,qe,Xe,A,Ge],[A,qe,Xe,A,Ge],[Zs,qe,A,A,Ge],[A,qe,Xe,A,Ge],[A,qe,Xe,Js,Ge],[A,qe,Xe,A,Ge]];var Dt=B.handleHelloRequest,$l=B.handleServerHello,en=B.handleCertificate,tn=B.handleServerKeyExchange,Ii=B.handleCertificateRequest,Gr=B.handleServerHelloDone,rn=B.handleFinished,jr=[];jr[B.ConnectionEnd.client]=[[A,A,$l,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],[Dt,A,A,A,A,A,A,A,A,A,A,en,tn,Ii,Gr,A,A,A,A,A,A],[Dt,A,A,A,A,A,A,A,A,A,A,A,tn,Ii,Gr,A,A,A,A,A,A],[Dt,A,A,A,A,A,A,A,A,A,A,A,A,Ii,Gr,A,A,A,A,A,A],[Dt,A,A,A,A,A,A,A,A,A,A,A,A,A,Gr,A,A,A,A,A,A],[Dt,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],[Dt,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,rn],[Dt,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],[Dt,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A]];var ql=B.handleClientHello,Gl=B.handleClientKeyExchange,jl=B.handleCertificateVerify;jr[B.ConnectionEnd.server]=[[A,ql,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],[A,A,A,A,A,A,A,A,A,A,A,en,A,A,A,A,A,A,A,A,A],[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,Gl,A,A,A,A],[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,jl,A,A,A,A,A],[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,rn],[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A]],B.generateKeys=function(e,t){var i=qr,r=t.client_random+t.server_random;e.session.resuming||(t.master_secret=i(t.pre_master_secret,"master secret",r,48).bytes(),t.pre_master_secret=null),r=t.server_random+t.client_random;var n=2*t.mac_key_length+2*t.enc_key_length,c=e.version.major===B.Versions.TLS_1_0.major&&e.version.minor===B.Versions.TLS_1_0.minor;c&&(n+=2*t.fixed_iv_length);var a=i(t.master_secret,"key expansion",r,n),s={client_write_MAC_key:a.getBytes(t.mac_key_length),server_write_MAC_key:a.getBytes(t.mac_key_length),client_write_key:a.getBytes(t.enc_key_length),server_write_key:a.getBytes(t.enc_key_length)};return c&&(s.client_write_IV=a.getBytes(t.fixed_iv_length),s.server_write_IV=a.getBytes(t.fixed_iv_length)),s},B.createConnectionState=function(e){var t=e.entity===B.ConnectionEnd.client,i=function(){var c={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(a){return!0},compressionState:null,compressFunction:function(a){return!0},updateSequenceNumber:function(){c.sequenceNumber[1]===4294967295?(c.sequenceNumber[1]=0,++c.sequenceNumber[0]):++c.sequenceNumber[1]}};return c},r={read:i(),write:i()};if(r.read.update=function(c,a){return r.read.cipherFunction(a,r.read)?r.read.compressFunction(c,a,r.read)||c.error(c,{message:"Could not decompress record.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.decompression_failure}}):c.error(c,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.bad_record_mac}}),!c.fail},r.write.update=function(c,a){return r.write.compressFunction(c,a,r.write)?r.write.cipherFunction(a,r.write)||c.error(c,{message:"Could not encrypt record.",send:!1,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.internal_error}}):c.error(c,{message:"Could not compress record.",send:!1,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.internal_error}}),!c.fail},e.session){var n=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(n),n.keys=B.generateKeys(e,n),r.read.macKey=t?n.keys.server_write_MAC_key:n.keys.client_write_MAC_key,r.write.macKey=t?n.keys.client_write_MAC_key:n.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(r,e,n),n.compression_algorithm){case B.CompressionMethod.none:break;case B.CompressionMethod.deflate:r.read.compressFunction=Rl,r.write.compressFunction=kl;break;default:throw new Error("Unsupported compression algorithm.")}}return r},B.createRandom=function(){var e=new Date,t=+e+e.getTimezoneOffset()*6e4,i=J.util.createBuffer();return i.putInt32(t),i.putBytes(J.random.getBytes(28)),i},B.createRecord=function(e,t){if(!t.data)return null;var i={type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data};return i},B.createAlert=function(e,t){var i=J.util.createBuffer();return i.putByte(t.level),i.putByte(t.description),B.createRecord(e,{type:B.ContentType.alert,data:i})},B.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=J.util.createBuffer(),i=0;i<e.cipherSuites.length;++i){var r=e.cipherSuites[i];t.putByte(r.id[0]),t.putByte(r.id[1])}var n=t.length(),c=J.util.createBuffer();c.putByte(B.CompressionMethod.none);var a=c.length(),s=J.util.createBuffer();if(e.virtualHost){var l=J.util.createBuffer();l.putByte(0),l.putByte(0);var o=J.util.createBuffer();o.putByte(0),ot(o,2,J.util.createBuffer(e.virtualHost));var f=J.util.createBuffer();ot(f,2,o),ot(l,2,f),s.putBuffer(l)}var u=s.length();u>0&&(u+=2);var g=e.session.id,_=g.length+1+2+4+28+2+n+1+a+u,y=J.util.createBuffer();return y.putByte(B.HandshakeType.client_hello),y.putInt24(_),y.putByte(e.version.major),y.putByte(e.version.minor),y.putBytes(e.session.sp.client_random),ot(y,1,J.util.createBuffer(g)),ot(y,2,t),ot(y,1,c),u>0&&ot(y,2,s),y},B.createServerHello=function(e){var t=e.session.id,i=t.length+1+2+4+28+2+1,r=J.util.createBuffer();return r.putByte(B.HandshakeType.server_hello),r.putInt24(i),r.putByte(e.version.major),r.putByte(e.version.minor),r.putBytes(e.session.sp.server_random),ot(r,1,J.util.createBuffer(t)),r.putByte(e.session.cipherSuite.id[0]),r.putByte(e.session.cipherSuite.id[1]),r.putByte(e.session.compressionMethod),r},B.createCertificate=function(e){var t=e.entity===B.ConnectionEnd.client,i=null;if(e.getCertificate){var r;t?r=e.session.certificateRequest:r=e.session.extensions.server_name.serverNameList,i=e.getCertificate(e,r)}var n=J.util.createBuffer();if(i!==null)try{J.util.isArray(i)||(i=[i]);for(var c=null,a=0;a<i.length;++a){var s=J.pem.decode(i[a])[0];if(s.type!=="CERTIFICATE"&&s.type!=="X509 CERTIFICATE"&&s.type!=="TRUSTED CERTIFICATE"){var l=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw l.headerType=s.type,l}if(s.procType&&s.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var o=J.util.createBuffer(s.body);c===null&&(c=J.asn1.fromDer(o.bytes(),!1));var f=J.util.createBuffer();ot(f,3,o),n.putBuffer(f)}i=J.pki.certificateFromAsn1(c),t?e.session.clientCertificate=i:e.session.serverCertificate=i}catch(_){return e.error(e,{message:"Could not send certificate list.",cause:_,send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.bad_certificate}})}var u=3+n.length(),g=J.util.createBuffer();return g.putByte(B.HandshakeType.certificate),g.putInt24(u),ot(g,3,n),g},B.createClientKeyExchange=function(e){var t=J.util.createBuffer();t.putByte(e.session.clientHelloVersion.major),t.putByte(e.session.clientHelloVersion.minor),t.putBytes(J.random.getBytes(46));var i=e.session.sp;i.pre_master_secret=t.getBytes();var r=e.session.serverCertificate.publicKey;t=r.encrypt(i.pre_master_secret);var n=t.length+2,c=J.util.createBuffer();return c.putByte(B.HandshakeType.client_key_exchange),c.putInt24(n),c.putInt16(t.length),c.putBytes(t),c},B.createServerKeyExchange=function(e){var t=J.util.createBuffer();return t},B.getClientSignature=function(e,t){var i=J.util.createBuffer();i.putBuffer(e.session.md5.digest()),i.putBuffer(e.session.sha1.digest()),i=i.getBytes(),e.getSignature=e.getSignature||function(r,n,c){var a=null;if(r.getPrivateKey)try{a=r.getPrivateKey(r,r.session.clientCertificate),a=J.pki.privateKeyFromPem(a)}catch(s){r.error(r,{message:"Could not get private key.",cause:s,send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.internal_error}})}a===null?r.error(r,{message:"No private key set.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.internal_error}}):n=a.sign(n,null),c(r,n)},e.getSignature(e,i,t)},B.createCertificateVerify=function(e,t){var i=t.length+2,r=J.util.createBuffer();return r.putByte(B.HandshakeType.certificate_verify),r.putInt24(i),r.putInt16(t.length),r.putBytes(t),r},B.createCertificateRequest=function(e){var t=J.util.createBuffer();t.putByte(1);var i=J.util.createBuffer();for(var r in e.caStore.certs){var n=e.caStore.certs[r],c=J.pki.distinguishedNameToAsn1(n.subject),a=J.asn1.toDer(c);i.putInt16(a.length()),i.putBuffer(a)}var s=1+t.length()+2+i.length(),l=J.util.createBuffer();return l.putByte(B.HandshakeType.certificate_request),l.putInt24(s),ot(l,1,t),ot(l,2,i),l},B.createServerHelloDone=function(e){var t=J.util.createBuffer();return t.putByte(B.HandshakeType.server_hello_done),t.putInt24(0),t},B.createChangeCipherSpec=function(){var e=J.util.createBuffer();return e.putByte(1),e},B.createFinished=function(e){var t=J.util.createBuffer();t.putBuffer(e.session.md5.digest()),t.putBuffer(e.session.sha1.digest());var i=e.entity===B.ConnectionEnd.client,r=e.session.sp,n=12,c=qr,a=i?"client finished":"server finished";t=c(r.master_secret,a,t.getBytes(),n);var s=J.util.createBuffer();return s.putByte(B.HandshakeType.finished),s.putInt24(t.length()),s.putBuffer(t),s},B.createHeartbeat=function(e,t,i){typeof i=="undefined"&&(i=t.length);var r=J.util.createBuffer();r.putByte(e),r.putInt16(i),r.putBytes(t);var n=r.length(),c=Math.max(16,n-i-3);return r.putBytes(J.random.getBytes(c)),r},B.queue=function(e,t){if(t&&!(t.fragment.length()===0&&(t.type===B.ContentType.handshake||t.type===B.ContentType.alert||t.type===B.ContentType.change_cipher_spec))){if(t.type===B.ContentType.handshake){var i=t.fragment.bytes();e.session.md5.update(i),e.session.sha1.update(i),i=null}var r;if(t.fragment.length()<=B.MaxFragment)r=[t];else{r=[];for(var n=t.fragment.bytes();n.length>B.MaxFragment;)r.push(B.createRecord(e,{type:t.type,data:J.util.createBuffer(n.slice(0,B.MaxFragment))})),n=n.slice(B.MaxFragment);n.length>0&&r.push(B.createRecord(e,{type:t.type,data:J.util.createBuffer(n)}))}for(var c=0;c<r.length&&!e.fail;++c){var a=r[c],s=e.state.current.write;s.update(e,a)&&e.records.push(a)}}},B.flush=function(e){for(var t=0;t<e.records.length;++t){var i=e.records[t];e.tlsData.putByte(i.type),e.tlsData.putByte(i.version.major),e.tlsData.putByte(i.version.minor),e.tlsData.putInt16(i.fragment.length()),e.tlsData.putBuffer(e.records[t].fragment)}return e.records=[],e.tlsDataReady(e)};var Li=function(e){switch(e){case!0:return!0;case J.pki.certificateError.bad_certificate:return B.Alert.Description.bad_certificate;case J.pki.certificateError.unsupported_certificate:return B.Alert.Description.unsupported_certificate;case J.pki.certificateError.certificate_revoked:return B.Alert.Description.certificate_revoked;case J.pki.certificateError.certificate_expired:return B.Alert.Description.certificate_expired;case J.pki.certificateError.certificate_unknown:return B.Alert.Description.certificate_unknown;case J.pki.certificateError.unknown_ca:return B.Alert.Description.unknown_ca;default:return B.Alert.Description.bad_certificate}},Ql=function(e){switch(e){case!0:return!0;case B.Alert.Description.bad_certificate:return J.pki.certificateError.bad_certificate;case B.Alert.Description.unsupported_certificate:return J.pki.certificateError.unsupported_certificate;case B.Alert.Description.certificate_revoked:return J.pki.certificateError.certificate_revoked;case B.Alert.Description.certificate_expired:return J.pki.certificateError.certificate_expired;case B.Alert.Description.certificate_unknown:return J.pki.certificateError.certificate_unknown;case B.Alert.Description.unknown_ca:return J.pki.certificateError.unknown_ca;default:return J.pki.certificateError.bad_certificate}};B.verifyCertificateChain=function(e,t){try{var i={};for(var r in e.verifyOptions)i[r]=e.verifyOptions[r];i.verify=function(c,a,s){var l=Li(c),o=e.verify(e,c,a,s);if(o!==!0){if(typeof o=="object"&&!J.util.isArray(o)){var f=new Error("The application rejected the certificate.");throw f.send=!0,f.alert={level:B.Alert.Level.fatal,description:B.Alert.Description.bad_certificate},o.message&&(f.message=o.message),o.alert&&(f.alert.description=o.alert),f}o!==c&&(o=Ql(o))}return o},J.pki.verifyCertificateChain(e.caStore,t,i)}catch(c){var n=c;(typeof n!="object"||J.util.isArray(n))&&(n={send:!0,alert:{level:B.Alert.Level.fatal,description:Li(c)}}),"send"in n||(n.send=!0),"alert"in n||(n.alert={level:B.Alert.Level.fatal,description:Li(n.error)}),e.error(e,n)}return!e.fail},B.createSessionCache=function(e,t){var i=null;if(e&&e.getSession&&e.setSession&&e.order)i=e;else{i={},i.cache=e||{},i.capacity=Math.max(t||100,1),i.order=[];for(var r in e)i.order.length<=t?i.order.push(r):delete e[r];i.getSession=function(n){var c=null,a=null;if(n?a=J.util.bytesToHex(n):i.order.length>0&&(a=i.order[0]),a!==null&&a in i.cache){c=i.cache[a],delete i.cache[a];for(var s in i.order)if(i.order[s]===a){i.order.splice(s,1);break}}return c},i.setSession=function(n,c){if(i.order.length===i.capacity){var a=i.order.shift();delete i.cache[a]}var a=J.util.bytesToHex(n);i.order.push(a),i.cache[a]=c}}return i},B.createConnection=function(e){var t=null;e.caStore?J.util.isArray(e.caStore)?t=J.pki.createCaStore(e.caStore):t=e.caStore:t=J.pki.createCaStore();var i=e.cipherSuites||null;if(i===null){i=[];for(var r in B.CipherSuites)i.push(B.CipherSuites[r])}var n=e.server?B.ConnectionEnd.server:B.ConnectionEnd.client,c=e.sessionCache?B.createSessionCache(e.sessionCache):null,a={version:{major:B.Version.major,minor:B.Version.minor},entity:n,sessionId:e.sessionId,caStore:t,sessionCache:c,cipherSuites:i,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(f,u,g,_){return u},verifyOptions:e.verifyOptions||{},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:J.util.createBuffer(),tlsData:J.util.createBuffer(),data:J.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(f,u){u.origin=u.origin||(f.entity===B.ConnectionEnd.client?"client":"server"),u.send&&(B.queue(f,B.createAlert(f,u.alert)),B.flush(f));var g=u.fatal!==!1;g&&(f.fail=!0),e.error(f,u),g&&f.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null};a.reset=function(f){a.version={major:B.Version.major,minor:B.Version.minor},a.record=null,a.session=null,a.peerCertificate=null,a.state={pending:null,current:null},a.expect=a.entity===B.ConnectionEnd.client?Dl:Hl,a.fragmented=null,a.records=[],a.open=!1,a.handshakes=0,a.handshaking=!1,a.isConnected=!1,a.fail=!(f||typeof f=="undefined"),a.input.clear(),a.tlsData.clear(),a.data.clear(),a.state.current=B.createConnectionState(a)},a.reset();var s=function(f,u){var g=u.type-B.ContentType.change_cipher_spec,_=Bi[f.entity][f.expect];g in _?_[g](f,u):B.handleUnexpected(f,u)},l=function(f){var u=0,g=f.input,_=g.length();if(_<5)u=5-_;else{f.record={type:g.getByte(),version:{major:g.getByte(),minor:g.getByte()},length:g.getInt16(),fragment:J.util.createBuffer(),ready:!1};var y=f.record.version.major===f.version.major;y&&f.session&&f.session.version&&(y=f.record.version.minor===f.version.minor),y||f.error(f,{message:"Incompatible TLS version.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.protocol_version}})}return u},o=function(f){var u=0,g=f.input,_=g.length();if(_<f.record.length)u=f.record.length-_;else{f.record.fragment.putBytes(g.getBytes(f.record.length)),g.compact();var y=f.state.current.read;y.update(f,f.record)&&(f.fragmented!==null&&(f.fragmented.type===f.record.type?(f.fragmented.fragment.putBuffer(f.record.fragment),f.record=f.fragmented):f.error(f,{message:"Invalid fragmented record.",send:!0,alert:{level:B.Alert.Level.fatal,description:B.Alert.Description.unexpected_message}})),f.record.ready=!0)}return u};return a.handshake=function(f){if(a.entity!==B.ConnectionEnd.client)a.error(a,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(a.handshaking)a.error(a,{message:"Handshake already in progress.",fatal:!1});else{a.fail&&!a.open&&a.handshakes===0&&(a.fail=!1),a.handshaking=!0,f=f||"";var u=null;f.length>0&&(a.sessionCache&&(u=a.sessionCache.getSession(f)),u===null&&(f="")),f.length===0&&a.sessionCache&&(u=a.sessionCache.getSession(),u!==null&&(f=u.id)),a.session={id:f,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:J.md.md5.create(),sha1:J.md.sha1.create()},u&&(a.version=u.version,a.session.sp=u.sp),a.session.sp.client_random=B.createRandom().getBytes(),a.open=!0,B.queue(a,B.createRecord(a,{type:B.ContentType.handshake,data:B.createClientHello(a)})),B.flush(a)}},a.process=function(f){var u=0;return f&&a.input.putBytes(f),a.fail||(a.record!==null&&a.record.ready&&a.record.fragment.isEmpty()&&(a.record=null),a.record===null&&(u=l(a)),!a.fail&&a.record!==null&&!a.record.ready&&(u=o(a)),!a.fail&&a.record!==null&&a.record.ready&&s(a,a.record)),u},a.prepare=function(f){return B.queue(a,B.createRecord(a,{type:B.ContentType.application_data,data:J.util.createBuffer(f)})),B.flush(a)},a.prepareHeartbeatRequest=function(f,u){return f instanceof J.util.ByteBuffer&&(f=f.bytes()),typeof u=="undefined"&&(u=f.length),a.expectedHeartbeatPayload=f,B.queue(a,B.createRecord(a,{type:B.ContentType.heartbeat,data:B.createHeartbeat(B.HeartbeatMessageType.heartbeat_request,f,u)})),B.flush(a)},a.close=function(f){if(!a.fail&&a.sessionCache&&a.session){var u={id:a.session.id,version:a.session.version,sp:a.session.sp};u.sp.keys=null,a.sessionCache.setSession(u.id,u)}a.open&&(a.open=!1,a.input.clear(),(a.isConnected||a.handshaking)&&(a.isConnected=a.handshaking=!1,B.queue(a,B.createAlert(a,{level:B.Alert.Level.warning,description:B.Alert.Description.close_notify})),B.flush(a)),a.closed(a)),a.reset(f)},a},J.tls=J.tls||{};for(var ki in B)typeof B[ki]!="function"&&(J.tls[ki]=B[ki]);J.tls.prf_tls1=qr,J.tls.hmac_sha1=Ll,J.tls.createSessionCache=B.createSessionCache,J.tls.createConnection=B.createConnection;var Pt=_e,lt=Pt.tls;lt.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=lt.BulkCipherAlgorithm.aes,e.cipher_type=lt.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=lt.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:sn},lt.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=lt.BulkCipherAlgorithm.aes,e.cipher_type=lt.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=lt.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:sn};function sn(e,t,i){var r=t.entity===Pt.tls.ConnectionEnd.client;e.read.cipherState={init:!1,cipher:Pt.cipher.createDecipher("AES-CBC",r?i.keys.server_write_key:i.keys.client_write_key),iv:r?i.keys.server_write_IV:i.keys.client_write_IV},e.write.cipherState={init:!1,cipher:Pt.cipher.createCipher("AES-CBC",r?i.keys.client_write_key:i.keys.server_write_key),iv:r?i.keys.client_write_IV:i.keys.server_write_IV},e.read.cipherFunction=Jl,e.write.cipherFunction=Yl,e.read.macLength=e.write.macLength=i.mac_length,e.read.macFunction=e.write.macFunction=lt.hmac_sha1}function Yl(e,t){var i=!1,r=t.macFunction(t.macKey,t.sequenceNumber,e);e.fragment.putBytes(r),t.updateSequenceNumber();var n;e.version.minor===lt.Versions.TLS_1_0.minor?n=t.cipherState.init?null:t.cipherState.iv:n=Pt.random.getBytesSync(16),t.cipherState.init=!0;var c=t.cipherState.cipher;return c.start({iv:n}),e.version.minor>=lt.Versions.TLS_1_1.minor&&c.output.putBytes(n),c.update(e.fragment),c.finish(Xl)&&(e.fragment=c.output,e.length=e.fragment.length(),i=!0),i}function Xl(e,t,i){if(!i){var r=e-t.length()%e;t.fillWithByte(r-1,r)}return!0}function Zl(e,t,i){var r=!0;if(i){for(var n=t.length(),c=t.last(),a=n-1-c;a<n-1;++a)r=r&&t.at(a)==c;r&&t.truncate(c+1)}return r}function Jl(e,t){var i=!1,r;e.version.minor===lt.Versions.TLS_1_0.minor?r=t.cipherState.init?null:t.cipherState.iv:r=e.fragment.getBytes(16),t.cipherState.init=!0;var n=t.cipherState.cipher;n.start({iv:r}),n.update(e.fragment),i=n.finish(Zl);var c=t.macLength,a=Pt.random.getBytesSync(c),s=n.output.length();s>=c?(e.fragment=n.output.getBytes(s-c),a=n.output.getBytes(c)):e.fragment=n.output.getBytes(),e.fragment=Pt.util.createBuffer(e.fragment),e.length=e.fragment.length();var l=t.macFunction(t.macKey,t.sequenceNumber,e);return t.updateSequenceNumber(),i=ec(t.macKey,a,l)&&i,i}function ec(e,t,i){var r=Pt.hmac.create();return r.start("SHA1",e),r.update(t),t=r.digest().getBytes(),r.start(null,null),r.update(i),i=r.digest().getBytes(),t===i}var De=_e,yr=De.sha512=De.sha512||{};De.md.sha512=De.md.algorithms.sha512=yr;var nn=De.sha384=De.sha512.sha384=De.sha512.sha384||{};nn.create=function(){return yr.create("SHA-384")},De.md.sha384=De.md.algorithms.sha384=nn,De.sha512.sha256=De.sha512.sha256||{create:function(){return yr.create("SHA-512/256")}},De.md["sha512/256"]=De.md.algorithms["sha512/256"]=De.sha512.sha256,De.sha512.sha224=De.sha512.sha224||{create:function(){return yr.create("SHA-512/224")}},De.md["sha512/224"]=De.md.algorithms["sha512/224"]=De.sha512.sha224,yr.create=function(e){if(an||tc(),typeof e=="undefined"&&(e="SHA-512"),!(e in $t))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=$t[e],i=null,r=De.util.createBuffer(),n=new Array(80),c=0;c<80;++c)n[c]=new Array(2);var a=64;switch(e){case"SHA-384":a=48;break;case"SHA-512/256":a=32;break;case"SHA-512/224":a=28;break}var s={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:a,messageLength:0,fullMessageLength:null,messageLengthSize:16};return s.start=function(){s.messageLength=0,s.fullMessageLength=s.messageLength128=[];for(var l=s.messageLengthSize/4,o=0;o<l;++o)s.fullMessageLength.push(0);r=De.util.createBuffer(),i=new Array(t.length);for(var o=0;o<t.length;++o)i[o]=t[o].slice(0);return s},s.start(),s.update=function(l,o){o==="utf8"&&(l=De.util.encodeUtf8(l));var f=l.length;s.messageLength+=f,f=[f/4294967296>>>0,f>>>0];for(var u=s.fullMessageLength.length-1;u>=0;--u)s.fullMessageLength[u]+=f[1],f[1]=f[0]+(s.fullMessageLength[u]/4294967296>>>0),s.fullMessageLength[u]=s.fullMessageLength[u]>>>0,f[0]=f[1]/4294967296>>>0;return r.putBytes(l),on(i,n,r),(r.read>2048||r.length()===0)&&r.compact(),s},s.digest=function(){var l=De.util.createBuffer();l.putBytes(r.bytes());var o=s.fullMessageLength[s.fullMessageLength.length-1]+s.messageLengthSize,f=o&s.blockLength-1;l.putBytes(Ri.substr(0,s.blockLength-f));for(var u,g,_=s.fullMessageLength[0]*8,y=0;y<s.fullMessageLength.length-1;++y)u=s.fullMessageLength[y+1]*8,g=u/4294967296>>>0,_+=g,l.putInt32(_>>>0),_=u>>>0;l.putInt32(_);for(var m=new Array(i.length),y=0;y<i.length;++y)m[y]=i[y].slice(0);on(m,n,l);var h=De.util.createBuffer(),d;e==="SHA-512"?d=m.length:e==="SHA-384"?d=m.length-2:d=m.length-4;for(var y=0;y<d;++y)h.putInt32(m[y][0]),(y!==d-1||e!=="SHA-512/224")&&h.putInt32(m[y][1]);return h},s};var Ri=null,an=!1,Di=null,$t=null;function tc(){Ri=String.fromCharCode(128),Ri+=De.util.fillString(String.fromCharCode(0),128),Di=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],$t={},$t["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],$t["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],$t["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],$t["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],an=!0}function on(e,t,i){for(var r,n,c,a,s,l,o,f,u,g,_,y,m,h,d,p,v,C,S,b,w,E,x,k,D,R,O,G,q,X,W,L,P,N,U,z=i.length();z>=128;){for(q=0;q<16;++q)t[q][0]=i.getInt32()>>>0,t[q][1]=i.getInt32()>>>0;for(;q<80;++q)L=t[q-2],X=L[0],W=L[1],r=((X>>>19|W<<13)^(W>>>29|X<<3)^X>>>6)>>>0,n=((X<<13|W>>>19)^(W<<3|X>>>29)^(X<<26|W>>>6))>>>0,N=t[q-15],X=N[0],W=N[1],c=((X>>>1|W<<31)^(X>>>8|W<<24)^X>>>7)>>>0,a=((X<<31|W>>>1)^(X<<24|W>>>8)^(X<<25|W>>>7))>>>0,P=t[q-7],U=t[q-16],W=n+P[1]+a+U[1],t[q][0]=r+P[0]+c+U[0]+(W/4294967296>>>0)>>>0,t[q][1]=W>>>0;for(m=e[0][0],h=e[0][1],d=e[1][0],p=e[1][1],v=e[2][0],C=e[2][1],S=e[3][0],b=e[3][1],w=e[4][0],E=e[4][1],x=e[5][0],k=e[5][1],D=e[6][0],R=e[6][1],O=e[7][0],G=e[7][1],q=0;q<80;++q)o=((w>>>14|E<<18)^(w>>>18|E<<14)^(E>>>9|w<<23))>>>0,f=((w<<18|E>>>14)^(w<<14|E>>>18)^(E<<23|w>>>9))>>>0,u=(D^w&(x^D))>>>0,g=(R^E&(k^R))>>>0,s=((m>>>28|h<<4)^(h>>>2|m<<30)^(h>>>7|m<<25))>>>0,l=((m<<4|h>>>28)^(h<<30|m>>>2)^(h<<25|m>>>7))>>>0,_=(m&d|v&(m^d))>>>0,y=(h&p|C&(h^p))>>>0,W=G+f+g+Di[q][1]+t[q][1],r=O+o+u+Di[q][0]+t[q][0]+(W/4294967296>>>0)>>>0,n=W>>>0,W=l+y,c=s+_+(W/4294967296>>>0)>>>0,a=W>>>0,O=D,G=R,D=x,R=k,x=w,k=E,W=b+n,w=S+r+(W/4294967296>>>0)>>>0,E=W>>>0,S=v,b=C,v=d,C=p,d=m,p=h,W=n+a,m=r+c+(W/4294967296>>>0)>>>0,h=W>>>0;W=e[0][1]+h,e[0][0]=e[0][0]+m+(W/4294967296>>>0)>>>0,e[0][1]=W>>>0,W=e[1][1]+p,e[1][0]=e[1][0]+d+(W/4294967296>>>0)>>>0,e[1][1]=W>>>0,W=e[2][1]+C,e[2][0]=e[2][0]+v+(W/4294967296>>>0)>>>0,e[2][1]=W>>>0,W=e[3][1]+b,e[3][0]=e[3][0]+S+(W/4294967296>>>0)>>>0,e[3][1]=W>>>0,W=e[4][1]+E,e[4][0]=e[4][0]+w+(W/4294967296>>>0)>>>0,e[4][1]=W>>>0,W=e[5][1]+k,e[5][0]=e[5][0]+x+(W/4294967296>>>0)>>>0,e[5][1]=W>>>0,W=e[6][1]+R,e[6][0]=e[6][0]+D+(W/4294967296>>>0)>>>0,e[6][1]=W>>>0,W=e[7][1]+G,e[7][0]=e[7][0]+O+(W/4294967296>>>0)>>>0,e[7][1]=W>>>0,z-=128}}var Pi={},rc=_e,$e=rc.asn1;Pi.privateKeyValidator={name:"PrivateKeyInfo",tagClass:$e.Class.UNIVERSAL,type:$e.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:$e.Class.UNIVERSAL,type:$e.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:$e.Class.UNIVERSAL,type:$e.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:$e.Class.UNIVERSAL,type:$e.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:$e.Class.UNIVERSAL,type:$e.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},Pi.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:$e.Class.UNIVERSAL,type:$e.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:$e.Class.UNIVERSAL,type:$e.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:$e.Class.UNIVERSAL,type:$e.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:$e.Class.UNIVERSAL,type:$e.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]};var je=_e,ln=Pi,ic=ln.publicKeyValidator,sc=ln.privateKeyValidator;if(typeof nc=="undefined")var nc=je.jsbn.BigInteger;var Ni=je.util.ByteBuffer,tt=typeof Buffer=="undefined"?Uint8Array:Buffer;je.pki=je.pki||{},je.pki.ed25519=je.ed25519=je.ed25519||{};var Ce=je.ed25519;Ce.constants={},Ce.constants.PUBLIC_KEY_BYTE_LENGTH=32,Ce.constants.PRIVATE_KEY_BYTE_LENGTH=64,Ce.constants.SEED_BYTE_LENGTH=32,Ce.constants.SIGN_BYTE_LENGTH=64,Ce.constants.HASH_BYTE_LENGTH=64,Ce.generateKeyPair=function(e){e=e||{};var t=e.seed;if(t===void 0)t=je.random.getBytesSync(Ce.constants.SEED_BYTE_LENGTH);else if(typeof t=="string"){if(t.length!==Ce.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+Ce.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(t instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');t=Tt({message:t,encoding:"binary"});for(var i=new tt(Ce.constants.PUBLIC_KEY_BYTE_LENGTH),r=new tt(Ce.constants.PRIVATE_KEY_BYTE_LENGTH),n=0;n<32;++n)r[n]=t[n];return cc(i,r),{publicKey:i,privateKey:r}},Ce.privateKeyFromAsn1=function(e){var t={},i=[],r=je.asn1.validate(e,sc,t,i);if(!r){var n=new Error("Invalid Key.");throw n.errors=i,n}var c=je.asn1.derToOid(t.privateKeyOid),a=je.oids.EdDSA25519;if(c!==a)throw new Error('Invalid OID "'+c+'"; OID must be "'+a+'".');var s=t.privateKey,l=Tt({message:je.asn1.fromDer(s).value,encoding:"binary"});return{privateKeyBytes:l}},Ce.publicKeyFromAsn1=function(e){var t={},i=[],r=je.asn1.validate(e,ic,t,i);if(!r){var n=new Error("Invalid Key.");throw n.errors=i,n}var c=je.asn1.derToOid(t.publicKeyOid),a=je.oids.EdDSA25519;if(c!==a)throw new Error('Invalid OID "'+c+'"; OID must be "'+a+'".');var s=t.ed25519PublicKey;if(s.length!==Ce.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return Tt({message:s,encoding:"binary"})},Ce.publicKeyFromPrivateKey=function(e){e=e||{};var t=Tt({message:e.privateKey,encoding:"binary"});if(t.length!==Ce.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+Ce.constants.PRIVATE_KEY_BYTE_LENGTH);for(var i=new tt(Ce.constants.PUBLIC_KEY_BYTE_LENGTH),r=0;r<i.length;++r)i[r]=t[32+r];return i},Ce.sign=function(e){e=e||{};var t=Tt(e),i=Tt({message:e.privateKey,encoding:"binary"});if(i.length===Ce.constants.SEED_BYTE_LENGTH){var r=Ce.generateKeyPair({seed:i});i=r.privateKey}else if(i.length!==Ce.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+Ce.constants.SEED_BYTE_LENGTH+" or "+Ce.constants.PRIVATE_KEY_BYTE_LENGTH);var n=new tt(Ce.constants.SIGN_BYTE_LENGTH+t.length);hc(n,t,t.length,i);for(var c=new tt(Ce.constants.SIGN_BYTE_LENGTH),a=0;a<c.length;++a)c[a]=n[a];return c},Ce.verify=function(e){e=e||{};var t=Tt(e);if(e.signature===void 0)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var i=Tt({message:e.signature,encoding:"binary"});if(i.length!==Ce.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+Ce.constants.SIGN_BYTE_LENGTH);var r=Tt({message:e.publicKey,encoding:"binary"});if(r.length!==Ce.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+Ce.constants.PUBLIC_KEY_BYTE_LENGTH);var n=new tt(Ce.constants.SIGN_BYTE_LENGTH+t.length),c=new tt(Ce.constants.SIGN_BYTE_LENGTH+t.length),a;for(a=0;a<Ce.constants.SIGN_BYTE_LENGTH;++a)n[a]=i[a];for(a=0;a<t.length;++a)n[a+Ce.constants.SIGN_BYTE_LENGTH]=t[a];return uc(c,n,n.length,r)>=0};function Tt(e){var t=e.message;if(t instanceof Uint8Array||t instanceof tt)return t;var i=e.encoding;if(t===void 0)if(e.md)t=e.md.digest().getBytes(),i="binary";else throw new TypeError('"options.message" or "options.md" not specified.');if(typeof t=="string"&&!i)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if(typeof t=="string"){if(typeof Buffer!="undefined")return Buffer.from(t,i);t=new Ni(t,i)}else if(!(t instanceof Ni))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var r=new tt(t.length()),n=0;n<r.length;++n)r[n]=t.at(n);return r}var Oi=fe(),Qr=fe([1]),ac=fe([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),oc=fe([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),cn=fe([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),hn=fe([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),Mi=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),lc=fe([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function mr(e,t){var i=je.md.sha512.create(),r=new Ni(e);i.update(r.getBytes(t),"binary");var n=i.digest().getBytes();if(typeof Buffer!="undefined")return Buffer.from(n,"binary");for(var c=new tt(Ce.constants.HASH_BYTE_LENGTH),a=0;a<64;++a)c[a]=n.charCodeAt(a);return c}function cc(e,t){var i=[fe(),fe(),fe(),fe()],r,n=mr(t,32);for(n[0]&=248,n[31]&=127,n[31]|=64,Vi(i,n),Hi(e,i),r=0;r<32;++r)t[r+32]=e[r];return 0}function hc(e,t,i,r){var n,c,a=new Float64Array(64),s=[fe(),fe(),fe(),fe()],l=mr(r,32);l[0]&=248,l[31]&=127,l[31]|=64;var o=i+64;for(n=0;n<i;++n)e[64+n]=t[n];for(n=0;n<32;++n)e[32+n]=l[32+n];var f=mr(e.subarray(32),i+32);for(Ui(f),Vi(s,f),Hi(e,s),n=32;n<64;++n)e[n]=r[n];var u=mr(e,i+64);for(Ui(u),n=32;n<64;++n)a[n]=0;for(n=0;n<32;++n)a[n]=f[n];for(n=0;n<32;++n)for(c=0;c<32;c++)a[n+c]+=u[n]*l[c];return un(e.subarray(32),a),o}function uc(e,t,i,r){var n,c,a=new tt(32),s=[fe(),fe(),fe(),fe()],l=[fe(),fe(),fe(),fe()];if(c=-1,i<64||fc(l,r))return-1;for(n=0;n<i;++n)e[n]=t[n];for(n=0;n<32;++n)e[n+32]=r[n];var o=mr(e,i);if(Ui(o),gn(s,l,o),Vi(l,t.subarray(32)),Fi(s,l),Hi(a,s),i-=64,pn(t,0,a,0)){for(n=0;n<i;++n)e[n]=0;return-1}for(n=0;n<i;++n)e[n]=t[n+64];return c=i,c}function un(e,t){var i,r,n,c;for(r=63;r>=32;--r){for(i=0,n=r-32,c=r-12;n<c;++n)t[n]+=i-16*t[r]*Mi[n-(r-32)],i=t[n]+128>>8,t[n]-=i*256;t[n]+=i,t[r]=0}for(i=0,n=0;n<32;++n)t[n]+=i-(t[31]>>4)*Mi[n],i=t[n]>>8,t[n]&=255;for(n=0;n<32;++n)t[n]-=i*Mi[n];for(r=0;r<32;++r)t[r+1]+=t[r]>>8,e[r]=t[r]&255}function Ui(e){for(var t=new Float64Array(64),i=0;i<64;++i)t[i]=e[i],e[i]=0;un(e,t)}function Fi(e,t){var i=fe(),r=fe(),n=fe(),c=fe(),a=fe(),s=fe(),l=fe(),o=fe(),f=fe();sr(i,e[1],e[0]),sr(f,t[1],t[0]),Ie(i,i,f),ir(r,e[0],e[1]),ir(f,t[0],t[1]),Ie(r,r,f),Ie(n,e[3],t[3]),Ie(n,n,oc),Ie(c,e[2],t[2]),ir(c,c,c),sr(a,r,i),sr(s,c,n),ir(l,c,n),ir(o,r,i),Ie(e[0],a,s),Ie(e[1],o,l),Ie(e[2],l,s),Ie(e[3],a,o)}function fn(e,t,i){for(var r=0;r<4;++r)_n(e[r],t[r],i)}function Hi(e,t){var i=fe(),r=fe(),n=fe();gc(n,t[2]),Ie(i,t[0],n),Ie(r,t[1],n),Yr(e,r),e[31]^=vn(i)<<7}function Yr(e,t){var i,r,n,c=fe(),a=fe();for(i=0;i<16;++i)a[i]=t[i];for(Ki(a),Ki(a),Ki(a),r=0;r<2;++r){for(c[0]=a[0]-65517,i=1;i<15;++i)c[i]=a[i]-65535-(c[i-1]>>16&1),c[i-1]&=65535;c[15]=a[15]-32767-(c[14]>>16&1),n=c[15]>>16&1,c[14]&=65535,_n(a,c,1-n)}for(i=0;i<16;i++)e[2*i]=a[i]&255,e[2*i+1]=a[i]>>8}function fc(e,t){var i=fe(),r=fe(),n=fe(),c=fe(),a=fe(),s=fe(),l=fe();return Nt(e[2],Qr),dc(e[1],t),qt(n,e[1]),Ie(c,n,ac),sr(n,n,e[2]),ir(c,e[2],c),qt(a,c),qt(s,a),Ie(l,s,a),Ie(i,l,n),Ie(i,i,c),pc(i,i),Ie(i,i,n),Ie(i,i,c),Ie(i,i,c),Ie(e[0],i,c),qt(r,e[0]),Ie(r,r,c),dn(r,n)&&Ie(e[0],e[0],lc),qt(r,e[0]),Ie(r,r,c),dn(r,n)?-1:(vn(e[0])===t[31]>>7&&sr(e[0],Oi,e[0]),Ie(e[3],e[0],e[1]),0)}function dc(e,t){var i;for(i=0;i<16;++i)e[i]=t[2*i]+(t[2*i+1]<<8);e[15]&=32767}function pc(e,t){var i=fe(),r;for(r=0;r<16;++r)i[r]=t[r];for(r=250;r>=0;--r)qt(i,i),r!==1&&Ie(i,i,t);for(r=0;r<16;++r)e[r]=i[r]}function dn(e,t){var i=new tt(32),r=new tt(32);return Yr(i,e),Yr(r,t),pn(i,0,r,0)}function pn(e,t,i,r){return vc(e,t,i,r,32)}function vc(e,t,i,r,n){var c,a=0;for(c=0;c<n;++c)a|=e[t+c]^i[r+c];return(1&a-1>>>8)-1}function vn(e){var t=new tt(32);return Yr(t,e),t[0]&1}function gn(e,t,i){var r,n;for(Nt(e[0],Oi),Nt(e[1],Qr),Nt(e[2],Qr),Nt(e[3],Oi),n=255;n>=0;--n)r=i[n/8|0]>>(n&7)&1,fn(e,t,r),Fi(t,e),Fi(e,e),fn(e,t,r)}function Vi(e,t){var i=[fe(),fe(),fe(),fe()];Nt(i[0],cn),Nt(i[1],hn),Nt(i[2],Qr),Ie(i[3],cn,hn),gn(e,i,t)}function Nt(e,t){var i;for(i=0;i<16;i++)e[i]=t[i]|0}function gc(e,t){var i=fe(),r;for(r=0;r<16;++r)i[r]=t[r];for(r=253;r>=0;--r)qt(i,i),r!==2&&r!==4&&Ie(i,i,t);for(r=0;r<16;++r)e[r]=i[r]}function Ki(e){var t,i,r=1;for(t=0;t<16;++t)i=e[t]+r+65535,r=Math.floor(i/65536),e[t]=i-r*65536;e[0]+=r-1+37*(r-1)}function _n(e,t,i){for(var r,n=~(i-1),c=0;c<16;++c)r=n&(e[c]^t[c]),e[c]^=r,t[c]^=r}function fe(e){var t,i=new Float64Array(16);if(e)for(t=0;t<e.length;++t)i[t]=e[t];return i}function ir(e,t,i){for(var r=0;r<16;++r)e[r]=t[r]+i[r]}function sr(e,t,i){for(var r=0;r<16;++r)e[r]=t[r]-i[r]}function qt(e,t){Ie(e,t,t)}function Ie(e,t,i){var r,n,c=0,a=0,s=0,l=0,o=0,f=0,u=0,g=0,_=0,y=0,m=0,h=0,d=0,p=0,v=0,C=0,S=0,b=0,w=0,E=0,x=0,k=0,D=0,R=0,O=0,G=0,q=0,X=0,W=0,L=0,P=0,N=i[0],U=i[1],z=i[2],$=i[3],se=i[4],te=i[5],de=i[6],I=i[7],V=i[8],Q=i[9],j=i[10],ce=i[11],ie=i[12],pe=i[13],xe=i[14],Ae=i[15];r=t[0],c+=r*N,a+=r*U,s+=r*z,l+=r*$,o+=r*se,f+=r*te,u+=r*de,g+=r*I,_+=r*V,y+=r*Q,m+=r*j,h+=r*ce,d+=r*ie,p+=r*pe,v+=r*xe,C+=r*Ae,r=t[1],a+=r*N,s+=r*U,l+=r*z,o+=r*$,f+=r*se,u+=r*te,g+=r*de,_+=r*I,y+=r*V,m+=r*Q,h+=r*j,d+=r*ce,p+=r*ie,v+=r*pe,C+=r*xe,S+=r*Ae,r=t[2],s+=r*N,l+=r*U,o+=r*z,f+=r*$,u+=r*se,g+=r*te,_+=r*de,y+=r*I,m+=r*V,h+=r*Q,d+=r*j,p+=r*ce,v+=r*ie,C+=r*pe,S+=r*xe,b+=r*Ae,r=t[3],l+=r*N,o+=r*U,f+=r*z,u+=r*$,g+=r*se,_+=r*te,y+=r*de,m+=r*I,h+=r*V,d+=r*Q,p+=r*j,v+=r*ce,C+=r*ie,S+=r*pe,b+=r*xe,w+=r*Ae,r=t[4],o+=r*N,f+=r*U,u+=r*z,g+=r*$,_+=r*se,y+=r*te,m+=r*de,h+=r*I,d+=r*V,p+=r*Q,v+=r*j,C+=r*ce,S+=r*ie,b+=r*pe,w+=r*xe,E+=r*Ae,r=t[5],f+=r*N,u+=r*U,g+=r*z,_+=r*$,y+=r*se,m+=r*te,h+=r*de,d+=r*I,p+=r*V,v+=r*Q,C+=r*j,S+=r*ce,b+=r*ie,w+=r*pe,E+=r*xe,x+=r*Ae,r=t[6],u+=r*N,g+=r*U,_+=r*z,y+=r*$,m+=r*se,h+=r*te,d+=r*de,p+=r*I,v+=r*V,C+=r*Q,S+=r*j,b+=r*ce,w+=r*ie,E+=r*pe,x+=r*xe,k+=r*Ae,r=t[7],g+=r*N,_+=r*U,y+=r*z,m+=r*$,h+=r*se,d+=r*te,p+=r*de,v+=r*I,C+=r*V,S+=r*Q,b+=r*j,w+=r*ce,E+=r*ie,x+=r*pe,k+=r*xe,D+=r*Ae,r=t[8],_+=r*N,y+=r*U,m+=r*z,h+=r*$,d+=r*se,p+=r*te,v+=r*de,C+=r*I,S+=r*V,b+=r*Q,w+=r*j,E+=r*ce,x+=r*ie,k+=r*pe,D+=r*xe,R+=r*Ae,r=t[9],y+=r*N,m+=r*U,h+=r*z,d+=r*$,p+=r*se,v+=r*te,C+=r*de,S+=r*I,b+=r*V,w+=r*Q,E+=r*j,x+=r*ce,k+=r*ie,D+=r*pe,R+=r*xe,O+=r*Ae,r=t[10],m+=r*N,h+=r*U,d+=r*z,p+=r*$,v+=r*se,C+=r*te,S+=r*de,b+=r*I,w+=r*V,E+=r*Q,x+=r*j,k+=r*ce,D+=r*ie,R+=r*pe,O+=r*xe,G+=r*Ae,r=t[11],h+=r*N,d+=r*U,p+=r*z,v+=r*$,C+=r*se,S+=r*te,b+=r*de,w+=r*I,E+=r*V,x+=r*Q,k+=r*j,D+=r*ce,R+=r*ie,O+=r*pe,G+=r*xe,q+=r*Ae,r=t[12],d+=r*N,p+=r*U,v+=r*z,C+=r*$,S+=r*se,b+=r*te,w+=r*de,E+=r*I,x+=r*V,k+=r*Q,D+=r*j,R+=r*ce,O+=r*ie,G+=r*pe,q+=r*xe,X+=r*Ae,r=t[13],p+=r*N,v+=r*U,C+=r*z,S+=r*$,b+=r*se,w+=r*te,E+=r*de,x+=r*I,k+=r*V,D+=r*Q,R+=r*j,O+=r*ce,G+=r*ie,q+=r*pe,X+=r*xe,W+=r*Ae,r=t[14],v+=r*N,C+=r*U,S+=r*z,b+=r*$,w+=r*se,E+=r*te,x+=r*de,k+=r*I,D+=r*V,R+=r*Q,O+=r*j,G+=r*ce,q+=r*ie,X+=r*pe,W+=r*xe,L+=r*Ae,r=t[15],C+=r*N,S+=r*U,b+=r*z,w+=r*$,E+=r*se,x+=r*te,k+=r*de,D+=r*I,R+=r*V,O+=r*Q,G+=r*j,q+=r*ce,X+=r*ie,W+=r*pe,L+=r*xe,P+=r*Ae,c+=38*S,a+=38*b,s+=38*w,l+=38*E,o+=38*x,f+=38*k,u+=38*D,g+=38*R,_+=38*O,y+=38*G,m+=38*q,h+=38*X,d+=38*W,p+=38*L,v+=38*P,n=1,r=c+n+65535,n=Math.floor(r/65536),c=r-n*65536,r=a+n+65535,n=Math.floor(r/65536),a=r-n*65536,r=s+n+65535,n=Math.floor(r/65536),s=r-n*65536,r=l+n+65535,n=Math.floor(r/65536),l=r-n*65536,r=o+n+65535,n=Math.floor(r/65536),o=r-n*65536,r=f+n+65535,n=Math.floor(r/65536),f=r-n*65536,r=u+n+65535,n=Math.floor(r/65536),u=r-n*65536,r=g+n+65535,n=Math.floor(r/65536),g=r-n*65536,r=_+n+65535,n=Math.floor(r/65536),_=r-n*65536,r=y+n+65535,n=Math.floor(r/65536),y=r-n*65536,r=m+n+65535,n=Math.floor(r/65536),m=r-n*65536,r=h+n+65535,n=Math.floor(r/65536),h=r-n*65536,r=d+n+65535,n=Math.floor(r/65536),d=r-n*65536,r=p+n+65535,n=Math.floor(r/65536),p=r-n*65536,r=v+n+65535,n=Math.floor(r/65536),v=r-n*65536,r=C+n+65535,n=Math.floor(r/65536),C=r-n*65536,c+=n-1+37*(n-1),n=1,r=c+n+65535,n=Math.floor(r/65536),c=r-n*65536,r=a+n+65535,n=Math.floor(r/65536),a=r-n*65536,r=s+n+65535,n=Math.floor(r/65536),s=r-n*65536,r=l+n+65535,n=Math.floor(r/65536),l=r-n*65536,r=o+n+65535,n=Math.floor(r/65536),o=r-n*65536,r=f+n+65535,n=Math.floor(r/65536),f=r-n*65536,r=u+n+65535,n=Math.floor(r/65536),u=r-n*65536,r=g+n+65535,n=Math.floor(r/65536),g=r-n*65536,r=_+n+65535,n=Math.floor(r/65536),_=r-n*65536,r=y+n+65535,n=Math.floor(r/65536),y=r-n*65536,r=m+n+65535,n=Math.floor(r/65536),m=r-n*65536,r=h+n+65535,n=Math.floor(r/65536),h=r-n*65536,r=d+n+65535,n=Math.floor(r/65536),d=r-n*65536,r=p+n+65535,n=Math.floor(r/65536),p=r-n*65536,r=v+n+65535,n=Math.floor(r/65536),v=r-n*65536,r=C+n+65535,n=Math.floor(r/65536),C=r-n*65536,c+=n-1+37*(n-1),e[0]=c,e[1]=a,e[2]=s,e[3]=l,e[4]=o,e[5]=f,e[6]=u,e[7]=g,e[8]=_,e[9]=y,e[10]=m,e[11]=h,e[12]=d,e[13]=p,e[14]=v,e[15]=C}var it=_e;it.kem=it.kem||{};var yn=it.jsbn.BigInteger;it.kem.rsa={},it.kem.rsa.create=function(e,t){t=t||{};var i=t.prng||it.random,r={};return r.encrypt=function(n,c){var a=Math.ceil(n.n.bitLength()/8),s;do s=new yn(it.util.bytesToHex(i.getBytesSync(a)),16).mod(n.n);while(s.compareTo(yn.ONE)<=0);s=it.util.hexToBytes(s.toString(16));var l=a-s.length;l>0&&(s=it.util.fillString(String.fromCharCode(0),l)+s);var o=n.encrypt(s,"NONE"),f=e.generate(s,c);return{encapsulation:o,key:f}},r.decrypt=function(n,c,a){var s=n.decrypt(c,"NONE");return e.generate(s,a)},r},it.kem.kdf1=function(e,t){mn(this,e,0,t||e.digestLength)},it.kem.kdf2=function(e,t){mn(this,e,1,t||e.digestLength)};function mn(e,t,i,r){e.generate=function(n,c){for(var a=new it.util.ByteBuffer,s=Math.ceil(c/r)+i,l=new it.util.ByteBuffer,o=i;o<s;++o){l.putInt32(o),t.start(),t.update(n+l.getBytes());var f=t.digest();a.putBytes(f.getBytes(r))}return a.truncate(a.length()-c),a.getBytes()}}var Ee=_e;Ee.log=Ee.log||{},Ee.log.levels=["none","error","warning","info","debug","verbose","max"];var Xr={},Wi=[],Cr=null;Ee.log.LEVEL_LOCKED=2,Ee.log.NO_LEVEL_CHECK=4,Ee.log.INTERPOLATE=8;for(var Ot=0;Ot<Ee.log.levels.length;++Ot){var Cn=Ee.log.levels[Ot];Xr[Cn]={index:Ot,name:Cn.toUpperCase()}}Ee.log.logMessage=function(e){for(var t=Xr[e.level].index,i=0;i<Wi.length;++i){var r=Wi[i];if(r.flags&Ee.log.NO_LEVEL_CHECK)r.f(e);else{var n=Xr[r.level].index;t<=n&&r.f(r,e)}}},Ee.log.prepareStandard=function(e){"standard"in e||(e.standard=Xr[e.level].name+" ["+e.category+"] "+e.message)},Ee.log.prepareFull=function(e){if(!("full"in e)){var t=[e.message];t=t.concat([]),e.full=Ee.util.format.apply(this,t)}},Ee.log.prepareStandardFull=function(e){"standardFull"in e||(Ee.log.prepareStandard(e),e.standardFull=e.standard)};for(var Sn=["error","warning","info","debug","verbose"],Ot=0;Ot<Sn.length;++Ot)(function(t){Ee.log[t]=function(i,r){var n=Array.prototype.slice.call(arguments).slice(2),c={timestamp:new Date,level:t,category:i,message:r,arguments:n};Ee.log.logMessage(c)}})(Sn[Ot]);if(Ee.log.makeLogger=function(e){var t={flags:0,f:e};return Ee.log.setLevel(t,"none"),t},Ee.log.setLevel=function(e,t){var i=!1;if(e&&!(e.flags&Ee.log.LEVEL_LOCKED))for(var r=0;r<Ee.log.levels.length;++r){var n=Ee.log.levels[r];if(t==n){e.level=t,i=!0;break}}return i},Ee.log.lock=function(e,t){typeof t=="undefined"||t?e.flags|=Ee.log.LEVEL_LOCKED:e.flags&=~Ee.log.LEVEL_LOCKED},Ee.log.addLogger=function(e){Wi.push(e)},typeof console!="undefined"&&"log"in console){var Sr;if(console.error&&console.warn&&console.info&&console.debug){var _c={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},zi=function(e,t){Ee.log.prepareStandard(t);var i=_c[t.level],r=[t.standard];r=r.concat(t.arguments.slice()),i.apply(console,r)};Sr=Ee.log.makeLogger(zi)}else{var zi=function(t,i){Ee.log.prepareStandardFull(i),console.log(i.standardFull)};Sr=Ee.log.makeLogger(zi)}Ee.log.setLevel(Sr,"debug"),Ee.log.addLogger(Sr),Cr=Sr}else console={log:function(){}};if(Cr!==null&&typeof window!="undefined"&&window.location){var Zr=new URL(window.location.href).searchParams;if(Zr.has("console.level")&&Ee.log.setLevel(Cr,Zr.get("console.level").slice(-1)[0]),Zr.has("console.lock")){var yc=Zr.get("console.lock").slice(-1)[0];yc=="true"&&Ee.log.lock(Cr)}}Ee.log.consoleLogger=Cr;var ne=_e,F=ne.asn1,Ze=ne.pkcs7=ne.pkcs7||{};Ze.messageFromPem=function(e){var t=ne.pem.decode(e)[0];if(t.type!=="PKCS7"){var i=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw i.headerType=t.type,i}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var r=F.fromDer(t.body);return Ze.messageFromAsn1(r)},Ze.messageToPem=function(e,t){var i={type:"PKCS7",body:F.toDer(e.toAsn1()).getBytes()};return ne.pem.encode(i,{maxline:t})},Ze.messageFromAsn1=function(e){var t={},i=[];if(!F.validate(e,Ze.asn1.contentInfoValidator,t,i)){var r=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw r.errors=i,r}var n=F.derToOid(t.contentType),c;switch(n){case ne.pki.oids.envelopedData:c=Ze.createEnvelopedData();break;case ne.pki.oids.encryptedData:c=Ze.createEncryptedData();break;case ne.pki.oids.signedData:c=Ze.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+n+" is not (yet) supported.")}return c.fromAsn1(t.content.value[0]),c},Ze.createSignedData=function(){var e=null;return e={type:ne.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(r){if(qi(e,r,Ze.asn1.signedDataValidator),e.certificates=[],e.crls=[],e.digestAlgorithmIdentifiers=[],e.contentInfo=null,e.signerInfos=[],e.rawCapture.certificates)for(var n=e.rawCapture.certificates.value,c=0;c<n.length;++c)e.certificates.push(ne.pki.certificateFromAsn1(n[c]))},toAsn1:function(){e.contentInfo||e.sign();for(var r=[],n=0;n<e.certificates.length;++n)r.push(ne.pki.certificateToAsn1(e.certificates[n]));var c=[],a=F.create(F.Class.CONTEXT_SPECIFIC,0,!0,[F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,F.integerToDer(e.version).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.SET,!0,e.digestAlgorithmIdentifiers),e.contentInfo])]);return r.length>0&&a.value[0].value.push(F.create(F.Class.CONTEXT_SPECIFIC,0,!0,r)),c.length>0&&a.value[0].value.push(F.create(F.Class.CONTEXT_SPECIFIC,1,!0,c)),a.value[0].value.push(F.create(F.Class.UNIVERSAL,F.Type.SET,!0,e.signerInfos)),F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(e.type).getBytes()),a])},addSigner:function(r){var n=r.issuer,c=r.serialNumber;if(r.certificate){var a=r.certificate;typeof a=="string"&&(a=ne.pki.certificateFromPem(a)),n=a.issuer.attributes,c=a.serialNumber}var s=r.key;if(!s)throw new Error("Could not add PKCS#7 signer; no private key specified.");typeof s=="string"&&(s=ne.pki.privateKeyFromPem(s));var l=r.digestAlgorithm||ne.pki.oids.sha1;switch(l){case ne.pki.oids.sha1:case ne.pki.oids.sha256:case ne.pki.oids.sha384:case ne.pki.oids.sha512:case ne.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+l)}var o=r.authenticatedAttributes||[];if(o.length>0){for(var f=!1,u=!1,g=0;g<o.length;++g){var _=o[g];if(!f&&_.type===ne.pki.oids.contentType){if(f=!0,u)break;continue}if(!u&&_.type===ne.pki.oids.messageDigest){if(u=!0,f)break;continue}}if(!f||!u)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}e.signers.push({key:s,version:1,issuer:n,serialNumber:c,digestAlgorithm:l,signatureAlgorithm:ne.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:o,unauthenticatedAttributes:[]})},sign:function(r){if(r=r||{},(typeof e.content!="object"||e.contentInfo===null)&&(e.contentInfo=F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(ne.pki.oids.data).getBytes())]),"content"in e)){var n;e.content instanceof ne.util.ByteBuffer?n=e.content.bytes():typeof e.content=="string"&&(n=ne.util.encodeUtf8(e.content)),r.detached?e.detachedContent=F.create(F.Class.UNIVERSAL,F.Type.OCTETSTRING,!1,n):e.contentInfo.value.push(F.create(F.Class.CONTEXT_SPECIFIC,0,!0,[F.create(F.Class.UNIVERSAL,F.Type.OCTETSTRING,!1,n)]))}if(e.signers.length!==0){var c=t();i(c)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(r){typeof r=="string"&&(r=ne.pki.certificateFromPem(r)),e.certificates.push(r)},addCertificateRevokationList:function(r){throw new Error("PKCS#7 CRL support not yet implemented.")}},e;function t(){for(var r={},n=0;n<e.signers.length;++n){var c=e.signers[n],a=c.digestAlgorithm;a in r||(r[a]=ne.md[ne.pki.oids[a]].create()),c.authenticatedAttributes.length===0?c.md=r[a]:c.md=ne.md[ne.pki.oids[a]].create()}e.digestAlgorithmIdentifiers=[];for(var a in r)e.digestAlgorithmIdentifiers.push(F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(a).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.NULL,!1,"")]));return r}function i(r){var n;if(e.detachedContent?n=e.detachedContent:(n=e.contentInfo.value[1],n=n.value[0]),!n)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var c=F.derToOid(e.contentInfo.value[0].value),a=F.toDer(n);a.getByte(),F.getBerValueLength(a),a=a.getBytes();for(var s in r)r[s].start().update(a);for(var l=new Date,o=0;o<e.signers.length;++o){var f=e.signers[o];if(f.authenticatedAttributes.length===0){if(c!==ne.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{f.authenticatedAttributesAsn1=F.create(F.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var u=F.create(F.Class.UNIVERSAL,F.Type.SET,!0,[]),g=0;g<f.authenticatedAttributes.length;++g){var _=f.authenticatedAttributes[g];_.type===ne.pki.oids.messageDigest?_.value=r[f.digestAlgorithm].digest():_.type===ne.pki.oids.signingTime&&(_.value||(_.value=l)),u.value.push($i(_)),f.authenticatedAttributesAsn1.value.push($i(_))}a=F.toDer(u).getBytes(),f.md.start().update(a)}f.signature=f.key.sign(f.md,"RSASSA-PKCS1-V1_5")}e.signerInfos=xc(e.signers)}},Ze.createEncryptedData=function(){var e=null;return e={type:ne.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:ne.pki.oids["aes256-CBC"]},fromAsn1:function(t){qi(e,t,Ze.asn1.encryptedDataValidator)},decrypt:function(t){t!==void 0&&(e.encryptedContent.key=t),En(e)}},e},Ze.createEnvelopedData=function(){var e=null;return e={type:ne.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:ne.pki.oids["aes256-CBC"]},fromAsn1:function(t){var i=qi(e,t,Ze.asn1.envelopedDataValidator);e.recipients=Sc(i.recipientInfos.value)},toAsn1:function(){return F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(e.type).getBytes()),F.create(F.Class.CONTEXT_SPECIFIC,0,!0,[F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,F.integerToDer(e.version).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.SET,!0,Ec(e.recipients)),F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,wc(e.encryptedContent))])])])},findRecipient:function(t){for(var i=t.issuer.attributes,r=0;r<e.recipients.length;++r){var n=e.recipients[r],c=n.issuer;if(n.serialNumber===t.serialNumber&&c.length===i.length){for(var a=!0,s=0;s<i.length;++s)if(c[s].type!==i[s].type||c[s].value!==i[s].value){a=!1;break}if(a)return n}}return null},decrypt:function(t,i){if(e.encryptedContent.key===void 0&&t!==void 0&&i!==void 0)switch(t.encryptedContent.algorithm){case ne.pki.oids.rsaEncryption:case ne.pki.oids.desCBC:var r=i.decrypt(t.encryptedContent.content);e.encryptedContent.key=ne.util.createBuffer(r);break;default:throw new Error("Unsupported asymmetric cipher, OID "+t.encryptedContent.algorithm)}En(e)},addRecipient:function(t){e.recipients.push({version:0,issuer:t.issuer.attributes,serialNumber:t.serialNumber,encryptedContent:{algorithm:ne.pki.oids.rsaEncryption,key:t.publicKey}})},encrypt:function(t,i){if(e.encryptedContent.content===void 0){i=i||e.encryptedContent.algorithm,t=t||e.encryptedContent.key;var r,n,c;switch(i){case ne.pki.oids["aes128-CBC"]:r=16,n=16,c=ne.aes.createEncryptionCipher;break;case ne.pki.oids["aes192-CBC"]:r=24,n=16,c=ne.aes.createEncryptionCipher;break;case ne.pki.oids["aes256-CBC"]:r=32,n=16,c=ne.aes.createEncryptionCipher;break;case ne.pki.oids["des-EDE3-CBC"]:r=24,n=8,c=ne.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+i)}if(t===void 0)t=ne.util.createBuffer(ne.random.getBytes(r));else if(t.length()!=r)throw new Error("Symmetric key has wrong length; got "+t.length()+" bytes, expected "+r+".");e.encryptedContent.algorithm=i,e.encryptedContent.key=t,e.encryptedContent.parameter=ne.util.createBuffer(ne.random.getBytes(n));var a=c(t);if(a.start(e.encryptedContent.parameter.copy()),a.update(e.content),!a.finish())throw new Error("Symmetric encryption failed.");e.encryptedContent.content=a.output}for(var s=0;s<e.recipients.length;++s){var l=e.recipients[s];if(l.encryptedContent.content===void 0)switch(l.encryptedContent.algorithm){case ne.pki.oids.rsaEncryption:l.encryptedContent.content=l.encryptedContent.key.encrypt(e.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+l.encryptedContent.algorithm)}}}},e};function mc(e){var t={},i=[];if(!F.validate(e,Ze.asn1.recipientInfoValidator,t,i)){var r=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw r.errors=i,r}return{version:t.version.charCodeAt(0),issuer:ne.pki.RDNAttributesAsArray(t.issuer),serialNumber:ne.util.createBuffer(t.serial).toHex(),encryptedContent:{algorithm:F.derToOid(t.encAlgorithm),parameter:t.encParameter?t.encParameter.value:void 0,content:t.encKey}}}function Cc(e){return F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,F.integerToDer(e.version).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[ne.pki.distinguishedNameToAsn1({attributes:e.issuer}),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,ne.util.hexToBytes(e.serialNumber))]),F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(e.encryptedContent.algorithm).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.NULL,!1,"")]),F.create(F.Class.UNIVERSAL,F.Type.OCTETSTRING,!1,e.encryptedContent.content)])}function Sc(e){for(var t=[],i=0;i<e.length;++i)t.push(mc(e[i]));return t}function Ec(e){for(var t=[],i=0;i<e.length;++i)t.push(Cc(e[i]));return t}function bc(e){var t=F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,F.integerToDer(e.version).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[ne.pki.distinguishedNameToAsn1({attributes:e.issuer}),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,ne.util.hexToBytes(e.serialNumber))]),F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(e.digestAlgorithm).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.NULL,!1,"")])]);if(e.authenticatedAttributesAsn1&&t.value.push(e.authenticatedAttributesAsn1),t.value.push(F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(e.signatureAlgorithm).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.NULL,!1,"")])),t.value.push(F.create(F.Class.UNIVERSAL,F.Type.OCTETSTRING,!1,e.signature)),e.unauthenticatedAttributes.length>0){for(var i=F.create(F.Class.CONTEXT_SPECIFIC,1,!0,[]),r=0;r<e.unauthenticatedAttributes.length;++r){var n=e.unauthenticatedAttributes[r];i.values.push($i(n))}t.value.push(i)}return t}function xc(e){for(var t=[],i=0;i<e.length;++i)t.push(bc(e[i]));return t}function $i(e){var t;if(e.type===ne.pki.oids.contentType)t=F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(e.value).getBytes());else if(e.type===ne.pki.oids.messageDigest)t=F.create(F.Class.UNIVERSAL,F.Type.OCTETSTRING,!1,e.value.bytes());else if(e.type===ne.pki.oids.signingTime){var i=new Date("1950-01-01T00:00:00Z"),r=new Date("2050-01-01T00:00:00Z"),n=e.value;if(typeof n=="string"){var c=Date.parse(n);isNaN(c)?n.length===13?n=F.utcTimeToDate(n):n=F.generalizedTimeToDate(n):n=new Date(c)}n>=i&&n<r?t=F.create(F.Class.UNIVERSAL,F.Type.UTCTIME,!1,F.dateToUtcTime(n)):t=F.create(F.Class.UNIVERSAL,F.Type.GENERALIZEDTIME,!1,F.dateToGeneralizedTime(n))}return F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(e.type).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.SET,!0,[t])])}function wc(e){return[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(ne.pki.oids.data).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(e.algorithm).getBytes()),e.parameter?F.create(F.Class.UNIVERSAL,F.Type.OCTETSTRING,!1,e.parameter.getBytes()):void 0]),F.create(F.Class.CONTEXT_SPECIFIC,0,!0,[F.create(F.Class.UNIVERSAL,F.Type.OCTETSTRING,!1,e.content.getBytes())])]}function qi(e,t,i){var r={},n=[];if(!F.validate(t,i,r,n)){var c=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw c.errors=c,c}var a=F.derToOid(r.contentType);if(a!==ne.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(r.encryptedContent){var s="";if(ne.util.isArray(r.encryptedContent))for(var l=0;l<r.encryptedContent.length;++l){if(r.encryptedContent[l].type!==F.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");s+=r.encryptedContent[l].value}else s=r.encryptedContent;e.encryptedContent={algorithm:F.derToOid(r.encAlgorithm),parameter:ne.util.createBuffer(r.encParameter.value),content:ne.util.createBuffer(s)}}if(r.content){var s="";if(ne.util.isArray(r.content))for(var l=0;l<r.content.length;++l){if(r.content[l].type!==F.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");s+=r.content[l].value}else s=r.content;e.content=ne.util.createBuffer(s)}return e.version=r.version.charCodeAt(0),e.rawCapture=r,r}function En(e){if(e.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(e.content===void 0){var t;switch(e.encryptedContent.algorithm){case ne.pki.oids["aes128-CBC"]:case ne.pki.oids["aes192-CBC"]:case ne.pki.oids["aes256-CBC"]:t=ne.aes.createDecryptionCipher(e.encryptedContent.key);break;case ne.pki.oids.desCBC:case ne.pki.oids["des-EDE3-CBC"]:t=ne.des.createDecryptionCipher(e.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+e.encryptedContent.algorithm)}if(t.start(e.encryptedContent.parameter),t.update(e.encryptedContent.content),!t.finish())throw new Error("Symmetric decryption failed.");e.content=t.output}}var Fe=_e,Jr=Fe.ssh=Fe.ssh||{};Jr.privateKeyToPutty=function(e,t,i){i=i||"",t=t||"";var r="ssh-rsa",n=t===""?"none":"aes256-cbc",c="PuTTY-User-Key-File-2: "+r+`\r
`;c+="Encryption: "+n+`\r
`,c+="Comment: "+i+`\r
`;var a=Fe.util.createBuffer();nr(a,r),Ct(a,e.e),Ct(a,e.n);var s=Fe.util.encode64(a.bytes(),64),l=Math.floor(s.length/66)+1;c+="Public-Lines: "+l+`\r
`,c+=s;var o=Fe.util.createBuffer();Ct(o,e.d),Ct(o,e.p),Ct(o,e.q),Ct(o,e.qInv);var f;if(!t)f=Fe.util.encode64(o.bytes(),64);else{var u=o.length()+16-1;u-=u%16;var g=ei(o.bytes());g.truncate(g.length()-u+o.length()),o.putBuffer(g);var _=Fe.util.createBuffer();_.putBuffer(ei("\0\0\0\0",t)),_.putBuffer(ei("\0\0\0",t));var y=Fe.aes.createEncryptionCipher(_.truncate(8),"CBC");y.start(Fe.util.createBuffer().fillWithByte(0,16)),y.update(o.copy()),y.finish();var m=y.output;m.truncate(16),f=Fe.util.encode64(m.bytes(),64)}l=Math.floor(f.length/66)+1,c+=`\r
Private-Lines: `+l+`\r
`,c+=f;var h=ei("putty-private-key-file-mac-key",t),d=Fe.util.createBuffer();nr(d,r),nr(d,n),nr(d,i),d.putInt32(a.length()),d.putBuffer(a),d.putInt32(o.length()),d.putBuffer(o);var p=Fe.hmac.create();return p.start("sha1",h),p.update(d.bytes()),c+=`\r
Private-MAC: `+p.digest().toHex()+`\r
`,c},Jr.publicKeyToOpenSSH=function(e,t){var i="ssh-rsa";t=t||"";var r=Fe.util.createBuffer();return nr(r,i),Ct(r,e.e),Ct(r,e.n),i+" "+Fe.util.encode64(r.bytes())+" "+t},Jr.privateKeyToOpenSSH=function(e,t){return t?Fe.pki.encryptRsaPrivateKey(e,t,{legacy:!0,algorithm:"aes128"}):Fe.pki.privateKeyToPem(e)},Jr.getPublicKeyFingerprint=function(e,t){t=t||{};var i=t.md||Fe.md.md5.create(),r="ssh-rsa",n=Fe.util.createBuffer();nr(n,r),Ct(n,e.e),Ct(n,e.n),i.start(),i.update(n.getBytes());var c=i.digest();if(t.encoding==="hex"){var a=c.toHex();return t.delimiter?a.match(/.{2}/g).join(t.delimiter):a}else{if(t.encoding==="binary")return c.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".')}return c};function Ct(e,t){var i=t.toString(16);i[0]>="8"&&(i="00"+i);var r=Fe.util.hexToBytes(i);e.putInt32(r.length),e.putBytes(r)}function nr(e,t){e.putInt32(t.length),e.putString(t)}function ei(){for(var e=Fe.md.sha1.create(),t=arguments.length,i=0;i<t;++i)e.update(arguments[i]);return e.digest()}var bn=_e;const Tc=Pe({__proto__:null,default:Et(bn)},[bn]);Me.SSHTerminal=lr,Me.Vue2SSHTerminal=lr,Me.default=lr,Object.defineProperties(Me,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});