UNPKG

399 kBJavaScriptView Raw
1/*! OpenPGP.js v5.0.0-1 - 2021-03-03 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2const e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol:e=>`Symbol(${e})`;function r(){}const n=Number.isNaN||function(e){return e!=e},i=r;function a(e){return"object"==typeof e&&null!==e||"function"==typeof e}function s(e){return e.slice()}function o(e){return!1!==function(e){if("number"!=typeof e)return!1;if(n(e))return!1;if(e<0)return!1;return!0}(e)&&e!==1/0}function c(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function u(e,t,r,n){const i=e[t];if(void 0!==i){if("function"!=typeof i)throw new TypeError(i+" is not a method");switch(r){case 0:return()=>h(i,e,n);case 1:return t=>{const r=[t].concat(n);return h(i,e,r)}}}return()=>b(void 0)}function l(e,t,r){const n=e[t];if(void 0!==n)return c(n,e,r)}function h(e,t,r){try{return b(c(e,t,r))}catch(e){return _(e)}}function d(e){if(n(e=Number(e))||e<0)throw new RangeError("highWaterMark property of a queuing strategy must be non-negative and non-NaN");return e}function f(e){if(void 0===e)return()=>1;if("function"!=typeof e)throw new TypeError("size property of a queuing strategy must be a function");return t=>e(t)}const y=Promise,p=Promise.prototype.then,g=Promise.resolve.bind(y),m=Promise.reject.bind(y);function w(e){return new y(e)}function b(e){return g(e)}function _(e){return m(e)}function v(e,t,r){return p.call(e,t,r)}function k(e,t,r){v(v(e,t,r),void 0,i)}function A(e,t){k(e,t)}function S(e,t){k(e,void 0,t)}function E(e,t,r){return v(e,t,r)}function P(e){v(e,void 0,i)}class x{constructor(){this._cursor=0,this._size=0,this._front={_elements:[],_next:void 0},this._back=this._front,this._cursor=0,this._size=0}get length(){return this._size}push(e){const t=this._back;let r=t;16383===t._elements.length&&(r={_elements:[],_next:void 0}),t._elements.push(e),r!==t&&(this._back=r,t._next=r),++this._size}shift(){const e=this._front;let t=e;const r=this._cursor;let n=r+1;const i=e._elements,a=i[r];return 16384===n&&(t=e._next,n=0),--this._size,this._cursor=n,e!==t&&(this._front=t),i[r]=void 0,a}forEach(e){let t=this._cursor,r=this._front,n=r._elements;for(;!(t===n.length&&void 0===r._next||t===n.length&&(r=r._next,n=r._elements,t=0,0===n.length));)e(n[t]),++t}peek(){const e=this._front,t=this._cursor;return e._elements[t]}}function K(e,t,r){let n=null;!0===r&&(n=Object.prototype);const i=Object.create(n);return i.value=e,i.done=t,i}function C(e,t){e._forAuthorCode=!0,e._ownerReadableStream=t,t._reader=e,"readable"===t._state?D(e):"closed"===t._state?function(e){D(e),z(e)}(e):I(e,t._storedError)}function U(e,t){return qt(e._ownerReadableStream,t)}function R(e){"readable"===e._ownerReadableStream._state?B(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e,t){I(e,t)}(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),e._ownerReadableStream._reader=void 0,e._ownerReadableStream=void 0}function T(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function D(e){e._closedPromise=w((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r})}function I(e,t){D(e),B(e,t)}function B(e,t){P(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}function z(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}const O=t("[[CancelSteps]]"),q=t("[[PullSteps]]");function N(e,t=!1){const r=new H(e);return r._forAuthorCode=t,r}function M(e){return w((t,r)=>{const n={_resolve:t,_reject:r};e._reader._readRequests.push(n)})}function L(e,t,r){const n=e._reader;n._readRequests.shift()._resolve(K(t,r,n._forAuthorCode))}function j(e){return e._reader._readRequests.length}function F(e){const t=e._reader;return void 0!==t&&!!W(t)}class H{constructor(e){if(!1===zt(e))throw new TypeError("ReadableStreamDefaultReader can only be constructed with a ReadableStream instance");if(!0===Ot(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");C(this,e),this._readRequests=new x}get closed(){return W(this)?this._closedPromise:_(V("closed"))}cancel(e){return W(this)?void 0===this._ownerReadableStream?_(T("cancel")):U(this,e):_(V("cancel"))}read(){return W(this)?void 0===this._ownerReadableStream?_(T("read from")):G(this):_(V("read"))}releaseLock(){if(!W(this))throw V("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");R(this)}}}function W(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")}function G(e){const t=e._ownerReadableStream;return t._disturbed=!0,"closed"===t._state?b(K(void 0,!0,e._forAuthorCode)):"errored"===t._state?_(t._storedError):t._readableStreamController[q]()}function V(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}let $;"symbol"==typeof t.asyncIterator&&($={[t.asyncIterator](){return this}},Object.defineProperty($,t.asyncIterator,{enumerable:!1}));const Y={next(){if(!1===Z(this))return _(Q("next"));const e=this._asyncIteratorReader;return void 0===e._ownerReadableStream?_(T("iterate")):E(G(e),t=>{const r=t.done;return r&&R(e),K(t.value,r,!0)})},return(e){if(!1===Z(this))return _(Q("next"));const t=this._asyncIteratorReader;if(void 0===t._ownerReadableStream)return _(T("finish iterating"));if(t._readRequests.length>0)return _(new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled"));if(!1===this._preventCancel){const r=U(t,e);return R(t),E(r,()=>K(e,!0,!0))}return R(t),b(K(e,!0,!0))}};function Z(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorReader")}function Q(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}function X(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function J(e,t,r){if(!o(r=Number(r)))throw new RangeError("Size must be a finite, non-NaN, non-negative number.");e._queue.push({value:t,size:r}),e._queueTotalSize+=r}function ee(e){e._queue=new x,e._queueTotalSize=0}void 0!==$&&Object.setPrototypeOf(Y,$),Object.defineProperty(Y,"next",{enumerable:!1}),Object.defineProperty(Y,"return",{enumerable:!1});const te=t("[[AbortSteps]]"),re=t("[[ErrorSteps]]");class ne{constructor(e={},t={}){ae(this);const r=t.size;let n=t.highWaterMark;if(void 0!==e.type)throw new RangeError("Invalid type is specified");const i=f(r);void 0===n&&(n=1),n=d(n),function(e,t,r,n){const i=Object.create(Ae.prototype);const a=u(t,"write",1,[i]),s=u(t,"close",0,[]),o=u(t,"abort",1,[]);Se(e,i,(function(){return l(t,"start",[i])}),a,s,o,r,n)}(this,e,n,i)}get locked(){if(!1===se(this))throw Re("locked");return oe(this)}abort(e){return!1===se(this)?_(Re("abort")):!0===oe(this)?_(new TypeError("Cannot abort a stream that already has a writer")):ce(this,e)}close(){return!1===se(this)?_(Re("close")):!0===oe(this)?_(new TypeError("Cannot close a stream that already has a writer")):!0===fe(this)?_(new TypeError("Cannot close an already-closing stream")):ue(this)}getWriter(){if(!1===se(this))throw Re("getWriter");return ie(this)}}function ie(e){return new ge(e)}function ae(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new x,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function se(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")}function oe(e){return void 0!==e._writer}function ce(e,t){const r=e._state;if("closed"===r||"errored"===r)return b(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let n=!1;"erroring"===r&&(n=!0,t=void 0);const i=w((r,i)=>{e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:i,_reason:t,_wasAlreadyErroring:n}});return e._pendingAbortRequest._promise=i,!1===n&&he(e,t),i}function ue(e){const t=e._state;if("closed"===t||"errored"===t)return _(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const r=w((t,r)=>{const n={_resolve:t,_reject:r};e._closeRequest=n}),n=e._writer;var i;return void 0!==n&&!0===e._backpressure&&"writable"===t&&je(n),J(i=e._writableStreamController,"close",0),xe(i),r}function le(e,t){"writable"!==e._state?de(e):he(e,t)}function he(e,t){const r=e._writableStreamController;e._state="erroring",e._storedError=t;const n=e._writer;void 0!==n&&_e(n,t),!1===function(e){if(void 0===e._inFlightWriteRequest&&void 0===e._inFlightCloseRequest)return!1;return!0}(e)&&!0===r._started&&de(e)}function de(e){e._state="errored",e._writableStreamController[re]();const t=e._storedError;if(e._writeRequests.forEach(e=>{e._reject(t)}),e._writeRequests=new x,void 0===e._pendingAbortRequest)return void ye(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,!0===r._wasAlreadyErroring)return r._reject(t),void ye(e);k(e._writableStreamController[te](r._reason),()=>{r._resolve(),ye(e)},t=>{r._reject(t),ye(e)})}function fe(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function ye(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&ze(t,e._storedError)}function pe(e,t){const r=e._writer;void 0!==r&&t!==e._backpressure&&(!0===t?function(e){qe(e)}(r):je(r)),e._backpressure=t}class ge{constructor(e){if(!1===se(e))throw new TypeError("WritableStreamDefaultWriter can only be constructed with a WritableStream instance");if(!0===oe(e))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=e,e._writer=this;const t=e._state;if("writable"===t)!1===fe(e)&&!0===e._backpressure?qe(this):Me(this),Ie(this);else if("erroring"===t)Ne(this,e._storedError),Ie(this);else if("closed"===t)Me(this),Ie(r=this),Oe(r);else{const t=e._storedError;Ne(this,t),Be(this,t)}var r}get closed(){return!1===me(this)?_(Te("closed")):this._closedPromise}get desiredSize(){if(!1===me(this))throw Te("desiredSize");if(void 0===this._ownerWritableStream)throw De("desiredSize");return function(e){const t=e._ownerWritableStream,r=t._state;if("errored"===r||"erroring"===r)return null;if("closed"===r)return 0;return Pe(t._writableStreamController)}(this)}get ready(){return!1===me(this)?_(Te("ready")):this._readyPromise}abort(e){return!1===me(this)?_(Te("abort")):void 0===this._ownerWritableStream?_(De("abort")):function(e,t){return ce(e._ownerWritableStream,t)}(this,e)}close(){if(!1===me(this))return _(Te("close"));const e=this._ownerWritableStream;return void 0===e?_(De("close")):!0===fe(e)?_(new TypeError("Cannot close an already-closing stream")):we(this)}releaseLock(){if(!1===me(this))throw Te("releaseLock");void 0!==this._ownerWritableStream&&ve(this)}write(e){return!1===me(this)?_(Te("write")):void 0===this._ownerWritableStream?_(De("write to")):ke(this,e)}}function me(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")}function we(e){return ue(e._ownerWritableStream)}function be(e,t){"pending"===e._closedPromiseState?ze(e,t):function(e,t){Be(e,t)}(e,t)}function _e(e,t){"pending"===e._readyPromiseState?Le(e,t):function(e,t){Ne(e,t)}(e,t)}function ve(e){const t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");_e(e,r),be(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function ke(e,t){const r=e._ownerWritableStream,n=r._writableStreamController,i=function(e,t){try{return e._strategySizeAlgorithm(t)}catch(t){return Ke(e,t),1}}(n,t);if(r!==e._ownerWritableStream)return _(De("write to"));const a=r._state;if("errored"===a)return _(r._storedError);if(!0===fe(r)||"closed"===a)return _(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===a)return _(r._storedError);const s=function(e){return w((t,r)=>{const n={_resolve:t,_reject:r};e._writeRequests.push(n)})}(r);return function(e,t,r){const n={chunk:t};try{J(e,n,r)}catch(t){return void Ke(e,t)}const i=e._controlledWritableStream;if(!1===fe(i)&&"writable"===i._state){const t=Ce(e);pe(i,t)}xe(e)}(n,t,i),s}class Ae{constructor(){throw new TypeError("WritableStreamDefaultController cannot be constructed explicitly")}error(e){if(!1===function(e){if(!a(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream"))return!1;return!0}(this))throw new TypeError("WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController");"writable"===this._controlledWritableStream._state&&Ue(this,e)}[te](e){const t=this._abortAlgorithm(e);return Ee(this),t}[re](){ee(this)}}function Se(e,t,r,n,i,a,s,o){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,ee(t),t._started=!1,t._strategySizeAlgorithm=o,t._strategyHWM=s,t._writeAlgorithm=n,t._closeAlgorithm=i,t._abortAlgorithm=a;const c=Ce(t);pe(e,c),k(b(r()),()=>{t._started=!0,xe(t)},r=>{t._started=!0,le(e,r)})}function Ee(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Pe(e){return e._strategyHWM-e._queueTotalSize}function xe(e){const t=e._controlledWritableStream;if(!1===e._started)return;if(void 0!==t._inFlightWriteRequest)return;if("erroring"===t._state)return void de(t);if(0===e._queue.length)return;const r=e._queue.peek().value;"close"===r?function(e){const t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),X(e);const r=e._closeAlgorithm();Ee(e),k(r,()=>{!function(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";const t=e._writer;void 0!==t&&Oe(t)}(t)},e=>{!function(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),le(e,t)}(t,e)})}(e):function(e,t){const r=e._controlledWritableStream;(function(e){e._inFlightWriteRequest=e._writeRequests.shift()})(r),k(e._writeAlgorithm(t),()=>{!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(r);const t=r._state;if(X(e),!1===fe(r)&&"writable"===t){const t=Ce(e);pe(r,t)}xe(e)},t=>{"writable"===r._state&&Ee(e),function(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,le(e,t)}(r,t)})}(e,r.chunk)}function Ke(e,t){"writable"===e._controlledWritableStream._state&&Ue(e,t)}function Ce(e){return Pe(e)<=0}function Ue(e,t){const r=e._controlledWritableStream;Ee(e),he(r,t)}function Re(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function Te(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function De(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function Ie(e){e._closedPromise=w((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"})}function Be(e,t){Ie(e),ze(e,t)}function ze(e,t){P(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected"}function Oe(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved"}function qe(e){e._readyPromise=w((t,r)=>{e._readyPromise_resolve=t,e._readyPromise_reject=r}),e._readyPromiseState="pending"}function Ne(e,t){qe(e),Le(e,t)}function Me(e){qe(e),je(e)}function Le(e,t){P(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected"}function je(e){e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled"}function Fe(e){if("object"!=typeof e||null===e)return!1;try{return"boolean"==typeof e.aborted}catch(e){return!1}}const He="undefined"!=typeof DOMException?DOMException:void 0;const We=function(e){if("function"!=typeof e&&"object"!=typeof e)return!1;try{return new e,!0}catch(e){return!1}}(He)?He:function(){const e=function(e,t){this.message=e||"",this.name=t||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return Object.defineProperty(e.prototype=Object.create(Error.prototype),"constructor",{value:e,writable:!0,configurable:!0}),e}();function Ge(e,t,n,i,a,s){const o=N(e),c=ie(t);e._disturbed=!0;let u=!1,l=b(void 0);return w((h,d)=>{let f;if(void 0!==s){if(f=()=>{const r=new We("Aborted","AbortError"),n=[];!1===i&&n.push(()=>"writable"===t._state?ce(t,r):b(void 0)),!1===a&&n.push(()=>"readable"===e._state?qt(e,r):b(void 0)),g(()=>Promise.all(n.map(e=>e())),!0,r)},!0===s.aborted)return void f();s.addEventListener("abort",f)}if(p(e,o._closedPromise,e=>{!1===i?g(()=>ce(t,e),!0,e):m(!0,e)}),p(t,c._closedPromise,t=>{!1===a?g(()=>qt(e,t),!0,t):m(!0,t)}),function(e,t,r){"closed"===e._state?r():A(t,r)}(e,o._closedPromise,()=>{!1===n?g(()=>function(e){const t=e._ownerWritableStream,r=t._state;return!0===fe(t)||"closed"===r?b(void 0):"errored"===r?_(t._storedError):we(e)}(c)):m()}),!0===fe(t)||"closed"===t._state){const t=new TypeError("the destination writable stream closed before all data could be piped to it");!1===a?g(()=>qt(e,t),!0,t):m(!0,t)}function y(){const e=l;return v(l,()=>e!==l?y():void 0)}function p(e,t,r){"errored"===e._state?r(e._storedError):S(t,r)}function g(e,r,n){function i(){k(e(),()=>E(r,n),e=>E(!0,e))}!0!==u&&(u=!0,"writable"===t._state&&!1===fe(t)?A(y(),i):i())}function m(e,r){!0!==u&&(u=!0,"writable"===t._state&&!1===fe(t)?A(y(),()=>E(e,r)):E(e,r))}function E(e,t){ve(c),R(o),void 0!==s&&s.removeEventListener("abort",f),e?d(t):h(void 0)}P(w((e,t)=>{!function n(i){i?e():v(!0===u?b(!0):v(c._readyPromise,()=>v(G(o),e=>!0===e.done||(l=v(ke(c,e.value),void 0,r),!1))),n,t)}(!1)}))})}class Ve{constructor(){throw new TypeError}get desiredSize(){if(!1===$e(this))throw it("desiredSize");return tt(this)}close(){if(!1===$e(this))throw it("close");if(!1===rt(this))throw new TypeError("The stream is not in a state that permits close");Xe(this)}enqueue(e){if(!1===$e(this))throw it("enqueue");if(!1===rt(this))throw new TypeError("The stream is not in a state that permits enqueue");return Je(this,e)}error(e){if(!1===$e(this))throw it("error");et(this,e)}[O](e){ee(this);const t=this._cancelAlgorithm(e);return Qe(this),t}[q](){const e=this._controlledReadableStream;if(this._queue.length>0){const t=X(this);return!0===this._closeRequested&&0===this._queue.length?(Qe(this),Nt(e)):Ye(this),b(K(t,!1,e._reader._forAuthorCode))}const t=M(e);return Ye(this),t}}function $e(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")}function Ye(e){!1!==Ze(e)&&(!0!==e._pulling?(e._pulling=!0,k(e._pullAlgorithm(),()=>{e._pulling=!1,!0===e._pullAgain&&(e._pullAgain=!1,Ye(e))},t=>{et(e,t)})):e._pullAgain=!0)}function Ze(e){const t=e._controlledReadableStream;return!1!==rt(e)&&(!1!==e._started&&(!0===Ot(t)&&j(t)>0||tt(e)>0))}function Qe(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Xe(e){const t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(Qe(e),Nt(t))}function Je(e,t){const r=e._controlledReadableStream;if(!0===Ot(r)&&j(r)>0)L(r,t,!1);else{let r;try{r=e._strategySizeAlgorithm(t)}catch(t){throw et(e,t),t}try{J(e,t,r)}catch(t){throw et(e,t),t}}Ye(e)}function et(e,t){const r=e._controlledReadableStream;"readable"===r._state&&(ee(e),Qe(e),Mt(r,t))}function tt(e){const t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function rt(e){const t=e._controlledReadableStream._state;return!1===e._closeRequested&&"readable"===t}function nt(e,t,r,n,i,a,s){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,ee(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=s,t._strategyHWM=a,t._pullAlgorithm=n,t._cancelAlgorithm=i,e._readableStreamController=t,k(b(r()),()=>{t._started=!0,Ye(t)},e=>{et(t,e)})}function it(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}const at=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};class st{constructor(){throw new TypeError("ReadableStreamBYOBRequest cannot be used directly")}get view(){if(!1===ut(this))throw Et("view");return this._view}respond(e){if(!1===ut(this))throw Et("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");this._view.buffer,function(e,t){if(!1===o(t=Number(t)))throw new RangeError("bytesWritten must be a finite");bt(e,t)}(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!1===ut(this))throw Et("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(!ArrayBuffer.isView(e))throw new TypeError("You can only respond with array buffer views");e.buffer,function(e,t){const r=e._pendingPullIntos.peek();if(r.byteOffset+r.bytesFilled!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.byteLength!==t.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");r.buffer=t.buffer,bt(e,t.byteLength)}(this._associatedReadableByteStreamController,e)}}class ot{constructor(){throw new TypeError("ReadableByteStreamController constructor cannot be used directly")}get byobRequest(){if(!1===ct(this))throw Pt("byobRequest");if(void 0===this._byobRequest&&this._pendingPullIntos.length>0){const e=this._pendingPullIntos.peek(),t=new Uint8Array(e.buffer,e.byteOffset+e.bytesFilled,e.byteLength-e.bytesFilled),r=Object.create(st.prototype);!function(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}(r,this,t),this._byobRequest=r}return this._byobRequest}get desiredSize(){if(!1===ct(this))throw Pt("desiredSize");return At(this)}close(){if(!1===ct(this))throw Pt("close");if(!0===this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");const e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError(`The stream (in ${e} state) is not in the readable state and cannot be closed`);!function(e){const t=e._controlledReadableByteStream;if(e._queueTotalSize>0)return void(e._closeRequested=!0);if(e._pendingPullIntos.length>0){if(e._pendingPullIntos.peek().bytesFilled>0){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");throw kt(e,t),t}}vt(e),Nt(t)}(this)}enqueue(e){if(!1===ct(this))throw Pt("enqueue");if(!0===this._closeRequested)throw new TypeError("stream is closed or draining");const t=this._controlledReadableByteStream._state;if("readable"!==t)throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be enqueued to`);if(!ArrayBuffer.isView(e))throw new TypeError("You can only enqueue array buffer views when using a ReadableByteStreamController");e.buffer,function(e,t){const r=e._controlledReadableByteStream,n=t.buffer,i=t.byteOffset,a=t.byteLength,s=n;if(!0===F(r))if(0===j(r))ft(e,s,i,a);else{const e=new Uint8Array(s,i,a);L(r,e,!1)}else!0===Ct(r)?(ft(e,s,i,a),wt(e)):ft(e,s,i,a);lt(e)}(this,e)}error(e){if(!1===ct(this))throw Pt("error");kt(this,e)}[O](e){if(this._pendingPullIntos.length>0){this._pendingPullIntos.peek().bytesFilled=0}ee(this);const t=this._cancelAlgorithm(e);return vt(this),t}[q](){const e=this._controlledReadableByteStream;if(this._queueTotalSize>0){const t=this._queue.shift();let r;this._queueTotalSize-=t.byteLength,gt(this);try{r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}catch(e){return _(e)}return b(K(r,!1,e._reader._forAuthorCode))}const t=this._autoAllocateChunkSize;if(void 0!==t){let e;try{e=new ArrayBuffer(t)}catch(e){return _(e)}const r={buffer:e,byteOffset:0,byteLength:t,bytesFilled:0,elementSize:1,ctor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(r)}const r=M(e);return lt(this),r}}function ct(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")}function ut(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")}function lt(e){!1!==function(e){const t=e._controlledReadableByteStream;if("readable"!==t._state)return!1;if(!0===e._closeRequested)return!1;if(!1===e._started)return!1;if(!0===F(t)&&j(t)>0)return!0;if(!0===Ct(t)&&Kt(t)>0)return!0;if(At(e)>0)return!0;return!1}(e)&&(!0!==e._pulling?(e._pulling=!0,k(e._pullAlgorithm(),()=>{e._pulling=!1,!0===e._pullAgain&&(e._pullAgain=!1,lt(e))},t=>{kt(e,t)})):e._pullAgain=!0)}function ht(e,t){let r=!1;"closed"===e._state&&(r=!0);const n=dt(t);"default"===t.readerType?L(e,n,r):function(e,t,r){const n=e._reader;n._readIntoRequests.shift()._resolve(K(t,r,n._forAuthorCode))}(e,n,r)}function dt(e){const t=e.bytesFilled,r=e.elementSize;return new e.ctor(e.buffer,e.byteOffset,t/r)}function ft(e,t,r,n){e._queue.push({buffer:t,byteOffset:r,byteLength:n}),e._queueTotalSize+=n}function yt(e,t){const r=t.elementSize,n=t.bytesFilled-t.bytesFilled%r,i=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),a=t.bytesFilled+i,s=a-a%r;let o=i,c=!1;s>n&&(o=s-t.bytesFilled,c=!0);const u=e._queue;for(;o>0;){const r=u.peek(),n=Math.min(o,r.byteLength),i=t.byteOffset+t.bytesFilled;l=t.buffer,h=i,d=r.buffer,f=r.byteOffset,y=n,new Uint8Array(l).set(new Uint8Array(d,f,y),h),r.byteLength===n?u.shift():(r.byteOffset+=n,r.byteLength-=n),e._queueTotalSize-=n,pt(e,n,t),o-=n}var l,h,d,f,y;return c}function pt(e,t,r){mt(e),r.bytesFilled+=t}function gt(e){0===e._queueTotalSize&&!0===e._closeRequested?(vt(e),Nt(e._controlledReadableByteStream)):lt(e)}function mt(e){void 0!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=void 0,e._byobRequest=void 0)}function wt(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const t=e._pendingPullIntos.peek();!0===yt(e,t)&&(_t(e),ht(e._controlledReadableByteStream,t))}}function bt(e,t){const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");!function(e,t){t.buffer=t.buffer;const r=e._controlledReadableByteStream;if(!0===Ct(r))for(;Kt(r)>0;){ht(r,_t(e))}}(e,r)}else!function(e,t,r){if(r.bytesFilled+t>r.byteLength)throw new RangeError("bytesWritten out of range");if(pt(e,t,r),r.bytesFilled<r.elementSize)return;_t(e);const n=r.bytesFilled%r.elementSize;if(n>0){const t=r.byteOffset+r.bytesFilled,i=r.buffer.slice(t-n,t);ft(e,i,0,i.byteLength)}r.buffer=r.buffer,r.bytesFilled-=n,ht(e._controlledReadableByteStream,r),wt(e)}(e,t,r);lt(e)}function _t(e){const t=e._pendingPullIntos.shift();return mt(e),t}function vt(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function kt(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(!function(e){mt(e),e._pendingPullIntos=new x}(e),ee(e),vt(e),Mt(r,t))}function At(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function St(e,t,r){const n=Object.create(ot.prototype);const i=u(t,"pull",0,[n]),a=u(t,"cancel",1,[]);let s=t.autoAllocateChunkSize;if(void 0!==s&&(s=Number(s),!1===at(s)||s<=0))throw new RangeError("autoAllocateChunkSize must be a positive integer");!function(e,t,r,n,i,a,s){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,t._byobRequest=void 0,t._queue=t._queueTotalSize=void 0,ee(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=d(a),t._pullAlgorithm=n,t._cancelAlgorithm=i,t._autoAllocateChunkSize=s,t._pendingPullIntos=new x,e._readableStreamController=t,k(b(r()),()=>{t._started=!0,lt(t)},e=>{kt(t,e)})}(e,n,(function(){return l(t,"start",[n])}),i,a,r,s)}function Et(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function Pt(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function xt(e){return w((t,r)=>{const n={_resolve:t,_reject:r};e._reader._readIntoRequests.push(n)})}function Kt(e){return e._reader._readIntoRequests.length}function Ct(e){const t=e._reader;return void 0!==t&&!!Rt(t)}class Ut{constructor(e){if(!zt(e))throw new TypeError("ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a byte source");if(!1===ct(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");if(Ot(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");C(this,e),this._readIntoRequests=new x}get closed(){return Rt(this)?this._closedPromise:_(Tt("closed"))}cancel(e){return Rt(this)?void 0===this._ownerReadableStream?_(T("cancel")):U(this,e):_(Tt("cancel"))}read(e){return Rt(this)?void 0===this._ownerReadableStream?_(T("read from")):ArrayBuffer.isView(e)?(e.buffer,0===e.byteLength?_(new TypeError("view must have non-zero byteLength")):function(e,t){const r=e._ownerReadableStream;if(r._disturbed=!0,"errored"===r._state)return _(r._storedError);return function(e,t){const r=e._controlledReadableByteStream;let n=1;t.constructor!==DataView&&(n=t.constructor.BYTES_PER_ELEMENT);const i=t.constructor,a={buffer:t.buffer,byteOffset:t.byteOffset,byteLength:t.byteLength,bytesFilled:0,elementSize:n,ctor:i,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(a),xt(r);if("closed"===r._state){return b(K(new i(a.buffer,a.byteOffset,0),!0,r._reader._forAuthorCode))}if(e._queueTotalSize>0){if(!0===yt(e,a)){const t=dt(a);return gt(e),b(K(t,!1,r._reader._forAuthorCode))}if(!0===e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return kt(e,t),_(t)}}e._pendingPullIntos.push(a);const s=xt(r);return lt(e),s}(r._readableStreamController,t)}(this,e)):_(new TypeError("view must be an array buffer view")):_(Tt("read"))}releaseLock(){if(!Rt(this))throw Tt("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readIntoRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");R(this)}}}function Rt(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")}function Tt(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}class Dt{constructor(e={},t={}){Bt(this);const r=t.size;let n=t.highWaterMark;const i=e.type;if("bytes"===i+""){if(void 0!==r)throw new RangeError("The strategy for a byte stream cannot have a size function");void 0===n&&(n=0),n=d(n),St(this,e,n)}else{if(void 0!==i)throw new RangeError("Invalid type is specified");{const t=f(r);void 0===n&&(n=1),n=d(n),function(e,t,r,n){const i=Object.create(Ve.prototype),a=u(t,"pull",0,[i]),s=u(t,"cancel",1,[]);nt(e,i,(function(){return l(t,"start",[i])}),a,s,r,n)}(this,e,n,t)}}}get locked(){if(!1===zt(this))throw Lt("locked");return Ot(this)}cancel(e){return!1===zt(this)?_(Lt("cancel")):!0===Ot(this)?_(new TypeError("Cannot cancel a stream that already has a reader")):qt(this,e)}getReader({mode:e}={}){if(!1===zt(this))throw Lt("getReader");if(void 0===e)return N(this,!0);if("byob"===(e+=""))return function(e,t=!1){const r=new Ut(e);return r._forAuthorCode=t,r}(this,!0);throw new RangeError("Invalid mode is specified")}pipeThrough({writable:e,readable:t},{preventClose:r,preventAbort:n,preventCancel:i,signal:a}={}){if(!1===zt(this))throw Lt("pipeThrough");if(!1===se(e))throw new TypeError("writable argument to pipeThrough must be a WritableStream");if(!1===zt(t))throw new TypeError("readable argument to pipeThrough must be a ReadableStream");if(r=!!r,n=!!n,i=!!i,void 0!==a&&!Fe(a))throw new TypeError("ReadableStream.prototype.pipeThrough's signal option must be an AbortSignal");if(!0===Ot(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(!0===oe(e))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return P(Ge(this,e,r,n,i,a)),t}pipeTo(e,{preventClose:t,preventAbort:r,preventCancel:n,signal:i}={}){return!1===zt(this)?_(Lt("pipeTo")):!1===se(e)?_(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream")):(t=!!t,r=!!r,n=!!n,void 0===i||Fe(i)?!0===Ot(this)?_(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):!0===oe(e)?_(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):Ge(this,e,t,r,n,i):_(new TypeError("ReadableStream.prototype.pipeTo's signal option must be an AbortSignal")))}tee(){if(!1===zt(this))throw Lt("tee");const e=function(e,t){const r=N(e);let n,i,a,o,c,u=!1,l=!1,h=!1;const d=w(e=>{c=e});function f(){if(!0===u)return b(void 0);return u=!0,P(E(G(r),e=>{if(u=!1,!0===e.done)return!1===l&&Xe(a._readableStreamController),void(!1===h&&Xe(o._readableStreamController));const t=e.value,r=t,n=t;!1===l&&Je(a._readableStreamController,r),!1===h&&Je(o._readableStreamController,n)})),b(void 0)}function y(){}return a=It(y,f,(function(t){if(l=!0,n=t,!0===h){const t=s([n,i]),r=qt(e,t);c(r)}return d})),o=It(y,f,(function(t){if(h=!0,i=t,!0===l){const t=s([n,i]),r=qt(e,t);c(r)}return d})),S(r._closedPromise,e=>{et(a._readableStreamController,e),et(o._readableStreamController,e)}),[a,o]}(this);return s(e)}getIterator({preventCancel:e=!1}={}){if(!1===zt(this))throw Lt("getIterator");return function(e,t=!1){const r=N(e),n=Object.create(Y);return n._asyncIteratorReader=r,n._preventCancel=!!t,n}(this,e)}}function It(e,t,r,n=1,i=(()=>1)){const a=Object.create(Dt.prototype);return Bt(a),nt(a,Object.create(Ve.prototype),e,t,r,n,i),a}function Bt(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function zt(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")}function Ot(e){return void 0!==e._reader}function qt(e,t){if(e._disturbed=!0,"closed"===e._state)return b(void 0);if("errored"===e._state)return _(e._storedError);return Nt(e),E(e._readableStreamController[O](t),r)}function Nt(e){e._state="closed";const t=e._reader;void 0!==t&&(W(t)&&(t._readRequests.forEach(e=>{e._resolve(K(void 0,!0,t._forAuthorCode))}),t._readRequests=new x),z(t))}function Mt(e,t){e._state="errored",e._storedError=t;const r=e._reader;void 0!==r&&(W(r)?(r._readRequests.forEach(e=>{e._reject(t)}),r._readRequests=new x):(r._readIntoRequests.forEach(e=>{e._reject(t)}),r._readIntoRequests=new x),B(r,t))}function Lt(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}"symbol"==typeof t.asyncIterator&&Object.defineProperty(Dt.prototype,t.asyncIterator,{value:Dt.prototype.getIterator,enumerable:!1,writable:!0,configurable:!0});function jt(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")}function Ft(e,t){et(e._readable._readableStreamController,t),Ht(e,t)}function Ht(e,t){$t(e._transformStreamController),Ke(e._writable._writableStreamController,t),!0===e._backpressure&&Wt(e,!1)}function Wt(e,t){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=w(t=>{e._backpressureChangePromise_resolve=t}),e._backpressure=t}class Gt{constructor(){throw new TypeError("TransformStreamDefaultController instances cannot be created directly")}get desiredSize(){if(!1===Vt(this))throw Qt("desiredSize");return tt(this._controlledTransformStream._readable._readableStreamController)}enqueue(e){if(!1===Vt(this))throw Qt("enqueue");Yt(this,e)}error(e){if(!1===Vt(this))throw Qt("error");var t;t=e,Ft(this._controlledTransformStream,t)}terminate(){if(!1===Vt(this))throw Qt("terminate");!function(e){const t=e._controlledTransformStream,r=t._readable._readableStreamController;!0===rt(r)&&Xe(r);Ht(t,new TypeError("TransformStream terminated"))}(this)}}function Vt(e){return!!a(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")}function $t(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0}function Yt(e,t){const r=e._controlledTransformStream,n=r._readable._readableStreamController;if(!1===rt(n))throw new TypeError("Readable side is not in a state that permits enqueue");try{Je(n,t)}catch(e){throw Ht(r,e),r._readable._storedError}(function(e){return!0!==Ze(e)})(n)!==r._backpressure&&Wt(r,!0)}function Zt(e,t){return E(e._transformAlgorithm(t),void 0,t=>{throw Ft(e._controlledTransformStream,t),t})}function Qt(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function Xt(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}
3/*! *****************************************************************************
4Copyright (c) Microsoft Corporation. All rights reserved.
5Licensed under the Apache License, Version 2.0 (the "License"); you may not use
6this file except in compliance with the License. You may obtain a copy of the
7License at http://www.apache.org/licenses/LICENSE-2.0
8
9THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
10KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
11WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
12MERCHANTABLITY OR NON-INFRINGEMENT.
13
14See the Apache Version 2.0 License for specific language governing permissions
15and limitations under the License.
16***************************************************************************** */var Jt=function(e,t){return(Jt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function er(e,t){function r(){this.constructor=e}Jt(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function tr(e){if(!e)throw new TypeError("Assertion failed")}function rr(){}function nr(e){return("object"==typeof(t=e)&&null!==t||"function"==typeof t)&&"function"==typeof e.getReader;var t}function ir(e){try{return e.getReader({mode:"byob"}).releaseLock(),!0}catch(e){return!1}}function ar(e){tr(function(e){return!!function(e){if("function"!=typeof e)return!1;var t=!1;try{new e({start:function(){t=!0}})}catch(e){}return t}(e)&&!!nr(new e)}(e));var t=function(e){try{return new e({type:"bytes"}),!0}catch(e){return!1}}(e);return function(r,n){var i=(void 0===n?{}:n).type;if("bytes"!==(i=sr(i))||t||(i=void 0),r.constructor===e&&("bytes"!==i||ir(r)))return r;var a=function(e,t){var r,n=(void 0===t?{}:t).type;tr(nr(e)),tr(!1===e.locked),r="bytes"===(n=sr(n))?new lr(e):new cr(e);return r}(r,{type:i});return new e(a)}}function sr(e){var t=e+"";if("bytes"===t)return t;if(void 0===e)return e;throw new RangeError("Invalid type is specified")}var or=function(){function e(e){this._underlyingReader=void 0,this._readerMode=void 0,this._readableStreamController=void 0,this._pendingRead=void 0,this._underlyingStream=e,this._attachDefaultReader()}return e.prototype.start=function(e){this._readableStreamController=e},e.prototype.cancel=function(e){return tr(void 0!==this._underlyingReader),this._underlyingReader.cancel(e)},e.prototype._attachDefaultReader=function(){if("default"!==this._readerMode){this._detachReader();var e=this._underlyingStream.getReader();this._readerMode="default",this._attachReader(e)}},e.prototype._attachReader=function(e){var t=this;tr(void 0===this._underlyingReader),this._underlyingReader=e;var r=this._underlyingReader.closed;r&&r.then((function(){return t._finishPendingRead()})).then((function(){e===t._underlyingReader&&t._readableStreamController.close()}),(function(r){e===t._underlyingReader&&t._readableStreamController.error(r)})).catch(rr)},e.prototype._detachReader=function(){void 0!==this._underlyingReader&&(this._underlyingReader.releaseLock(),this._underlyingReader=void 0,this._readerMode=void 0)},e.prototype._pullWithDefaultReader=function(){var e=this;this._attachDefaultReader();var t=this._underlyingReader.read().then((function(t){var r=e._readableStreamController;t.done?e._tryClose():r.enqueue(t.value)}));return this._setPendingRead(t),t},e.prototype._tryClose=function(){try{this._readableStreamController.close()}catch(e){}},e.prototype._setPendingRead=function(e){var t,r=this,n=function(){r._pendingRead===t&&(r._pendingRead=void 0)};this._pendingRead=t=e.then(n,n)},e.prototype._finishPendingRead=function(){var e=this;if(this._pendingRead){var t=function(){return e._finishPendingRead()};return this._pendingRead.then(t,t)}},e}(),cr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return er(t,e),t.prototype.pull=function(){return this._pullWithDefaultReader()},t}(or);function ur(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var lr=function(e){function t(t){var r=this,n=ir(t);return(r=e.call(this,t)||this)._supportsByob=n,r}return er(t,e),Object.defineProperty(t.prototype,"type",{get:function(){return"bytes"},enumerable:!0,configurable:!0}),t.prototype._attachByobReader=function(){if("byob"!==this._readerMode){tr(this._supportsByob),this._detachReader();var e=this._underlyingStream.getReader({mode:"byob"});this._readerMode="byob",this._attachReader(e)}},t.prototype.pull=function(){if(this._supportsByob){var e=this._readableStreamController.byobRequest;if(void 0!==e)return this._pullWithByobRequest(e)}return this._pullWithDefaultReader()},t.prototype._pullWithByobRequest=function(e){var t=this;this._attachByobReader();var r=new Uint8Array(e.view.byteLength),n=this._underlyingReader.read(r).then((function(r){var n,i,a;t._readableStreamController,r.done?(t._tryClose(),e.respond(0)):(n=r.value,i=e.view,a=ur(n),ur(i).set(a,0),e.respond(r.value.byteLength))}));return this._setPendingRead(n),n},t}(or);const hr="object"==typeof e.process&&"object"==typeof e.process.versions,dr=hr&&void 0;function fr(t){return e.ReadableStream&&e.ReadableStream.prototype.isPrototypeOf(t)?"web":Fr.ReadableStream.prototype.isPrototypeOf(t)?"ponyfill":!(!dr||!dr.prototype.isPrototypeOf(t))&&"node"}function yr(e){return Uint8Array.prototype.isPrototypeOf(e)}function pr(e){if(1===e.length)return e[0];let t=0;for(let r=0;r<e.length;r++){if(!yr(e[r]))throw Error("concatUint8Array: Data must be in the form of a Uint8Array");t+=e[r].length}const r=new Uint8Array(t);let n=0;return e.forEach((function(e){r.set(e,n),n+=e.length})),r}const gr=hr&&void 0,mr=hr&&void 0;let wr,br;if(mr){wr=function(e){return new Fr.ReadableStream({start(t){e.pause(),e.on("data",r=>{gr.isBuffer(r)&&(r=new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),t.enqueue(r),e.pause()}),e.on("end",()=>t.close()),e.on("error",e=>t.error(e))},pull(){e.resume()},cancel(t){if(e.pause(),e.cancel)return e.cancel(t)}})};class e extends mr{constructor(e,t){super(t),this._webStream=e,this._reader=Fr.getReader(e),this._reading=!1,this._doneReadingPromise=Promise.resolve(),this._cancelling=!1}_read(e){if(this._reading||this._cancelling)return;this._reading=!0;this._doneReadingPromise=(async()=>{try{for(;;){const{done:e,value:t}=await this._reader.read();if(e){this.push(null);break}if(!this.push(t)||this._cancelling){this._reading=!1;break}}}catch(e){this.emit("error",e)}})()}async cancel(e){return this._cancelling=!0,await this._doneReadingPromise,this._reader.releaseLock(),this._webStream.cancel(e)}}br=function(t){return new e(t)}}const _r=new WeakSet,vr=Symbol("externalBuffer");function kr(e){this.stream=e,e[vr]&&(this[vr]=e[vr].slice());let t=Fr.isStream(e);if("node"===t&&(e=Fr.nodeToWeb(e)),t){const t=e.getReader();return this._read=t.read.bind(t),void(this._releaseLock=()=>{t.closed.catch((function(){})),t.releaseLock()})}let r=!1;this._read=async()=>r||_r.has(e)?{value:void 0,done:!0}:(r=!0,{value:e,done:!1}),this._releaseLock=()=>{if(r)try{_r.add(e)}catch(e){}}}kr.prototype.read=async function(){if(this[vr]&&this[vr].length){return{done:!1,value:this[vr].shift()}}return this._read()},kr.prototype.releaseLock=function(){this[vr]&&(this.stream[vr]=this[vr]),this._releaseLock()},kr.prototype.readLine=async function(){let e,t=[];for(;!e;){let{done:r,value:n}=await this.read();if(n+="",r)return t.length?Fr.concat(t):void 0;const i=n.indexOf("\n")+1;i&&(e=Fr.concat(t.concat(n.substr(0,i))),t=[]),i!==n.length&&t.push(n.substr(i))}return this.unshift(...t),e},kr.prototype.readByte=async function(){const{done:e,value:t}=await this.read();if(e)return;const r=t[0];return this.unshift(Fr.slice(t,1)),r},kr.prototype.readBytes=async function(e){const t=[];let r=0;for(;;){const{done:n,value:i}=await this.read();if(n)return t.length?Fr.concat(t):void 0;if(t.push(i),r+=i.length,r>=e){const r=Fr.concat(t);return this.unshift(Fr.slice(r,e)),Fr.slice(r,0,e)}}},kr.prototype.peekBytes=async function(e){const t=await this.readBytes(e);return this.unshift(t),t},kr.prototype.unshift=function(...e){this[vr]||(this[vr]=[]),1===e.length&&yr(e[0])&&this[vr].length&&e[0].length&&this[vr][0].byteOffset>=e[0].length?this[vr][0]=new Uint8Array(this[vr][0].buffer,this[vr][0].byteOffset-e[0].length,this[vr][0].byteLength+e[0].length):this[vr].unshift(...e.filter(e=>e&&e.length))},kr.prototype.readToEnd=async function(e=Fr.concat){const t=[];for(;;){const{done:e,value:r}=await this.read();if(e)break;t.push(r)}return e(t)};const{ReadableStream:Ar,WritableStream:Sr,TransformStream:Er}=e.TransformStream?e:{ReadableStream:Dt,WritableStream:ne,TransformStream:class{constructor(e={},t={},r={}){const n=t.size;let i=t.highWaterMark;const a=r.size;let s=r.highWaterMark;if(void 0!==e.writableType)throw new RangeError("Invalid writable type specified");const o=f(n);if(void 0===i&&(i=1),i=d(i),void 0!==e.readableType)throw new RangeError("Invalid readable type specified");const c=f(a);let y;void 0===s&&(s=0),s=d(s),function(e,t,r,n,i,a){function s(){return t}e._writable=function(e,t,r,n,i=1,a=(()=>1)){const s=Object.create(ne.prototype);return ae(s),Se(s,Object.create(Ae.prototype),e,t,r,n,i,a),s}(s,(function(t){return function(e,t){const r=e._transformStreamController;if(!0===e._backpressure){return E(e._backpressureChangePromise,()=>{const n=e._writable;if("erroring"===n._state)throw n._storedError;return Zt(r,t)})}return Zt(r,t)}(e,t)}),(function(){return function(e){const t=e._readable,r=e._transformStreamController,n=r._flushAlgorithm();return $t(r),E(n,()=>{if("errored"===t._state)throw t._storedError;const e=t._readableStreamController;!0===rt(e)&&Xe(e)},r=>{throw Ft(e,r),t._storedError})}(e)}),(function(t){return function(e,t){return Ft(e,t),b(void 0)}(e,t)}),r,n),e._readable=It(s,(function(){return function(e){return Wt(e,!1),e._backpressureChangePromise}(e)}),(function(t){return Ht(e,t),b(void 0)}),i,a),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,Wt(e,!0),e._transformStreamController=void 0}(this,w(e=>{y=e}),i,o,s,c),function(e,t){const r=Object.create(Gt.prototype);let n=e=>{try{return Yt(r,e),b(void 0)}catch(e){return _(e)}};const i=t.transform;if(void 0!==i){if("function"!=typeof i)throw new TypeError("transform is not a method");n=e=>h(i,t,[e,r])}const a=u(t,"flush",0,[r]);!function(e,t,r,n){t._controlledTransformStream=e,e._transformStreamController=t,t._transformAlgorithm=r,t._flushAlgorithm=n}(e,r,n,a)}(this,e);const p=l(e,"start",[this._transformStreamController]);y(p)}get readable(){if(!1===jt(this))throw Xt("readable");return this._readable}get writable(){if(!1===jt(this))throw Xt("writable");return this._writable}}},Pr=e.ReadableStream&&Ar!==e.ReadableStream&&ar(Ar),xr=hr&&void 0;function Kr(e){let t=fr(e);return"node"===t?wr(e):"web"===t&&Pr?Pr(e):t?e:new Ar({start(t){t.enqueue(e),t.close()}})}function Cr(e){return e.some(fr)?Ur(e):"string"==typeof e[0]?e.join(""):xr&&xr.isBuffer(e[0])?xr.concat(e):pr(e)}function Ur(e){e=e.map(Kr);const t=Br((async function(e){await Promise.all(n.map(t=>Lr(t,e)))}));let r=Promise.resolve();const n=e.map((n,i)=>Or(n,(n,a)=>(r=r.then(()=>Dr(n,t.writable,{preventClose:i!==e.length-1})),r)));return t.readable}function Rr(e){return new kr(e)}function Tr(e){const t=e.getWriter(),r=t.releaseLock;return t.releaseLock=()=>{t.closed.catch((function(){})),r.call(t)},t}async function Dr(e,t,r){e=Kr(e);try{if(e[vr]){const r=Tr(t);for(let t=0;t<e[vr].length;t++)await r.ready,await r.write(e[vr][t]);r.releaseLock()}return await e.pipeTo(t,r)}catch(e){}}function Ir(e,t){const r=new Er(t);return Dr(e,r.writable),r.readable}function Br(e){let t,r,n=!1;return{readable:new Ar({start(e){r=e},pull(){t?t():n=!0},cancel:e},{highWaterMark:0}),writable:new Sr({write:async function(e){r.enqueue(e),n?n=!1:(await new Promise(e=>{t=e}),t=null)},close:r.close.bind(r),abort:r.error.bind(r)})}}function zr(e,t=(()=>{}),r=(()=>{})){if(fr(e))return Ir(e,{async transform(e,r){try{const n=await t(e);void 0!==n&&r.enqueue(n)}catch(e){r.error(e)}},async flush(e){try{const t=await r();void 0!==t&&e.enqueue(t)}catch(t){e.error(t)}}});const n=t(e),i=r();return void 0!==n&&void 0!==i?Cr([n,i]):void 0!==n?n:i}function Or(e,t){let r;const n=new Er({start(e){r=e}}),i=Dr(e,n.writable),a=Br((async function(){r.error(Error("Readable side was canceled.")),await i,await new Promise(setTimeout)}));return t(n.readable,a.writable),a.readable}function qr(e,t){Object.entries(Object.getOwnPropertyDescriptors(Ar.prototype)).forEach(([r,n])=>{"constructor"!==r&&(n.value?n.value=n.value.bind(t):n.get=n.get.bind(t),Object.defineProperty(e,r,n))})}function Nr(e,t=0,r=1/0){if(fr(e)){if(t>=0&&r>=0){let n=0;return Ir(e,{transform(e,i){n<r?(n+e.length>=t&&i.enqueue(Nr(e,Math.max(t-n,0),r-n)),n+=e.length):i.terminate()}})}if(t<0&&(r<0||r===1/0)){let n=[];return zr(e,e=>{e.length>=-t?n=[e]:n.push(e)},()=>Nr(Cr(n),t,r))}if(0===t&&r<0){let n;return zr(e,e=>{const i=n?Cr([n,e]):e;if(i.length>=-r)return n=Nr(i,r),Nr(i,t,r);n=i})}return console.warn(`stream.slice(input, ${t}, ${r}) not implemented efficiently.`),jr(async()=>Nr(await Mr(e),t,r))}return e[vr]&&(e=Cr(e[vr].concat([e]))),!yr(e)||xr&&xr.isBuffer(e)?e.slice(t,r):(r===1/0&&(r=e.length),e.subarray(t,r))}async function Mr(e,t){return fr(e)?Rr(e).readToEnd(t):e}async function Lr(e,t){if(fr(e)&&e.cancel)return e.cancel(t)}function jr(e){return new Ar({pull:async t=>{try{t.enqueue(await e()),t.close()}catch(e){t.error(e)}}})}var Fr={ReadableStream:Ar,WritableStream:Sr,TransformStream:Er,isStream:fr,isUint8Array:yr,toStream:Kr,concatUint8Array:pr,concatStream:Ur,concat:Cr,getReader:Rr,getWriter:Tr,pipe:Dr,transformRaw:Ir,transform:zr,transformPair:Or,parse:function(e,t){let r;const n=Or(e,(e,i)=>{const a=Rr(e);a.remainder=()=>(a.releaseLock(),Dr(e,i),n),r=t(a)});return r},clone:function(e){if(fr(e)){const t=function(e){if(fr(e)){const t=Kr(e).tee();return t[0][vr]=t[1][vr]=e[vr],t}return[Nr(e),Nr(e)]}(e);return qr(e,t[0]),t[1]}return Nr(e)},passiveClone:function(e){return fr(e)?new Ar({start(t){const r=Or(e,async(e,r)=>{const n=Rr(e),i=Tr(r);try{for(;;){await i.ready;const{done:e,value:r}=await n.read();if(e){try{t.close()}catch(e){}return void await i.close()}try{t.enqueue(r)}catch(e){}await i.write(r)}}catch(e){t.error(e),await i.abort(e)}});qr(e,r)}}):Nr(e)},slice:Nr,readToEnd:Mr,cancel:Lr,fromAsync:jr,nodeToWeb:wr,webToNode:br};class Hr{constructor(e){if(void 0===e)throw Error("Invalid BigInteger input");if(e instanceof Uint8Array){const t=e,r=Array(t.length);for(let e=0;e<t.length;e++){const n=t[e].toString(16);r[e]=t[e]<=15?"0"+n:n}this.value=BigInt("0x0"+r.join(""))}else this.value=BigInt(e)}clone(){return new Hr(this.value)}iinc(){return this.value++,this}inc(){return this.clone().iinc()}idec(){return this.value--,this}dec(){return this.clone().idec()}iadd(e){return this.value+=e.value,this}add(e){return this.clone().iadd(e)}isub(e){return this.value-=e.value,this}sub(e){return this.clone().isub(e)}imul(e){return this.value*=e.value,this}mul(e){return this.clone().imul(e)}imod(e){return this.value%=e.value,this.isNegative()&&this.iadd(e),this}mod(e){return this.clone().imod(e)}modExp(e,t){if(t.isZero())throw Error("Modulo cannot be zero");if(t.isOne())return new Hr(0);if(e.isNegative())throw Error("Unsopported negative exponent");let r=e.value,n=this.value;n%=t.value;let i=BigInt(1);for(;r>BigInt(0);){const e=r&BigInt(1);r>>=BigInt(1);const a=i*n%t.value;i=e?a:i,n=n*n%t.value}return new Hr(i)}modInv(e){const{gcd:t,x:r}=this._egcd(e);if(!t.isOne())throw Error("Inverse does not exist");return r.add(e).mod(e)}_egcd(e){let t=BigInt(0),r=BigInt(1),n=BigInt(1),i=BigInt(0),a=this.value;for(e=e.value;e!==BigInt(0);){const s=a/e;let o=t;t=n-s*t,n=o,o=r,r=i-s*r,i=o,o=e,e=a%e,a=o}return{x:new Hr(n),y:new Hr(i),gcd:new Hr(a)}}gcd(e){let t=this.value;for(e=e.value;e!==BigInt(0);){const r=e;e=t%e,t=r}return new Hr(t)}ileftShift(e){return this.value<<=e.value,this}leftShift(e){return this.clone().ileftShift(e)}irightShift(e){return this.value>>=e.value,this}rightShift(e){return this.clone().irightShift(e)}equal(e){return this.value===e.value}lt(e){return this.value<e.value}lte(e){return this.value<=e.value}gt(e){return this.value>e.value}gte(e){return this.value>=e.value}isZero(){return this.value===BigInt(0)}isOne(){return this.value===BigInt(1)}isNegative(){return this.value<BigInt(0)}isEven(){return!(this.value&BigInt(1))}abs(){const e=this.clone();return this.isNegative()&&(e.value=-e.value),e}toString(){return this.value.toString()}toNumber(){const e=Number(this.value);if(e>Number.MAX_SAFE_INTEGER)throw Error("Number can only safely store up to 53 bits");return e}getBit(e){return(this.value>>BigInt(e)&BigInt(1))===BigInt(0)?0:1}bitLength(){const e=new Hr(0),t=new Hr(1),r=new Hr(-1),n=this.isNegative()?r:e;let i=1;const a=this.clone();for(;!a.irightShift(t).equal(n);)i++;return i}byteLength(){const e=new Hr(0),t=new Hr(-1),r=this.isNegative()?t:e,n=new Hr(8);let i=1;const a=this.clone();for(;!a.irightShift(n).equal(r);)i++;return i}toUint8Array(e="be",t){let r=this.value.toString(16);r.length%2==1&&(r="0"+r);const n=r.length/2,i=new Uint8Array(t||n),a=t?t-n:0;let s=0;for(;s<n;)i[s+a]=parseInt(r.slice(2*s,2*s+2),16),s++;return"be"!==e&&i.reverse(),i}}const Wr=e.process&&"development"===e.process.env.NODE_ENV,Gr={isString:function(e){return"string"==typeof e||String.prototype.isPrototypeOf(e)},isArray:function(e){return Array.prototype.isPrototypeOf(e)},isBigInteger:function(e){return null!==e&&"object"==typeof e&&e.value&&("bigint"==typeof e.value||this.isBN(e.value))},isBN:function(e){return null!==e&&"object"==typeof e&&("BN"===e.constructor.name||26===e.constructor.wordSize&&Array.isArray(e.words))},isUint8Array:Fr.isUint8Array,isStream:Fr.isStream,restoreStreams:function(t,r){return"[object MessagePort]"===Object.prototype.toString.call(t)?new("web"===r?e.ReadableStream:Fr.ReadableStream)({pull:e=>new Promise(r=>{t.onmessage=t=>{const{done:n,value:i,error:a}=t.data;a?e.error(Error(a)):n?e.close():e.enqueue(i),r()},t.postMessage({action:"read"})}),cancel:()=>new Promise(e=>{t.onmessage=e,t.postMessage({action:"cancel"})})},{highWaterMark:0}):(Object.prototype.isPrototypeOf(t)&&!Uint8Array.prototype.isPrototypeOf(t)&&Object.entries(t).forEach(([e,n])=>{t[e]=Gr.restoreStreams(n,r)}),t)},readNumber:function(e){let t=0;for(let r=0;r<e.length;r++)t+=256**r*e[e.length-1-r];return t},writeNumber:function(e,t){const r=new Uint8Array(t);for(let n=0;n<t;n++)r[n]=e>>8*(t-n-1)&255;return r},readDate:function(e){const t=Gr.readNumber(e);return new Date(1e3*t)},writeDate:function(e){const t=Math.floor(e.getTime()/1e3);return Gr.writeNumber(t,4)},normalizeDate:function(e=Date.now()){return null===e||e===1/0?e:new Date(1e3*Math.floor(+e/1e3))},strToHex:function(e){if(null===e)return"";const t=[],r=e.length;let n,i=0;for(;i<r;){for(n=e.charCodeAt(i++).toString(16);n.length<2;)n="0"+n;t.push(""+n)}return t.join("")},hexToStr:function(e){let t="";for(let r=0;r<e.length;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t},readMPI:function(e){const t=(e[0]<<8|e[1])+7>>>3;return e.subarray(2,2+t)},leftPad(e,t){const r=new Uint8Array(t),n=t-e.length;return r.set(e,n),r},uint8ArrayToMpi:function(e){let t;for(t=0;t<e.length&&0===e[t];t++);if(t===e.length)throw Error("Zero MPI");const r=e.subarray(t),n=8*(r.length-1)+Gr.nbits(r[0]),i=Uint8Array.from([(65280&n)>>8,255&n]);return Gr.concatUint8Array([i,r])},hexToUint8Array:function(e){const t=new Uint8Array(e.length>>1);for(let r=0;r<e.length>>1;r++)t[r]=parseInt(e.substr(r<<1,2),16);return t},uint8ArrayToHex:function(e){const t=[],r=e.length;let n,i=0;for(;i<r;){for(n=e[i++].toString(16);n.length<2;)n="0"+n;t.push(""+n)}return t.join("")},strToUint8Array:function(e){return Fr.transform(e,e=>{if(!Gr.isString(e))throw Error("strToUint8Array: Data must be in the form of a string");const t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})},uint8ArrayToStr:function(e){const t=[],r=(e=new Uint8Array(e)).length;for(let n=0;n<r;n+=16384)t.push(String.fromCharCode.apply(String,e.subarray(n,n+16384<r?n+16384:r)));return t.join("")},encodeUtf8:function(e){const t=new TextEncoder("utf-8");function r(e,r=!1){return t.encode(e,{stream:!r})}return Fr.transform(e,r,()=>r("",!0))},decodeUtf8:function(e){const t=new TextDecoder("utf-8");function r(e,r=!1){return t.decode(e,{stream:!r})}return Fr.transform(e,r,()=>r(new Uint8Array,!0))},concat:Fr.concat,concatUint8Array:Fr.concatUint8Array,equalsUint8Array:function(e,t){if(!Gr.isUint8Array(e)||!Gr.isUint8Array(t))throw Error("Data must be in the form of a Uint8Array");if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0},writeChecksum:function(e){let t=0;for(let r=0;r<e.length;r++)t=t+e[r]&65535;return Gr.writeNumber(t,2)},printDebug:function(e){Wr&&console.log(e)},printDebugHexArrayDump:function(e,t){Wr&&(e+=": "+Gr.uint8ArrayToHex(t),console.log(e))},printDebugHexStrDump:function(e,t){Wr&&(e+=Gr.strToHex(t),console.log(e))},printDebugError:function(e){Wr&&console.error(e)},printEntireStream:function(e,t,r){Fr.readToEnd(Fr.clone(t),r).then(t=>{console.log(e+": ",t)})},nbits:function(e){let t=1,r=e>>>16;return 0!==r&&(e=r,t+=16),r=e>>8,0!==r&&(e=r,t+=8),r=e>>4,0!==r&&(e=r,t+=4),r=e>>2,0!==r&&(e=r,t+=2),r=e>>1,0!==r&&(e=r,t+=1),t},double:function(e){const t=new Uint8Array(e.length),r=e.length-1;for(let n=0;n<r;n++)t[n]=e[n]<<1^e[n+1]>>7;return t[r]=e[r]<<1^135*(e[0]>>7),t},shiftRight:function(e,t){if(t)for(let r=e.length-1;r>=0;r--)e[r]>>=t,r>0&&(e[r]|=e[r-1]<<8-t);return e},getWebCrypto:function(){return void 0!==e&&e.crypto&&e.crypto.subtle},detectNode:function(){return"object"==typeof e.process&&"object"==typeof e.process.versions},detectBigInt:()=>"undefined"!=typeof BigInt,getBigInteger:async function(){if(Gr.detectBigInt())return Hr;{const{default:e}=await import("./bn.interface.min.mjs");return e}},getNodeCrypto:function(){},getNodeZlib:function(){},getNodeBuffer:function(){return{}.Buffer},getNodeStream:function(){return{}.Readable},getHardwareConcurrency:function(){if(Gr.detectNode()){return(void 0).cpus().length}return navigator.hardwareConcurrency||1},isEmailAddress:function(e){if(!Gr.isString(e))return!1;return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+([a-zA-Z]{2,}|xn--[a-zA-Z\-0-9]+)))$/.test(e)},canonicalizeEOL:function(e){let t=!1;return Fr.transform(e,e=>{let r;t&&(e=Gr.concatUint8Array([new Uint8Array([13]),e])),13===e[e.length-1]?(t=!0,e=e.subarray(0,-1)):t=!1;const n=[];for(let t=0;r=e.indexOf(10,t)+1,r;t=r)13!==e[r-2]&&n.push(r);if(!n.length)return e;const i=new Uint8Array(e.length+n.length);let a=0;for(let t=0;t<n.length;t++){const r=e.subarray(n[t-1]||0,n[t]);i.set(r,a),a+=r.length,i[a-1]=13,i[a]=10,a++}return i.set(e.subarray(n[n.length-1]||0),a),i},()=>t?new Uint8Array([13]):void 0)},nativeEOL:function(e){let t=!1;return Fr.transform(e,e=>{let r;13===(e=t&&10!==e[0]?Gr.concatUint8Array([new Uint8Array([13]),e]):new Uint8Array(e))[e.length-1]?(t=!0,e=e.subarray(0,-1)):t=!1;let n=0;for(let t=0;t!==e.length;t=r){r=e.indexOf(13,t)+1,r||(r=e.length);const i=r-(10===e[r]?1:0);t&&e.copyWithin(n,t,i),n+=i-t}return e.subarray(0,n)},()=>t?new Uint8Array([13]):void 0)},removeTrailingSpaces:function(e){return e.split("\n").map(e=>{let t=e.length-1;for(;t>=0&&(" "===e[t]||"\t"===e[t]);t--);return e.substr(0,t+1)}).join("\n")},wrapError:function(e,t){if(!t)return Error(e);try{t.message=e+": "+t.message}catch(e){}return t}},Vr=Gr.getNodeBuffer();let $r,Yr;function Zr(e){let t=new Uint8Array;return Fr.transform(e,e=>{t=Gr.concatUint8Array([t,e]);const r=[],n=Math.floor(t.length/45),i=45*n,a=$r(t.subarray(0,i));for(let e=0;e<n;e++)r.push(a.substr(60*e,60)),r.push("\n");return t=t.subarray(i),r.join("")},()=>t.length?$r(t)+"\n":"")}function Qr(e){let t="";return Fr.transform(e,e=>{t+=e;let r=0;const n=[" ","\t","\r","\n"];for(let e=0;e<n.length;e++){const i=n[e];for(let e=t.indexOf(i);-1!==e;e=t.indexOf(i,e+1))r++}let i=t.length;for(;i>0&&(i-r)%4!=0;i--)n.includes(t[i])&&r--;const a=Yr(t.substr(0,i));return t=t.substr(i),a},()=>Yr(t))}function Xr(e){return Qr(e.replace(/-/g,"+").replace(/_/g,"/"))}function Jr(e,t){let r=Zr(e).replace(/[\r\n]/g,"");return t&&(r=r.replace(/[+]/g,"-").replace(/[/]/g,"_").replace(/[=]/g,"")),r}Vr?($r=e=>Vr.from(e).toString("base64"),Yr=e=>{const t=Vr.from(e,"base64");return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}):($r=e=>btoa(Gr.uint8ArrayToStr(e)),Yr=e=>Gr.strToUint8Array(atob(e)));const en=Symbol("byValue");var tn={curve:{p256:"p256","P-256":"p256",secp256r1:"p256",prime256v1:"p256","1.2.840.10045.3.1.7":"p256","2a8648ce3d030107":"p256","2A8648CE3D030107":"p256",p384:"p384","P-384":"p384",secp384r1:"p384","1.3.132.0.34":"p384","2b81040022":"p384","2B81040022":"p384",p521:"p521","P-521":"p521",secp521r1:"p521","1.3.132.0.35":"p521","2b81040023":"p521","2B81040023":"p521",secp256k1:"secp256k1","1.3.132.0.10":"secp256k1","2b8104000a":"secp256k1","2B8104000A":"secp256k1",ED25519:"ed25519",ed25519:"ed25519",Ed25519:"ed25519","1.3.6.1.4.1.11591.15.1":"ed25519","2b06010401da470f01":"ed25519","2B06010401DA470F01":"ed25519",X25519:"curve25519",cv25519:"curve25519",curve25519:"curve25519",Curve25519:"curve25519","1.3.6.1.4.1.3029.1.5.1":"curve25519","2b060104019755010501":"curve25519","2B060104019755010501":"curve25519",brainpoolP256r1:"brainpoolP256r1","1.3.36.3.3.2.8.1.1.7":"brainpoolP256r1","2b2403030208010107":"brainpoolP256r1","2B2403030208010107":"brainpoolP256r1",brainpoolP384r1:"brainpoolP384r1","1.3.36.3.3.2.8.1.1.11":"brainpoolP384r1","2b240303020801010b":"brainpoolP384r1","2B240303020801010B":"brainpoolP384r1",brainpoolP512r1:"brainpoolP512r1","1.3.36.3.3.2.8.1.1.13":"brainpoolP512r1","2b240303020801010d":"brainpoolP512r1","2B240303020801010D":"brainpoolP512r1"},s2k:{simple:0,salted:1,iterated:3,gnu:101},publicKey:{rsaEncryptSign:1,rsaEncrypt:2,rsaSign:3,elgamal:16,dsa:17,ecdh:18,ecdsa:19,eddsa:22,aedh:23,aedsa:24},symmetric:{plaintext:0,idea:1,tripledes:2,cast5:3,blowfish:4,aes128:7,aes192:8,aes256:9,twofish:10},compression:{uncompressed:0,zip:1,zlib:2,bzip2:3},hash:{md5:1,sha1:2,ripemd:3,sha256:8,sha384:9,sha512:10,sha224:11},webHash:{"SHA-1":2,"SHA-256":8,"SHA-384":9,"SHA-512":10},aead:{eax:1,ocb:2,experimentalGcm:100},packet:{publicKeyEncryptedSessionKey:1,signature:2,symEncryptedSessionKey:3,onePassSignature:4,secretKey:5,publicKey:6,secretSubkey:7,compressedData:8,symmetricallyEncryptedData:9,marker:10,literalData:11,trust:12,userID:13,publicSubkey:14,userAttribute:17,symEncryptedIntegrityProtectedData:18,modificationDetectionCode:19,AEADEncryptedData:20},literal:{binary:98,text:116,utf8:117,mime:109},signature:{binary:0,text:1,standalone:2,certGeneric:16,certPersona:17,certCasual:18,certPositive:19,certRevocation:48,subkeyBinding:24,keyBinding:25,key:31,keyRevocation:32,subkeyRevocation:40,timestamp:64,thirdParty:80},signatureSubpacket:{signatureCreationTime:2,signatureExpirationTime:3,exportableCertification:4,trustSignature:5,regularExpression:6,revocable:7,keyExpirationTime:9,placeholderBackwardsCompatibility:10,preferredSymmetricAlgorithms:11,revocationKey:12,issuer:16,notationData:20,preferredHashAlgorithms:21,preferredCompressionAlgorithms:22,keyServerPreferences:23,preferredKeyServer:24,primaryUserId:25,policyUri:26,keyFlags:27,signersUserId:28,reasonForRevocation:29,features:30,signatureTarget:31,embeddedSignature:32,issuerFingerprint:33,preferredAeadAlgorithms:34},keyFlags:{certifyKeys:1,signData:2,encryptCommunication:4,encryptStorage:8,splitPrivateKey:16,authentication:32,sharedPrivateKey:128},armor:{multipartSection:0,multipartLast:1,signed:2,message:3,publicKey:4,privateKey:5,signature:6},reasonForRevocation:{noReason:0,keySuperseded:1,keyCompromised:2,keyRetired:3,userIdInvalid:32},features:{modificationDetection:1,aead:2,v5Keys:4},write:function(e,t){if("number"==typeof t&&(t=this.read(e,t)),void 0!==e[t])return e[t];throw Error("Invalid enum value.")},read:function(e,t){if(e[en]||(e[en]=[],Object.entries(e).forEach(([t,r])=>{e[en][r]=t})),void 0!==e[en][t])return e[en][t];throw Error("Invalid enum value.")}},rn={preferHashAlgorithm:tn.hash.sha256,encryptionCipher:tn.symmetric.aes256,compression:tn.compression.uncompressed,deflateLevel:6,aeadProtect:!1,aeadMode:tn.aead.eax,aeadChunkSizeByte:12,v5Keys:!1,s2kIterationCountByte:224,allowUnauthenticatedMessages:!1,allowUnauthenticatedStream:!1,checksumRequired:!1,minRsaBits:2048,passwordCollisionCheck:!1,revocationsExpire:!1,allowInsecureDecryptionWithSigningKeys:!1,minBytesForWebCrypto:1e3,tolerant:!0,showVersion:!1,showComment:!1,versionString:"OpenPGP.js 5.0.0-1",commentString:"https://openpgpjs.org",maxUseridLength:5120,knownNotations:["preferred-email-encoding@pgp.com","pka-address@gnupg.org"],useIndutnyElliptic:!0,rejectHashAlgorithms:new e.Set([tn.hash.md5,tn.hash.ripemd]),rejectMessageHashAlgorithms:new e.Set([tn.hash.md5,tn.hash.ripemd,tn.hash.sha1])};function nn(e){const t=e.match(/^-----BEGIN PGP (MESSAGE, PART \d+\/\d+|MESSAGE, PART \d+|SIGNED MESSAGE|MESSAGE|PUBLIC KEY BLOCK|PRIVATE KEY BLOCK|SIGNATURE)-----$/m);if(!t)throw Error("Unknown ASCII armor type");return/MESSAGE, PART \d+\/\d+/.test(t[1])?tn.armor.multipartSection:/MESSAGE, PART \d+/.test(t[1])?tn.armor.multipartLast:/SIGNED MESSAGE/.test(t[1])?tn.armor.signed:/MESSAGE/.test(t[1])?tn.armor.message:/PUBLIC KEY BLOCK/.test(t[1])?tn.armor.publicKey:/PRIVATE KEY BLOCK/.test(t[1])?tn.armor.privateKey:/SIGNATURE/.test(t[1])?tn.armor.signature:void 0}function an(e,t){let r="";return t.showVersion&&(r+="Version: "+t.versionString+"\n"),t.showComment&&(r+="Comment: "+t.commentString+"\n"),e&&(r+="Comment: "+e+"\n"),r+="\n",r}function sn(e){return Zr(function(e){let t=13501623;return Fr.transform(e,e=>{const r=cn?Math.floor(e.length/4):0,n=new Uint32Array(e.buffer,e.byteOffset,r);for(let e=0;e<r;e++)t^=n[e],t=on[0][t>>24&255]^on[1][t>>16&255]^on[2][t>>8&255]^on[3][t>>0&255];for(let n=4*r;n<e.length;n++)t=t>>8^on[0][255&t^e[n]]},()=>new Uint8Array([t,t>>8,t>>16]))}(e))}const on=[Array(255),Array(255),Array(255),Array(255)];for(let e=0;e<=255;e++){let t=e<<16;for(let e=0;e<8;e++)t=t<<1^(0!=(8388608&t)?8801531:0);on[0][e]=(16711680&t)>>16|65280&t|(255&t)<<16}for(let e=0;e<=255;e++)on[1][e]=on[0][e]>>8^on[0][255&on[0][e]];for(let e=0;e<=255;e++)on[2][e]=on[1][e]>>8^on[0][255&on[1][e]];for(let e=0;e<=255;e++)on[3][e]=on[2][e]>>8^on[0][255&on[2][e]];const cn=function(){const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,255,!0),255===new Int16Array(e)[0]}();function un(e){for(let t=0;t<e.length;t++){if(!/^([^\s:]|[^\s:][^:]*[^\s:]): .+$/.test(e[t]))throw Error("Improperly formatted armor header: "+e[t]);/^(Version|Comment|MessageID|Hash|Charset): .+$/.test(e[t])||Gr.printDebugError(Error("Unknown header: "+e[t]))}}function ln(e){let t=e,r="";const n=e.lastIndexOf("=");return n>=0&&n!==e.length-1&&(t=e.slice(0,n),r=e.slice(n+1).substr(0,4)),{body:t,checksum:r}}function hn(e,t=rn){return new Promise(async(r,n)=>{try{const i=/^-----[^-]+-----$/m,a=/^[ \f\r\t\u00a0\u2000-\u200a\u202f\u205f\u3000]*$/;let s;const o=[];let c,u,l,h=o,d=[],f=Qr(Fr.transformPair(e,async(e,t)=>{const y=Fr.getReader(e);try{for(;;){let e=await y.readLine();if(void 0===e)throw Error("Misformed armored text");if(e=Gr.removeTrailingSpaces(e.replace(/[\r\n]/g,"")),s)if(c)u||2!==s||(i.test(e)?(d=d.join("\r\n"),u=!0,un(h),h=[],c=!1):d.push(e.replace(/^- /,"")));else if(i.test(e)&&n(Error("Mandatory blank line missing between armor headers and armor data")),a.test(e)){if(un(h),c=!0,u||2!==s){r({text:d,data:f,headers:o,type:s});break}}else h.push(e);else i.test(e)&&(s=nn(e))}}catch(e){return void n(e)}const p=Fr.getWriter(t);try{for(;;){await p.ready;const{done:e,value:t}=await y.read();if(e)throw Error("Misformed armored text");const r=t+"";if(-1!==r.indexOf("=")||-1!==r.indexOf("-")){let e=await y.readToEnd();e.length||(e=""),e=r+e,e=Gr.removeTrailingSpaces(e.replace(/\r/g,""));const t=e.split(i);if(1===t.length)throw Error("Misformed armored text");const n=ln(t[0].slice(0,-1));l=n.checksum,await p.write(n.body);break}await p.write(r)}await p.ready,await p.close()}catch(e){await p.abort(e)}}));f=Fr.transformPair(f,async(e,r)=>{const n=Fr.readToEnd(sn(Fr.passiveClone(e)));n.catch(()=>{}),await Fr.pipe(e,r,{preventClose:!0});const i=Fr.getWriter(r);try{const e=(await n).replace("\n","");if(l!==e&&(l||t.checksumRequired))throw Error("Ascii armor integrity check on message failed: '"+l+"' should be '"+e+"'");await i.ready,await i.close()}catch(e){await i.abort(e)}})}catch(e){n(e)}})}function dn(e,t,r,n,i,a=rn){let s,o;e===tn.armor.signed&&(s=t.text,o=t.hash,t=t.data);const c=Fr.passiveClone(t),u=[];switch(e){case tn.armor.multipartSection:u.push("-----BEGIN PGP MESSAGE, PART "+r+"/"+n+"-----\n"),u.push(an(i,a)),u.push(Zr(t)),u.push("=",sn(c)),u.push("-----END PGP MESSAGE, PART "+r+"/"+n+"-----\n");break;case tn.armor.multipartLast:u.push("-----BEGIN PGP MESSAGE, PART "+r+"-----\n"),u.push(an(i,a)),u.push(Zr(t)),u.push("=",sn(c)),u.push("-----END PGP MESSAGE, PART "+r+"-----\n");break;case tn.armor.signed:u.push("\n-----BEGIN PGP SIGNED MESSAGE-----\n"),u.push("Hash: "+o+"\n\n"),u.push(s.replace(/^-/gm,"- -")),u.push("\n-----BEGIN PGP SIGNATURE-----\n"),u.push(an(i,a)),u.push(Zr(t)),u.push("=",sn(c)),u.push("-----END PGP SIGNATURE-----\n");break;case tn.armor.message:u.push("-----BEGIN PGP MESSAGE-----\n"),u.push(an(i,a)),u.push(Zr(t)),u.push("=",sn(c)),u.push("-----END PGP MESSAGE-----\n");break;case tn.armor.publicKey:u.push("-----BEGIN PGP PUBLIC KEY BLOCK-----\n"),u.push(an(i,a)),u.push(Zr(t)),u.push("=",sn(c)),u.push("-----END PGP PUBLIC KEY BLOCK-----\n");break;case tn.armor.privateKey:u.push("-----BEGIN PGP PRIVATE KEY BLOCK-----\n"),u.push(an(i,a)),u.push(Zr(t)),u.push("=",sn(c)),u.push("-----END PGP PRIVATE KEY BLOCK-----\n");break;case tn.armor.signature:u.push("-----BEGIN PGP SIGNATURE-----\n"),u.push(an(i,a)),u.push(Zr(t)),u.push("=",sn(c)),u.push("-----END PGP SIGNATURE-----\n")}return Gr.concat(u)}class fn{constructor(){this.bytes=""}read(e){this.bytes=Gr.uint8ArrayToStr(e.subarray(0,8))}write(){return Gr.strToUint8Array(this.bytes)}toHex(){return Gr.strToHex(this.bytes)}equals(e,t=!1){return t&&(e.isWildcard()||this.isWildcard())||this.bytes===e.bytes}isNull(){return""===this.bytes}isWildcard(){return/^0+$/.test(this.toHex())}static mapToHex(e){return e.toHex()}static fromId(e){const t=new fn;return t.read(Gr.hexToUint8Array(e)),t}static wildcard(){const e=new fn;return e.read(new Uint8Array(8)),e}}var yn=function(){var e,t,r=!1;function n(r,n){var i=e[(t[r]+t[n])%255];return 0!==r&&0!==n||(i=0),i}var i,a,s,o,c=!1;function u(){function u(r){var n,i,a;for(i=a=function(r){var n=e[255-t[r]];return 0===r&&(n=0),n}(r),n=0;n<4;n++)a^=i=255&(i<<1|i>>>7);return a^=99}r||function(){e=[],t=[];var n,i,a=1;for(n=0;n<255;n++)e[n]=a,i=128&a,a<<=1,a&=255,128===i&&(a^=27),a^=e[n],t[e[n]]=n;e[255]=e[0],t[0]=0,r=!0}(),i=[],a=[],s=[[],[],[],[]],o=[[],[],[],[]];for(var l=0;l<256;l++){var h=u(l);i[l]=h,a[h]=l,s[0][l]=n(2,h)<<24|h<<16|h<<8|n(3,h),o[0][h]=n(14,l)<<24|n(9,l)<<16|n(13,l)<<8|n(11,l);for(var d=1;d<4;d++)s[d][l]=s[d-1][l]>>>8|s[d-1][l]<<24,o[d][h]=o[d-1][h]>>>8|o[d-1][h]<<24}c=!0}var l=function(e,t){c||u();var r=new Uint32Array(t);r.set(i,512),r.set(a,768);for(var n=0;n<4;n++)r.set(s[n],4096+1024*n>>2),r.set(o[n],8192+1024*n>>2);var l=function(e,t,r){"use asm";var n=0,i=0,a=0,s=0,o=0,c=0,u=0,l=0,h=0,d=0,f=0,y=0,p=0,g=0,m=0,w=0,b=0,_=0,v=0,k=0,A=0;var S=new e.Uint32Array(r),E=new e.Uint8Array(r);function P(e,t,r,o,c,u,l,h){e=e|0;t=t|0;r=r|0;o=o|0;c=c|0;u=u|0;l=l|0;h=h|0;var d=0,f=0,y=0,p=0,g=0,m=0,w=0,b=0;d=r|0x400,f=r|0x800,y=r|0xc00;c=c^S[(e|0)>>2],u=u^S[(e|4)>>2],l=l^S[(e|8)>>2],h=h^S[(e|12)>>2];for(b=16;(b|0)<=o<<4;b=b+16|0){p=S[(r|c>>22&1020)>>2]^S[(d|u>>14&1020)>>2]^S[(f|l>>6&1020)>>2]^S[(y|h<<2&1020)>>2]^S[(e|b|0)>>2],g=S[(r|u>>22&1020)>>2]^S[(d|l>>14&1020)>>2]^S[(f|h>>6&1020)>>2]^S[(y|c<<2&1020)>>2]^S[(e|b|4)>>2],m=S[(r|l>>22&1020)>>2]^S[(d|h>>14&1020)>>2]^S[(f|c>>6&1020)>>2]^S[(y|u<<2&1020)>>2]^S[(e|b|8)>>2],w=S[(r|h>>22&1020)>>2]^S[(d|c>>14&1020)>>2]^S[(f|u>>6&1020)>>2]^S[(y|l<<2&1020)>>2]^S[(e|b|12)>>2];c=p,u=g,l=m,h=w}n=S[(t|c>>22&1020)>>2]<<24^S[(t|u>>14&1020)>>2]<<16^S[(t|l>>6&1020)>>2]<<8^S[(t|h<<2&1020)>>2]^S[(e|b|0)>>2],i=S[(t|u>>22&1020)>>2]<<24^S[(t|l>>14&1020)>>2]<<16^S[(t|h>>6&1020)>>2]<<8^S[(t|c<<2&1020)>>2]^S[(e|b|4)>>2],a=S[(t|l>>22&1020)>>2]<<24^S[(t|h>>14&1020)>>2]<<16^S[(t|c>>6&1020)>>2]<<8^S[(t|u<<2&1020)>>2]^S[(e|b|8)>>2],s=S[(t|h>>22&1020)>>2]<<24^S[(t|c>>14&1020)>>2]<<16^S[(t|u>>6&1020)>>2]<<8^S[(t|l<<2&1020)>>2]^S[(e|b|12)>>2]}function x(e,t,r,n){e=e|0;t=t|0;r=r|0;n=n|0;P(0x0000,0x0800,0x1000,A,e,t,r,n)}function K(e,t,r,n){e=e|0;t=t|0;r=r|0;n=n|0;var a=0;P(0x0400,0x0c00,0x2000,A,e,n,r,t);a=i,i=s,s=a}function C(e,t,r,h){e=e|0;t=t|0;r=r|0;h=h|0;P(0x0000,0x0800,0x1000,A,o^e,c^t,u^r,l^h);o=n,c=i,u=a,l=s}function U(e,t,r,h){e=e|0;t=t|0;r=r|0;h=h|0;var d=0;P(0x0400,0x0c00,0x2000,A,e,h,r,t);d=i,i=s,s=d;n=n^o,i=i^c,a=a^u,s=s^l;o=e,c=t,u=r,l=h}function R(e,t,r,h){e=e|0;t=t|0;r=r|0;h=h|0;P(0x0000,0x0800,0x1000,A,o,c,u,l);o=n=n^e,c=i=i^t,u=a=a^r,l=s=s^h}function T(e,t,r,h){e=e|0;t=t|0;r=r|0;h=h|0;P(0x0000,0x0800,0x1000,A,o,c,u,l);n=n^e,i=i^t,a=a^r,s=s^h;o=e,c=t,u=r,l=h}function D(e,t,r,h){e=e|0;t=t|0;r=r|0;h=h|0;P(0x0000,0x0800,0x1000,A,o,c,u,l);o=n,c=i,u=a,l=s;n=n^e,i=i^t,a=a^r,s=s^h}function I(e,t,r,o){e=e|0;t=t|0;r=r|0;o=o|0;P(0x0000,0x0800,0x1000,A,h,d,f,y);y=~w&y|w&y+1;f=~m&f|m&f+((y|0)==0);d=~g&d|g&d+((f|0)==0);h=~p&h|p&h+((d|0)==0);n=n^e;i=i^t;a=a^r;s=s^o}function B(e,t,r,n){e=e|0;t=t|0;r=r|0;n=n|0;var i=0,a=0,s=0,h=0,d=0,f=0,y=0,p=0,g=0,m=0;e=e^o,t=t^c,r=r^u,n=n^l;i=b|0,a=_|0,s=v|0,h=k|0;for(;(g|0)<128;g=g+1|0){if(i>>>31){d=d^e,f=f^t,y=y^r,p=p^n}i=i<<1|a>>>31,a=a<<1|s>>>31,s=s<<1|h>>>31,h=h<<1;m=n&1;n=n>>>1|r<<31,r=r>>>1|t<<31,t=t>>>1|e<<31,e=e>>>1;if(m)e=e^0xe1000000}o=d,c=f,u=y,l=p}function z(e){e=e|0;A=e}function O(e,t,r,o){e=e|0;t=t|0;r=r|0;o=o|0;n=e,i=t,a=r,s=o}function q(e,t,r,n){e=e|0;t=t|0;r=r|0;n=n|0;o=e,c=t,u=r,l=n}function N(e,t,r,n){e=e|0;t=t|0;r=r|0;n=n|0;h=e,d=t,f=r,y=n}function M(e,t,r,n){e=e|0;t=t|0;r=r|0;n=n|0;p=e,g=t,m=r,w=n}function L(e,t,r,n){e=e|0;t=t|0;r=r|0;n=n|0;y=~w&y|w&n,f=~m&f|m&r,d=~g&d|g&t,h=~p&h|p&e}function j(e){e=e|0;if(e&15)return-1;E[e|0]=n>>>24,E[e|1]=n>>>16&255,E[e|2]=n>>>8&255,E[e|3]=n&255,E[e|4]=i>>>24,E[e|5]=i>>>16&255,E[e|6]=i>>>8&255,E[e|7]=i&255,E[e|8]=a>>>24,E[e|9]=a>>>16&255,E[e|10]=a>>>8&255,E[e|11]=a&255,E[e|12]=s>>>24,E[e|13]=s>>>16&255,E[e|14]=s>>>8&255,E[e|15]=s&255;return 16}function F(e){e=e|0;if(e&15)return-1;E[e|0]=o>>>24,E[e|1]=o>>>16&255,E[e|2]=o>>>8&255,E[e|3]=o&255,E[e|4]=c>>>24,E[e|5]=c>>>16&255,E[e|6]=c>>>8&255,E[e|7]=c&255,E[e|8]=u>>>24,E[e|9]=u>>>16&255,E[e|10]=u>>>8&255,E[e|11]=u&255,E[e|12]=l>>>24,E[e|13]=l>>>16&255,E[e|14]=l>>>8&255,E[e|15]=l&255;return 16}function H(){x(0,0,0,0);b=n,_=i,v=a,k=s}function W(e,t,r){e=e|0;t=t|0;r=r|0;var o=0;if(t&15)return-1;while((r|0)>=16){V[e&7](E[t|0]<<24|E[t|1]<<16|E[t|2]<<8|E[t|3],E[t|4]<<24|E[t|5]<<16|E[t|6]<<8|E[t|7],E[t|8]<<24|E[t|9]<<16|E[t|10]<<8|E[t|11],E[t|12]<<24|E[t|13]<<16|E[t|14]<<8|E[t|15]);E[t|0]=n>>>24,E[t|1]=n>>>16&255,E[t|2]=n>>>8&255,E[t|3]=n&255,E[t|4]=i>>>24,E[t|5]=i>>>16&255,E[t|6]=i>>>8&255,E[t|7]=i&255,E[t|8]=a>>>24,E[t|9]=a>>>16&255,E[t|10]=a>>>8&255,E[t|11]=a&255,E[t|12]=s>>>24,E[t|13]=s>>>16&255,E[t|14]=s>>>8&255,E[t|15]=s&255;o=o+16|0,t=t+16|0,r=r-16|0}return o|0}function G(e,t,r){e=e|0;t=t|0;r=r|0;var n=0;if(t&15)return-1;while((r|0)>=16){$[e&1](E[t|0]<<24|E[t|1]<<16|E[t|2]<<8|E[t|3],E[t|4]<<24|E[t|5]<<16|E[t|6]<<8|E[t|7],E[t|8]<<24|E[t|9]<<16|E[t|10]<<8|E[t|11],E[t|12]<<24|E[t|13]<<16|E[t|14]<<8|E[t|15]);n=n+16|0,t=t+16|0,r=r-16|0}return n|0}var V=[x,K,C,U,R,T,D,I];var $=[C,B];return{set_rounds:z,set_state:O,set_iv:q,set_nonce:N,set_mask:M,set_counter:L,get_state:j,get_iv:F,gcm_init:H,cipher:W,mac:G}}({Uint8Array,Uint32Array},e,t);return l.set_key=function(e,t,n,a,s,c,u,h,d){var f=r.subarray(0,60),y=r.subarray(256,316);f.set([t,n,a,s,c,u,h,d]);for(var p=e,g=1;p<4*e+28;p++){var m=f[p-1];(p%e==0||8===e&&p%e==4)&&(m=i[m>>>24]<<24^i[m>>>16&255]<<16^i[m>>>8&255]<<8^i[255&m]),p%e==0&&(m=m<<8^m>>>24^g<<24,g=g<<1^(128&g?27:0)),f[p]=f[p-e]^m}for(var w=0;w<p;w+=4)for(var b=0;b<4;b++){m=f[p-(4+w)+(4-b)%4];y[w+b]=w<4||w>=p-4?m:o[0][i[m>>>24]]^o[1][i[m>>>16&255]]^o[2][i[m>>>8&255]]^o[3][i[255&m]]}l.set_rounds(e+5)},l};return l.ENC={ECB:0,CBC:2,CFB:4,OFB:6,CTR:7},l.DEC={ECB:1,CBC:3,CFB:5,OFB:6,CTR:7},l.MAC={CBC:0,GCM:1},l.HEAP_DATA=16384,l}();function pn(e){return e instanceof Uint8Array}function gn(e,t){const r=e?e.byteLength:t||65536;if(4095&r||r<=0)throw Error("heap size must be a positive integer and a multiple of 4096");return e=e||new Uint8Array(new ArrayBuffer(r))}function mn(e,t,r,n,i){const a=e.length-t,s=a<i?a:i;return e.set(r.subarray(n,n+s),t),s}function wn(...e){const t=e.reduce((e,t)=>e+t.length,0),r=new Uint8Array(t);let n=0;for(let t=0;t<e.length;t++)r.set(e[t],n),n+=e[t].length;return r}class bn extends Error{constructor(...e){super(...e)}}class _n extends Error{constructor(...e){super(...e)}}class vn extends Error{constructor(...e){super(...e)}}const kn=[],An=[];class Sn{constructor(e,t,r=!0,n,i,a){this.pos=0,this.len=0,this.mode=n,this.pos=0,this.len=0,this.key=e,this.iv=t,this.padding=r,this.acquire_asm(i,a)}acquire_asm(e,t){return void 0!==this.heap&&void 0!==this.asm||(this.heap=e||kn.pop()||gn().subarray(yn.HEAP_DATA),this.asm=t||An.pop()||new yn(null,this.heap.buffer),this.reset(this.key,this.iv)),{heap:this.heap,asm:this.asm}}release_asm(){void 0!==this.heap&&void 0!==this.asm&&(kn.push(this.heap),An.push(this.asm)),this.heap=void 0,this.asm=void 0}reset(e,t){const{asm:r}=this.acquire_asm(),n=e.length;if(16!==n&&24!==n&&32!==n)throw new _n("illegal key size");const i=new DataView(e.buffer,e.byteOffset,e.byteLength);if(r.set_key(n>>2,i.getUint32(0),i.getUint32(4),i.getUint32(8),i.getUint32(12),n>16?i.getUint32(16):0,n>16?i.getUint32(20):0,n>24?i.getUint32(24):0,n>24?i.getUint32(28):0),void 0!==t){if(16!==t.length)throw new _n("illegal iv size");let e=new DataView(t.buffer,t.byteOffset,t.byteLength);r.set_iv(e.getUint32(0),e.getUint32(4),e.getUint32(8),e.getUint32(12))}else r.set_iv(0,0,0,0)}AES_Encrypt_process(e){if(!pn(e))throw new TypeError("data isn't of expected type");let{heap:t,asm:r}=this.acquire_asm(),n=yn.ENC[this.mode],i=yn.HEAP_DATA,a=this.pos,s=this.len,o=0,c=e.length||0,u=0,l=0,h=new Uint8Array(s+c&-16);for(;c>0;)l=mn(t,a+s,e,o,c),s+=l,o+=l,c-=l,l=r.cipher(n,i+a,s),l&&h.set(t.subarray(a,a+l),u),u+=l,l<s?(a+=l,s-=l):(a=0,s=0);return this.pos=a,this.len=s,h}AES_Encrypt_finish(){let{heap:e,asm:t}=this.acquire_asm(),r=yn.ENC[this.mode],n=yn.HEAP_DATA,i=this.pos,a=this.len,s=16-a%16,o=a;if(this.hasOwnProperty("padding")){if(this.padding){for(let t=0;t<s;++t)e[i+a+t]=s;a+=s,o=a}else if(a%16)throw new _n("data length must be a multiple of the block size")}else a+=s;const c=new Uint8Array(o);return a&&t.cipher(r,n+i,a),o&&c.set(e.subarray(i,i+o)),this.pos=0,this.len=0,this.release_asm(),c}AES_Decrypt_process(e){if(!pn(e))throw new TypeError("data isn't of expected type");let{heap:t,asm:r}=this.acquire_asm(),n=yn.DEC[this.mode],i=yn.HEAP_DATA,a=this.pos,s=this.len,o=0,c=e.length||0,u=0,l=s+c&-16,h=0,d=0;this.padding&&(h=s+c-l||16,l-=h);const f=new Uint8Array(l);for(;c>0;)d=mn(t,a+s,e,o,c),s+=d,o+=d,c-=d,d=r.cipher(n,i+a,s-(c?0:h)),d&&f.set(t.subarray(a,a+d),u),u+=d,d<s?(a+=d,s-=d):(a=0,s=0);return this.pos=a,this.len=s,f}AES_Decrypt_finish(){let{heap:e,asm:t}=this.acquire_asm(),r=yn.DEC[this.mode],n=yn.HEAP_DATA,i=this.pos,a=this.len,s=a;if(a>0){if(a%16){if(this.hasOwnProperty("padding"))throw new _n("data length must be a multiple of the block size");a+=16-a%16}if(t.cipher(r,n+i,a),this.hasOwnProperty("padding")&&this.padding){let t=e[i+s-1];if(t<1||t>16||t>s)throw new vn("bad padding");let r=0;for(let n=t;n>1;n--)r|=t^e[i+s-n];if(r)throw new vn("bad padding");s-=t}}const o=new Uint8Array(s);return s>0&&o.set(e.subarray(i,i+s)),this.pos=0,this.len=0,this.release_asm(),o}}class En{static encrypt(e,t,r=!1){return new En(t,r).encrypt(e)}static decrypt(e,t,r=!1){return new En(t,r).decrypt(e)}constructor(e,t=!1,r){this.aes=r||new Sn(e,void 0,t,"ECB")}encrypt(e){return wn(this.aes.AES_Encrypt_process(e),this.aes.AES_Encrypt_finish())}decrypt(e){return wn(this.aes.AES_Decrypt_process(e),this.aes.AES_Decrypt_finish())}}function Pn(e){const t=function(e){const t=new En(e);this.encrypt=function(e){return t.encrypt(e)},this.decrypt=function(e){return t.decrypt(e)}};return t.blockSize=t.prototype.blockSize=16,t.keySize=t.prototype.keySize=e/8,t}function xn(e,t,r,n,i,a){const s=[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],o=[-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],c=[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],u=[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],l=[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],h=[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],d=[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],f=[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];let y,p,g,m,w,b,_,v,k,A,S,E,P,x,K=0,C=t.length;const U=32===e.length?3:9;v=3===U?r?[0,32,2]:[30,-2,-2]:r?[0,32,2,62,30,-2,64,96,2]:[94,62,-2,32,64,2,30,-2,-2],r&&(C=(t=function(e,t){const r=8-e.length%8;let n;if(2===t&&r<8)n=32;else if(1===t)n=r;else{if(t||!(r<8)){if(8===r)return e;throw Error("des: invalid padding")}n=0}const i=new Uint8Array(e.length+r);for(let t=0;t<e.length;t++)i[t]=e[t];for(let t=0;t<r;t++)i[e.length+t]=n;return i}(t,a)).length);let R=new Uint8Array(C),T=0;for(1===n&&(k=i[K++]<<24|i[K++]<<16|i[K++]<<8|i[K++],S=i[K++]<<24|i[K++]<<16|i[K++]<<8|i[K++],K=0);K<C;){for(b=t[K++]<<24|t[K++]<<16|t[K++]<<8|t[K++],_=t[K++]<<24|t[K++]<<16|t[K++]<<8|t[K++],1===n&&(r?(b^=k,_^=S):(A=k,E=S,k=b,S=_)),g=252645135&(b>>>4^_),_^=g,b^=g<<4,g=65535&(b>>>16^_),_^=g,b^=g<<16,g=858993459&(_>>>2^b),b^=g,_^=g<<2,g=16711935&(_>>>8^b),b^=g,_^=g<<8,g=1431655765&(b>>>1^_),_^=g,b^=g<<1,b=b<<1|b>>>31,_=_<<1|_>>>31,p=0;p<U;p+=3){for(P=v[p+1],x=v[p+2],y=v[p];y!==P;y+=x)m=_^e[y],w=(_>>>4|_<<28)^e[y+1],g=b,b=_,_=g^(o[m>>>24&63]|u[m>>>16&63]|h[m>>>8&63]|f[63&m]|s[w>>>24&63]|c[w>>>16&63]|l[w>>>8&63]|d[63&w]);g=b,b=_,_=g}b=b>>>1|b<<31,_=_>>>1|_<<31,g=1431655765&(b>>>1^_),_^=g,b^=g<<1,g=16711935&(_>>>8^b),b^=g,_^=g<<8,g=858993459&(_>>>2^b),b^=g,_^=g<<2,g=65535&(b>>>16^_),_^=g,b^=g<<16,g=252645135&(b>>>4^_),_^=g,b^=g<<4,1===n&&(r?(k=b,S=_):(b^=A,_^=E)),R[T++]=b>>>24,R[T++]=b>>>16&255,R[T++]=b>>>8&255,R[T++]=255&b,R[T++]=_>>>24,R[T++]=_>>>16&255,R[T++]=_>>>8&255,R[T++]=255&_}return r||(R=function(e,t){let r,n=null;if(2===t)r=32;else if(1===t)n=e[e.length-1];else{if(t)throw Error("des: invalid padding");r=0}if(!n){for(n=1;e[e.length-n]===r;)n++;n--}return e.subarray(0,e.length-n)}(R,a)),R}function Kn(e){const t=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],r=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],n=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],i=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],a=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],s=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],o=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],c=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],u=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],l=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],h=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],d=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],f=[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],p=e.length>8?3:1,g=Array(32*p),m=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0];let w,b,_,v=0,k=0;for(let A=0;A<p;A++){let p=e[v++]<<24|e[v++]<<16|e[v++]<<8|e[v++],A=e[v++]<<24|e[v++]<<16|e[v++]<<8|e[v++];_=252645135&(p>>>4^A),A^=_,p^=_<<4,_=65535&(A>>>-16^p),p^=_,A^=_<<-16,_=858993459&(p>>>2^A),A^=_,p^=_<<2,_=65535&(A>>>-16^p),p^=_,A^=_<<-16,_=1431655765&(p>>>1^A),A^=_,p^=_<<1,_=16711935&(A>>>8^p),p^=_,A^=_<<8,_=1431655765&(p>>>1^A),A^=_,p^=_<<1,_=p<<8|A>>>20&240,p=A<<24|A<<8&16711680|A>>>8&65280|A>>>24&240,A=_;for(let e=0;e<16;e++)m[e]?(p=p<<2|p>>>26,A=A<<2|A>>>26):(p=p<<1|p>>>27,A=A<<1|A>>>27),p&=-15,A&=-15,w=t[p>>>28]|r[p>>>24&15]|n[p>>>20&15]|i[p>>>16&15]|a[p>>>12&15]|s[p>>>8&15]|o[p>>>4&15],b=c[A>>>28]|u[A>>>24&15]|l[A>>>20&15]|h[A>>>16&15]|d[A>>>12&15]|f[A>>>8&15]|y[A>>>4&15],_=65535&(b>>>16^w),g[k++]=w^_,g[k++]=b^_<<16}return g}function Cn(e){this.key=[];for(let t=0;t<3;t++)this.key.push(new Uint8Array(e.subarray(8*t,8*t+8)));this.encrypt=function(e){return xn(Kn(this.key[2]),xn(Kn(this.key[1]),xn(Kn(this.key[0]),e,!0,0,null,null),!1,0,null,null),!0,0,null,null)}}function Un(){this.BlockSize=8,this.KeySize=16,this.setKey=function(e){if(this.masking=Array(16),this.rotate=Array(16),this.reset(),e.length!==this.KeySize)throw Error("CAST-128: keys must be 16 bytes");return this.keySchedule(e),!0},this.reset=function(){for(let e=0;e<16;e++)this.masking[e]=0,this.rotate[e]=0},this.getBlockSize=function(){return this.BlockSize},this.encrypt=function(e){const t=Array(e.length);for(let a=0;a<e.length;a+=8){let s,o=e[a]<<24|e[a+1]<<16|e[a+2]<<8|e[a+3],c=e[a+4]<<24|e[a+5]<<16|e[a+6]<<8|e[a+7];s=c,c=o^r(c,this.masking[0],this.rotate[0]),o=s,s=c,c=o^n(c,this.masking[1],this.rotate[1]),o=s,s=c,c=o^i(c,this.masking[2],this.rotate[2]),o=s,s=c,c=o^r(c,this.masking[3],this.rotate[3]),o=s,s=c,c=o^n(c,this.masking[4],this.rotate[4]),o=s,s=c,c=o^i(c,this.masking[5],this.rotate[5]),o=s,s=c,c=o^r(c,this.masking[6],this.rotate[6]),o=s,s=c,c=o^n(c,this.masking[7],this.rotate[7]),o=s,s=c,c=o^i(c,this.masking[8],this.rotate[8]),o=s,s=c,c=o^r(c,this.masking[9],this.rotate[9]),o=s,s=c,c=o^n(c,this.masking[10],this.rotate[10]),o=s,s=c,c=o^i(c,this.masking[11],this.rotate[11]),o=s,s=c,c=o^r(c,this.masking[12],this.rotate[12]),o=s,s=c,c=o^n(c,this.masking[13],this.rotate[13]),o=s,s=c,c=o^i(c,this.masking[14],this.rotate[14]),o=s,s=c,c=o^r(c,this.masking[15],this.rotate[15]),o=s,t[a]=c>>>24&255,t[a+1]=c>>>16&255,t[a+2]=c>>>8&255,t[a+3]=255&c,t[a+4]=o>>>24&255,t[a+5]=o>>>16&255,t[a+6]=o>>>8&255,t[a+7]=255&o}return t},this.decrypt=function(e){const t=Array(e.length);for(let a=0;a<e.length;a+=8){let s,o=e[a]<<24|e[a+1]<<16|e[a+2]<<8|e[a+3],c=e[a+4]<<24|e[a+5]<<16|e[a+6]<<8|e[a+7];s=c,c=o^r(c,this.masking[15],this.rotate[15]),o=s,s=c,c=o^i(c,this.masking[14],this.rotate[14]),o=s,s=c,c=o^n(c,this.masking[13],this.rotate[13]),o=s,s=c,c=o^r(c,this.masking[12],this.rotate[12]),o=s,s=c,c=o^i(c,this.masking[11],this.rotate[11]),o=s,s=c,c=o^n(c,this.masking[10],this.rotate[10]),o=s,s=c,c=o^r(c,this.masking[9],this.rotate[9]),o=s,s=c,c=o^i(c,this.masking[8],this.rotate[8]),o=s,s=c,c=o^n(c,this.masking[7],this.rotate[7]),o=s,s=c,c=o^r(c,this.masking[6],this.rotate[6]),o=s,s=c,c=o^i(c,this.masking[5],this.rotate[5]),o=s,s=c,c=o^n(c,this.masking[4],this.rotate[4]),o=s,s=c,c=o^r(c,this.masking[3],this.rotate[3]),o=s,s=c,c=o^i(c,this.masking[2],this.rotate[2]),o=s,s=c,c=o^n(c,this.masking[1],this.rotate[1]),o=s,s=c,c=o^r(c,this.masking[0],this.rotate[0]),o=s,t[a]=c>>>24&255,t[a+1]=c>>>16&255,t[a+2]=c>>>8&255,t[a+3]=255&c,t[a+4]=o>>>24&255,t[a+5]=o>>16&255,t[a+6]=o>>8&255,t[a+7]=255&o}return t};const e=[,,,,];e[0]=[,,,,],e[0][0]=[4,0,13,15,12,14,8],e[0][1]=[5,2,16,18,17,19,10],e[0][2]=[6,3,23,22,21,20,9],e[0][3]=[7,1,26,25,27,24,11],e[1]=[,,,,],e[1][0]=[0,6,21,23,20,22,16],e[1][1]=[1,4,0,2,1,3,18],e[1][2]=[2,5,7,6,5,4,17],e[1][3]=[3,7,10,9,11,8,19],e[2]=[,,,,],e[2][0]=[4,0,13,15,12,14,8],e[2][1]=[5,2,16,18,17,19,10],e[2][2]=[6,3,23,22,21,20,9],e[2][3]=[7,1,26,25,27,24,11],e[3]=[,,,,],e[3][0]=[0,6,21,23,20,22,16],e[3][1]=[1,4,0,2,1,3,18],e[3][2]=[2,5,7,6,5,4,17],e[3][3]=[3,7,10,9,11,8,19];const t=[,,,,];function r(e,t,r){const n=t+e,i=n<<r|n>>>32-r;return(a[0][i>>>24]^a[1][i>>>16&255])-a[2][i>>>8&255]+a[3][255&i]}function n(e,t,r){const n=t^e,i=n<<r|n>>>32-r;return a[0][i>>>24]-a[1][i>>>16&255]+a[2][i>>>8&255]^a[3][255&i]}function i(e,t,r){const n=t-e,i=n<<r|n>>>32-r;return(a[0][i>>>24]+a[1][i>>>16&255]^a[2][i>>>8&255])-a[3][255&i]}t[0]=[,,,,],t[0][0]=[24,25,23,22,18],t[0][1]=[26,27,21,20,22],t[0][2]=[28,29,19,18,25],t[0][3]=[30,31,17,16,28],t[1]=[,,,,],t[1][0]=[3,2,12,13,8],t[1][1]=[1,0,14,15,13],t[1][2]=[7,6,8,9,3],t[1][3]=[5,4,10,11,7],t[2]=[,,,,],t[2][0]=[19,18,28,29,25],t[2][1]=[17,16,30,31,28],t[2][2]=[23,22,24,25,18],t[2][3]=[21,20,26,27,22],t[3]=[,,,,],t[3][0]=[8,9,7,6,3],t[3][1]=[10,11,5,4,7],t[3][2]=[12,13,3,2,8],t[3][3]=[14,15,1,0,13],this.keySchedule=function(r){const n=[,,,,,,,,],i=Array(32);let s;for(let e=0;e<4;e++)s=4*e,n[e]=r[s]<<24|r[s+1]<<16|r[s+2]<<8|r[s+3];const o=[6,7,4,5];let c,u=0;for(let r=0;r<2;r++)for(let r=0;r<4;r++){for(s=0;s<4;s++){const t=e[r][s];c=n[t[1]],c^=a[4][n[t[2]>>>2]>>>24-8*(3&t[2])&255],c^=a[5][n[t[3]>>>2]>>>24-8*(3&t[3])&255],c^=a[6][n[t[4]>>>2]>>>24-8*(3&t[4])&255],c^=a[7][n[t[5]>>>2]>>>24-8*(3&t[5])&255],c^=a[o[s]][n[t[6]>>>2]>>>24-8*(3&t[6])&255],n[t[0]]=c}for(s=0;s<4;s++){const e=t[r][s];c=a[4][n[e[0]>>>2]>>>24-8*(3&e[0])&255],c^=a[5][n[e[1]>>>2]>>>24-8*(3&e[1])&255],c^=a[6][n[e[2]>>>2]>>>24-8*(3&e[2])&255],c^=a[7][n[e[3]>>>2]>>>24-8*(3&e[3])&255],c^=a[4+s][n[e[4]>>>2]>>>24-8*(3&e[4])&255],i[u]=c,u++}}for(let e=0;e<16;e++)this.masking[e]=i[e],this.rotate[e]=31&i[16+e]};const a=[,,,,,,,,];a[0]=[821772500,2678128395,1810681135,1059425402,505495343,2617265619,1610868032,3483355465,3218386727,2294005173,3791863952,2563806837,1852023008,365126098,3269944861,584384398,677919599,3229601881,4280515016,2002735330,1136869587,3744433750,2289869850,2731719981,2714362070,879511577,1639411079,575934255,717107937,2857637483,576097850,2731753936,1725645e3,2810460463,5111599,767152862,2543075244,1251459544,1383482551,3052681127,3089939183,3612463449,1878520045,1510570527,2189125840,2431448366,582008916,3163445557,1265446783,1354458274,3529918736,3202711853,3073581712,3912963487,3029263377,1275016285,4249207360,2905708351,3304509486,1442611557,3585198765,2712415662,2731849581,3248163920,2283946226,208555832,2766454743,1331405426,1447828783,3315356441,3108627284,2957404670,2981538698,3339933917,1669711173,286233437,1465092821,1782121619,3862771680,710211251,980974943,1651941557,430374111,2051154026,704238805,4128970897,3144820574,2857402727,948965521,3333752299,2227686284,718756367,2269778983,2731643755,718440111,2857816721,3616097120,1113355533,2478022182,410092745,1811985197,1944238868,2696854588,1415722873,1682284203,1060277122,1998114690,1503841958,82706478,2315155686,1068173648,845149890,2167947013,1768146376,1993038550,3566826697,3390574031,940016341,3355073782,2328040721,904371731,1205506512,4094660742,2816623006,825647681,85914773,2857843460,1249926541,1417871568,3287612,3211054559,3126306446,1975924523,1353700161,2814456437,2438597621,1800716203,722146342,2873936343,1151126914,4160483941,2877670899,458611604,2866078500,3483680063,770352098,2652916994,3367839148,3940505011,3585973912,3809620402,718646636,2504206814,2914927912,3631288169,2857486607,2860018678,575749918,2857478043,718488780,2069512688,3548183469,453416197,1106044049,3032691430,52586708,3378514636,3459808877,3211506028,1785789304,218356169,3571399134,3759170522,1194783844,1523787992,3007827094,1975193539,2555452411,1341901877,3045838698,3776907964,3217423946,2802510864,2889438986,1057244207,1636348243,3761863214,1462225785,2632663439,481089165,718503062,24497053,3332243209,3344655856,3655024856,3960371065,1195698900,2971415156,3710176158,2115785917,4027663609,3525578417,2524296189,2745972565,3564906415,1372086093,1452307862,2780501478,1476592880,3389271281,18495466,2378148571,901398090,891748256,3279637769,3157290713,2560960102,1447622437,4284372637,216884176,2086908623,1879786977,3588903153,2242455666,2938092967,3559082096,2810645491,758861177,1121993112,215018983,642190776,4169236812,1196255959,2081185372,3508738393,941322904,4124243163,2877523539,1848581667,2205260958,3180453958,2589345134,3694731276,550028657,2519456284,3789985535,2973870856,2093648313,443148163,46942275,2734146937,1117713533,1115362972,1523183689,3717140224,1551984063],a[1]=[522195092,4010518363,1776537470,960447360,4267822970,4005896314,1435016340,1929119313,2913464185,1310552629,3579470798,3724818106,2579771631,1594623892,417127293,2715217907,2696228731,1508390405,3994398868,3925858569,3695444102,4019471449,3129199795,3770928635,3520741761,990456497,4187484609,2783367035,21106139,3840405339,631373633,3783325702,532942976,396095098,3548038825,4267192484,2564721535,2011709262,2039648873,620404603,3776170075,2898526339,3612357925,4159332703,1645490516,223693667,1567101217,3362177881,1029951347,3470931136,3570957959,1550265121,119497089,972513919,907948164,3840628539,1613718692,3594177948,465323573,2659255085,654439692,2575596212,2699288441,3127702412,277098644,624404830,4100943870,2717858591,546110314,2403699828,3655377447,1321679412,4236791657,1045293279,4010672264,895050893,2319792268,494945126,1914543101,2777056443,3894764339,2219737618,311263384,4275257268,3458730721,669096869,3584475730,3835122877,3319158237,3949359204,2005142349,2713102337,2228954793,3769984788,569394103,3855636576,1425027204,108000370,2736431443,3671869269,3043122623,1750473702,2211081108,762237499,3972989403,2798899386,3061857628,2943854345,867476300,964413654,1591880597,1594774276,2179821409,552026980,3026064248,3726140315,2283577634,3110545105,2152310760,582474363,1582640421,1383256631,2043843868,3322775884,1217180674,463797851,2763038571,480777679,2718707717,2289164131,3118346187,214354409,200212307,3810608407,3025414197,2674075964,3997296425,1847405948,1342460550,510035443,4080271814,815934613,833030224,1620250387,1945732119,2703661145,3966000196,1388869545,3456054182,2687178561,2092620194,562037615,1356438536,3409922145,3261847397,1688467115,2150901366,631725691,3840332284,549916902,3455104640,394546491,837744717,2114462948,751520235,2221554606,2415360136,3999097078,2063029875,803036379,2702586305,821456707,3019566164,360699898,4018502092,3511869016,3677355358,2402471449,812317050,49299192,2570164949,3259169295,2816732080,3331213574,3101303564,2156015656,3705598920,3546263921,143268808,3200304480,1638124008,3165189453,3341807610,578956953,2193977524,3638120073,2333881532,807278310,658237817,2969561766,1641658566,11683945,3086995007,148645947,1138423386,4158756760,1981396783,2401016740,3699783584,380097457,2680394679,2803068651,3334260286,441530178,4016580796,1375954390,761952171,891809099,2183123478,157052462,3683840763,1592404427,341349109,2438483839,1417898363,644327628,2233032776,2353769706,2201510100,220455161,1815641738,182899273,2995019788,3627381533,3702638151,2890684138,1052606899,588164016,1681439879,4038439418,2405343923,4229449282,167996282,1336969661,1688053129,2739224926,1543734051,1046297529,1138201970,2121126012,115334942,1819067631,1902159161,1941945968,2206692869,1159982321],a[2]=[2381300288,637164959,3952098751,3893414151,1197506559,916448331,2350892612,2932787856,3199334847,4009478890,3905886544,1373570990,2450425862,4037870920,3778841987,2456817877,286293407,124026297,3001279700,1028597854,3115296800,4208886496,2691114635,2188540206,1430237888,1218109995,3572471700,308166588,570424558,2187009021,2455094765,307733056,1310360322,3135275007,1384269543,2388071438,863238079,2359263624,2801553128,3380786597,2831162807,1470087780,1728663345,4072488799,1090516929,532123132,2389430977,1132193179,2578464191,3051079243,1670234342,1434557849,2711078940,1241591150,3314043432,3435360113,3091448339,1812415473,2198440252,267246943,796911696,3619716990,38830015,1526438404,2806502096,374413614,2943401790,1489179520,1603809326,1920779204,168801282,260042626,2358705581,1563175598,2397674057,1356499128,2217211040,514611088,2037363785,2186468373,4022173083,2792511869,2913485016,1173701892,4200428547,3896427269,1334932762,2455136706,602925377,2835607854,1613172210,41346230,2499634548,2457437618,2188827595,41386358,4172255629,1313404830,2405527007,3801973774,2217704835,873260488,2528884354,2478092616,4012915883,2555359016,2006953883,2463913485,575479328,2218240648,2099895446,660001756,2341502190,3038761536,3888151779,3848713377,3286851934,1022894237,1620365795,3449594689,1551255054,15374395,3570825345,4249311020,4151111129,3181912732,310226346,1133119310,530038928,136043402,2476768958,3107506709,2544909567,1036173560,2367337196,1681395281,1758231547,3641649032,306774401,1575354324,3716085866,1990386196,3114533736,2455606671,1262092282,3124342505,2768229131,4210529083,1833535011,423410938,660763973,2187129978,1639812e3,3508421329,3467445492,310289298,272797111,2188552562,2456863912,310240523,677093832,1013118031,901835429,3892695601,1116285435,3036471170,1337354835,243122523,520626091,277223598,4244441197,4194248841,1766575121,594173102,316590669,742362309,3536858622,4176435350,3838792410,2501204839,1229605004,3115755532,1552908988,2312334149,979407927,3959474601,1148277331,176638793,3614686272,2083809052,40992502,1340822838,2731552767,3535757508,3560899520,1354035053,122129617,7215240,2732932949,3118912700,2718203926,2539075635,3609230695,3725561661,1928887091,2882293555,1988674909,2063640240,2491088897,1459647954,4189817080,2302804382,1113892351,2237858528,1927010603,4002880361,1856122846,1594404395,2944033133,3855189863,3474975698,1643104450,4054590833,3431086530,1730235576,2984608721,3084664418,2131803598,4178205752,267404349,1617849798,1616132681,1462223176,736725533,2327058232,551665188,2945899023,1749386277,2575514597,1611482493,674206544,2201269090,3642560800,728599968,1680547377,2620414464,1388111496,453204106,4156223445,1094905244,2754698257,2201108165,3757000246,2704524545,3922940700,3996465027],a[3]=[2645754912,532081118,2814278639,3530793624,1246723035,1689095255,2236679235,4194438865,2116582143,3859789411,157234593,2045505824,4245003587,1687664561,4083425123,605965023,672431967,1336064205,3376611392,214114848,4258466608,3232053071,489488601,605322005,3998028058,264917351,1912574028,756637694,436560991,202637054,135989450,85393697,2152923392,3896401662,2895836408,2145855233,3535335007,115294817,3147733898,1922296357,3464822751,4117858305,1037454084,2725193275,2127856640,1417604070,1148013728,1827919605,642362335,2929772533,909348033,1346338451,3547799649,297154785,1917849091,4161712827,2883604526,3968694238,1469521537,3780077382,3375584256,1763717519,136166297,4290970789,1295325189,2134727907,2798151366,1566297257,3672928234,2677174161,2672173615,965822077,2780786062,289653839,1133871874,3491843819,35685304,1068898316,418943774,672553190,642281022,2346158704,1954014401,3037126780,4079815205,2030668546,3840588673,672283427,1776201016,359975446,3750173538,555499703,2769985273,1324923,69110472,152125443,3176785106,3822147285,1340634837,798073664,1434183902,15393959,216384236,1303690150,3881221631,3711134124,3960975413,106373927,2578434224,1455997841,1801814300,1578393881,1854262133,3188178946,3258078583,2302670060,1539295533,3505142565,3078625975,2372746020,549938159,3278284284,2620926080,181285381,2865321098,3970029511,68876850,488006234,1728155692,2608167508,836007927,2435231793,919367643,3339422534,3655756360,1457871481,40520939,1380155135,797931188,234455205,2255801827,3990488299,397000196,739833055,3077865373,2871719860,4022553888,772369276,390177364,3853951029,557662966,740064294,1640166671,1699928825,3535942136,622006121,3625353122,68743880,1742502,219489963,1664179233,1577743084,1236991741,410585305,2366487942,823226535,1050371084,3426619607,3586839478,212779912,4147118561,1819446015,1911218849,530248558,3486241071,3252585495,2886188651,3410272728,2342195030,20547779,2982490058,3032363469,3631753222,312714466,1870521650,1493008054,3491686656,615382978,4103671749,2534517445,1932181,2196105170,278426614,6369430,3274544417,2913018367,697336853,2143000447,2946413531,701099306,1558357093,2805003052,3500818408,2321334417,3567135975,216290473,3591032198,23009561,1996984579,3735042806,2024298078,3739440863,569400510,2339758983,3016033873,3097871343,3639523026,3844324983,3256173865,795471839,2951117563,4101031090,4091603803,3603732598,971261452,534414648,428311343,3389027175,2844869880,694888862,1227866773,2456207019,3043454569,2614353370,3749578031,3676663836,459166190,4132644070,1794958188,51825668,2252611902,3084671440,2036672799,3436641603,1099053433,2469121526,3059204941,1323291266,2061838604,1018778475,2233344254,2553501054,334295216,3556750194,1065731521,183467730],a[4]=[2127105028,745436345,2601412319,2788391185,3093987327,500390133,1155374404,389092991,150729210,3891597772,3523549952,1935325696,716645080,946045387,2901812282,1774124410,3869435775,4039581901,3293136918,3438657920,948246080,363898952,3867875531,1286266623,1598556673,68334250,630723836,1104211938,1312863373,613332731,2377784574,1101634306,441780740,3129959883,1917973735,2510624549,3238456535,2544211978,3308894634,1299840618,4076074851,1756332096,3977027158,297047435,3790297736,2265573040,3621810518,1311375015,1667687725,47300608,3299642885,2474112369,201668394,1468347890,576830978,3594690761,3742605952,1958042578,1747032512,3558991340,1408974056,3366841779,682131401,1033214337,1545599232,4265137049,206503691,103024618,2855227313,1337551222,2428998917,2963842932,4015366655,3852247746,2796956967,3865723491,3747938335,247794022,3755824572,702416469,2434691994,397379957,851939612,2314769512,218229120,1380406772,62274761,214451378,3170103466,2276210409,3845813286,28563499,446592073,1693330814,3453727194,29968656,3093872512,220656637,2470637031,77972100,1667708854,1358280214,4064765667,2395616961,325977563,4277240721,4220025399,3605526484,3355147721,811859167,3069544926,3962126810,652502677,3075892249,4132761541,3498924215,1217549313,3250244479,3858715919,3053989961,1538642152,2279026266,2875879137,574252750,3324769229,2651358713,1758150215,141295887,2719868960,3515574750,4093007735,4194485238,1082055363,3417560400,395511885,2966884026,179534037,3646028556,3738688086,1092926436,2496269142,257381841,3772900718,1636087230,1477059743,2499234752,3811018894,2675660129,3285975680,90732309,1684827095,1150307763,1723134115,3237045386,1769919919,1240018934,815675215,750138730,2239792499,1234303040,1995484674,138143821,675421338,1145607174,1936608440,3238603024,2345230278,2105974004,323969391,779555213,3004902369,2861610098,1017501463,2098600890,2628620304,2940611490,2682542546,1171473753,3656571411,3687208071,4091869518,393037935,159126506,1662887367,1147106178,391545844,3452332695,1891500680,3016609650,1851642611,546529401,1167818917,3194020571,2848076033,3953471836,575554290,475796850,4134673196,450035699,2351251534,844027695,1080539133,86184846,1554234488,3692025454,1972511363,2018339607,1491841390,1141460869,1061690759,4244549243,2008416118,2351104703,2868147542,1598468138,722020353,1027143159,212344630,1387219594,1725294528,3745187956,2500153616,458938280,4129215917,1828119673,544571780,3503225445,2297937496,1241802790,267843827,2694610800,1397140384,1558801448,3782667683,1806446719,929573330,2234912681,400817706,616011623,4121520928,3603768725,1761550015,1968522284,4053731006,4192232858,4005120285,872482584,3140537016,3894607381,2287405443,1963876937,3663887957,1584857e3,2975024454,1833426440,4025083860],a[5]=[4143615901,749497569,1285769319,3795025788,2514159847,23610292,3974978748,844452780,3214870880,3751928557,2213566365,1676510905,448177848,3730751033,4086298418,2307502392,871450977,3222878141,4110862042,3831651966,2735270553,1310974780,2043402188,1218528103,2736035353,4274605013,2702448458,3936360550,2693061421,162023535,2827510090,687910808,23484817,3784910947,3371371616,779677500,3503626546,3473927188,4157212626,3500679282,4248902014,2466621104,3899384794,1958663117,925738300,1283408968,3669349440,1840910019,137959847,2679828185,1239142320,1315376211,1547541505,1690155329,739140458,3128809933,3933172616,3876308834,905091803,1548541325,4040461708,3095483362,144808038,451078856,676114313,2861728291,2469707347,993665471,373509091,2599041286,4025009006,4170239449,2149739950,3275793571,3749616649,2794760199,1534877388,572371878,2590613551,1753320020,3467782511,1405125690,4270405205,633333386,3026356924,3475123903,632057672,2846462855,1404951397,3882875879,3915906424,195638627,2385783745,3902872553,1233155085,3355999740,2380578713,2702246304,2144565621,3663341248,3894384975,2502479241,4248018925,3094885567,1594115437,572884632,3385116731,767645374,1331858858,1475698373,3793881790,3532746431,1321687957,619889600,1121017241,3440213920,2070816767,2833025776,1933951238,4095615791,890643334,3874130214,859025556,360630002,925594799,1764062180,3920222280,4078305929,979562269,2810700344,4087740022,1949714515,546639971,1165388173,3069891591,1495988560,922170659,1291546247,2107952832,1813327274,3406010024,3306028637,4241950635,153207855,2313154747,1608695416,1150242611,1967526857,721801357,1220138373,3691287617,3356069787,2112743302,3281662835,1111556101,1778980689,250857638,2298507990,673216130,2846488510,3207751581,3562756981,3008625920,3417367384,2198807050,529510932,3547516680,3426503187,2364944742,102533054,2294910856,1617093527,1204784762,3066581635,1019391227,1069574518,1317995090,1691889997,3661132003,510022745,3238594800,1362108837,1817929911,2184153760,805817662,1953603311,3699844737,120799444,2118332377,207536705,2282301548,4120041617,145305846,2508124933,3086745533,3261524335,1877257368,2977164480,3160454186,2503252186,4221677074,759945014,254147243,2767453419,3801518371,629083197,2471014217,907280572,3900796746,940896768,2751021123,2625262786,3161476951,3661752313,3260732218,1425318020,2977912069,1496677566,3988592072,2140652971,3126511541,3069632175,977771578,1392695845,1698528874,1411812681,1369733098,1343739227,3620887944,1142123638,67414216,3102056737,3088749194,1626167401,2546293654,3941374235,697522451,33404913,143560186,2595682037,994885535,1247667115,3859094837,2699155541,3547024625,4114935275,2968073508,3199963069,2732024527,1237921620,951448369,1898488916,1211705605,2790989240,2233243581,3598044975],a[6]=[2246066201,858518887,1714274303,3485882003,713916271,2879113490,3730835617,539548191,36158695,1298409750,419087104,1358007170,749914897,2989680476,1261868530,2995193822,2690628854,3443622377,3780124940,3796824509,2976433025,4259637129,1551479e3,512490819,1296650241,951993153,2436689437,2460458047,144139966,3136204276,310820559,3068840729,643875328,1969602020,1680088954,2185813161,3283332454,672358534,198762408,896343282,276269502,3014846926,84060815,197145886,376173866,3943890818,3813173521,3545068822,1316698879,1598252827,2633424951,1233235075,859989710,2358460855,3503838400,3409603720,1203513385,1193654839,2792018475,2060853022,207403770,1144516871,3068631394,1121114134,177607304,3785736302,326409831,1929119770,2983279095,4183308101,3474579288,3200513878,3228482096,119610148,1170376745,3378393471,3163473169,951863017,3337026068,3135789130,2907618374,1183797387,2015970143,4045674555,2182986399,2952138740,3928772205,384012900,2454997643,10178499,2879818989,2596892536,111523738,2995089006,451689641,3196290696,235406569,1441906262,3890558523,3013735005,4158569349,1644036924,376726067,1006849064,3664579700,2041234796,1021632941,1374734338,2566452058,371631263,4007144233,490221539,206551450,3140638584,1053219195,1853335209,3412429660,3562156231,735133835,1623211703,3104214392,2738312436,4096837757,3366392578,3110964274,3956598718,3196820781,2038037254,3877786376,2339753847,300912036,3766732888,2372630639,1516443558,4200396704,1574567987,4069441456,4122592016,2699739776,146372218,2748961456,2043888151,35287437,2596680554,655490400,1132482787,110692520,1031794116,2188192751,1324057718,1217253157,919197030,686247489,3261139658,1028237775,3135486431,3059715558,2460921700,986174950,2661811465,4062904701,2752986992,3709736643,367056889,1353824391,731860949,1650113154,1778481506,784341916,357075625,3608602432,1074092588,2480052770,3811426202,92751289,877911070,3600361838,1231880047,480201094,3756190983,3094495953,434011822,87971354,363687820,1717726236,1901380172,3926403882,2481662265,400339184,1490350766,2661455099,1389319756,2558787174,784598401,1983468483,30828846,3550527752,2716276238,3841122214,1765724805,1955612312,1277890269,1333098070,1564029816,2704417615,1026694237,3287671188,1260819201,3349086767,1016692350,1582273796,1073413053,1995943182,694588404,1025494639,3323872702,3551898420,4146854327,453260480,1316140391,1435673405,3038941953,3486689407,1622062951,403978347,817677117,950059133,4246079218,3278066075,1486738320,1417279718,481875527,2549965225,3933690356,760697757,1452955855,3897451437,1177426808,1702951038,4085348628,2447005172,1084371187,3516436277,3068336338,1073369276,1027665953,3284188590,1230553676,1368340146,2226246512,267243139,2274220762,4070734279,2497715176,2423353163,2504755875],a[7]=[3793104909,3151888380,2817252029,895778965,2005530807,3871412763,237245952,86829237,296341424,3851759377,3974600970,2475086196,709006108,1994621201,2972577594,937287164,3734691505,168608556,3189338153,2225080640,3139713551,3033610191,3025041904,77524477,185966941,1208824168,2344345178,1721625922,3354191921,1066374631,1927223579,1971335949,2483503697,1551748602,2881383779,2856329572,3003241482,48746954,1398218158,2050065058,313056748,4255789917,393167848,1912293076,940740642,3465845460,3091687853,2522601570,2197016661,1727764327,364383054,492521376,1291706479,3264136376,1474851438,1685747964,2575719748,1619776915,1814040067,970743798,1561002147,2925768690,2123093554,1880132620,3151188041,697884420,2550985770,2607674513,2659114323,110200136,1489731079,997519150,1378877361,3527870668,478029773,2766872923,1022481122,431258168,1112503832,897933369,2635587303,669726182,3383752315,918222264,163866573,3246985393,3776823163,114105080,1903216136,761148244,3571337562,1690750982,3166750252,1037045171,1888456500,2010454850,642736655,616092351,365016990,1185228132,4174898510,1043824992,2023083429,2241598885,3863320456,3279669087,3674716684,108438443,2132974366,830746235,606445527,4173263986,2204105912,1844756978,2532684181,4245352700,2969441100,3796921661,1335562986,4061524517,2720232303,2679424040,634407289,885462008,3294724487,3933892248,2094100220,339117932,4048830727,3202280980,1458155303,2689246273,1022871705,2464987878,3714515309,353796843,2822958815,4256850100,4052777845,551748367,618185374,3778635579,4020649912,1904685140,3069366075,2670879810,3407193292,2954511620,4058283405,2219449317,3135758300,1120655984,3447565834,1474845562,3577699062,550456716,3466908712,2043752612,881257467,869518812,2005220179,938474677,3305539448,3850417126,1315485940,3318264702,226533026,965733244,321539988,1136104718,804158748,573969341,3708209826,937399083,3290727049,2901666755,1461057207,4013193437,4066861423,3242773476,2421326174,1581322155,3028952165,786071460,3900391652,3918438532,1485433313,4023619836,3708277595,3678951060,953673138,1467089153,1930354364,1533292819,2492563023,1346121658,1685000834,1965281866,3765933717,4190206607,2052792609,3515332758,690371149,3125873887,2180283551,2903598061,3933952357,436236910,289419410,14314871,1242357089,2904507907,1616633776,2666382180,585885352,3471299210,2699507360,1432659641,277164553,3354103607,770115018,2303809295,3741942315,3177781868,2853364978,2269453327,3774259834,987383833,1290892879,225909803,1741533526,890078084,1496906255,1111072499,916028167,243534141,1252605537,2204162171,531204876,290011180,3916834213,102027703,237315147,209093447,1486785922,220223953,2758195998,4175039106,82940208,3127791296,2569425252,518464269,1353887104,3941492737,2377294467,3935040926]}function Rn(e){this.cast5=new Un,this.cast5.setKey(e),this.encrypt=function(e){return this.cast5.encrypt(e)}}Cn.keySize=Cn.prototype.keySize=24,Cn.blockSize=Cn.prototype.blockSize=8,Rn.blockSize=Rn.prototype.blockSize=8,Rn.keySize=Rn.prototype.keySize=16;const Tn=4294967295;function Dn(e,t){return(e<<t|e>>>32-t)&Tn}function In(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24}function Bn(e,t,r){e.splice(t,4,255&r,r>>>8&255,r>>>16&255,r>>>24&255)}function zn(e,t){return e>>>8*t&255}function On(e){this.tf=function(){let e=null,t=null,r=-1,n=[],i=[[],[],[],[]];function a(e){return i[0][zn(e,0)]^i[1][zn(e,1)]^i[2][zn(e,2)]^i[3][zn(e,3)]}function s(e){return i[0][zn(e,3)]^i[1][zn(e,0)]^i[2][zn(e,1)]^i[3][zn(e,2)]}function o(e,t){let r=a(t[0]),i=s(t[1]);t[2]=Dn(t[2]^r+i+n[4*e+8]&Tn,31),t[3]=Dn(t[3],1)^r+2*i+n[4*e+9]&Tn,r=a(t[2]),i=s(t[3]),t[0]=Dn(t[0]^r+i+n[4*e+10]&Tn,31),t[1]=Dn(t[1],1)^r+2*i+n[4*e+11]&Tn}function c(e,t){let r=a(t[0]),i=s(t[1]);t[2]=Dn(t[2],1)^r+i+n[4*e+10]&Tn,t[3]=Dn(t[3]^r+2*i+n[4*e+11]&Tn,31),r=a(t[2]),i=s(t[3]),t[0]=Dn(t[0],1)^r+i+n[4*e+8]&Tn,t[1]=Dn(t[1]^r+2*i+n[4*e+9]&Tn,31)}return{name:"twofish",blocksize:16,open:function(t){let r,a,s,o,c;e=t;const u=[],l=[],h=[];let d;const f=[];let y,p,g;const m=[[8,1,7,13,6,15,3,2,0,11,5,9,14,12,10,4],[2,8,11,13,15,7,6,14,3,1,9,4,0,10,12,5]],w=[[14,12,11,8,1,2,3,5,15,4,10,6,7,0,9,13],[1,14,2,11,4,12,3,7,6,13,10,5,15,9,0,8]],b=[[11,10,5,14,6,13,9,0,12,8,15,3,2,4,7,1],[4,12,7,5,1,6,9,10,0,14,13,8,2,11,3,15]],_=[[13,7,15,4,1,2,6,14,9,11,3,0,8,5,12,10],[11,9,5,1,12,3,13,14,6,4,7,15,2,0,8,10]],v=[0,8,1,9,2,10,3,11,4,12,5,13,6,14,7,15],k=[0,9,2,11,4,13,6,15,8,1,10,3,12,5,14,7],A=[[],[]],S=[[],[],[],[]];function E(e){return e^e>>2^[0,90,180,238][3&e]}function P(e){return e^e>>1^e>>2^[0,238,180,90][3&e]}function x(e,t){let r,n,i;for(r=0;r<8;r++)n=t>>>24,t=t<<8&Tn|e>>>24,e=e<<8&Tn,i=n<<1,128&n&&(i^=333),t^=n^i<<16,i^=n>>>1,1&n&&(i^=166),t^=i<<24|i<<8;return t}function K(e,t){const r=t>>4,n=15&t,i=m[e][r^n],a=w[e][v[n]^k[r]];return _[e][v[a]^k[i]]<<4|b[e][i^a]}function C(e,t){let r=zn(e,0),n=zn(e,1),i=zn(e,2),a=zn(e,3);switch(d){case 4:r=A[1][r]^zn(t[3],0),n=A[0][n]^zn(t[3],1),i=A[0][i]^zn(t[3],2),a=A[1][a]^zn(t[3],3);case 3:r=A[1][r]^zn(t[2],0),n=A[1][n]^zn(t[2],1),i=A[0][i]^zn(t[2],2),a=A[0][a]^zn(t[2],3);case 2:r=A[0][A[0][r]^zn(t[1],0)]^zn(t[0],0),n=A[0][A[1][n]^zn(t[1],1)]^zn(t[0],1),i=A[1][A[0][i]^zn(t[1],2)]^zn(t[0],2),a=A[1][A[1][a]^zn(t[1],3)]^zn(t[0],3)}return S[0][r]^S[1][n]^S[2][i]^S[3][a]}for(e=e.slice(0,32),r=e.length;16!==r&&24!==r&&32!==r;)e[r++]=0;for(r=0;r<e.length;r+=4)h[r>>2]=In(e,r);for(r=0;r<256;r++)A[0][r]=K(0,r),A[1][r]=K(1,r);for(r=0;r<256;r++)y=A[1][r],p=E(y),g=P(y),S[0][r]=y+(p<<8)+(g<<16)+(g<<24),S[2][r]=p+(g<<8)+(y<<16)+(g<<24),y=A[0][r],p=E(y),g=P(y),S[1][r]=g+(g<<8)+(p<<16)+(y<<24),S[3][r]=p+(y<<8)+(g<<16)+(p<<24);for(d=h.length/2,r=0;r<d;r++)a=h[r+r],u[r]=a,s=h[r+r+1],l[r]=s,f[d-r-1]=x(a,s);for(r=0;r<40;r+=2)a=16843009*r,s=a+16843009,a=C(a,u),s=Dn(C(s,l),8),n[r]=a+s&Tn,n[r+1]=Dn(a+2*s,9);for(r=0;r<256;r++)switch(a=s=o=c=r,d){case 4:a=A[1][a]^zn(f[3],0),s=A[0][s]^zn(f[3],1),o=A[0][o]^zn(f[3],2),c=A[1][c]^zn(f[3],3);case 3:a=A[1][a]^zn(f[2],0),s=A[1][s]^zn(f[2],1),o=A[0][o]^zn(f[2],2),c=A[0][c]^zn(f[2],3);case 2:i[0][r]=S[0][A[0][A[0][a]^zn(f[1],0)]^zn(f[0],0)],i[1][r]=S[1][A[0][A[1][s]^zn(f[1],1)]^zn(f[0],1)],i[2][r]=S[2][A[1][A[0][o]^zn(f[1],2)]^zn(f[0],2)],i[3][r]=S[3][A[1][A[1][c]^zn(f[1],3)]^zn(f[0],3)]}},close:function(){n=[],i=[[],[],[],[]]},encrypt:function(e,i){t=e,r=i;const a=[In(t,r)^n[0],In(t,r+4)^n[1],In(t,r+8)^n[2],In(t,r+12)^n[3]];for(let e=0;e<8;e++)o(e,a);return Bn(t,r,a[2]^n[4]),Bn(t,r+4,a[3]^n[5]),Bn(t,r+8,a[0]^n[6]),Bn(t,r+12,a[1]^n[7]),r+=16,t},decrypt:function(e,i){t=e,r=i;const a=[In(t,r)^n[4],In(t,r+4)^n[5],In(t,r+8)^n[6],In(t,r+12)^n[7]];for(let e=7;e>=0;e--)c(e,a);Bn(t,r,a[2]^n[0]),Bn(t,r+4,a[3]^n[1]),Bn(t,r+8,a[0]^n[2]),Bn(t,r+12,a[1]^n[3]),r+=16},finalize:function(){return t}}}(),this.tf.open(Array.from(e),0),this.encrypt=function(e){return this.tf.encrypt(Array.from(e),0)}}function qn(){}function Nn(e){this.bf=new qn,this.bf.init(e),this.encrypt=function(e){return this.bf.encrypt_block(e)}}On.keySize=On.prototype.keySize=32,On.blockSize=On.prototype.blockSize=16,qn.prototype.BLOCKSIZE=8,qn.prototype.SBOXES=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946],[1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055],[3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504],[976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]],qn.prototype.PARRAY=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],qn.prototype.NN=16,qn.prototype._clean=function(e){if(e<0){e=(2147483647&e)+2147483648}return e},qn.prototype._F=function(e){let t;const r=255&e,n=255&(e>>>=8),i=255&(e>>>=8),a=255&(e>>>=8);return t=this.sboxes[0][a]+this.sboxes[1][i],t^=this.sboxes[2][n],t+=this.sboxes[3][r],t},qn.prototype._encrypt_block=function(e){let t,r=e[0],n=e[1];for(t=0;t<this.NN;++t){r^=this.parray[t],n=this._F(r)^n;const e=r;r=n,n=e}r^=this.parray[this.NN+0],n^=this.parray[this.NN+1],e[0]=this._clean(n),e[1]=this._clean(r)},qn.prototype.encrypt_block=function(e){let t;const r=[0,0],n=this.BLOCKSIZE/2;for(t=0;t<this.BLOCKSIZE/2;++t)r[0]=r[0]<<8|255&e[t+0],r[1]=r[1]<<8|255&e[t+n];this._encrypt_block(r);const i=[];for(t=0;t<this.BLOCKSIZE/2;++t)i[t+0]=r[0]>>>24-8*t&255,i[t+n]=r[1]>>>24-8*t&255;return i},qn.prototype._decrypt_block=function(e){let t,r=e[0],n=e[1];for(t=this.NN+1;t>1;--t){r^=this.parray[t],n=this._F(r)^n;const e=r;r=n,n=e}r^=this.parray[1],n^=this.parray[0],e[0]=this._clean(n),e[1]=this._clean(r)},qn.prototype.init=function(e){let t,r=0;for(this.parray=[],t=0;t<this.NN+2;++t){let n=0;for(let t=0;t<4;++t)n=n<<8|255&e[r],++r>=e.length&&(r=0);this.parray[t]=this.PARRAY[t]^n}for(this.sboxes=[],t=0;t<4;++t)for(this.sboxes[t]=[],r=0;r<256;++r)this.sboxes[t][r]=this.SBOXES[t][r];const n=[0,0];for(t=0;t<this.NN+2;t+=2)this._encrypt_block(n),this.parray[t+0]=n[0],this.parray[t+1]=n[1];for(t=0;t<4;++t)for(r=0;r<256;r+=2)this._encrypt_block(n),this.sboxes[t][r+0]=n[0],this.sboxes[t][r+1]=n[1]},Nn.keySize=Nn.prototype.keySize=16,Nn.blockSize=Nn.prototype.blockSize=8;const Mn=Pn(128),Ln=Pn(192),jn=Pn(256);var Fn=/*#__PURE__*/Object.freeze({__proto__:null,aes128:Mn,aes192:Ln,aes256:jn,des:function(e){this.key=e,this.encrypt=function(e,t){return xn(Kn(this.key),e,!0,0,null,t)},this.decrypt=function(e,t){return xn(Kn(this.key),e,!1,0,null,t)}},tripledes:Cn,cast5:Rn,twofish:On,blowfish:Nn,idea:function(){throw Error("IDEA symmetric-key algorithm not implemented")}}),Hn=function(e,t,r){"use asm";var n=0,i=0,a=0,s=0,o=0,c=0,u=0;var l=0,h=0,d=0,f=0,y=0,p=0,g=0,m=0,w=0,b=0;var _=new e.Uint8Array(r);function v(e,t,r,c,u,l,h,d,f,y,p,g,m,w,b,_){e=e|0;t=t|0;r=r|0;c=c|0;u=u|0;l=l|0;h=h|0;d=d|0;f=f|0;y=y|0;p=p|0;g=g|0;m=m|0;w=w|0;b=b|0;_=_|0;var v=0,k=0,A=0,S=0,E=0,P=0,x=0,K=0,C=0,U=0,R=0,T=0,D=0,I=0,B=0,z=0,O=0,q=0,N=0,M=0,L=0,j=0,F=0,H=0,W=0,G=0,V=0,$=0,Y=0,Z=0,Q=0,X=0,J=0,ee=0,te=0,re=0,ne=0,ie=0,ae=0,se=0,oe=0,ce=0,ue=0,le=0,he=0,de=0,fe=0,ye=0,pe=0,ge=0,me=0,we=0,be=0,_e=0,ve=0,ke=0,Ae=0,Se=0,Ee=0,Pe=0,xe=0,Ke=0,Ce=0,Ue=0,Re=0,Te=0,De=0,Ie=0,Be=0,ze=0,Oe=0;v=n;k=i;A=a;S=s;E=o;x=e+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;x=t+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;x=r+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;x=c+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;x=u+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;x=l+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;x=h+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;x=d+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;x=f+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;x=y+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;x=p+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;x=g+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;x=m+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;x=w+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;x=b+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;x=_+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=w^f^r^e;K=P<<1|P>>>31;x=K+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=b^y^c^t;C=P<<1|P>>>31;x=C+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=_^p^u^r;U=P<<1|P>>>31;x=U+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=K^g^l^c;R=P<<1|P>>>31;x=R+(v<<5|v>>>27)+E+(k&A|~k&S)+0x5a827999|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=C^m^h^u;T=P<<1|P>>>31;x=T+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=U^w^d^l;D=P<<1|P>>>31;x=D+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=R^b^f^h;I=P<<1|P>>>31;x=I+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=T^_^y^d;B=P<<1|P>>>31;x=B+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=D^K^p^f;z=P<<1|P>>>31;x=z+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=I^C^g^y;O=P<<1|P>>>31;x=O+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=B^U^m^p;q=P<<1|P>>>31;x=q+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=z^R^w^g;N=P<<1|P>>>31;x=N+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=O^T^b^m;M=P<<1|P>>>31;x=M+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=q^D^_^w;L=P<<1|P>>>31;x=L+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=N^I^K^b;j=P<<1|P>>>31;x=j+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=M^B^C^_;F=P<<1|P>>>31;x=F+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=L^z^U^K;H=P<<1|P>>>31;x=H+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=j^O^R^C;W=P<<1|P>>>31;x=W+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=F^q^T^U;G=P<<1|P>>>31;x=G+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=H^N^D^R;V=P<<1|P>>>31;x=V+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=W^M^I^T;$=P<<1|P>>>31;x=$+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=G^L^B^D;Y=P<<1|P>>>31;x=Y+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=V^j^z^I;Z=P<<1|P>>>31;x=Z+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=$^F^O^B;Q=P<<1|P>>>31;x=Q+(v<<5|v>>>27)+E+(k^A^S)+0x6ed9eba1|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=Y^H^q^z;X=P<<1|P>>>31;x=X+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=Z^W^N^O;J=P<<1|P>>>31;x=J+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=Q^G^M^q;ee=P<<1|P>>>31;x=ee+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=X^V^L^N;te=P<<1|P>>>31;x=te+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=J^$^j^M;re=P<<1|P>>>31;x=re+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=ee^Y^F^L;ne=P<<1|P>>>31;x=ne+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=te^Z^H^j;ie=P<<1|P>>>31;x=ie+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=re^Q^W^F;ae=P<<1|P>>>31;x=ae+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=ne^X^G^H;se=P<<1|P>>>31;x=se+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=ie^J^V^W;oe=P<<1|P>>>31;x=oe+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=ae^ee^$^G;ce=P<<1|P>>>31;x=ce+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=se^te^Y^V;ue=P<<1|P>>>31;x=ue+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=oe^re^Z^$;le=P<<1|P>>>31;x=le+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=ce^ne^Q^Y;he=P<<1|P>>>31;x=he+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=ue^ie^X^Z;de=P<<1|P>>>31;x=de+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=le^ae^J^Q;fe=P<<1|P>>>31;x=fe+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=he^se^ee^X;ye=P<<1|P>>>31;x=ye+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=de^oe^te^J;pe=P<<1|P>>>31;x=pe+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=fe^ce^re^ee;ge=P<<1|P>>>31;x=ge+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=ye^ue^ne^te;me=P<<1|P>>>31;x=me+(v<<5|v>>>27)+E+(k&A|k&S|A&S)-0x70e44324|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=pe^le^ie^re;we=P<<1|P>>>31;x=we+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=ge^he^ae^ne;be=P<<1|P>>>31;x=be+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=me^de^se^ie;_e=P<<1|P>>>31;x=_e+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=we^fe^oe^ae;ve=P<<1|P>>>31;x=ve+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=be^ye^ce^se;ke=P<<1|P>>>31;x=ke+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=_e^pe^ue^oe;Ae=P<<1|P>>>31;x=Ae+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=ve^ge^le^ce;Se=P<<1|P>>>31;x=Se+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=ke^me^he^ue;Ee=P<<1|P>>>31;x=Ee+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=Ae^we^de^le;Pe=P<<1|P>>>31;x=Pe+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=Se^be^fe^he;xe=P<<1|P>>>31;x=xe+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=Ee^_e^ye^de;Ke=P<<1|P>>>31;x=Ke+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=Pe^ve^pe^fe;Ce=P<<1|P>>>31;x=Ce+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=xe^ke^ge^ye;Ue=P<<1|P>>>31;x=Ue+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=Ke^Ae^me^pe;Re=P<<1|P>>>31;x=Re+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=Ce^Se^we^ge;Te=P<<1|P>>>31;x=Te+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=Ue^Ee^be^me;De=P<<1|P>>>31;x=De+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=Re^Pe^_e^we;Ie=P<<1|P>>>31;x=Ie+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=Te^xe^ve^be;Be=P<<1|P>>>31;x=Be+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=De^Ke^ke^_e;ze=P<<1|P>>>31;x=ze+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;P=Ie^Ce^Ae^ve;Oe=P<<1|P>>>31;x=Oe+(v<<5|v>>>27)+E+(k^A^S)-0x359d3e2a|0;E=S;S=A;A=k<<30|k>>>2;k=v;v=x;n=n+v|0;i=i+k|0;a=a+A|0;s=s+S|0;o=o+E|0}function k(e){e=e|0;v(_[e|0]<<24|_[e|1]<<16|_[e|2]<<8|_[e|3],_[e|4]<<24|_[e|5]<<16|_[e|6]<<8|_[e|7],_[e|8]<<24|_[e|9]<<16|_[e|10]<<8|_[e|11],_[e|12]<<24|_[e|13]<<16|_[e|14]<<8|_[e|15],_[e|16]<<24|_[e|17]<<16|_[e|18]<<8|_[e|19],_[e|20]<<24|_[e|21]<<16|_[e|22]<<8|_[e|23],_[e|24]<<24|_[e|25]<<16|_[e|26]<<8|_[e|27],_[e|28]<<24|_[e|29]<<16|_[e|30]<<8|_[e|31],_[e|32]<<24|_[e|33]<<16|_[e|34]<<8|_[e|35],_[e|36]<<24|_[e|37]<<16|_[e|38]<<8|_[e|39],_[e|40]<<24|_[e|41]<<16|_[e|42]<<8|_[e|43],_[e|44]<<24|_[e|45]<<16|_[e|46]<<8|_[e|47],_[e|48]<<24|_[e|49]<<16|_[e|50]<<8|_[e|51],_[e|52]<<24|_[e|53]<<16|_[e|54]<<8|_[e|55],_[e|56]<<24|_[e|57]<<16|_[e|58]<<8|_[e|59],_[e|60]<<24|_[e|61]<<16|_[e|62]<<8|_[e|63])}function A(e){e=e|0;_[e|0]=n>>>24;_[e|1]=n>>>16&255;_[e|2]=n>>>8&255;_[e|3]=n&255;_[e|4]=i>>>24;_[e|5]=i>>>16&255;_[e|6]=i>>>8&255;_[e|7]=i&255;_[e|8]=a>>>24;_[e|9]=a>>>16&255;_[e|10]=a>>>8&255;_[e|11]=a&255;_[e|12]=s>>>24;_[e|13]=s>>>16&255;_[e|14]=s>>>8&255;_[e|15]=s&255;_[e|16]=o>>>24;_[e|17]=o>>>16&255;_[e|18]=o>>>8&255;_[e|19]=o&255}function S(){n=0x67452301;i=0xefcdab89;a=0x98badcfe;s=0x10325476;o=0xc3d2e1f0;c=u=0}function E(e,t,r,l,h,d,f){e=e|0;t=t|0;r=r|0;l=l|0;h=h|0;d=d|0;f=f|0;n=e;i=t;a=r;s=l;o=h;c=d;u=f}function P(e,t){e=e|0;t=t|0;var r=0;if(e&63)return-1;while((t|0)>=64){k(e);e=e+64|0;t=t-64|0;r=r+64|0}c=c+r|0;if(c>>>0<r>>>0)u=u+1|0;return r|0}function x(e,t,r){e=e|0;t=t|0;r=r|0;var n=0,i=0;if(e&63)return-1;if(~r)if(r&31)return-1;if((t|0)>=64){n=P(e,t)|0;if((n|0)==-1)return-1;e=e+n|0;t=t-n|0}n=n+t|0;c=c+t|0;if(c>>>0<t>>>0)u=u+1|0;_[e|t]=0x80;if((t|0)>=56){for(i=t+1|0;(i|0)<64;i=i+1|0)_[e|i]=0x00;k(e);t=0;_[e|0]=0}for(i=t+1|0;(i|0)<59;i=i+1|0)_[e|i]=0;_[e|56]=u>>>21&255;_[e|57]=u>>>13&255;_[e|58]=u>>>5&255;_[e|59]=u<<3&255|c>>>29;_[e|60]=c>>>21&255;_[e|61]=c>>>13&255;_[e|62]=c>>>5&255;_[e|63]=c<<3&255;k(e);if(~r)A(r);return n|0}function K(){n=l;i=h;a=d;s=f;o=y;c=64;u=0}function C(){n=p;i=g;a=m;s=w;o=b;c=64;u=0}function U(e,t,r,_,k,A,E,P,x,K,C,U,R,T,D,I){e=e|0;t=t|0;r=r|0;_=_|0;k=k|0;A=A|0;E=E|0;P=P|0;x=x|0;K=K|0;C=C|0;U=U|0;R=R|0;T=T|0;D=D|0;I=I|0;S();v(e^0x5c5c5c5c,t^0x5c5c5c5c,r^0x5c5c5c5c,_^0x5c5c5c5c,k^0x5c5c5c5c,A^0x5c5c5c5c,E^0x5c5c5c5c,P^0x5c5c5c5c,x^0x5c5c5c5c,K^0x5c5c5c5c,C^0x5c5c5c5c,U^0x5c5c5c5c,R^0x5c5c5c5c,T^0x5c5c5c5c,D^0x5c5c5c5c,I^0x5c5c5c5c);p=n;g=i;m=a;w=s;b=o;S();v(e^0x36363636,t^0x36363636,r^0x36363636,_^0x36363636,k^0x36363636,A^0x36363636,E^0x36363636,P^0x36363636,x^0x36363636,K^0x36363636,C^0x36363636,U^0x36363636,R^0x36363636,T^0x36363636,D^0x36363636,I^0x36363636);l=n;h=i;d=a;f=s;y=o;c=64;u=0}function R(e,t,r){e=e|0;t=t|0;r=r|0;var c=0,u=0,l=0,h=0,d=0,f=0;if(e&63)return-1;if(~r)if(r&31)return-1;f=x(e,t,-1)|0;c=n,u=i,l=a,h=s,d=o;C();v(c,u,l,h,d,0x80000000,0,0,0,0,0,0,0,0,0,672);if(~r)A(r);return f|0}function T(e,t,r,c,u){e=e|0;t=t|0;r=r|0;c=c|0;u=u|0;var l=0,h=0,d=0,f=0,y=0,p=0,g=0,m=0,w=0,b=0;if(e&63)return-1;if(~u)if(u&31)return-1;_[e+t|0]=r>>>24;_[e+t+1|0]=r>>>16&255;_[e+t+2|0]=r>>>8&255;_[e+t+3|0]=r&255;R(e,t+4|0,-1)|0;l=p=n,h=g=i,d=m=a,f=w=s,y=b=o;c=c-1|0;while((c|0)>0){K();v(p,g,m,w,b,0x80000000,0,0,0,0,0,0,0,0,0,672);p=n,g=i,m=a,w=s,b=o;C();v(p,g,m,w,b,0x80000000,0,0,0,0,0,0,0,0,0,672);p=n,g=i,m=a,w=s,b=o;l=l^n;h=h^i;d=d^a;f=f^s;y=y^o;c=c-1|0}n=l;i=h;a=d;s=f;o=y;if(~u)A(u);return 0}return{reset:S,init:E,process:P,finish:x,hmac_reset:K,hmac_init:U,hmac_finish:R,pbkdf2_generate_block:T}};class Wn{constructor(){this.pos=0,this.len=0}reset(){const{asm:e}=this.acquire_asm();return this.result=null,this.pos=0,this.len=0,e.reset(),this}process(e){if(null!==this.result)throw new bn("state must be reset before processing new data");const{asm:t,heap:r}=this.acquire_asm();let n=this.pos,i=this.len,a=0,s=e.length,o=0;for(;s>0;)o=mn(r,n+i,e,a,s),i+=o,a+=o,s-=o,o=t.process(n,i),n+=o,i-=o,i||(n=0);return this.pos=n,this.len=i,this}finish(){if(null!==this.result)throw new bn("state must be reset before processing new data");const{asm:e,heap:t}=this.acquire_asm();return e.finish(this.pos,this.len,0),this.result=new Uint8Array(this.HASH_SIZE),this.result.set(t.subarray(0,this.HASH_SIZE)),this.pos=0,this.len=0,this.release_asm(),this}}const Gn=[],Vn=[];class $n extends Wn{constructor(){super(),this.NAME="sha1",this.BLOCK_SIZE=64,this.HASH_SIZE=20,this.acquire_asm()}acquire_asm(){return void 0!==this.heap&&void 0!==this.asm||(this.heap=Gn.pop()||gn(),this.asm=Vn.pop()||Hn({Uint8Array},null,this.heap.buffer),this.reset()),{heap:this.heap,asm:this.asm}}release_asm(){void 0!==this.heap&&void 0!==this.asm&&(Gn.push(this.heap),Vn.push(this.asm)),this.heap=void 0,this.asm=void 0}static bytes(e){return(new $n).process(e).finish().result}}$n.NAME="sha1",$n.heap_pool=[],$n.asm_pool=[],$n.asm_function=Hn;const Yn=[],Zn=[];class Qn extends Wn{constructor(){super(),this.NAME="sha256",this.BLOCK_SIZE=64,this.HASH_SIZE=32,this.acquire_asm()}acquire_asm(){return void 0!==this.heap&&void 0!==this.asm||(this.heap=Yn.pop()||gn(),this.asm=Zn.pop()||function(e,t,r){"use asm";var n=0,i=0,a=0,s=0,o=0,c=0,u=0,l=0,h=0,d=0,f=0,y=0,p=0,g=0,m=0,w=0,b=0,_=0,v=0,k=0,A=0,S=0,E=0,P=0,x=0,K=0,C=new e.Uint8Array(r);function U(e,t,r,h,d,f,y,p,g,m,w,b,_,v,k,A){e=e|0;t=t|0;r=r|0;h=h|0;d=d|0;f=f|0;y=y|0;p=p|0;g=g|0;m=m|0;w=w|0;b=b|0;_=_|0;v=v|0;k=k|0;A=A|0;var S=0,E=0,P=0,x=0,K=0,C=0,U=0,R=0;S=n;E=i;P=a;x=s;K=o;C=c;U=u;R=l;R=e+R+(K>>>6^K>>>11^K>>>25^K<<26^K<<21^K<<7)+(U^K&(C^U))+0x428a2f98|0;x=x+R|0;R=R+(S&E^P&(S^E))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;U=t+U+(x>>>6^x>>>11^x>>>25^x<<26^x<<21^x<<7)+(C^x&(K^C))+0x71374491|0;P=P+U|0;U=U+(R&S^E&(R^S))+(R>>>2^R>>>13^R>>>22^R<<30^R<<19^R<<10)|0;C=r+C+(P>>>6^P>>>11^P>>>25^P<<26^P<<21^P<<7)+(K^P&(x^K))+0xb5c0fbcf|0;E=E+C|0;C=C+(U&R^S&(U^R))+(U>>>2^U>>>13^U>>>22^U<<30^U<<19^U<<10)|0;K=h+K+(E>>>6^E>>>11^E>>>25^E<<26^E<<21^E<<7)+(x^E&(P^x))+0xe9b5dba5|0;S=S+K|0;K=K+(C&U^R&(C^U))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;x=d+x+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(P^S&(E^P))+0x3956c25b|0;R=R+x|0;x=x+(K&C^U&(K^C))+(K>>>2^K>>>13^K>>>22^K<<30^K<<19^K<<10)|0;P=f+P+(R>>>6^R>>>11^R>>>25^R<<26^R<<21^R<<7)+(E^R&(S^E))+0x59f111f1|0;U=U+P|0;P=P+(x&K^C&(x^K))+(x>>>2^x>>>13^x>>>22^x<<30^x<<19^x<<10)|0;E=y+E+(U>>>6^U>>>11^U>>>25^U<<26^U<<21^U<<7)+(S^U&(R^S))+0x923f82a4|0;C=C+E|0;E=E+(P&x^K&(P^x))+(P>>>2^P>>>13^P>>>22^P<<30^P<<19^P<<10)|0;S=p+S+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(R^C&(U^R))+0xab1c5ed5|0;K=K+S|0;S=S+(E&P^x&(E^P))+(E>>>2^E>>>13^E>>>22^E<<30^E<<19^E<<10)|0;R=g+R+(K>>>6^K>>>11^K>>>25^K<<26^K<<21^K<<7)+(U^K&(C^U))+0xd807aa98|0;x=x+R|0;R=R+(S&E^P&(S^E))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;U=m+U+(x>>>6^x>>>11^x>>>25^x<<26^x<<21^x<<7)+(C^x&(K^C))+0x12835b01|0;P=P+U|0;U=U+(R&S^E&(R^S))+(R>>>2^R>>>13^R>>>22^R<<30^R<<19^R<<10)|0;C=w+C+(P>>>6^P>>>11^P>>>25^P<<26^P<<21^P<<7)+(K^P&(x^K))+0x243185be|0;E=E+C|0;C=C+(U&R^S&(U^R))+(U>>>2^U>>>13^U>>>22^U<<30^U<<19^U<<10)|0;K=b+K+(E>>>6^E>>>11^E>>>25^E<<26^E<<21^E<<7)+(x^E&(P^x))+0x550c7dc3|0;S=S+K|0;K=K+(C&U^R&(C^U))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;x=_+x+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(P^S&(E^P))+0x72be5d74|0;R=R+x|0;x=x+(K&C^U&(K^C))+(K>>>2^K>>>13^K>>>22^K<<30^K<<19^K<<10)|0;P=v+P+(R>>>6^R>>>11^R>>>25^R<<26^R<<21^R<<7)+(E^R&(S^E))+0x80deb1fe|0;U=U+P|0;P=P+(x&K^C&(x^K))+(x>>>2^x>>>13^x>>>22^x<<30^x<<19^x<<10)|0;E=k+E+(U>>>6^U>>>11^U>>>25^U<<26^U<<21^U<<7)+(S^U&(R^S))+0x9bdc06a7|0;C=C+E|0;E=E+(P&x^K&(P^x))+(P>>>2^P>>>13^P>>>22^P<<30^P<<19^P<<10)|0;S=A+S+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(R^C&(U^R))+0xc19bf174|0;K=K+S|0;S=S+(E&P^x&(E^P))+(E>>>2^E>>>13^E>>>22^E<<30^E<<19^E<<10)|0;e=(t>>>7^t>>>18^t>>>3^t<<25^t<<14)+(k>>>17^k>>>19^k>>>10^k<<15^k<<13)+e+m|0;R=e+R+(K>>>6^K>>>11^K>>>25^K<<26^K<<21^K<<7)+(U^K&(C^U))+0xe49b69c1|0;x=x+R|0;R=R+(S&E^P&(S^E))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;t=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(A>>>17^A>>>19^A>>>10^A<<15^A<<13)+t+w|0;U=t+U+(x>>>6^x>>>11^x>>>25^x<<26^x<<21^x<<7)+(C^x&(K^C))+0xefbe4786|0;P=P+U|0;U=U+(R&S^E&(R^S))+(R>>>2^R>>>13^R>>>22^R<<30^R<<19^R<<10)|0;r=(h>>>7^h>>>18^h>>>3^h<<25^h<<14)+(e>>>17^e>>>19^e>>>10^e<<15^e<<13)+r+b|0;C=r+C+(P>>>6^P>>>11^P>>>25^P<<26^P<<21^P<<7)+(K^P&(x^K))+0x0fc19dc6|0;E=E+C|0;C=C+(U&R^S&(U^R))+(U>>>2^U>>>13^U>>>22^U<<30^U<<19^U<<10)|0;h=(d>>>7^d>>>18^d>>>3^d<<25^d<<14)+(t>>>17^t>>>19^t>>>10^t<<15^t<<13)+h+_|0;K=h+K+(E>>>6^E>>>11^E>>>25^E<<26^E<<21^E<<7)+(x^E&(P^x))+0x240ca1cc|0;S=S+K|0;K=K+(C&U^R&(C^U))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;d=(f>>>7^f>>>18^f>>>3^f<<25^f<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+d+v|0;x=d+x+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(P^S&(E^P))+0x2de92c6f|0;R=R+x|0;x=x+(K&C^U&(K^C))+(K>>>2^K>>>13^K>>>22^K<<30^K<<19^K<<10)|0;f=(y>>>7^y>>>18^y>>>3^y<<25^y<<14)+(h>>>17^h>>>19^h>>>10^h<<15^h<<13)+f+k|0;P=f+P+(R>>>6^R>>>11^R>>>25^R<<26^R<<21^R<<7)+(E^R&(S^E))+0x4a7484aa|0;U=U+P|0;P=P+(x&K^C&(x^K))+(x>>>2^x>>>13^x>>>22^x<<30^x<<19^x<<10)|0;y=(p>>>7^p>>>18^p>>>3^p<<25^p<<14)+(d>>>17^d>>>19^d>>>10^d<<15^d<<13)+y+A|0;E=y+E+(U>>>6^U>>>11^U>>>25^U<<26^U<<21^U<<7)+(S^U&(R^S))+0x5cb0a9dc|0;C=C+E|0;E=E+(P&x^K&(P^x))+(P>>>2^P>>>13^P>>>22^P<<30^P<<19^P<<10)|0;p=(g>>>7^g>>>18^g>>>3^g<<25^g<<14)+(f>>>17^f>>>19^f>>>10^f<<15^f<<13)+p+e|0;S=p+S+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(R^C&(U^R))+0x76f988da|0;K=K+S|0;S=S+(E&P^x&(E^P))+(E>>>2^E>>>13^E>>>22^E<<30^E<<19^E<<10)|0;g=(m>>>7^m>>>18^m>>>3^m<<25^m<<14)+(y>>>17^y>>>19^y>>>10^y<<15^y<<13)+g+t|0;R=g+R+(K>>>6^K>>>11^K>>>25^K<<26^K<<21^K<<7)+(U^K&(C^U))+0x983e5152|0;x=x+R|0;R=R+(S&E^P&(S^E))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;m=(w>>>7^w>>>18^w>>>3^w<<25^w<<14)+(p>>>17^p>>>19^p>>>10^p<<15^p<<13)+m+r|0;U=m+U+(x>>>6^x>>>11^x>>>25^x<<26^x<<21^x<<7)+(C^x&(K^C))+0xa831c66d|0;P=P+U|0;U=U+(R&S^E&(R^S))+(R>>>2^R>>>13^R>>>22^R<<30^R<<19^R<<10)|0;w=(b>>>7^b>>>18^b>>>3^b<<25^b<<14)+(g>>>17^g>>>19^g>>>10^g<<15^g<<13)+w+h|0;C=w+C+(P>>>6^P>>>11^P>>>25^P<<26^P<<21^P<<7)+(K^P&(x^K))+0xb00327c8|0;E=E+C|0;C=C+(U&R^S&(U^R))+(U>>>2^U>>>13^U>>>22^U<<30^U<<19^U<<10)|0;b=(_>>>7^_>>>18^_>>>3^_<<25^_<<14)+(m>>>17^m>>>19^m>>>10^m<<15^m<<13)+b+d|0;K=b+K+(E>>>6^E>>>11^E>>>25^E<<26^E<<21^E<<7)+(x^E&(P^x))+0xbf597fc7|0;S=S+K|0;K=K+(C&U^R&(C^U))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;_=(v>>>7^v>>>18^v>>>3^v<<25^v<<14)+(w>>>17^w>>>19^w>>>10^w<<15^w<<13)+_+f|0;x=_+x+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(P^S&(E^P))+0xc6e00bf3|0;R=R+x|0;x=x+(K&C^U&(K^C))+(K>>>2^K>>>13^K>>>22^K<<30^K<<19^K<<10)|0;v=(k>>>7^k>>>18^k>>>3^k<<25^k<<14)+(b>>>17^b>>>19^b>>>10^b<<15^b<<13)+v+y|0;P=v+P+(R>>>6^R>>>11^R>>>25^R<<26^R<<21^R<<7)+(E^R&(S^E))+0xd5a79147|0;U=U+P|0;P=P+(x&K^C&(x^K))+(x>>>2^x>>>13^x>>>22^x<<30^x<<19^x<<10)|0;k=(A>>>7^A>>>18^A>>>3^A<<25^A<<14)+(_>>>17^_>>>19^_>>>10^_<<15^_<<13)+k+p|0;E=k+E+(U>>>6^U>>>11^U>>>25^U<<26^U<<21^U<<7)+(S^U&(R^S))+0x06ca6351|0;C=C+E|0;E=E+(P&x^K&(P^x))+(P>>>2^P>>>13^P>>>22^P<<30^P<<19^P<<10)|0;A=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(v>>>17^v>>>19^v>>>10^v<<15^v<<13)+A+g|0;S=A+S+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(R^C&(U^R))+0x14292967|0;K=K+S|0;S=S+(E&P^x&(E^P))+(E>>>2^E>>>13^E>>>22^E<<30^E<<19^E<<10)|0;e=(t>>>7^t>>>18^t>>>3^t<<25^t<<14)+(k>>>17^k>>>19^k>>>10^k<<15^k<<13)+e+m|0;R=e+R+(K>>>6^K>>>11^K>>>25^K<<26^K<<21^K<<7)+(U^K&(C^U))+0x27b70a85|0;x=x+R|0;R=R+(S&E^P&(S^E))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;t=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(A>>>17^A>>>19^A>>>10^A<<15^A<<13)+t+w|0;U=t+U+(x>>>6^x>>>11^x>>>25^x<<26^x<<21^x<<7)+(C^x&(K^C))+0x2e1b2138|0;P=P+U|0;U=U+(R&S^E&(R^S))+(R>>>2^R>>>13^R>>>22^R<<30^R<<19^R<<10)|0;r=(h>>>7^h>>>18^h>>>3^h<<25^h<<14)+(e>>>17^e>>>19^e>>>10^e<<15^e<<13)+r+b|0;C=r+C+(P>>>6^P>>>11^P>>>25^P<<26^P<<21^P<<7)+(K^P&(x^K))+0x4d2c6dfc|0;E=E+C|0;C=C+(U&R^S&(U^R))+(U>>>2^U>>>13^U>>>22^U<<30^U<<19^U<<10)|0;h=(d>>>7^d>>>18^d>>>3^d<<25^d<<14)+(t>>>17^t>>>19^t>>>10^t<<15^t<<13)+h+_|0;K=h+K+(E>>>6^E>>>11^E>>>25^E<<26^E<<21^E<<7)+(x^E&(P^x))+0x53380d13|0;S=S+K|0;K=K+(C&U^R&(C^U))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;d=(f>>>7^f>>>18^f>>>3^f<<25^f<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+d+v|0;x=d+x+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(P^S&(E^P))+0x650a7354|0;R=R+x|0;x=x+(K&C^U&(K^C))+(K>>>2^K>>>13^K>>>22^K<<30^K<<19^K<<10)|0;f=(y>>>7^y>>>18^y>>>3^y<<25^y<<14)+(h>>>17^h>>>19^h>>>10^h<<15^h<<13)+f+k|0;P=f+P+(R>>>6^R>>>11^R>>>25^R<<26^R<<21^R<<7)+(E^R&(S^E))+0x766a0abb|0;U=U+P|0;P=P+(x&K^C&(x^K))+(x>>>2^x>>>13^x>>>22^x<<30^x<<19^x<<10)|0;y=(p>>>7^p>>>18^p>>>3^p<<25^p<<14)+(d>>>17^d>>>19^d>>>10^d<<15^d<<13)+y+A|0;E=y+E+(U>>>6^U>>>11^U>>>25^U<<26^U<<21^U<<7)+(S^U&(R^S))+0x81c2c92e|0;C=C+E|0;E=E+(P&x^K&(P^x))+(P>>>2^P>>>13^P>>>22^P<<30^P<<19^P<<10)|0;p=(g>>>7^g>>>18^g>>>3^g<<25^g<<14)+(f>>>17^f>>>19^f>>>10^f<<15^f<<13)+p+e|0;S=p+S+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(R^C&(U^R))+0x92722c85|0;K=K+S|0;S=S+(E&P^x&(E^P))+(E>>>2^E>>>13^E>>>22^E<<30^E<<19^E<<10)|0;g=(m>>>7^m>>>18^m>>>3^m<<25^m<<14)+(y>>>17^y>>>19^y>>>10^y<<15^y<<13)+g+t|0;R=g+R+(K>>>6^K>>>11^K>>>25^K<<26^K<<21^K<<7)+(U^K&(C^U))+0xa2bfe8a1|0;x=x+R|0;R=R+(S&E^P&(S^E))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;m=(w>>>7^w>>>18^w>>>3^w<<25^w<<14)+(p>>>17^p>>>19^p>>>10^p<<15^p<<13)+m+r|0;U=m+U+(x>>>6^x>>>11^x>>>25^x<<26^x<<21^x<<7)+(C^x&(K^C))+0xa81a664b|0;P=P+U|0;U=U+(R&S^E&(R^S))+(R>>>2^R>>>13^R>>>22^R<<30^R<<19^R<<10)|0;w=(b>>>7^b>>>18^b>>>3^b<<25^b<<14)+(g>>>17^g>>>19^g>>>10^g<<15^g<<13)+w+h|0;C=w+C+(P>>>6^P>>>11^P>>>25^P<<26^P<<21^P<<7)+(K^P&(x^K))+0xc24b8b70|0;E=E+C|0;C=C+(U&R^S&(U^R))+(U>>>2^U>>>13^U>>>22^U<<30^U<<19^U<<10)|0;b=(_>>>7^_>>>18^_>>>3^_<<25^_<<14)+(m>>>17^m>>>19^m>>>10^m<<15^m<<13)+b+d|0;K=b+K+(E>>>6^E>>>11^E>>>25^E<<26^E<<21^E<<7)+(x^E&(P^x))+0xc76c51a3|0;S=S+K|0;K=K+(C&U^R&(C^U))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;_=(v>>>7^v>>>18^v>>>3^v<<25^v<<14)+(w>>>17^w>>>19^w>>>10^w<<15^w<<13)+_+f|0;x=_+x+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(P^S&(E^P))+0xd192e819|0;R=R+x|0;x=x+(K&C^U&(K^C))+(K>>>2^K>>>13^K>>>22^K<<30^K<<19^K<<10)|0;v=(k>>>7^k>>>18^k>>>3^k<<25^k<<14)+(b>>>17^b>>>19^b>>>10^b<<15^b<<13)+v+y|0;P=v+P+(R>>>6^R>>>11^R>>>25^R<<26^R<<21^R<<7)+(E^R&(S^E))+0xd6990624|0;U=U+P|0;P=P+(x&K^C&(x^K))+(x>>>2^x>>>13^x>>>22^x<<30^x<<19^x<<10)|0;k=(A>>>7^A>>>18^A>>>3^A<<25^A<<14)+(_>>>17^_>>>19^_>>>10^_<<15^_<<13)+k+p|0;E=k+E+(U>>>6^U>>>11^U>>>25^U<<26^U<<21^U<<7)+(S^U&(R^S))+0xf40e3585|0;C=C+E|0;E=E+(P&x^K&(P^x))+(P>>>2^P>>>13^P>>>22^P<<30^P<<19^P<<10)|0;A=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(v>>>17^v>>>19^v>>>10^v<<15^v<<13)+A+g|0;S=A+S+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(R^C&(U^R))+0x106aa070|0;K=K+S|0;S=S+(E&P^x&(E^P))+(E>>>2^E>>>13^E>>>22^E<<30^E<<19^E<<10)|0;e=(t>>>7^t>>>18^t>>>3^t<<25^t<<14)+(k>>>17^k>>>19^k>>>10^k<<15^k<<13)+e+m|0;R=e+R+(K>>>6^K>>>11^K>>>25^K<<26^K<<21^K<<7)+(U^K&(C^U))+0x19a4c116|0;x=x+R|0;R=R+(S&E^P&(S^E))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;t=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(A>>>17^A>>>19^A>>>10^A<<15^A<<13)+t+w|0;U=t+U+(x>>>6^x>>>11^x>>>25^x<<26^x<<21^x<<7)+(C^x&(K^C))+0x1e376c08|0;P=P+U|0;U=U+(R&S^E&(R^S))+(R>>>2^R>>>13^R>>>22^R<<30^R<<19^R<<10)|0;r=(h>>>7^h>>>18^h>>>3^h<<25^h<<14)+(e>>>17^e>>>19^e>>>10^e<<15^e<<13)+r+b|0;C=r+C+(P>>>6^P>>>11^P>>>25^P<<26^P<<21^P<<7)+(K^P&(x^K))+0x2748774c|0;E=E+C|0;C=C+(U&R^S&(U^R))+(U>>>2^U>>>13^U>>>22^U<<30^U<<19^U<<10)|0;h=(d>>>7^d>>>18^d>>>3^d<<25^d<<14)+(t>>>17^t>>>19^t>>>10^t<<15^t<<13)+h+_|0;K=h+K+(E>>>6^E>>>11^E>>>25^E<<26^E<<21^E<<7)+(x^E&(P^x))+0x34b0bcb5|0;S=S+K|0;K=K+(C&U^R&(C^U))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;d=(f>>>7^f>>>18^f>>>3^f<<25^f<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+d+v|0;x=d+x+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(P^S&(E^P))+0x391c0cb3|0;R=R+x|0;x=x+(K&C^U&(K^C))+(K>>>2^K>>>13^K>>>22^K<<30^K<<19^K<<10)|0;f=(y>>>7^y>>>18^y>>>3^y<<25^y<<14)+(h>>>17^h>>>19^h>>>10^h<<15^h<<13)+f+k|0;P=f+P+(R>>>6^R>>>11^R>>>25^R<<26^R<<21^R<<7)+(E^R&(S^E))+0x4ed8aa4a|0;U=U+P|0;P=P+(x&K^C&(x^K))+(x>>>2^x>>>13^x>>>22^x<<30^x<<19^x<<10)|0;y=(p>>>7^p>>>18^p>>>3^p<<25^p<<14)+(d>>>17^d>>>19^d>>>10^d<<15^d<<13)+y+A|0;E=y+E+(U>>>6^U>>>11^U>>>25^U<<26^U<<21^U<<7)+(S^U&(R^S))+0x5b9cca4f|0;C=C+E|0;E=E+(P&x^K&(P^x))+(P>>>2^P>>>13^P>>>22^P<<30^P<<19^P<<10)|0;p=(g>>>7^g>>>18^g>>>3^g<<25^g<<14)+(f>>>17^f>>>19^f>>>10^f<<15^f<<13)+p+e|0;S=p+S+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(R^C&(U^R))+0x682e6ff3|0;K=K+S|0;S=S+(E&P^x&(E^P))+(E>>>2^E>>>13^E>>>22^E<<30^E<<19^E<<10)|0;g=(m>>>7^m>>>18^m>>>3^m<<25^m<<14)+(y>>>17^y>>>19^y>>>10^y<<15^y<<13)+g+t|0;R=g+R+(K>>>6^K>>>11^K>>>25^K<<26^K<<21^K<<7)+(U^K&(C^U))+0x748f82ee|0;x=x+R|0;R=R+(S&E^P&(S^E))+(S>>>2^S>>>13^S>>>22^S<<30^S<<19^S<<10)|0;m=(w>>>7^w>>>18^w>>>3^w<<25^w<<14)+(p>>>17^p>>>19^p>>>10^p<<15^p<<13)+m+r|0;U=m+U+(x>>>6^x>>>11^x>>>25^x<<26^x<<21^x<<7)+(C^x&(K^C))+0x78a5636f|0;P=P+U|0;U=U+(R&S^E&(R^S))+(R>>>2^R>>>13^R>>>22^R<<30^R<<19^R<<10)|0;w=(b>>>7^b>>>18^b>>>3^b<<25^b<<14)+(g>>>17^g>>>19^g>>>10^g<<15^g<<13)+w+h|0;C=w+C+(P>>>6^P>>>11^P>>>25^P<<26^P<<21^P<<7)+(K^P&(x^K))+0x84c87814|0;E=E+C|0;C=C+(U&R^S&(U^R))+(U>>>2^U>>>13^U>>>22^U<<30^U<<19^U<<10)|0;b=(_>>>7^_>>>18^_>>>3^_<<25^_<<14)+(m>>>17^m>>>19^m>>>10^m<<15^m<<13)+b+d|0;K=b+K+(E>>>6^E>>>11^E>>>25^E<<26^E<<21^E<<7)+(x^E&(P^x))+0x8cc70208|0;S=S+K|0;K=K+(C&U^R&(C^U))+(C>>>2^C>>>13^C>>>22^C<<30^C<<19^C<<10)|0;_=(v>>>7^v>>>18^v>>>3^v<<25^v<<14)+(w>>>17^w>>>19^w>>>10^w<<15^w<<13)+_+f|0;x=_+x+(S>>>6^S>>>11^S>>>25^S<<26^S<<21^S<<7)+(P^S&(E^P))+0x90befffa|0;R=R+x|0;x=x+(K&C^U&(K^C))+(K>>>2^K>>>13^K>>>22^K<<30^K<<19^K<<10)|0;v=(k>>>7^k>>>18^k>>>3^k<<25^k<<14)+(b>>>17^b>>>19^b>>>10^b<<15^b<<13)+v+y|0;P=v+P+(R>>>6^R>>>11^R>>>25^R<<26^R<<21^R<<7)+(E^R&(S^E))+0xa4506ceb|0;U=U+P|0;P=P+(x&K^C&(x^K))+(x>>>2^x>>>13^x>>>22^x<<30^x<<19^x<<10)|0;k=(A>>>7^A>>>18^A>>>3^A<<25^A<<14)+(_>>>17^_>>>19^_>>>10^_<<15^_<<13)+k+p|0;E=k+E+(U>>>6^U>>>11^U>>>25^U<<26^U<<21^U<<7)+(S^U&(R^S))+0xbef9a3f7|0;C=C+E|0;E=E+(P&x^K&(P^x))+(P>>>2^P>>>13^P>>>22^P<<30^P<<19^P<<10)|0;A=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(v>>>17^v>>>19^v>>>10^v<<15^v<<13)+A+g|0;S=A+S+(C>>>6^C>>>11^C>>>25^C<<26^C<<21^C<<7)+(R^C&(U^R))+0xc67178f2|0;K=K+S|0;S=S+(E&P^x&(E^P))+(E>>>2^E>>>13^E>>>22^E<<30^E<<19^E<<10)|0;n=n+S|0;i=i+E|0;a=a+P|0;s=s+x|0;o=o+K|0;c=c+C|0;u=u+U|0;l=l+R|0}function R(e){e=e|0;U(C[e|0]<<24|C[e|1]<<16|C[e|2]<<8|C[e|3],C[e|4]<<24|C[e|5]<<16|C[e|6]<<8|C[e|7],C[e|8]<<24|C[e|9]<<16|C[e|10]<<8|C[e|11],C[e|12]<<24|C[e|13]<<16|C[e|14]<<8|C[e|15],C[e|16]<<24|C[e|17]<<16|C[e|18]<<8|C[e|19],C[e|20]<<24|C[e|21]<<16|C[e|22]<<8|C[e|23],C[e|24]<<24|C[e|25]<<16|C[e|26]<<8|C[e|27],C[e|28]<<24|C[e|29]<<16|C[e|30]<<8|C[e|31],C[e|32]<<24|C[e|33]<<16|C[e|34]<<8|C[e|35],C[e|36]<<24|C[e|37]<<16|C[e|38]<<8|C[e|39],C[e|40]<<24|C[e|41]<<16|C[e|42]<<8|C[e|43],C[e|44]<<24|C[e|45]<<16|C[e|46]<<8|C[e|47],C[e|48]<<24|C[e|49]<<16|C[e|50]<<8|C[e|51],C[e|52]<<24|C[e|53]<<16|C[e|54]<<8|C[e|55],C[e|56]<<24|C[e|57]<<16|C[e|58]<<8|C[e|59],C[e|60]<<24|C[e|61]<<16|C[e|62]<<8|C[e|63])}function T(e){e=e|0;C[e|0]=n>>>24;C[e|1]=n>>>16&255;C[e|2]=n>>>8&255;C[e|3]=n&255;C[e|4]=i>>>24;C[e|5]=i>>>16&255;C[e|6]=i>>>8&255;C[e|7]=i&255;C[e|8]=a>>>24;C[e|9]=a>>>16&255;C[e|10]=a>>>8&255;C[e|11]=a&255;C[e|12]=s>>>24;C[e|13]=s>>>16&255;C[e|14]=s>>>8&255;C[e|15]=s&255;C[e|16]=o>>>24;C[e|17]=o>>>16&255;C[e|18]=o>>>8&255;C[e|19]=o&255;C[e|20]=c>>>24;C[e|21]=c>>>16&255;C[e|22]=c>>>8&255;C[e|23]=c&255;C[e|24]=u>>>24;C[e|25]=u>>>16&255;C[e|26]=u>>>8&255;C[e|27]=u&255;C[e|28]=l>>>24;C[e|29]=l>>>16&255;C[e|30]=l>>>8&255;C[e|31]=l&255}function D(){n=0x6a09e667;i=0xbb67ae85;a=0x3c6ef372;s=0xa54ff53a;o=0x510e527f;c=0x9b05688c;u=0x1f83d9ab;l=0x5be0cd19;h=d=0}function I(e,t,r,f,y,p,g,m,w,b){e=e|0;t=t|0;r=r|0;f=f|0;y=y|0;p=p|0;g=g|0;m=m|0;w=w|0;b=b|0;n=e;i=t;a=r;s=f;o=y;c=p;u=g;l=m;h=w;d=b}function B(e,t){e=e|0;t=t|0;var r=0;if(e&63)return-1;while((t|0)>=64){R(e);e=e+64|0;t=t-64|0;r=r+64|0}h=h+r|0;if(h>>>0<r>>>0)d=d+1|0;return r|0}function z(e,t,r){e=e|0;t=t|0;r=r|0;var n=0,i=0;if(e&63)return-1;if(~r)if(r&31)return-1;if((t|0)>=64){n=B(e,t)|0;if((n|0)==-1)return-1;e=e+n|0;t=t-n|0}n=n+t|0;h=h+t|0;if(h>>>0<t>>>0)d=d+1|0;C[e|t]=0x80;if((t|0)>=56){for(i=t+1|0;(i|0)<64;i=i+1|0)C[e|i]=0x00;R(e);t=0;C[e|0]=0}for(i=t+1|0;(i|0)<59;i=i+1|0)C[e|i]=0;C[e|56]=d>>>21&255;C[e|57]=d>>>13&255;C[e|58]=d>>>5&255;C[e|59]=d<<3&255|h>>>29;C[e|60]=h>>>21&255;C[e|61]=h>>>13&255;C[e|62]=h>>>5&255;C[e|63]=h<<3&255;R(e);if(~r)T(r);return n|0}function O(){n=f;i=y;a=p;s=g;o=m;c=w;u=b;l=_;h=64;d=0}function q(){n=v;i=k;a=A;s=S;o=E;c=P;u=x;l=K;h=64;d=0}function N(e,t,r,C,R,T,I,B,z,O,q,N,M,L,j,F){e=e|0;t=t|0;r=r|0;C=C|0;R=R|0;T=T|0;I=I|0;B=B|0;z=z|0;O=O|0;q=q|0;N=N|0;M=M|0;L=L|0;j=j|0;F=F|0;D();U(e^0x5c5c5c5c,t^0x5c5c5c5c,r^0x5c5c5c5c,C^0x5c5c5c5c,R^0x5c5c5c5c,T^0x5c5c5c5c,I^0x5c5c5c5c,B^0x5c5c5c5c,z^0x5c5c5c5c,O^0x5c5c5c5c,q^0x5c5c5c5c,N^0x5c5c5c5c,M^0x5c5c5c5c,L^0x5c5c5c5c,j^0x5c5c5c5c,F^0x5c5c5c5c);v=n;k=i;A=a;S=s;E=o;P=c;x=u;K=l;D();U(e^0x36363636,t^0x36363636,r^0x36363636,C^0x36363636,R^0x36363636,T^0x36363636,I^0x36363636,B^0x36363636,z^0x36363636,O^0x36363636,q^0x36363636,N^0x36363636,M^0x36363636,L^0x36363636,j^0x36363636,F^0x36363636);f=n;y=i;p=a;g=s;m=o;w=c;b=u;_=l;h=64;d=0}function M(e,t,r){e=e|0;t=t|0;r=r|0;var h=0,d=0,f=0,y=0,p=0,g=0,m=0,w=0,b=0;if(e&63)return-1;if(~r)if(r&31)return-1;b=z(e,t,-1)|0;h=n,d=i,f=a,y=s,p=o,g=c,m=u,w=l;q();U(h,d,f,y,p,g,m,w,0x80000000,0,0,0,0,0,0,768);if(~r)T(r);return b|0}function L(e,t,r,h,d){e=e|0;t=t|0;r=r|0;h=h|0;d=d|0;var f=0,y=0,p=0,g=0,m=0,w=0,b=0,_=0,v=0,k=0,A=0,S=0,E=0,P=0,x=0,K=0;if(e&63)return-1;if(~d)if(d&31)return-1;C[e+t|0]=r>>>24;C[e+t+1|0]=r>>>16&255;C[e+t+2|0]=r>>>8&255;C[e+t+3|0]=r&255;M(e,t+4|0,-1)|0;f=v=n,y=k=i,p=A=a,g=S=s,m=E=o,w=P=c,b=x=u,_=K=l;h=h-1|0;while((h|0)>0){O();U(v,k,A,S,E,P,x,K,0x80000000,0,0,0,0,0,0,768);v=n,k=i,A=a,S=s,E=o,P=c,x=u,K=l;q();U(v,k,A,S,E,P,x,K,0x80000000,0,0,0,0,0,0,768);v=n,k=i,A=a,S=s,E=o,P=c,x=u,K=l;f=f^n;y=y^i;p=p^a;g=g^s;m=m^o;w=w^c;b=b^u;_=_^l;h=h-1|0}n=f;i=y;a=p;s=g;o=m;c=w;u=b;l=_;if(~d)T(d);return 0}return{reset:D,init:I,process:B,finish:z,hmac_reset:O,hmac_init:N,hmac_finish:M,pbkdf2_generate_block:L}}({Uint8Array},null,this.heap.buffer),this.reset()),{heap:this.heap,asm:this.asm}}release_asm(){void 0!==this.heap&&void 0!==this.asm&&(Yn.push(this.heap),Zn.push(this.asm)),this.heap=void 0,this.asm=void 0}static bytes(e){return(new Qn).process(e).finish().result}}Qn.NAME="sha256";var Xn=Jn;function Jn(e,t){if(!e)throw Error(t||"Assertion failed")}Jn.equal=function(e,t,r){if(e!=t)throw Error(r||"Assertion failed: "+e+" != "+t)};var ei=void 0!==e?e:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ti(e,t){return e(t={exports:{}},t.exports),t.exports}var ri=ti((function(e){e.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}));function ni(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function ii(e){return 1===e.length?"0"+e:e}function ai(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}var si={inherits:ri,toArray:function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n<e.length;n+=2)r.push(parseInt(e[n]+e[n+1],16))}else for(var n=0;n<e.length;n++){var i=e.charCodeAt(n),a=i>>8,s=255&i;a?r.push(a,s):r.push(s)}else for(n=0;n<e.length;n++)r[n]=0|e[n];return r},toHex:function(e){for(var t="",r=0;r<e.length;r++)t+=ii(e[r].toString(16));return t},htonl:ni,toHex32:function(e,t){for(var r="",n=0;n<e.length;n++){var i=e[n];"little"===t&&(i=ni(i)),r+=ai(i.toString(16))}return r},zero2:ii,zero8:ai,join32:function(e,t,r,n){var i=r-t;Xn(i%4==0);for(var a=Array(i/4),s=0,o=t;s<a.length;s++,o+=4){var c;c="big"===n?e[o]<<24|e[o+1]<<16|e[o+2]<<8|e[o+3]:e[o+3]<<24|e[o+2]<<16|e[o+1]<<8|e[o],a[s]=c>>>0}return a},split32:function(e,t){for(var r=Array(4*e.length),n=0,i=0;n<e.length;n++,i+=4){var a=e[n];"big"===t?(r[i]=a>>>24,r[i+1]=a>>>16&255,r[i+2]=a>>>8&255,r[i+3]=255&a):(r[i+3]=a>>>24,r[i+2]=a>>>16&255,r[i+1]=a>>>8&255,r[i]=255&a)}return r},rotr32:function(e,t){return e>>>t|e<<32-t},rotl32:function(e,t){return e<<t|e>>>32-t},sum32:function(e,t){return e+t>>>0},sum32_3:function(e,t,r){return e+t+r>>>0},sum32_4:function(e,t,r,n){return e+t+r+n>>>0},sum32_5:function(e,t,r,n,i){return e+t+r+n+i>>>0},sum64:function(e,t,r,n){var i=e[t],a=n+e[t+1]>>>0,s=(a<n?1:0)+r+i;e[t]=s>>>0,e[t+1]=a},sum64_hi:function(e,t,r,n){return(t+n>>>0<t?1:0)+e+r>>>0},sum64_lo:function(e,t,r,n){return t+n>>>0},sum64_4_hi:function(e,t,r,n,i,a,s,o){var c=0,u=t;return c+=(u=u+n>>>0)<t?1:0,c+=(u=u+a>>>0)<a?1:0,e+r+i+s+(c+=(u=u+o>>>0)<o?1:0)>>>0},sum64_4_lo:function(e,t,r,n,i,a,s,o){return t+n+a+o>>>0},sum64_5_hi:function(e,t,r,n,i,a,s,o,c,u){var l=0,h=t;return l+=(h=h+n>>>0)<t?1:0,l+=(h=h+a>>>0)<a?1:0,l+=(h=h+o>>>0)<o?1:0,e+r+i+s+c+(l+=(h=h+u>>>0)<u?1:0)>>>0},sum64_5_lo:function(e,t,r,n,i,a,s,o,c,u){return t+n+a+o+u>>>0},rotr64_hi:function(e,t,r){return(t<<32-r|e>>>r)>>>0},rotr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0},shr64_hi:function(e,t,r){return e>>>r},shr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0}};function oi(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var ci=oi;oi.prototype.update=function(e,t){if(e=si.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=si.join32(e,0,e.length-r,this.endian);for(var n=0;n<e.length;n+=this._delta32)this._update(e,n,n+this._delta32)}return this},oi.prototype.digest=function(e){return this.update(this._pad()),Xn(null===this.pending),this._digest(e)},oi.prototype._pad=function(){var e=this.pendingTotal,t=this._delta8,r=t-(e+this.padLength)%t,n=Array(r+this.padLength);n[0]=128;for(var i=1;i<r;i++)n[i]=0;if(e<<=3,"big"===this.endian){for(var a=8;a<this.padLength;a++)n[i++]=0;n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=e>>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,a=8;a<this.padLength;a++)n[i++]=0;return n};var ui={BlockHash:ci},li=si.rotr32;function hi(e,t,r){return e&t^~e&r}function di(e,t,r){return e&t^e&r^t&r}function fi(e,t,r){return e^t^r}var yi={ft_1:function(e,t,r,n){return 0===e?hi(t,r,n):1===e||3===e?fi(t,r,n):2===e?di(t,r,n):void 0},ch32:hi,maj32:di,p32:fi,s0_256:function(e){return li(e,2)^li(e,13)^li(e,22)},s1_256:function(e){return li(e,6)^li(e,11)^li(e,25)},g0_256:function(e){return li(e,7)^li(e,18)^e>>>3},g1_256:function(e){return li(e,17)^li(e,19)^e>>>10}},pi=si.sum32,gi=si.sum32_4,mi=si.sum32_5,wi=yi.ch32,bi=yi.maj32,_i=yi.s0_256,vi=yi.s1_256,ki=yi.g0_256,Ai=yi.g1_256,Si=ui.BlockHash,Ei=[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];function Pi(){if(!(this instanceof Pi))return new Pi;Si.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Ei,this.W=Array(64)}si.inherits(Pi,Si);var xi=Pi;function Ki(){if(!(this instanceof Ki))return new Ki;xi.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Pi.blockSize=512,Pi.outSize=256,Pi.hmacStrength=192,Pi.padLength=64,Pi.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;n<r.length;n++)r[n]=gi(Ai(r[n-2]),r[n-7],ki(r[n-15]),r[n-16]);var i=this.h[0],a=this.h[1],s=this.h[2],o=this.h[3],c=this.h[4],u=this.h[5],l=this.h[6],h=this.h[7];for(Xn(this.k.length===r.length),n=0;n<r.length;n++){var d=mi(h,vi(c),wi(c,u,l),this.k[n],r[n]),f=pi(_i(i),bi(i,a,s));h=l,l=u,u=c,c=pi(o,d),o=s,s=a,a=i,i=pi(d,f)}this.h[0]=pi(this.h[0],i),this.h[1]=pi(this.h[1],a),this.h[2]=pi(this.h[2],s),this.h[3]=pi(this.h[3],o),this.h[4]=pi(this.h[4],c),this.h[5]=pi(this.h[5],u),this.h[6]=pi(this.h[6],l),this.h[7]=pi(this.h[7],h)},Pi.prototype._digest=function(e){return"hex"===e?si.toHex32(this.h,"big"):si.split32(this.h,"big")},si.inherits(Ki,xi);var Ci=Ki;Ki.blockSize=512,Ki.outSize=224,Ki.hmacStrength=192,Ki.padLength=64,Ki.prototype._digest=function(e){return"hex"===e?si.toHex32(this.h.slice(0,7),"big"):si.split32(this.h.slice(0,7),"big")};var Ui=si.rotr64_hi,Ri=si.rotr64_lo,Ti=si.shr64_hi,Di=si.shr64_lo,Ii=si.sum64,Bi=si.sum64_hi,zi=si.sum64_lo,Oi=si.sum64_4_hi,qi=si.sum64_4_lo,Ni=si.sum64_5_hi,Mi=si.sum64_5_lo,Li=ui.BlockHash,ji=[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];function Fi(){if(!(this instanceof Fi))return new Fi;Li.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=ji,this.W=Array(160)}si.inherits(Fi,Li);var Hi=Fi;function Wi(e,t,r,n,i){var a=e&r^~e&i;return a<0&&(a+=4294967296),a}function Gi(e,t,r,n,i,a){var s=t&n^~t&a;return s<0&&(s+=4294967296),s}function Vi(e,t,r,n,i){var a=e&r^e&i^r&i;return a<0&&(a+=4294967296),a}function $i(e,t,r,n,i,a){var s=t&n^t&a^n&a;return s<0&&(s+=4294967296),s}function Yi(e,t){var r=Ui(e,t,28)^Ui(t,e,2)^Ui(t,e,7);return r<0&&(r+=4294967296),r}function Zi(e,t){var r=Ri(e,t,28)^Ri(t,e,2)^Ri(t,e,7);return r<0&&(r+=4294967296),r}function Qi(e,t){var r=Ui(e,t,14)^Ui(e,t,18)^Ui(t,e,9);return r<0&&(r+=4294967296),r}function Xi(e,t){var r=Ri(e,t,14)^Ri(e,t,18)^Ri(t,e,9);return r<0&&(r+=4294967296),r}function Ji(e,t){var r=Ui(e,t,1)^Ui(e,t,8)^Ti(e,t,7);return r<0&&(r+=4294967296),r}function ea(e,t){var r=Ri(e,t,1)^Ri(e,t,8)^Di(e,t,7);return r<0&&(r+=4294967296),r}function ta(e,t){var r=Ui(e,t,19)^Ui(t,e,29)^Ti(e,t,6);return r<0&&(r+=4294967296),r}function ra(e,t){var r=Ri(e,t,19)^Ri(t,e,29)^Di(e,t,6);return r<0&&(r+=4294967296),r}function na(){if(!(this instanceof na))return new na;Hi.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Fi.blockSize=1024,Fi.outSize=512,Fi.hmacStrength=192,Fi.padLength=128,Fi.prototype._prepareBlock=function(e,t){for(var r=this.W,n=0;n<32;n++)r[n]=e[t+n];for(;n<r.length;n+=2){var i=ta(r[n-4],r[n-3]),a=ra(r[n-4],r[n-3]),s=r[n-14],o=r[n-13],c=Ji(r[n-30],r[n-29]),u=ea(r[n-30],r[n-29]),l=r[n-32],h=r[n-31];r[n]=Oi(i,a,s,o,c,u,l,h),r[n+1]=qi(i,a,s,o,c,u,l,h)}},Fi.prototype._update=function(e,t){this._prepareBlock(e,t);var r=this.W,n=this.h[0],i=this.h[1],a=this.h[2],s=this.h[3],o=this.h[4],c=this.h[5],u=this.h[6],l=this.h[7],h=this.h[8],d=this.h[9],f=this.h[10],y=this.h[11],p=this.h[12],g=this.h[13],m=this.h[14],w=this.h[15];Xn(this.k.length===r.length);for(var b=0;b<r.length;b+=2){var _=m,v=w,k=Qi(h,d),A=Xi(h,d),S=Wi(h,d,f,y,p),E=Gi(h,d,f,y,p,g),P=this.k[b],x=this.k[b+1],K=r[b],C=r[b+1],U=Ni(_,v,k,A,S,E,P,x,K,C),R=Mi(_,v,k,A,S,E,P,x,K,C);_=Yi(n,i),v=Zi(n,i),k=Vi(n,i,a,s,o),A=$i(n,i,a,s,o,c);var T=Bi(_,v,k,A),D=zi(_,v,k,A);m=p,w=g,p=f,g=y,f=h,y=d,h=Bi(u,l,U,R),d=zi(l,l,U,R),u=o,l=c,o=a,c=s,a=n,s=i,n=Bi(U,R,T,D),i=zi(U,R,T,D)}Ii(this.h,0,n,i),Ii(this.h,2,a,s),Ii(this.h,4,o,c),Ii(this.h,6,u,l),Ii(this.h,8,h,d),Ii(this.h,10,f,y),Ii(this.h,12,p,g),Ii(this.h,14,m,w)},Fi.prototype._digest=function(e){return"hex"===e?si.toHex32(this.h,"big"):si.split32(this.h,"big")},si.inherits(na,Hi);var ia=na;na.blockSize=1024,na.outSize=384,na.hmacStrength=192,na.padLength=128,na.prototype._digest=function(e){return"hex"===e?si.toHex32(this.h.slice(0,12),"big"):si.split32(this.h.slice(0,12),"big")};var aa=si.rotl32,sa=si.sum32,oa=si.sum32_3,ca=si.sum32_4,ua=ui.BlockHash;function la(){if(!(this instanceof la))return new la;ua.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}si.inherits(la,ua);var ha=la;function da(e,t,r,n){return e<=15?t^r^n:e<=31?t&r|~t&n:e<=47?(t|~r)^n:e<=63?t&n|r&~n:t^(r|~n)}function fa(e){return e<=15?0:e<=31?1518500249:e<=47?1859775393:e<=63?2400959708:2840853838}function ya(e){return e<=15?1352829926:e<=31?1548603684:e<=47?1836072691:e<=63?2053994217:0}la.blockSize=512,la.outSize=160,la.hmacStrength=192,la.padLength=64,la.prototype._update=function(e,t){for(var r=this.h[0],n=this.h[1],i=this.h[2],a=this.h[3],s=this.h[4],o=r,c=n,u=i,l=a,h=s,d=0;d<80;d++){var f=sa(aa(ca(r,da(d,n,i,a),e[pa[d]+t],fa(d)),ma[d]),s);r=s,s=a,a=aa(i,10),i=n,n=f,f=sa(aa(ca(o,da(79-d,c,u,l),e[ga[d]+t],ya(d)),wa[d]),h),o=h,h=l,l=aa(u,10),u=c,c=f}f=oa(this.h[1],i,l),this.h[1]=oa(this.h[2],a,h),this.h[2]=oa(this.h[3],s,o),this.h[3]=oa(this.h[4],r,c),this.h[4]=oa(this.h[0],n,u),this.h[0]=f},la.prototype._digest=function(e){return"hex"===e?si.toHex32(this.h,"little"):si.split32(this.h,"little")};var pa=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],ga=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],ma=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],wa=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],ba={ripemd160:ha};function _a(e,t){let r=e[0],n=e[1],i=e[2],a=e[3];r=ka(r,n,i,a,t[0],7,-680876936),a=ka(a,r,n,i,t[1],12,-389564586),i=ka(i,a,r,n,t[2],17,606105819),n=ka(n,i,a,r,t[3],22,-1044525330),r=ka(r,n,i,a,t[4],7,-176418897),a=ka(a,r,n,i,t[5],12,1200080426),i=ka(i,a,r,n,t[6],17,-1473231341),n=ka(n,i,a,r,t[7],22,-45705983),r=ka(r,n,i,a,t[8],7,1770035416),a=ka(a,r,n,i,t[9],12,-1958414417),i=ka(i,a,r,n,t[10],17,-42063),n=ka(n,i,a,r,t[11],22,-1990404162),r=ka(r,n,i,a,t[12],7,1804603682),a=ka(a,r,n,i,t[13],12,-40341101),i=ka(i,a,r,n,t[14],17,-1502002290),n=ka(n,i,a,r,t[15],22,1236535329),r=Aa(r,n,i,a,t[1],5,-165796510),a=Aa(a,r,n,i,t[6],9,-1069501632),i=Aa(i,a,r,n,t[11],14,643717713),n=Aa(n,i,a,r,t[0],20,-373897302),r=Aa(r,n,i,a,t[5],5,-701558691),a=Aa(a,r,n,i,t[10],9,38016083),i=Aa(i,a,r,n,t[15],14,-660478335),n=Aa(n,i,a,r,t[4],20,-405537848),r=Aa(r,n,i,a,t[9],5,568446438),a=Aa(a,r,n,i,t[14],9,-1019803690),i=Aa(i,a,r,n,t[3],14,-187363961),n=Aa(n,i,a,r,t[8],20,1163531501),r=Aa(r,n,i,a,t[13],5,-1444681467),a=Aa(a,r,n,i,t[2],9,-51403784),i=Aa(i,a,r,n,t[7],14,1735328473),n=Aa(n,i,a,r,t[12],20,-1926607734),r=Sa(r,n,i,a,t[5],4,-378558),a=Sa(a,r,n,i,t[8],11,-2022574463),i=Sa(i,a,r,n,t[11],16,1839030562),n=Sa(n,i,a,r,t[14],23,-35309556),r=Sa(r,n,i,a,t[1],4,-1530992060),a=Sa(a,r,n,i,t[4],11,1272893353),i=Sa(i,a,r,n,t[7],16,-155497632),n=Sa(n,i,a,r,t[10],23,-1094730640),r=Sa(r,n,i,a,t[13],4,681279174),a=Sa(a,r,n,i,t[0],11,-358537222),i=Sa(i,a,r,n,t[3],16,-722521979),n=Sa(n,i,a,r,t[6],23,76029189),r=Sa(r,n,i,a,t[9],4,-640364487),a=Sa(a,r,n,i,t[12],11,-421815835),i=Sa(i,a,r,n,t[15],16,530742520),n=Sa(n,i,a,r,t[2],23,-995338651),r=Ea(r,n,i,a,t[0],6,-198630844),a=Ea(a,r,n,i,t[7],10,1126891415),i=Ea(i,a,r,n,t[14],15,-1416354905),n=Ea(n,i,a,r,t[5],21,-57434055),r=Ea(r,n,i,a,t[12],6,1700485571),a=Ea(a,r,n,i,t[3],10,-1894986606),i=Ea(i,a,r,n,t[10],15,-1051523),n=Ea(n,i,a,r,t[1],21,-2054922799),r=Ea(r,n,i,a,t[8],6,1873313359),a=Ea(a,r,n,i,t[15],10,-30611744),i=Ea(i,a,r,n,t[6],15,-1560198380),n=Ea(n,i,a,r,t[13],21,1309151649),r=Ea(r,n,i,a,t[4],6,-145523070),a=Ea(a,r,n,i,t[11],10,-1120210379),i=Ea(i,a,r,n,t[2],15,718787259),n=Ea(n,i,a,r,t[9],21,-343485551),e[0]=Ca(r,e[0]),e[1]=Ca(n,e[1]),e[2]=Ca(i,e[2]),e[3]=Ca(a,e[3])}function va(e,t,r,n,i,a){return t=Ca(Ca(t,e),Ca(n,a)),Ca(t<<i|t>>>32-i,r)}function ka(e,t,r,n,i,a,s){return va(t&r|~t&n,e,t,i,a,s)}function Aa(e,t,r,n,i,a,s){return va(t&n|r&~n,e,t,i,a,s)}function Sa(e,t,r,n,i,a,s){return va(t^r^n,e,t,i,a,s)}function Ea(e,t,r,n,i,a,s){return va(r^(t|~n),e,t,i,a,s)}function Pa(e){const t=[];let r;for(r=0;r<64;r+=4)t[r>>2]=e.charCodeAt(r)+(e.charCodeAt(r+1)<<8)+(e.charCodeAt(r+2)<<16)+(e.charCodeAt(r+3)<<24);return t}const xa="0123456789abcdef".split("");function Ka(e){let t="",r=0;for(;r<4;r++)t+=xa[e>>8*r+4&15]+xa[e>>8*r&15];return t}function Ca(e,t){return e+t&4294967295}const Ua=Gr.getWebCrypto(),Ra=Gr.getNodeCrypto(),Ta=Gr.getNodeBuffer();function Da(e){return async function(t){const r=Ra.createHash(e);return Fr.transform(t,e=>{r.update(Ta.from(e))},()=>new Uint8Array(r.digest()))}}function Ia(e,t){return async function(r,n=rn){if(!Gr.isStream(r)&&Ua&&t&&r.length>=n.minBytesForWebCrypto)return new Uint8Array(await Ua.digest(t,r));const i=e();return Fr.transform(r,e=>{i.update(e)},()=>new Uint8Array(i.digest()))}}function Ba(e,t){return async function(r,n=rn){if(Gr.isStream(r)){const t=new e;return Fr.transform(r,e=>{t.process(e)},()=>t.finish().result)}return Ua&&t&&r.length>=n.minBytesForWebCrypto?new Uint8Array(await Ua.digest(t,r)):e.bytes(r)}}let za;za=Ra?{md5:Da("md5"),sha1:Da("sha1"),sha224:Da("sha224"),sha256:Da("sha256"),sha384:Da("sha384"),sha512:Da("sha512"),ripemd:Da("ripemd160")}:{md5:async function(e){const t=function(e){const t=e.length,r=[1732584193,-271733879,-1732584194,271733878];let n;for(n=64;n<=e.length;n+=64)_a(r,Pa(e.substring(n-64,n)));e=e.substring(n-64);const i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(n=0;n<e.length;n++)i[n>>2]|=e.charCodeAt(n)<<(n%4<<3);if(i[n>>2]|=128<<(n%4<<3),n>55)for(_a(r,i),n=0;n<16;n++)i[n]=0;return i[14]=8*t,_a(r,i),r}(Gr.uint8ArrayToStr(e));return Gr.hexToUint8Array(function(e){for(let t=0;t<e.length;t++)e[t]=Ka(e[t]);return e.join("")}(t))},sha1:Ba($n,-1===navigator.userAgent.indexOf("Edge")&&"SHA-1"),sha224:Ia(Ci),sha256:Ba(Qn,"SHA-256"),sha384:Ia(ia,"SHA-384"),sha512:Ia(Hi,"SHA-512"),ripemd:Ia(ha)};var Oa={md5:za.md5,sha1:za.sha1,sha224:za.sha224,sha256:za.sha256,sha384:za.sha384,sha512:za.sha512,ripemd:za.ripemd,digest:function(e,t){switch(e){case 1:return this.md5(t);case 2:return this.sha1(t);case 3:return this.ripemd(t);case 8:return this.sha256(t);case 9:return this.sha384(t);case 10:return this.sha512(t);case 11:return this.sha224(t);default:throw Error("Invalid hash function.")}},getHashByteLength:function(e){switch(e){case 1:return 16;case 2:case 3:return 20;case 8:return 32;case 9:return 48;case 10:return 64;case 11:return 28;default:throw Error("Invalid hash algorithm.")}}};class qa{static encrypt(e,t,r){return new qa(t,r).encrypt(e)}static decrypt(e,t,r){return new qa(t,r).decrypt(e)}constructor(e,t,r){this.aes=r||new Sn(e,t,!0,"CFB"),delete this.aes.padding}encrypt(e){return wn(this.aes.AES_Encrypt_process(e),this.aes.AES_Encrypt_finish())}decrypt(e){return wn(this.aes.AES_Decrypt_process(e),this.aes.AES_Decrypt_finish())}}const Na=Gr.getWebCrypto(),Ma=Gr.getNodeCrypto(),La=Gr.getNodeBuffer(),ja=Ma?Ma.getCiphers():[],Fa={idea:ja.includes("idea-cfb")?"idea-cfb":void 0,tripledes:ja.includes("des-ede3-cfb")?"des-ede3-cfb":void 0,cast5:ja.includes("cast5-cfb")?"cast5-cfb":void 0,blowfish:ja.includes("bf-cfb")?"bf-cfb":void 0,aes128:ja.includes("aes-128-cfb")?"aes-128-cfb":void 0,aes192:ja.includes("aes-192-cfb")?"aes-192-cfb":void 0,aes256:ja.includes("aes-256-cfb")?"aes-256-cfb":void 0};var Ha=/*#__PURE__*/Object.freeze({__proto__:null,encrypt:async function(e,t,r,n,i){if(Gr.getNodeCrypto()&&Fa[e])return function(e,t,r,n){t=La.from(t),n=La.from(n);const i=new Ma.createCipheriv(Fa[e],t,n);return Fr.transform(r,e=>new Uint8Array(i.update(La.from(e))))}(e,t,r,n);if("aes"===e.substr(0,3))return function(e,t,r,n,i){if(Gr.getWebCrypto()&&24!==t.length&&!Gr.isStream(r)&&r.length>=3e3*i.minBytesForWebCrypto)return async function(e,t,r,n){const i=await Na.importKey("raw",t,{name:"AES-CBC"},!1,["encrypt"]),{blockSize:a}=Fn[e],s=Gr.concatUint8Array([new Uint8Array(a),r]),o=new Uint8Array(await Na.encrypt({name:"AES-CBC",iv:n},i,s)).subarray(0,r.length);return function(e,t){for(let r=0;r<e.length;r++)e[r]=e[r]^t[r]}(o,r),o}(e,t,r,n);const a=new qa(t,n);return Fr.transform(r,e=>a.aes.AES_Encrypt_process(e),()=>a.aes.AES_Encrypt_finish())}(e,t,r,n,i);const a=new Fn[e](t),s=a.blockSize,o=n.slice();let c=new Uint8Array;const u=e=>{e&&(c=Gr.concatUint8Array([c,e]));const t=new Uint8Array(c.length);let r,n=0;for(;e?c.length>=s:c.length;){const e=a.encrypt(o);for(r=0;r<s;r++)o[r]=c[r]^e[r],t[n++]=o[r];c=c.subarray(s)}return t.subarray(0,n)};return Fr.transform(r,u,u)},decrypt:async function(e,t,r,n){if(Gr.getNodeCrypto()&&Fa[e])return function(e,t,r,n){t=La.from(t),n=La.from(n);const i=new Ma.createDecipheriv(Fa[e],t,n);return Fr.transform(r,e=>new Uint8Array(i.update(La.from(e))))}(e,t,r,n);if("aes"===e.substr(0,3))return function(e,t,r,n){if(Gr.isStream(r)){const e=new qa(t,n);return Fr.transform(r,t=>e.aes.AES_Decrypt_process(t),()=>e.aes.AES_Decrypt_finish())}return qa.decrypt(r,t,n)}(0,t,r,n);const i=new Fn[e](t),a=i.blockSize;let s=n,o=new Uint8Array;const c=e=>{e&&(o=Gr.concatUint8Array([o,e]));const t=new Uint8Array(o.length);let r,n=0;for(;e?o.length>=a:o.length;){const e=i.encrypt(s);for(s=o,r=0;r<a;r++)t[n++]=s[r]^e[r];o=o.subarray(a)}return t.subarray(0,n)};return Fr.transform(r,c,c)}});class Wa{constructor(e,t,r,n=16,i){this.tagSize=n,this.gamma0=0,this.counter=1,this.aes=i||new Sn(e,void 0,!1,"CTR");let{asm:a,heap:s}=this.aes.acquire_asm();if(a.gcm_init(),this.tagSize<4||this.tagSize>16)throw new _n("illegal tagSize value");const o=t.length||0,c=new Uint8Array(16);12!==o?(this._gcm_mac_process(t),s[0]=0,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=0,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=0,s[11]=o>>>29,s[12]=o>>>21&255,s[13]=o>>>13&255,s[14]=o>>>5&255,s[15]=o<<3&255,a.mac(yn.MAC.GCM,yn.HEAP_DATA,16),a.get_iv(yn.HEAP_DATA),a.set_iv(0,0,0,0),c.set(s.subarray(0,16))):(c.set(t),c[15]=1);const u=new DataView(c.buffer);if(this.gamma0=u.getUint32(12),a.set_nonce(u.getUint32(0),u.getUint32(4),u.getUint32(8),0),a.set_mask(0,0,0,4294967295),void 0!==r){if(r.length>68719476704)throw new _n("illegal adata length");r.length?(this.adata=r,this._gcm_mac_process(r)):this.adata=void 0}else this.adata=void 0;if(this.counter<1||this.counter>4294967295)throw new RangeError("counter must be a positive 32-bit integer");a.set_counter(0,0,0,this.gamma0+this.counter|0)}static encrypt(e,t,r,n,i){return new Wa(t,r,n,i).encrypt(e)}static decrypt(e,t,r,n,i){return new Wa(t,r,n,i).decrypt(e)}encrypt(e){return this.AES_GCM_encrypt(e)}decrypt(e){return this.AES_GCM_decrypt(e)}AES_GCM_Encrypt_process(e){let t=0,r=e.length||0,{asm:n,heap:i}=this.aes.acquire_asm(),a=this.counter,s=this.aes.pos,o=this.aes.len,c=0,u=o+r&-16,l=0;if((a-1<<4)+o+r>68719476704)throw new RangeError("counter overflow");const h=new Uint8Array(u);for(;r>0;)l=mn(i,s+o,e,t,r),o+=l,t+=l,r-=l,l=n.cipher(yn.ENC.CTR,yn.HEAP_DATA+s,o),l=n.mac(yn.MAC.GCM,yn.HEAP_DATA+s,l),l&&h.set(i.subarray(s,s+l),c),a+=l>>>4,c+=l,l<o?(s+=l,o-=l):(s=0,o=0);return this.counter=a,this.aes.pos=s,this.aes.len=o,h}AES_GCM_Encrypt_finish(){let{asm:e,heap:t}=this.aes.acquire_asm(),r=this.counter,n=this.tagSize,i=this.adata,a=this.aes.pos,s=this.aes.len;const o=new Uint8Array(s+n);e.cipher(yn.ENC.CTR,yn.HEAP_DATA+a,s+15&-16),s&&o.set(t.subarray(a,a+s));let c=s;for(;15&c;c++)t[a+c]=0;e.mac(yn.MAC.GCM,yn.HEAP_DATA+a,c);const u=void 0!==i?i.length:0,l=(r-1<<4)+s;return t[0]=0,t[1]=0,t[2]=0,t[3]=u>>>29,t[4]=u>>>21,t[5]=u>>>13&255,t[6]=u>>>5&255,t[7]=u<<3&255,t[8]=t[9]=t[10]=0,t[11]=l>>>29,t[12]=l>>>21&255,t[13]=l>>>13&255,t[14]=l>>>5&255,t[15]=l<<3&255,e.mac(yn.MAC.GCM,yn.HEAP_DATA,16),e.get_iv(yn.HEAP_DATA),e.set_counter(0,0,0,this.gamma0),e.cipher(yn.ENC.CTR,yn.HEAP_DATA,16),o.set(t.subarray(0,n),s),this.counter=1,this.aes.pos=0,this.aes.len=0,o}AES_GCM_Decrypt_process(e){let t=0,r=e.length||0,{asm:n,heap:i}=this.aes.acquire_asm(),a=this.counter,s=this.tagSize,o=this.aes.pos,c=this.aes.len,u=0,l=c+r>s?c+r-s&-16:0,h=c+r-l,d=0;if((a-1<<4)+c+r>68719476704)throw new RangeError("counter overflow");const f=new Uint8Array(l);for(;r>h;)d=mn(i,o+c,e,t,r-h),c+=d,t+=d,r-=d,d=n.mac(yn.MAC.GCM,yn.HEAP_DATA+o,d),d=n.cipher(yn.DEC.CTR,yn.HEAP_DATA+o,d),d&&f.set(i.subarray(o,o+d),u),a+=d>>>4,u+=d,o=0,c=0;return r>0&&(c+=mn(i,0,e,t,r)),this.counter=a,this.aes.pos=o,this.aes.len=c,f}AES_GCM_Decrypt_finish(){let{asm:e,heap:t}=this.aes.acquire_asm(),r=this.tagSize,n=this.adata,i=this.counter,a=this.aes.pos,s=this.aes.len,o=s-r;if(s<r)throw new bn("authentication tag not found");const c=new Uint8Array(o),u=new Uint8Array(t.subarray(a+o,a+s));let l=o;for(;15&l;l++)t[a+l]=0;e.mac(yn.MAC.GCM,yn.HEAP_DATA+a,l),e.cipher(yn.DEC.CTR,yn.HEAP_DATA+a,l),o&&c.set(t.subarray(a,a+o));const h=void 0!==n?n.length:0,d=(i-1<<4)+s-r;t[0]=0,t[1]=0,t[2]=0,t[3]=h>>>29,t[4]=h>>>21,t[5]=h>>>13&255,t[6]=h>>>5&255,t[7]=h<<3&255,t[8]=t[9]=t[10]=0,t[11]=d>>>29,t[12]=d>>>21&255,t[13]=d>>>13&255,t[14]=d>>>5&255,t[15]=d<<3&255,e.mac(yn.MAC.GCM,yn.HEAP_DATA,16),e.get_iv(yn.HEAP_DATA),e.set_counter(0,0,0,this.gamma0),e.cipher(yn.ENC.CTR,yn.HEAP_DATA,16);let f=0;for(let e=0;e<r;++e)f|=u[e]^t[e];if(f)throw new vn("data integrity check failed");return this.counter=1,this.aes.pos=0,this.aes.len=0,c}AES_GCM_decrypt(e){const t=this.AES_GCM_Decrypt_process(e),r=this.AES_GCM_Decrypt_finish(),n=new Uint8Array(t.length+r.length);return t.length&&n.set(t),r.length&&n.set(r,t.length),n}AES_GCM_encrypt(e){const t=this.AES_GCM_Encrypt_process(e),r=this.AES_GCM_Encrypt_finish(),n=new Uint8Array(t.length+r.length);return t.length&&n.set(t),r.length&&n.set(r,t.length),n}_gcm_mac_process(e){let{asm:t,heap:r}=this.aes.acquire_asm(),n=0,i=e.length||0,a=0;for(;i>0;){for(a=mn(r,0,e,n,i),n+=a,i-=a;15&a;)r[a++]=0;t.mac(yn.MAC.GCM,yn.HEAP_DATA,a)}}}const Ga=Gr.getWebCrypto(),Va=Gr.getNodeCrypto(),$a=Gr.getNodeBuffer();async function Ya(e,t){if("aes"!==e.substr(0,3))throw Error("GCM mode supports only AES cipher");if(Gr.getWebCrypto()&&24!==t.length){const e=await Ga.importKey("raw",t,{name:"AES-GCM"},!1,["encrypt","decrypt"]);return{encrypt:async function(r,n,i=new Uint8Array){if(!r.length||!i.length&&-1!==navigator.userAgent.indexOf("Edge"))return Wa.encrypt(r,t,n,i);const a=await Ga.encrypt({name:"AES-GCM",iv:n,additionalData:i,tagLength:128},e,r);return new Uint8Array(a)},decrypt:async function(r,n,i=new Uint8Array){if(16===r.length||!i.length&&-1!==navigator.userAgent.indexOf("Edge"))return Wa.decrypt(r,t,n,i);const a=await Ga.decrypt({name:"AES-GCM",iv:n,additionalData:i,tagLength:128},e,r);return new Uint8Array(a)}}}return Gr.getNodeCrypto()?(t=$a.from(t),{encrypt:async function(e,r,n=new Uint8Array){e=$a.from(e),r=$a.from(r),n=$a.from(n);const i=new Va.createCipheriv("aes-"+8*t.length+"-gcm",t,r);i.setAAD(n);const a=$a.concat([i.update(e),i.final(),i.getAuthTag()]);return new Uint8Array(a)},decrypt:async function(e,r,n=new Uint8Array){e=$a.from(e),r=$a.from(r),n=$a.from(n);const i=new Va.createDecipheriv("aes-"+8*t.length+"-gcm",t,r);i.setAAD(n),i.setAuthTag(e.slice(e.length-16,e.length));const a=$a.concat([i.update(e.slice(0,e.length-16)),i.final()]);return new Uint8Array(a)}}):{encrypt:async function(e,r,n){return Wa.encrypt(e,t,r,n)},decrypt:async function(e,r,n){return Wa.decrypt(e,t,r,n)}}}Ya.getNonce=function(e,t){const r=e.slice();for(let e=0;e<t.length;e++)r[4+e]^=t[e];return r},Ya.blockLength=16,Ya.ivLength=12,Ya.tagLength=16;class Za{static encrypt(e,t,r){return new Za(t,r).encrypt(e)}static decrypt(e,t,r){return new Za(t,r).encrypt(e)}constructor(e,t,r){this.aes=r||new Sn(e,void 0,!1,"CTR"),delete this.aes.padding,this.AES_CTR_set_options(t)}encrypt(e){return wn(this.aes.AES_Encrypt_process(e),this.aes.AES_Encrypt_finish())}decrypt(e){return wn(this.aes.AES_Encrypt_process(e),this.aes.AES_Encrypt_finish())}AES_CTR_set_options(e,t,r){let{asm:n}=this.aes.acquire_asm();if(void 0!==r){if(r<8||r>48)throw new _n("illegal counter size");let e=Math.pow(2,r)-1;n.set_mask(0,0,e/4294967296|0,0|e)}else r=48,n.set_mask(0,0,65535,4294967295);if(void 0===e)throw Error("nonce is required");{let t=e.length;if(!t||t>16)throw new _n("illegal nonce size");let r=new DataView(new ArrayBuffer(16));new Uint8Array(r.buffer).set(e),n.set_nonce(r.getUint32(0),r.getUint32(4),r.getUint32(8),r.getUint32(12))}if(void 0!==t){if(t<0||t>=Math.pow(2,r))throw new _n("illegal counter value");n.set_counter(0,0,t/4294967296|0,0|t)}}}class Qa{static encrypt(e,t,r=!0,n){return new Qa(t,n,r).encrypt(e)}static decrypt(e,t,r=!0,n){return new Qa(t,n,r).decrypt(e)}constructor(e,t,r=!0,n){this.aes=n||new Sn(e,t,r,"CBC")}encrypt(e){return wn(this.aes.AES_Encrypt_process(e),this.aes.AES_Encrypt_finish())}decrypt(e){return wn(this.aes.AES_Decrypt_process(e),this.aes.AES_Decrypt_finish())}}const Xa=Gr.getWebCrypto(),Ja=Gr.getNodeCrypto(),es=Gr.getNodeBuffer();function ts(e,t){const r=e.length-16;for(let n=0;n<16;n++)e[n+r]^=t[n];return e}const rs=new Uint8Array(16);async function ns(e){const t=await async function(e){if(Gr.getWebCrypto()&&24!==e.length)return e=await Xa.importKey("raw",e,{name:"AES-CBC",length:8*e.length},!1,["encrypt"]),async function(t){const r=await Xa.encrypt({name:"AES-CBC",iv:rs,length:128},e,t);return new Uint8Array(r).subarray(0,r.byteLength-16)};if(Gr.getNodeCrypto())return e=es.from(e),async function(t){t=es.from(t);const r=new Ja.createCipheriv("aes-"+8*e.length+"-cbc",e,rs).update(t);return new Uint8Array(r)};return async function(t){return Qa.encrypt(t,e,!1,rs)}}(e),r=Gr.double(await t(rs)),n=Gr.double(r);return async function(e){return(await t(function(e,t,r){if(e.length&&e.length%16==0)return ts(e,t);const n=new Uint8Array(e.length+(16-e.length%16));return n.set(e),n[e.length]=128,ts(n,r)}(e,r,n))).subarray(-16)}}const is=Gr.getWebCrypto(),as=Gr.getNodeCrypto(),ss=Gr.getNodeBuffer(),os=new Uint8Array(16),cs=new Uint8Array(16);cs[15]=1;const us=new Uint8Array(16);async function ls(e){const t=await ns(e);return function(e,r){return t(Gr.concatUint8Array([e,r]))}}async function hs(e){return Gr.getWebCrypto()&&24!==e.length&&-1===navigator.userAgent.indexOf("Edge")?(e=await is.importKey("raw",e,{name:"AES-CTR",length:8*e.length},!1,["encrypt"]),async function(t,r){const n=await is.encrypt({name:"AES-CTR",counter:r,length:128},e,t);return new Uint8Array(n)}):Gr.getNodeCrypto()?(e=ss.from(e),async function(t,r){t=ss.from(t),r=ss.from(r);const n=new as.createCipheriv("aes-"+8*e.length+"-ctr",e,r),i=ss.concat([n.update(t),n.final()]);return new Uint8Array(i)}):async function(t,r){return Za.encrypt(t,e,r)}}async function ds(e,t){if("aes"!==e.substr(0,3))throw Error("EAX mode supports only AES cipher");const[r,n]=await Promise.all([ls(t),hs(t)]);return{encrypt:async function(e,t,i){const[a,s]=await Promise.all([r(os,t),r(cs,i)]),o=await n(e,a),c=await r(us,o);for(let e=0;e<16;e++)c[e]^=s[e]^a[e];return Gr.concatUint8Array([o,c])},decrypt:async function(e,t,i){if(e.length<16)throw Error("Invalid EAX ciphertext");const a=e.subarray(0,-16),s=e.subarray(-16),[o,c,u]=await Promise.all([r(os,t),r(cs,i),r(us,a)]),l=u;for(let e=0;e<16;e++)l[e]^=c[e]^o[e];if(!Gr.equalsUint8Array(s,l))throw Error("Authentication tag mismatch");return await n(a,o)}}}us[15]=2,ds.getNonce=function(e,t){const r=e.slice();for(let e=0;e<t.length;e++)r[8+e]^=t[e];return r},ds.blockLength=16,ds.ivLength=16,ds.tagLength=16;function fs(e){let t=0;for(let r=1;0==(e&r);r<<=1)t++;return t}function ys(e,t){for(let r=0;r<e.length;r++)e[r]^=t[r];return e}function ps(e,t){return ys(e.slice(),t)}const gs=new Uint8Array(16),ms=new Uint8Array([1]);async function ws(e,t){let r,n,i,a=0;function s(e,t,n,s){const o=t.length/16|0;!function(e,t){const r=Gr.nbits(Math.max(e.length,t.length)/16|0)-1;for(let e=a+1;e<=r;e++)i[e]=Gr.double(i[e-1]);a=r}(t,s);const c=Gr.concatUint8Array([gs.subarray(0,15-n.length),ms,n]),u=63&c[15];c[15]&=192;const l=r(c),h=Gr.concatUint8Array([l,ps(l.subarray(0,8),l.subarray(1,9))]),d=Gr.shiftRight(h.subarray(0+(u>>3),17+(u>>3)),8-(7&u)).subarray(1),f=new Uint8Array(16),y=new Uint8Array(t.length+16);let p,g=0;for(p=0;p<o;p++)ys(d,i[fs(p+1)]),y.set(ys(e(ps(d,t)),d),g),ys(f,e===r?t:y.subarray(g)),t=t.subarray(16),g+=16;if(t.length){ys(d,i.x);const n=r(d);y.set(ps(t,n),g);const a=new Uint8Array(16);a.set(e===r?t:y.subarray(g,-16),0),a[t.length]=128,ys(f,a),g+=t.length}const m=ys(r(ys(ys(f,d),i.$)),function(e){if(!e.length)return gs;const t=e.length/16|0,n=new Uint8Array(16),a=new Uint8Array(16);for(let s=0;s<t;s++)ys(n,i[fs(s+1)]),ys(a,r(ps(n,e))),e=e.subarray(16);if(e.length){ys(n,i.x);const t=new Uint8Array(16);t.set(e,0),t[e.length]=128,ys(t,n),ys(a,r(t))}return a}(s));return y.set(m,g),y}return function(e,t){const a=new Fn[e](t);r=a.encrypt.bind(a),n=a.decrypt.bind(a);const s=r(gs),o=Gr.double(s);i=[],i[0]=Gr.double(o),i.x=s,i.$=o}(e,t),{encrypt:async function(e,t,n){return s(r,e,t,n)},decrypt:async function(e,t,r){if(e.length<16)throw Error("Invalid OCB ciphertext");const i=e.subarray(-16);e=e.subarray(0,-16);const a=s(n,e,t,r);if(Gr.equalsUint8Array(i,a.subarray(-16)))return a.subarray(0,-16);throw Error("Authentication tag mismatch")}}}ws.getNonce=function(e,t){const r=e.slice();for(let e=0;e<t.length;e++)r[7+e]^=t[e];return r},ws.blockLength=16,ws.ivLength=15,ws.tagLength=16;var bs=ti((function(e){!function(e){var t=function(e){var t,r=new Float64Array(16);if(e)for(t=0;t<e.length;t++)r[t]=e[t];return r},r=function(){throw Error("no PRNG")},n=new Uint8Array(32);n[0]=9;var i=t(),a=t([1]),s=t([56129,1]),o=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),c=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),l=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),h=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function d(e,t,r,n){return function(e,t,r,n,i){var a,s=0;for(a=0;a<i;a++)s|=e[t+a]^r[n+a];return(1&s-1>>>8)-1}(e,t,r,n,32)}function f(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function y(e){var t,r,n=1;for(t=0;t<16;t++)r=e[t]+n+65535,n=Math.floor(r/65536),e[t]=r-65536*n;e[0]+=n-1+37*(n-1)}function p(e,t,r){for(var n,i=~(r-1),a=0;a<16;a++)n=i&(e[a]^t[a]),e[a]^=n,t[a]^=n}function g(e,r){var n,i,a,s=t(),o=t();for(n=0;n<16;n++)o[n]=r[n];for(y(o),y(o),y(o),i=0;i<2;i++){for(s[0]=o[0]-65517,n=1;n<15;n++)s[n]=o[n]-65535-(s[n-1]>>16&1),s[n-1]&=65535;s[15]=o[15]-32767-(s[14]>>16&1),a=s[15]>>16&1,s[14]&=65535,p(o,s,1-a)}for(n=0;n<16;n++)e[2*n]=255&o[n],e[2*n+1]=o[n]>>8}function m(e,t){var r=new Uint8Array(32),n=new Uint8Array(32);return g(r,e),g(n,t),d(r,0,n,0)}function w(e){var t=new Uint8Array(32);return g(t,e),1&t[0]}function b(e,t){var r;for(r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function _(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]+r[n]}function v(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]-r[n]}function k(e,t,r){var n,i,a=0,s=0,o=0,c=0,u=0,l=0,h=0,d=0,f=0,y=0,p=0,g=0,m=0,w=0,b=0,_=0,v=0,k=0,A=0,S=0,E=0,P=0,x=0,K=0,C=0,U=0,R=0,T=0,D=0,I=0,B=0,z=r[0],O=r[1],q=r[2],N=r[3],M=r[4],L=r[5],j=r[6],F=r[7],H=r[8],W=r[9],G=r[10],V=r[11],$=r[12],Y=r[13],Z=r[14],Q=r[15];a+=(n=t[0])*z,s+=n*O,o+=n*q,c+=n*N,u+=n*M,l+=n*L,h+=n*j,d+=n*F,f+=n*H,y+=n*W,p+=n*G,g+=n*V,m+=n*$,w+=n*Y,b+=n*Z,_+=n*Q,s+=(n=t[1])*z,o+=n*O,c+=n*q,u+=n*N,l+=n*M,h+=n*L,d+=n*j,f+=n*F,y+=n*H,p+=n*W,g+=n*G,m+=n*V,w+=n*$,b+=n*Y,_+=n*Z,v+=n*Q,o+=(n=t[2])*z,c+=n*O,u+=n*q,l+=n*N,h+=n*M,d+=n*L,f+=n*j,y+=n*F,p+=n*H,g+=n*W,m+=n*G,w+=n*V,b+=n*$,_+=n*Y,v+=n*Z,k+=n*Q,c+=(n=t[3])*z,u+=n*O,l+=n*q,h+=n*N,d+=n*M,f+=n*L,y+=n*j,p+=n*F,g+=n*H,m+=n*W,w+=n*G,b+=n*V,_+=n*$,v+=n*Y,k+=n*Z,A+=n*Q,u+=(n=t[4])*z,l+=n*O,h+=n*q,d+=n*N,f+=n*M,y+=n*L,p+=n*j,g+=n*F,m+=n*H,w+=n*W,b+=n*G,_+=n*V,v+=n*$,k+=n*Y,A+=n*Z,S+=n*Q,l+=(n=t[5])*z,h+=n*O,d+=n*q,f+=n*N,y+=n*M,p+=n*L,g+=n*j,m+=n*F,w+=n*H,b+=n*W,_+=n*G,v+=n*V,k+=n*$,A+=n*Y,S+=n*Z,E+=n*Q,h+=(n=t[6])*z,d+=n*O,f+=n*q,y+=n*N,p+=n*M,g+=n*L,m+=n*j,w+=n*F,b+=n*H,_+=n*W,v+=n*G,k+=n*V,A+=n*$,S+=n*Y,E+=n*Z,P+=n*Q,d+=(n=t[7])*z,f+=n*O,y+=n*q,p+=n*N,g+=n*M,m+=n*L,w+=n*j,b+=n*F,_+=n*H,v+=n*W,k+=n*G,A+=n*V,S+=n*$,E+=n*Y,P+=n*Z,x+=n*Q,f+=(n=t[8])*z,y+=n*O,p+=n*q,g+=n*N,m+=n*M,w+=n*L,b+=n*j,_+=n*F,v+=n*H,k+=n*W,A+=n*G,S+=n*V,E+=n*$,P+=n*Y,x+=n*Z,K+=n*Q,y+=(n=t[9])*z,p+=n*O,g+=n*q,m+=n*N,w+=n*M,b+=n*L,_+=n*j,v+=n*F,k+=n*H,A+=n*W,S+=n*G,E+=n*V,P+=n*$,x+=n*Y,K+=n*Z,C+=n*Q,p+=(n=t[10])*z,g+=n*O,m+=n*q,w+=n*N,b+=n*M,_+=n*L,v+=n*j,k+=n*F,A+=n*H,S+=n*W,E+=n*G,P+=n*V,x+=n*$,K+=n*Y,C+=n*Z,U+=n*Q,g+=(n=t[11])*z,m+=n*O,w+=n*q,b+=n*N,_+=n*M,v+=n*L,k+=n*j,A+=n*F,S+=n*H,E+=n*W,P+=n*G,x+=n*V,K+=n*$,C+=n*Y,U+=n*Z,R+=n*Q,m+=(n=t[12])*z,w+=n*O,b+=n*q,_+=n*N,v+=n*M,k+=n*L,A+=n*j,S+=n*F,E+=n*H,P+=n*W,x+=n*G,K+=n*V,C+=n*$,U+=n*Y,R+=n*Z,T+=n*Q,w+=(n=t[13])*z,b+=n*O,_+=n*q,v+=n*N,k+=n*M,A+=n*L,S+=n*j,E+=n*F,P+=n*H,x+=n*W,K+=n*G,C+=n*V,U+=n*$,R+=n*Y,T+=n*Z,D+=n*Q,b+=(n=t[14])*z,_+=n*O,v+=n*q,k+=n*N,A+=n*M,S+=n*L,E+=n*j,P+=n*F,x+=n*H,K+=n*W,C+=n*G,U+=n*V,R+=n*$,T+=n*Y,D+=n*Z,I+=n*Q,_+=(n=t[15])*z,s+=38*(k+=n*q),o+=38*(A+=n*N),c+=38*(S+=n*M),u+=38*(E+=n*L),l+=38*(P+=n*j),h+=38*(x+=n*F),d+=38*(K+=n*H),f+=38*(C+=n*W),y+=38*(U+=n*G),p+=38*(R+=n*V),g+=38*(T+=n*$),m+=38*(D+=n*Y),w+=38*(I+=n*Z),b+=38*(B+=n*Q),a=(n=(a+=38*(v+=n*O))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),o=(n=o+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),w=(n=w+i+65535)-65536*(i=Math.floor(n/65536)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),_=(n=_+i+65535)-65536*(i=Math.floor(n/65536)),a=(n=(a+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),o=(n=o+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),w=(n=w+i+65535)-65536*(i=Math.floor(n/65536)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),_=(n=_+i+65535)-65536*(i=Math.floor(n/65536)),a+=i-1+37*(i-1),e[0]=a,e[1]=s,e[2]=o,e[3]=c,e[4]=u,e[5]=l,e[6]=h,e[7]=d,e[8]=f,e[9]=y,e[10]=p,e[11]=g,e[12]=m,e[13]=w,e[14]=b,e[15]=_}function A(e,t){k(e,t,t)}function S(e,r){var n,i=t();for(n=0;n<16;n++)i[n]=r[n];for(n=253;n>=0;n--)A(i,i),2!==n&&4!==n&&k(i,i,r);for(n=0;n<16;n++)e[n]=i[n]}function E(e,r,n){var i,a,o=new Uint8Array(32),c=new Float64Array(80),u=t(),l=t(),h=t(),d=t(),f=t(),y=t();for(a=0;a<31;a++)o[a]=r[a];for(o[31]=127&r[31]|64,o[0]&=248,b(c,n),a=0;a<16;a++)l[a]=c[a],d[a]=u[a]=h[a]=0;for(u[0]=d[0]=1,a=254;a>=0;--a)p(u,l,i=o[a>>>3]>>>(7&a)&1),p(h,d,i),_(f,u,h),v(u,u,h),_(h,l,d),v(l,l,d),A(d,f),A(y,u),k(u,h,u),k(h,l,f),_(f,u,h),v(u,u,h),A(l,u),v(h,d,y),k(u,h,s),_(u,u,d),k(h,h,u),k(u,d,y),k(d,l,c),A(l,f),p(u,l,i),p(h,d,i);for(a=0;a<16;a++)c[a+16]=u[a],c[a+32]=h[a],c[a+48]=l[a],c[a+64]=d[a];var m=c.subarray(32),w=c.subarray(16);return S(m,m),k(w,w,m),g(e,w),0}function P(e,t){return E(e,t,n)}function x(e,r){var n=t(),i=t(),a=t(),s=t(),o=t(),u=t(),l=t(),h=t(),d=t();v(n,e[1],e[0]),v(d,r[1],r[0]),k(n,n,d),_(i,e[0],e[1]),_(d,r[0],r[1]),k(i,i,d),k(a,e[3],r[3]),k(a,a,c),k(s,e[2],r[2]),_(s,s,s),v(o,i,n),v(u,s,a),_(l,s,a),_(h,i,n),k(e[0],o,u),k(e[1],h,l),k(e[2],l,u),k(e[3],o,h)}function K(e,t,r){var n;for(n=0;n<4;n++)p(e[n],t[n],r)}function C(e,r){var n=t(),i=t(),a=t();S(a,r[2]),k(n,r[0],a),k(i,r[1],a),g(e,i),e[31]^=w(n)<<7}function U(e,t,r){var n,s;for(f(e[0],i),f(e[1],a),f(e[2],a),f(e[3],i),s=255;s>=0;--s)K(e,t,n=r[s/8|0]>>(7&s)&1),x(t,e),x(e,e),K(e,t,n)}function R(e,r){var n=[t(),t(),t(),t()];f(n[0],u),f(n[1],l),f(n[2],a),k(n[3],u,l),U(e,n,r)}function T(n,i,a){var s,o,c=[t(),t(),t(),t()];for(a||r(i,32),(s=e.hash(i.subarray(0,32)))[0]&=248,s[31]&=127,s[31]|=64,R(c,s),C(n,c),o=0;o<32;o++)i[o+32]=n[o];return 0}var D=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]);function I(e,t){var r,n,i,a;for(n=63;n>=32;--n){for(r=0,i=n-32,a=n-12;i<a;++i)t[i]+=r-16*t[n]*D[i-(n-32)],r=Math.floor((t[i]+128)/256),t[i]-=256*r;t[i]+=r,t[n]=0}for(r=0,i=0;i<32;i++)t[i]+=r-(t[31]>>4)*D[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*D[i];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function B(e){var t,r=new Float64Array(64);for(t=0;t<64;t++)r[t]=e[t];for(t=0;t<64;t++)e[t]=0;I(e,r)}function z(e,r){var n=t(),s=t(),c=t(),u=t(),l=t(),d=t(),y=t();return f(e[2],a),b(e[1],r),A(c,e[1]),k(u,c,o),v(c,c,e[2]),_(u,e[2],u),A(l,u),A(d,l),k(y,d,l),k(n,y,c),k(n,n,u),function(e,r){var n,i=t();for(n=0;n<16;n++)i[n]=r[n];for(n=250;n>=0;n--)A(i,i),1!==n&&k(i,i,r);for(n=0;n<16;n++)e[n]=i[n]}(n,n),k(n,n,c),k(n,n,u),k(n,n,u),k(e[0],n,u),A(s,e[0]),k(s,s,u),m(s,c)&&k(e[0],e[0],h),A(s,e[0]),k(s,s,u),m(s,c)?-1:(w(e[0])===r[31]>>7&&v(e[0],i,e[0]),k(e[3],e[0],e[1]),0)}function O(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function q(e){for(var t=0;t<e.length;t++)e[t]=0}e.scalarMult=function(e,t){if(O(e,t),32!==e.length)throw Error("bad n size");if(32!==t.length)throw Error("bad p size");var r=new Uint8Array(32);return E(r,e,t),r},e.box={},e.box.keyPair=function(){var e,t,n=new Uint8Array(32),i=new Uint8Array(32);return e=n,r(t=i,32),P(e,t),{publicKey:n,secretKey:i}},e.box.keyPair.fromSecretKey=function(e){if(O(e),32!==e.length)throw Error("bad secret key size");var t=new Uint8Array(32);return P(t,e),{publicKey:t,secretKey:new Uint8Array(e)}},e.sign=function(r,n){if(O(r,n),64!==n.length)throw Error("bad secret key size");var i=new Uint8Array(64+r.length);return function(r,n,i,a){var s,o,c,u,l,h=new Float64Array(64),d=[t(),t(),t(),t()];(s=e.hash(a.subarray(0,32)))[0]&=248,s[31]&=127,s[31]|=64;var f=i+64;for(u=0;u<i;u++)r[64+u]=n[u];for(u=0;u<32;u++)r[32+u]=s[32+u];for(B(c=e.hash(r.subarray(32,f))),R(d,c),C(r,d),u=32;u<64;u++)r[u]=a[u];for(B(o=e.hash(r.subarray(0,f))),u=0;u<64;u++)h[u]=0;for(u=0;u<32;u++)h[u]=c[u];for(u=0;u<32;u++)for(l=0;l<32;l++)h[u+l]+=o[u]*s[l];I(r.subarray(32),h)}(i,r,r.length,n),i},e.sign.detached=function(t,r){for(var n=e.sign(t,r),i=new Uint8Array(64),a=0;a<i.length;a++)i[a]=n[a];return i},e.sign.detached.verify=function(r,n,i){if(O(r,n,i),64!==n.length)throw Error("bad signature size");if(32!==i.length)throw Error("bad public key size");var a,s=new Uint8Array(64+r.length),o=new Uint8Array(64+r.length);for(a=0;a<64;a++)s[a]=n[a];for(a=0;a<r.length;a++)s[a+64]=r[a];return function(r,n,i,a){var s,o,c=new Uint8Array(32),u=[t(),t(),t(),t()],l=[t(),t(),t(),t()];if(i<64)return-1;if(z(l,a))return-1;for(s=0;s<i;s++)r[s]=n[s];for(s=0;s<32;s++)r[s+32]=a[s];if(B(o=e.hash(r.subarray(0,i))),U(u,l,o),R(l,n.subarray(32)),x(u,l),C(c,u),i-=64,d(n,0,c,0)){for(s=0;s<i;s++)r[s]=0;return-1}for(s=0;s<i;s++)r[s]=n[s+64];return i}(o,s,s.length,i)>=0},e.sign.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(64);return T(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(O(e),64!==e.length)throw Error("bad secret key size");for(var t=new Uint8Array(32),r=0;r<t.length;r++)t[r]=e[32+r];return{publicKey:t,secretKey:new Uint8Array(e)}},e.sign.keyPair.fromSeed=function(e){if(O(e),32!==e.length)throw Error("bad seed size");for(var t=new Uint8Array(32),r=new Uint8Array(64),n=0;n<32;n++)r[n]=e[n];return T(t,r,!0),{publicKey:t,secretKey:r}},e.setPRNG=function(e){r=e},function(){var t="undefined"!=typeof self?self.crypto||self.msCrypto:null;if(t&&t.getRandomValues){e.setPRNG((function(e,r){var n,i=new Uint8Array(r);for(n=0;n<r;n+=65536)t.getRandomValues(i.subarray(n,n+Math.min(r-n,65536)));for(n=0;n<r;n++)e[n]=i[n];q(i)}))}else(t=void 0)&&t.randomBytes&&e.setPRNG((function(e,r){var n,i=t.randomBytes(r);for(n=0;n<r;n++)e[n]=i[n];q(i)}))}()}(e.exports?e.exports:self.nacl=self.nacl||{})}));const _s=Gr.getNodeCrypto();async function vs(t){const r=new Uint8Array(t);if("undefined"!=typeof crypto&&crypto.getRandomValues)crypto.getRandomValues(r);else if(void 0!==e&&"object"==typeof e.msCrypto&&"function"==typeof e.msCrypto.getRandomValues)e.msCrypto.getRandomValues(r);else if(_s){const e=_s.randomBytes(r.length);r.set(e)}else{if(!As.buffer)throw Error("No secure random number generator available.");await As.get(r)}return r}async function ks(e,t){const r=await Gr.getBigInteger();if(t.lt(e))throw Error("Illegal parameter value: max <= min");const n=t.sub(e),i=n.byteLength();return new r(await vs(i+8)).mod(n).add(e)}const As=new class{constructor(){this.buffer=null,this.size=null,this.callback=null}init(e,t){this.buffer=new Uint8Array(e),this.size=0,this.callback=t}set(e){if(!this.buffer)throw Error("RandomBuffer is not initialized");if(!(e instanceof Uint8Array))throw Error("Invalid type: buf not an Uint8Array");const t=this.buffer.length-this.size;e.length>t&&(e=e.subarray(0,t)),this.buffer.set(e,this.size),this.size+=e.length}async get(e){if(!this.buffer)throw Error("RandomBuffer is not initialized");if(!(e instanceof Uint8Array))throw Error("Invalid type: buf not an Uint8Array");if(this.size<e.length){if(!this.callback)throw Error("Random number buffer depleted");return await this.callback(),this.get(e)}for(let t=0;t<e.length;t++)e[t]=this.buffer[--this.size],this.buffer[this.size]=0}};var Ss=/*#__PURE__*/Object.freeze({__proto__:null,getRandomBytes:vs,getRandomBigInteger:ks,randomBuffer:As});async function Es(e,t,r){const n=await Gr.getBigInteger(),i=new n(1),a=i.leftShift(new n(e-1)),s=new n(30),o=[1,6,5,4,3,2,1,4,3,2,1,2,1,4,3,2,1,2,1,4,3,2,1,6,5,4,3,2,1,2],c=await ks(a,a.leftShift(i));let u=c.mod(s).toNumber();do{c.iadd(new n(o[u])),u=(u+o[u])%o.length,c.bitLength()>e&&(c.imod(a.leftShift(i)).iadd(a),u=c.mod(s).toNumber())}while(!await Ps(c,t,r));return c}async function Ps(e,t,r){return!(t&&!e.dec().gcd(t).isOne())&&(!!await async function(e){const t=await Gr.getBigInteger();return xs.every(r=>0!==e.mod(new t(r)))}(e)&&(!!await async function(e,t){const r=await Gr.getBigInteger();return(t=t||new r(2)).modExp(e.dec(),e).isOne()}(e)&&!!await async function(e,t,r){const n=await Gr.getBigInteger(),i=e.bitLength();t||(t=Math.max(1,i/48|0));const a=e.dec();let s=0;for(;!a.getBit(s);)s++;const o=e.rightShift(new n(s));for(;t>0;t--){let t,i=(r?r():await ks(new n(2),a)).modExp(o,e);if(!i.isOne()&&!i.equal(a)){for(t=1;t<s;t++){if(i=i.mul(i).mod(e),i.isOne())return!1;if(i.equal(a))break}if(t===s)return!1}}return!0}(e,r)))}const xs=[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,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,2309,2311,2333,2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,2909,2917,2927,2939,2953,2957,2963,2969,2971,2999,3001,3011,3019,3023,3037,3041,3049,3061,3067,3079,3083,3089,3109,3119,3121,3137,3163,3167,3169,3181,3187,3191,3203,3209,3217,3221,3229,3251,3253,3257,3259,3271,3299,3301,3307,3313,3319,3323,3329,3331,3343,3347,3359,3361,3371,3373,3389,3391,3407,3413,3433,3449,3457,3461,3463,3467,3469,3491,3499,3511,3517,3527,3529,3533,3539,3541,3547,3557,3559,3571,3581,3583,3593,3607,3613,3617,3623,3631,3637,3643,3659,3671,3673,3677,3691,3697,3701,3709,3719,3727,3733,3739,3761,3767,3769,3779,3793,3797,3803,3821,3823,3833,3847,3851,3853,3863,3877,3881,3889,3907,3911,3917,3919,3923,3929,3931,3943,3947,3967,3989,4001,4003,4007,4013,4019,4021,4027,4049,4051,4057,4073,4079,4091,4093,4099,4111,4127,4129,4133,4139,4153,4157,4159,4177,4201,4211,4217,4219,4229,4231,4241,4243,4253,4259,4261,4271,4273,4283,4289,4297,4327,4337,4339,4349,4357,4363,4373,4391,4397,4409,4421,4423,4441,4447,4451,4457,4463,4481,4483,4493,4507,4513,4517,4519,4523,4547,4549,4561,4567,4583,4591,4597,4603,4621,4637,4639,4643,4649,4651,4657,4663,4673,4679,4691,4703,4721,4723,4729,4733,4751,4759,4783,4787,4789,4793,4799,4801,4813,4817,4831,4861,4871,4877,4889,4903,4909,4919,4931,4933,4937,4943,4951,4957,4967,4969,4973,4987,4993,4999];const Ks=[];async function Cs(e,t){const r=e.length;if(r>t-11)throw Error("Message too long");const n=await async function(e){const t=new Uint8Array(e);let r=0;for(;r<e;){const n=await vs(e-r);for(let e=0;e<n.length;e++)0!==n[e]&&(t[r++]=n[e])}return t}(t-r-3),i=new Uint8Array(t);return i[1]=2,i.set(n,2),i.set(e,t-r),i}function Us(e){let t=2;for(;0!==e[t]&&t<e.length;)t++;const r=t-2,n=e[t++];if(0===e[0]&&2===e[1]&&r>=8&&0===n)return e.subarray(t);throw Error("Decryption error")}async function Rs(e,t,r){let n;if(t.length!==Oa.getHashByteLength(e))throw Error("Invalid hash length");const i=new Uint8Array(Ks[e].length);for(n=0;n<Ks[e].length;n++)i[n]=Ks[e][n];const a=i.length+t.length;if(r<a+11)throw Error("Intended encoded message length too short");const s=new Uint8Array(r-a-3).fill(255),o=new Uint8Array(r);return o[1]=1,o.set(s,2),o.set(i,r-a),o.set(t,r-t.length),o}Ks[1]=[48,32,48,12,6,8,42,134,72,134,247,13,2,5,5,0,4,16],Ks[2]=[48,33,48,9,6,5,43,14,3,2,26,5,0,4,20],Ks[3]=[48,33,48,9,6,5,43,36,3,2,1,5,0,4,20],Ks[8]=[48,49,48,13,6,9,96,134,72,1,101,3,4,2,1,5,0,4,32],Ks[9]=[48,65,48,13,6,9,96,134,72,1,101,3,4,2,2,5,0,4,48],Ks[10]=[48,81,48,13,6,9,96,134,72,1,101,3,4,2,3,5,0,4,64],Ks[11]=[48,45,48,13,6,9,96,134,72,1,101,3,4,2,4,5,0,4,28];var Ts=/*#__PURE__*/Object.freeze({__proto__:null,emeEncode:Cs,emeDecode:Us,emsaEncode:Rs});const Ds=Gr.getWebCrypto(),Is=Gr.getNodeCrypto(),Bs=void 0;function zs(e,t){return"function"!=typeof e.then?new Promise((function(r,n){e.onerror=function(){n(Error(t))},e.oncomplete=function(e){r(e.target.result)}})):e}const Os=Gr.detectNode()?Bs.define("RSAPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())})):void 0,qs=Gr.detectNode()?Bs.define("RSAPubliceKey",(function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())})):void 0;var Ns=/*#__PURE__*/Object.freeze({__proto__:null,sign:async function(e,t,r,n,i,a,s,o,c){if(t&&!Gr.isStream(t))if(Gr.getWebCrypto())try{return await async function(e,t,r,n,i,a,s,o){const c=await async function(e,t,r,n,i,a){const s=await Gr.getBigInteger(),o=new s(n),c=new s(i),u=new s(r);let l=u.mod(c.dec()),h=u.mod(o.dec());return h=h.toUint8Array(),l=l.toUint8Array(),{kty:"RSA",n:Jr(e,!0),e:Jr(t,!0),d:Jr(r,!0),p:Jr(i,!0),q:Jr(n,!0),dp:Jr(l,!0),dq:Jr(h,!0),qi:Jr(a,!0),ext:!0}}(r,n,i,a,s,o),u={name:"RSASSA-PKCS1-v1_5",hash:{name:e}},l=await Ds.importKey("jwk",c,u,!1,["sign"]);return new Uint8Array(await Ds.sign({name:"RSASSA-PKCS1-v1_5",hash:e},l,t))}(tn.read(tn.webHash,e),t,r,n,i,a,s,o)}catch(e){Gr.printDebugError(e)}else if(Gr.getNodeCrypto())return async function(e,t,r,n,i,a,s,o){const{default:c}=await import("./bn.min.mjs"),u=new c(a),l=new c(s),h=new c(i),d=h.mod(l.subn(1)),f=h.mod(u.subn(1)),y=Is.createSign(tn.read(tn.hash,e));y.write(t),y.end();const p={version:0,modulus:new c(r),publicExponent:new c(n),privateExponent:new c(i),prime1:new c(s),prime2:new c(a),exponent1:d,exponent2:f,coefficient:new c(o)};if(void 0!==Is.createPrivateKey){const e=Os.encode(p,"der");return new Uint8Array(y.sign({key:e,format:"der",type:"pkcs1"}))}const g=Os.encode(p,"pem",{label:"RSA PRIVATE KEY"});return new Uint8Array(y.sign(g))}(e,t,r,n,i,a,s,o);return async function(e,t,r,n){const i=await Gr.getBigInteger();t=new i(t);const a=new i(await Rs(e,n,t.byteLength()));if(r=new i(r),a.gte(t))throw Error("Message size cannot exceed modulus size");return a.modExp(r,t).toUint8Array("be",t.byteLength())}(e,r,i,c)},verify:async function(e,t,r,n,i,a){if(t&&!Gr.isStream(t))if(Gr.getWebCrypto())try{return await async function(e,t,r,n,i){const a=function(e,t){return{kty:"RSA",n:Jr(e,!0),e:Jr(t,!0),ext:!0}}(n,i),s=await Ds.importKey("jwk",a,{name:"RSASSA-PKCS1-v1_5",hash:{name:e}},!1,["verify"]);return Ds.verify({name:"RSASSA-PKCS1-v1_5",hash:e},s,r,t)}(tn.read(tn.webHash,e),t,r,n,i)}catch(e){Gr.printDebugError(e)}else if(Gr.getNodeCrypto())return async function(e,t,r,n,i){const{default:a}=await import("./bn.min.mjs"),s=Is.createVerify(tn.read(tn.hash,e));s.write(t),s.end();const o={modulus:new a(n),publicExponent:new a(i)};let c;if(void 0!==Is.createPrivateKey){const e=qs.encode(o,"der");c={key:e,format:"der",type:"pkcs1"}}else c=qs.encode(o,"pem",{label:"RSA PUBLIC KEY"});try{return await s.verify(c,r)}catch(e){return!1}}(e,t,r,n,i);return async function(e,t,r,n,i){const a=await Gr.getBigInteger();if(r=new a(r),t=new a(t),n=new a(n),t.gte(r))throw Error("Signature size cannot exceed modulus size");const s=t.modExp(n,r).toUint8Array("be",r.byteLength()),o=await Rs(e,i,r.byteLength());return Gr.equalsUint8Array(s,o)}(e,r,n,i,a)},encrypt:async function(e,t,r){return Gr.getNodeCrypto()?async function(e,t,r){const{default:n}=await import("./bn.min.mjs"),i={modulus:new n(t),publicExponent:new n(r)};let a;if(void 0!==Is.createPrivateKey){const e=qs.encode(i,"der");a={key:e,format:"der",type:"pkcs1",padding:Is.constants.RSA_PKCS1_PADDING}}else{const e=qs.encode(i,"pem",{label:"RSA PUBLIC KEY"});a={key:e,padding:Is.constants.RSA_PKCS1_PADDING}}return new Uint8Array(Is.publicEncrypt(a,e))}(e,t,r):async function(e,t,r){const n=await Gr.getBigInteger();if(t=new n(t),e=new n(await Cs(e,t.byteLength())),r=new n(r),e.gte(t))throw Error("Message size cannot exceed modulus size");return e.modExp(r,t).toUint8Array("be",t.byteLength())}(e,t,r)},decrypt:async function(e,t,r,n,i,a,s){return Gr.getNodeCrypto()?async function(e,t,r,n,i,a,s){const{default:o}=await import("./bn.min.mjs"),c=new o(i),u=new o(a),l=new o(n),h=l.mod(u.subn(1)),d=l.mod(c.subn(1)),f={version:0,modulus:new o(t),publicExponent:new o(r),privateExponent:new o(n),prime1:new o(a),prime2:new o(i),exponent1:h,exponent2:d,coefficient:new o(s)};let y;if(void 0!==Is.createPrivateKey){const e=Os.encode(f,"der");y={key:e,format:"der",type:"pkcs1",padding:Is.constants.RSA_PKCS1_PADDING}}else{const e=Os.encode(f,"pem",{label:"RSA PRIVATE KEY"});y={key:e,padding:Is.constants.RSA_PKCS1_PADDING}}try{return new Uint8Array(Is.privateDecrypt(y,e))}catch(e){throw Error("Decryption error")}}(e,t,r,n,i,a,s):async function(e,t,r,n,i,a,s){const o=await Gr.getBigInteger();if(e=new o(e),t=new o(t),r=new o(r),n=new o(n),i=new o(i),a=new o(a),s=new o(s),e.gte(t))throw Error("Data too large.");const c=n.mod(a.dec()),u=n.mod(i.dec()),l=(await ks(new o(2),t)).mod(t),h=l.modInv(t).modExp(r,t),d=(e=e.mul(h).mod(t)).modExp(u,i),f=e.modExp(c,a);let y=s.mul(f.sub(d)).mod(a).mul(i).add(d);return y=y.mul(l).mod(t),Us(y.toUint8Array("be",t.byteLength()))}(e,t,r,n,i,a,s)},generate:async function(t,r){if(r=new(await Gr.getBigInteger())(r),Gr.getWebCrypto()){let n,i;if(e.crypto&&e.crypto.subtle||e.msCrypto)i={name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:r.toUint8Array(),hash:{name:"SHA-1"}},n=Ds.generateKey(i,!0,["sign","verify"]),n=await zs(n,"Error generating RSA key pair.");else{if(!e.crypto||!e.crypto.webkitSubtle)throw Error("Unknown WebCrypto implementation");i={name:"RSA-OAEP",modulusLength:t,publicExponent:r.toUint8Array(),hash:{name:"SHA-1"}},n=await Ds.generateKey(i,!0,["encrypt","decrypt"])}let a=Ds.exportKey("jwk",n.privateKey);return a=await zs(a,"Error exporting RSA key pair."),a instanceof ArrayBuffer&&(a=JSON.parse(String.fromCharCode.apply(null,new Uint8Array(a)))),{n:Xr(a.n),e:r.toUint8Array(),d:Xr(a.d),p:Xr(a.q),q:Xr(a.p),u:Xr(a.qi)}}if(Gr.getNodeCrypto()&&Is.generateKeyPair&&Os){const e={modulusLength:t,publicExponent:r.toNumber(),publicKeyEncoding:{type:"pkcs1",format:"der"},privateKeyEncoding:{type:"pkcs1",format:"der"}},n=await new Promise((t,r)=>Is.generateKeyPair("rsa",e,(e,n,i)=>{e?r(e):t(Os.decode(i,"der"))}));return{n:n.modulus.toArrayLike(Uint8Array),e:n.publicExponent.toArrayLike(Uint8Array),d:n.privateExponent.toArrayLike(Uint8Array),p:n.prime2.toArrayLike(Uint8Array),q:n.prime1.toArrayLike(Uint8Array),u:n.coefficient.toArrayLike(Uint8Array)}}let n=await Es(t-(t>>1),r,40),i=await Es(t>>1,r,40);n.lt(i)&&([i,n]=[n,i]);const a=i.dec().imul(n.dec());return{n:i.mul(n).toUint8Array(),e:r.toUint8Array(),d:r.modInv(a).toUint8Array(),p:i.toUint8Array(),q:n.toUint8Array(),u:i.modInv(n).toUint8Array()}},validateParams:async function(e,t,r,n,i,a){const s=await Gr.getBigInteger();if(e=new s(e),n=new s(n),i=new s(i),!n.mul(i).equal(e))return!1;const o=new s(2);if(a=new s(a),!n.mul(a).mod(i).isOne())return!1;t=new s(t),r=new s(r);const c=new s(Math.floor(e.bitLength()/3)),u=await ks(o,o.leftShift(c)),l=u.mul(r).mul(t);return!(!l.mod(n.dec()).equal(u)||!l.mod(i.dec()).equal(u))}});var Ms=/*#__PURE__*/Object.freeze({__proto__:null,encrypt:async function(e,t,r,n){const i=await Gr.getBigInteger();t=new i(t),r=new i(r),n=new i(n);const a=new i(await Cs(e,t.byteLength())),s=await ks(new i(1),t.dec());return{c1:r.modExp(s,t).toUint8Array(),c2:n.modExp(s,t).imul(a).imod(t).toUint8Array()}},decrypt:async function(e,t,r,n){const i=await Gr.getBigInteger();return e=new i(e),t=new i(t),r=new i(r),n=new i(n),Us(e.modExp(n,r).modInv(r).imul(t).imod(r).toUint8Array("be",r.byteLength()))},validateParams:async function(e,t,r,n){const i=await Gr.getBigInteger();e=new i(e),t=new i(t),r=new i(r);const a=new i(1);if(t.lte(a)||t.gte(e))return!1;const s=new i(e.bitLength()),o=new i(1023);if(s.lt(o))return!1;if(!t.modExp(e.dec(),e).isOne())return!1;let c=t;const u=new i(1),l=new i(2).leftShift(new i(17));for(;u.lt(l);){if(c=c.mul(t).imod(e),c.isOne())return!1;u.iinc()}n=new i(n);const h=new i(2),d=await ks(h.leftShift(s.dec()),h.leftShift(s)),f=e.dec().imul(d).iadd(n);return!!r.equal(t.modExp(f,e))}});class Ls{constructor(e){if(e instanceof Ls)this.oid=e.oid;else if(Gr.isArray(e)||Gr.isUint8Array(e)){if(6===(e=new Uint8Array(e))[0]){if(e[1]!==e.length-2)throw Error("Length mismatch in DER encoded oid");e=e.subarray(2)}this.oid=e}else this.oid=""}read(e){if(e.length>=1){const t=e[0];if(e.length>=1+t)return this.oid=e.subarray(1,1+t),1+this.oid.length}throw Error("Invalid oid")}write(){return Gr.concatUint8Array([new Uint8Array([this.oid.length]),this.oid])}toHex(){return Gr.uint8ArrayToHex(this.oid)}getName(){const e=this.toHex();if(tn.curve[e])return tn.write(tn.curve,e);throw Error("Unknown curve object identifier.")}}function js(e,t){return e.keyPair({priv:t})}function Fs(e,t){const r=e.keyPair({pub:t});if(!0!==r.validate().result)throw Error("Invalid elliptic public key");return r}async function Hs(e){if(!rn.useIndutnyElliptic)throw Error("This curve is only supported in the full build of OpenPGP.js");const{default:t}=await import("./elliptic.min.mjs");return new t.ec(e)}const Ws=Gr.getWebCrypto(),Gs=Gr.getNodeCrypto(),Vs={p256:"P-256",p384:"P-384",p521:"P-521"},$s=Gs?Gs.getCurves():[],Ys=Gs?{secp256k1:$s.includes("secp256k1")?"secp256k1":void 0,p256:$s.includes("prime256v1")?"prime256v1":void 0,p384:$s.includes("secp384r1")?"secp384r1":void 0,p521:$s.includes("secp521r1")?"secp521r1":void 0,ed25519:$s.includes("ED25519")?"ED25519":void 0,curve25519:$s.includes("X25519")?"X25519":void 0,brainpoolP256r1:$s.includes("brainpoolP256r1")?"brainpoolP256r1":void 0,brainpoolP384r1:$s.includes("brainpoolP384r1")?"brainpoolP384r1":void 0,brainpoolP512r1:$s.includes("brainpoolP512r1")?"brainpoolP512r1":void 0}:{},Zs={p256:{oid:[6,8,42,134,72,206,61,3,1,7],keyType:tn.publicKey.ecdsa,hash:tn.hash.sha256,cipher:tn.symmetric.aes128,node:Ys.p256,web:Vs.p256,payloadSize:32,sharedSize:256},p384:{oid:[6,5,43,129,4,0,34],keyType:tn.publicKey.ecdsa,hash:tn.hash.sha384,cipher:tn.symmetric.aes192,node:Ys.p384,web:Vs.p384,payloadSize:48,sharedSize:384},p521:{oid:[6,5,43,129,4,0,35],keyType:tn.publicKey.ecdsa,hash:tn.hash.sha512,cipher:tn.symmetric.aes256,node:Ys.p521,web:Vs.p521,payloadSize:66,sharedSize:528},secp256k1:{oid:[6,5,43,129,4,0,10],keyType:tn.publicKey.ecdsa,hash:tn.hash.sha256,cipher:tn.symmetric.aes128,node:Ys.secp256k1,payloadSize:32},ed25519:{oid:[6,9,43,6,1,4,1,218,71,15,1],keyType:tn.publicKey.eddsa,hash:tn.hash.sha512,node:!1,payloadSize:32},curve25519:{oid:[6,10,43,6,1,4,1,151,85,1,5,1],keyType:tn.publicKey.ecdh,hash:tn.hash.sha256,cipher:tn.symmetric.aes128,node:!1,payloadSize:32},brainpoolP256r1:{oid:[6,9,43,36,3,3,2,8,1,1,7],keyType:tn.publicKey.ecdsa,hash:tn.hash.sha256,cipher:tn.symmetric.aes128,node:Ys.brainpoolP256r1,payloadSize:32},brainpoolP384r1:{oid:[6,9,43,36,3,3,2,8,1,1,11],keyType:tn.publicKey.ecdsa,hash:tn.hash.sha384,cipher:tn.symmetric.aes192,node:Ys.brainpoolP384r1,payloadSize:48},brainpoolP512r1:{oid:[6,9,43,36,3,3,2,8,1,1,13],keyType:tn.publicKey.ecdsa,hash:tn.hash.sha512,cipher:tn.symmetric.aes256,node:Ys.brainpoolP512r1,payloadSize:64}};class Qs{constructor(e,t){try{(Gr.isArray(e)||Gr.isUint8Array(e))&&(e=new Ls(e)),e instanceof Ls&&(e=e.getName()),this.name=tn.write(tn.curve,e)}catch(e){throw Error("Not valid curve")}t=t||Zs[this.name],this.keyType=t.keyType,this.oid=t.oid,this.hash=t.hash,this.cipher=t.cipher,this.node=t.node&&Zs[this.name],this.web=t.web&&Zs[this.name],this.payloadSize=t.payloadSize,this.web&&Gr.getWebCrypto()?this.type="web":this.node&&Gr.getNodeCrypto()?this.type="node":"curve25519"===this.name?this.type="curve25519":"ed25519"===this.name&&(this.type="ed25519")}async genKeyPair(){let e;switch(this.type){case"web":try{return await async function(e){const t=await Ws.generateKey({name:"ECDSA",namedCurve:Vs[e]},!0,["sign","verify"]),r=await Ws.exportKey("jwk",t.privateKey);return{publicKey:Js(await Ws.exportKey("jwk",t.publicKey)),privateKey:Xr(r.d)}}(this.name)}catch(e){Gr.printDebugError("Browser did not support generating ec key "+e.message);break}case"node":return async function(e){const t=Gs.createECDH(Ys[e]);return await t.generateKeys(),{publicKey:new Uint8Array(t.getPublicKey()),privateKey:new Uint8Array(t.getPrivateKey())}}(this.name);case"curve25519":{const t=await vs(32);t[0]=127&t[0]|64,t[31]&=248;const r=t.slice().reverse();return e=bs.box.keyPair.fromSecretKey(r),{publicKey:Gr.concatUint8Array([new Uint8Array([64]),e.publicKey]),privateKey:t}}case"ed25519":{const e=await vs(32),t=bs.sign.keyPair.fromSeed(e);return{publicKey:Gr.concatUint8Array([new Uint8Array([64]),t.publicKey]),privateKey:e}}}const t=await Hs(this.name);return e=await t.genKeyPair({entropy:Gr.uint8ArrayToStr(await vs(32))}),{publicKey:new Uint8Array(e.getPublic("array",!1)),privateKey:e.getPrivate().toArrayLike(Uint8Array)}}}async function Xs(e,t,r,n){const i={p256:!0,p384:!0,p521:!0,secp256k1:!0,curve25519:e===tn.publicKey.ecdh,brainpoolP256r1:!0,brainpoolP384r1:!0,brainpoolP512r1:!0},a=t.getName();if(!i[a])return!1;if("curve25519"===a){n=n.slice().reverse();const{publicKey:e}=bs.box.keyPair.fromSecretKey(n);r=new Uint8Array(r);const t=new Uint8Array([64,...e]);return!!Gr.equalsUint8Array(t,r)}const s=await Hs(a);try{r=Fs(s,r).getPublic()}catch(e){return!1}return!!js(s,n).getPublic().eq(r)}function Js(e){const t=Xr(e.x),r=Xr(e.y),n=new Uint8Array(t.length+r.length+1);return n[0]=4,n.set(t,1),n.set(r,t.length+1),n}function eo(e,t,r){const n=e,i=r.slice(1,n+1),a=r.slice(n+1,2*n+1);return{kty:"EC",crv:t,x:Jr(i,!0),y:Jr(a,!0),ext:!0}}function to(e,t,r,n){const i=eo(e,t,r);return i.d=Jr(n,!0),i}const ro=Gr.getWebCrypto(),no=Gr.getNodeCrypto();async function io(e,t,r,n,i,a){const s=new Qs(e);if(r&&!Gr.isStream(r)){const e={publicKey:n,privateKey:i};switch(s.type){case"web":try{return await async function(e,t,r,n){const i=e.payloadSize,a=to(e.payloadSize,Vs[e.name],n.publicKey,n.privateKey),s=await ro.importKey("jwk",a,{name:"ECDSA",namedCurve:Vs[e.name],hash:{name:tn.read(tn.webHash,e.hash)}},!1,["sign"]),o=new Uint8Array(await ro.sign({name:"ECDSA",namedCurve:Vs[e.name],hash:{name:tn.read(tn.webHash,t)}},s,r));return{r:o.slice(0,i),s:o.slice(i,i<<1)}}(s,t,r,e)}catch(e){if("p521"!==s.name&&("DataError"===e.name||"OperationError"===e.name))throw e;Gr.printDebugError("Browser did not support signing: "+e.message)}break;case"node":{const n=await async function(e,t,r,n){const i=no.createSign(tn.read(tn.hash,t));i.write(r),i.end();const a=co.encode({version:1,parameters:e.oid,privateKey:Array.from(n.privateKey),publicKey:{unused:0,data:Array.from(n.publicKey)}},"pem",{label:"EC PRIVATE KEY"});return oo.decode(i.sign(a),"der")}(s,t,r,e);return{r:n.r.toArrayLike(Uint8Array),s:n.s.toArrayLike(Uint8Array)}}}}return async function(e,t,r){const n=js(await Hs(e.name),r).sign(t);return{r:n.r.toArrayLike(Uint8Array),s:n.s.toArrayLike(Uint8Array)}}(s,a,i)}async function ao(e,t,r,n,i,a){const s=new Qs(e);if(n&&!Gr.isStream(n))switch(s.type){case"web":try{return await async function(e,t,{r,s:n},i,a){const s=eo(e.payloadSize,Vs[e.name],a),o=await ro.importKey("jwk",s,{name:"ECDSA",namedCurve:Vs[e.name],hash:{name:tn.read(tn.webHash,e.hash)}},!1,["verify"]),c=Gr.concatUint8Array([r,n]).buffer;return ro.verify({name:"ECDSA",namedCurve:Vs[e.name],hash:{name:tn.read(tn.webHash,t)}},o,c,i)}(s,t,r,n,i)}catch(e){if("p521"!==s.name&&("DataError"===e.name||"OperationError"===e.name))throw e;Gr.printDebugError("Browser did not support verifying: "+e.message)}break;case"node":return async function(e,t,{r,s:n},i,a){const{default:s}=await import("./bn.min.mjs"),o=no.createVerify(tn.read(tn.hash,t));o.write(i),o.end();const c=lo.encode({algorithm:{algorithm:[1,2,840,10045,2,1],parameters:e.oid},subjectPublicKey:{unused:0,data:Array.from(a)}},"pem",{label:"PUBLIC KEY"}),u=oo.encode({r:new s(r),s:new s(n)},"der");try{return o.verify(c,u)}catch(e){return!1}}(s,t,r,n,i)}return async function(e,t,r,n){return Fs(await Hs(e.name),n).verify(r,t)}(s,r,void 0===t?n:a,i)}const so=void 0,oo=no?so.define("ECDSASignature",(function(){this.seq().obj(this.key("r").int(),this.key("s").int())})):void 0,co=no?so.define("ECPrivateKey",(function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").explicit(0).optional().any(),this.key("publicKey").explicit(1).optional().bitstr())})):void 0,uo=no?so.define("AlgorithmIdentifier",(function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional().any())})):void 0,lo=no?so.define("SubjectPublicKeyInfo",(function(){this.seq().obj(this.key("algorithm").use(uo),this.key("subjectPublicKey").bitstr())})):void 0;var ho=/*#__PURE__*/Object.freeze({__proto__:null,sign:io,verify:ao,validateParams:async function(e,t,r){const n=new Qs(e);if(n.keyType!==tn.publicKey.ecdsa)return!1;switch(n.type){case"web":case"node":{const n=await vs(8),i=tn.hash.sha256,a=await Oa.digest(i,n);try{const s=await io(e,i,n,t,r,a);return await ao(e,i,s,n,t,a)}catch(e){return!1}}default:return Xs(tn.publicKey.ecdsa,e,t,r)}}});bs.hash=e=>new Uint8Array(Hi().update(e).digest());var fo=/*#__PURE__*/Object.freeze({__proto__:null,sign:async function(e,t,r,n,i,a){const s=Gr.concatUint8Array([i,n.subarray(1)]),o=bs.sign.detached(a,s);return{r:o.subarray(0,32),s:o.subarray(32)}},verify:async function(e,t,{r,s:n},i,a,s){const o=Gr.concatUint8Array([r,n]);return bs.sign.detached.verify(s,o,a.subarray(1))},validateParams:async function(e,t,r){if("ed25519"!==e.getName())return!1;const{publicKey:n}=bs.sign.keyPair.fromSeed(r),i=new Uint8Array([64,...n]);return Gr.equalsUint8Array(t,i)}});function yo(e,t){const r=new Fn["aes"+8*e.length](e),n=new Uint32Array([2795939494,2795939494]),i=go(t);let a=n;const s=i,o=i.length/2,c=new Uint32Array([0,0]);let u=new Uint32Array(4);for(let e=0;e<=5;++e)for(let t=0;t<o;++t)c[1]=o*e+(1+t),u[0]=a[0],u[1]=a[1],u[2]=s[2*t],u[3]=s[2*t+1],u=go(r.encrypt(mo(u))),a=u.subarray(0,2),a[0]^=c[0],a[1]^=c[1],s[2*t]=u[2],s[2*t+1]=u[3];return mo(a,s)}function po(e,t){const r=new Fn["aes"+8*e.length](e),n=new Uint32Array([2795939494,2795939494]),i=go(t);let a=i.subarray(0,2);const s=i.subarray(2),o=i.length/2-1,c=new Uint32Array([0,0]);let u=new Uint32Array(4);for(let e=5;e>=0;--e)for(let t=o-1;t>=0;--t)c[1]=o*e+(t+1),u[0]=a[0]^c[0],u[1]=a[1]^c[1],u[2]=s[2*t],u[3]=s[2*t+1],u=go(r.decrypt(mo(u))),a=u.subarray(0,2),s[2*t]=u[2],s[2*t+1]=u[3];if(a[0]===n[0]&&a[1]===n[1])return mo(s);throw Error("Key Data Integrity failed")}function go(e){const{length:t}=e,r=function(e){if(Gr.isString(e)){const{length:t}=e,r=new ArrayBuffer(t),n=new Uint8Array(r);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r);return r}return new Uint8Array(e).buffer}(e),n=new DataView(r),i=new Uint32Array(t/4);for(let e=0;e<t/4;++e)i[e]=n.getUint32(4*e);return i}function mo(){let e=0;for(let t=0;t<arguments.length;++t)e+=4*arguments[t].length;const t=new ArrayBuffer(e),r=new DataView(t);let n=0;for(let e=0;e<arguments.length;++e){for(let t=0;t<arguments[e].length;++t)r.setUint32(n+4*t,arguments[e][t]);n+=4*arguments[e].length}return new Uint8Array(t)}var wo=/*#__PURE__*/Object.freeze({__proto__:null,wrap:yo,unwrap:po});function bo(e){const t=8-e.length%8,r=new Uint8Array(e.length+t).fill(t);return r.set(e),r}function _o(e){const t=e.length;if(t>0){const r=e[t-1];if(r>=1){const n=e.subarray(t-r),i=new Uint8Array(r).fill(r);if(Gr.equalsUint8Array(n,i))return e.subarray(0,t-r)}}throw Error("Invalid padding")}var vo=/*#__PURE__*/Object.freeze({__proto__:null,encode:bo,decode:_o});const ko=Gr.getWebCrypto(),Ao=Gr.getNodeCrypto();function So(e,t,r,n){return Gr.concatUint8Array([t.write(),new Uint8Array([e]),r.write(),Gr.strToUint8Array("Anonymous Sender "),n.subarray(0,20)])}async function Eo(e,t,r,n,i=!1,a=!1){let s;if(i){for(s=0;s<t.length&&0===t[s];s++);t=t.subarray(s)}if(a){for(s=t.length-1;s>=0&&0===t[s];s--);t=t.subarray(0,s+1)}return(await Oa.digest(e,Gr.concatUint8Array([new Uint8Array([0,0,0,1]),t,n]))).subarray(0,r)}async function Po(e,t){switch(e.type){case"curve25519":{const r=await vs(32),{secretKey:n,sharedKey:i}=await xo(e,t,null,r);let{publicKey:a}=bs.box.keyPair.fromSecretKey(n);return a=Gr.concatUint8Array([new Uint8Array([64]),a]),{publicKey:a,sharedKey:i}}case"web":if(e.web&&Gr.getWebCrypto())try{return await async function(e,t){const r=eo(e.payloadSize,e.web.web,t);let n=ko.generateKey({name:"ECDH",namedCurve:e.web.web},!0,["deriveKey","deriveBits"]),i=ko.importKey("jwk",r,{name:"ECDH",namedCurve:e.web.web},!1,[]);[n,i]=await Promise.all([n,i]);let a=ko.deriveBits({name:"ECDH",namedCurve:e.web.web,public:i},n.privateKey,e.web.sharedSize),s=ko.exportKey("jwk",n.publicKey);[a,s]=await Promise.all([a,s]);const o=new Uint8Array(a);return{publicKey:new Uint8Array(Js(s)),sharedKey:o}}(e,t)}catch(e){Gr.printDebugError(e)}break;case"node":return async function(e,t){const r=Ao.createECDH(e.node.node);r.generateKeys();const n=new Uint8Array(r.computeSecret(t));return{publicKey:new Uint8Array(r.getPublicKey()),sharedKey:n}}(e,t)}return async function(e,t){const r=await Hs(e.name),n=await e.genKeyPair();t=Fs(r,t);const i=js(r,n.privateKey),a=n.publicKey,s=i.derive(t.getPublic()),o=r.curve.p.byteLength(),c=s.toArrayLike(Uint8Array,"be",o);return{publicKey:a,sharedKey:c}}(e,t)}async function xo(e,t,r,n){if(n.length!==e.payloadSize){const t=new Uint8Array(e.payloadSize);t.set(n,e.payloadSize-n.length),n=t}switch(e.type){case"curve25519":{const e=n.slice().reverse();return{secretKey:e,sharedKey:bs.scalarMult(e,t.subarray(1))}}case"web":if(e.web&&Gr.getWebCrypto())try{return await async function(e,t,r,n){const i=to(e.payloadSize,e.web.web,r,n);let a=ko.importKey("jwk",i,{name:"ECDH",namedCurve:e.web.web},!0,["deriveKey","deriveBits"]);const s=eo(e.payloadSize,e.web.web,t);let o=ko.importKey("jwk",s,{name:"ECDH",namedCurve:e.web.web},!0,[]);[a,o]=await Promise.all([a,o]);let c=ko.deriveBits({name:"ECDH",namedCurve:e.web.web,public:o},a,e.web.sharedSize),u=ko.exportKey("jwk",a);[c,u]=await Promise.all([c,u]);const l=new Uint8Array(c);return{secretKey:Xr(u.d),sharedKey:l}}(e,t,r,n)}catch(e){Gr.printDebugError(e)}break;case"node":return async function(e,t,r){const n=Ao.createECDH(e.node.node);n.setPrivateKey(r);const i=new Uint8Array(n.computeSecret(t));return{secretKey:new Uint8Array(n.getPrivateKey()),sharedKey:i}}(e,t,n)}return async function(e,t,r){const n=await Hs(e.name);t=Fs(n,t),r=js(n,r);const i=new Uint8Array(r.getPrivate()),a=r.derive(t.getPublic()),s=n.curve.p.byteLength(),o=a.toArrayLike(Uint8Array,"be",s);return{secretKey:i,sharedKey:o}}(e,t,n)}var Ko=/*#__PURE__*/Object.freeze({__proto__:null,validateParams:async function(e,t,r){return Xs(tn.publicKey.ecdh,e,t,r)},encrypt:async function(e,t,r,n,i){const a=bo(r),s=new Qs(e),{publicKey:o,sharedKey:c}=await Po(s,n),u=So(tn.publicKey.ecdh,e,t,i),l=tn.read(tn.symmetric,t.cipher);return{publicKey:o,wrappedKey:yo(await Eo(t.hash,c,Fn[l].keySize,u),a)}},decrypt:async function(e,t,r,n,i,a,s){const o=new Qs(e),{sharedKey:c}=await xo(o,r,i,a),u=So(tn.publicKey.ecdh,e,t,s),l=tn.read(tn.symmetric,t.cipher);let h;for(let e=0;e<3;e++)try{return _o(po(await Eo(t.hash,c,Fn[l].keySize,u,1===e,2===e),n))}catch(e){h=e}throw h}});var Co={rsa:Ns,elgamal:Ms,elliptic:/*#__PURE__*/Object.freeze({__proto__:null,Curve:Qs,ecdh:Ko,ecdsa:ho,eddsa:fo,generate:async function(e){const t=await Gr.getBigInteger();e=new Qs(e);const r=await e.genKeyPair(),n=new t(r.publicKey).toUint8Array(),i=new t(r.privateKey).toUint8Array("be",e.payloadSize);return{oid:e.oid,Q:n,secret:i,hash:e.hash,cipher:e.cipher}},getPreferredHashAlgo:function(e){return Zs[tn.write(tn.curve,e.toHex())].hash}}),dsa:/*#__PURE__*/Object.freeze({__proto__:null,sign:async function(e,t,r,n,i,a){const s=await Gr.getBigInteger(),o=new s(1);let c,u,l,h;n=new s(n),i=new s(i),r=new s(r),a=new s(a),r=r.mod(n),a=a.mod(i);const d=new s(t.subarray(0,i.byteLength())).mod(i);for(;;){if(c=await ks(o,i),u=r.modExp(c,n).imod(i),u.isZero())continue;const e=a.mul(u).imod(i);if(h=d.add(e).imod(i),l=c.modInv(i).imul(h).imod(i),!l.isZero())break}return{r:u.toUint8Array("be",i.byteLength()),s:l.toUint8Array("be",i.byteLength())}},verify:async function(e,t,r,n,i,a,s,o){const c=await Gr.getBigInteger(),u=new c(0);if(t=new c(t),r=new c(r),a=new c(a),s=new c(s),i=new c(i),o=new c(o),t.lte(u)||t.gte(s)||r.lte(u)||r.gte(s))return Gr.printDebug("invalid DSA Signature"),!1;const l=new c(n.subarray(0,s.byteLength())).imod(s),h=r.modInv(s);if(h.isZero())return Gr.printDebug("invalid DSA Signature"),!1;i=i.mod(a),o=o.mod(a);const d=l.mul(h).imod(s),f=t.mul(h).imod(s),y=i.modExp(d,a),p=o.modExp(f,a);return y.mul(p).imod(a).imod(s).equal(t)},validateParams:async function(e,t,r,n,i){const a=await Gr.getBigInteger();e=new a(e),t=new a(t),r=new a(r),n=new a(n);const s=new a(1);if(r.lte(s)||r.gte(e))return!1;if(!e.dec().mod(t).isZero())return!1;if(!r.modExp(t,e).isOne())return!1;const o=new a(t.bitLength()),c=new a(150);if(o.lt(c)||!await Ps(t,null,32))return!1;i=new a(i);const u=new a(2),l=await ks(u.leftShift(o.dec()),u.leftShift(o)),h=t.mul(l).add(i);return!!n.equal(r.modExp(h,e))}}),nacl:bs};var Uo=/*#__PURE__*/Object.freeze({__proto__:null,parseSignatureParams:function(e,t){let r=0;switch(e){case tn.publicKey.rsaEncryptSign:case tn.publicKey.rsaEncrypt:case tn.publicKey.rsaSign:return{s:Gr.readMPI(t.subarray(r))};case tn.publicKey.dsa:case tn.publicKey.ecdsa:{const e=Gr.readMPI(t.subarray(r));return r+=e.length+2,{r:e,s:Gr.readMPI(t.subarray(r))}}case tn.publicKey.eddsa:{let e=Gr.readMPI(t.subarray(r));r+=e.length+2,e=Gr.leftPad(e,32);let n=Gr.readMPI(t.subarray(r));return n=Gr.leftPad(n,32),{r:e,s:n}}default:throw Error("Invalid signature algorithm.")}},verify:async function(e,t,r,n,i,a){switch(e){case tn.publicKey.rsaEncryptSign:case tn.publicKey.rsaEncrypt:case tn.publicKey.rsaSign:{const{n:e,e:s}=n,o=Gr.leftPad(r.s,e.length);return Co.rsa.verify(t,i,o,e,s,a)}case tn.publicKey.dsa:{const{g:e,p:i,q:s,y:o}=n,{r:c,s:u}=r;return Co.dsa.verify(t,c,u,a,e,i,s,o)}case tn.publicKey.ecdsa:{const{oid:e,Q:s}=n,o=new Co.elliptic.Curve(e).payloadSize,c=Gr.leftPad(r.r,o),u=Gr.leftPad(r.s,o);return Co.elliptic.ecdsa.verify(e,t,{r:c,s:u},i,s,a)}case tn.publicKey.eddsa:{const{oid:e,Q:s}=n;return Co.elliptic.eddsa.verify(e,t,r,i,s,a)}default:throw Error("Invalid signature algorithm.")}},sign:async function(e,t,r,n,i,a){if(!r||!n)throw Error("Missing key parameters");switch(e){case tn.publicKey.rsaEncryptSign:case tn.publicKey.rsaEncrypt:case tn.publicKey.rsaSign:{const{n:e,e:s}=r,{d:o,p:c,q:u,u:l}=n;return{s:await Co.rsa.sign(t,i,e,s,o,c,u,l,a)}}case tn.publicKey.dsa:{const{g:e,p:i,q:s}=r,{x:o}=n;return Co.dsa.sign(t,a,e,i,s,o)}case tn.publicKey.elgamal:throw Error("Signing with Elgamal is not defined in the OpenPGP standard.");case tn.publicKey.ecdsa:{const{oid:e,Q:s}=r,{d:o}=n;return Co.elliptic.ecdsa.sign(e,t,i,s,o,a)}case tn.publicKey.eddsa:{const{oid:e,Q:s}=r,{seed:o}=n;return Co.elliptic.eddsa.sign(e,t,i,s,o,a)}default:throw Error("Invalid signature algorithm.")}}});class Ro{constructor(e){e=void 0===e?new Uint8Array([]):Gr.isString(e)?Gr.strToUint8Array(e):new Uint8Array(e),this.data=e}read(e){if(e.length>=1){const t=e[0];if(e.length>=1+t)return this.data=e.subarray(1,1+t),1+this.data.length}throw Error("Invalid symmetric key")}write(){return Gr.concatUint8Array([new Uint8Array([this.data.length]),this.data])}}class To{constructor(e){if(e){const{hash:t,cipher:r}=e;this.hash=t,this.cipher=r}else this.hash=null,this.cipher=null}read(e){if(e.length<4||3!==e[0]||1!==e[1])throw Error("Cannot read KDFParams");return this.hash=e[2],this.cipher=e[3],4}write(){return new Uint8Array([3,1,this.hash,this.cipher])}}var Do=/*#__PURE__*/Object.freeze({__proto__:null,publicKeyEncrypt:async function(e,t,r,n){switch(e){case tn.publicKey.rsaEncrypt:case tn.publicKey.rsaEncryptSign:{const{n:e,e:n}=t;return{c:await Co.rsa.encrypt(r,e,n)}}case tn.publicKey.elgamal:{const{p:e,g:n,y:i}=t;return Co.elgamal.encrypt(r,e,n,i)}case tn.publicKey.ecdh:{const{oid:e,Q:i,kdfParams:a}=t,{publicKey:s,wrappedKey:o}=await Co.elliptic.ecdh.encrypt(e,a,r,i,n);return{V:s,C:new Ro(o)}}default:return[]}},publicKeyDecrypt:async function(e,t,r,n,i){switch(e){case tn.publicKey.rsaEncryptSign:case tn.publicKey.rsaEncrypt:{const{c:e}=n,{n:i,e:a}=t,{d:s,p:o,q:c,u}=r;return Co.rsa.decrypt(e,i,a,s,o,c,u)}case tn.publicKey.elgamal:{const{c1:e,c2:i}=n,a=t.p,s=r.x;return Co.elgamal.decrypt(e,i,a,s)}case tn.publicKey.ecdh:{const{oid:e,Q:a,kdfParams:s}=t,{d:o}=r,{V:c,C:u}=n;return Co.elliptic.ecdh.decrypt(e,s,c,u.data,a,o,i)}default:throw Error("Invalid public key encryption algorithm.")}},parsePublicKeyParams:function(e,t){let r=0;switch(e){case tn.publicKey.rsaEncrypt:case tn.publicKey.rsaEncryptSign:case tn.publicKey.rsaSign:{const e=Gr.readMPI(t.subarray(r));r+=e.length+2;const n=Gr.readMPI(t.subarray(r));return r+=n.length+2,{read:r,publicParams:{n:e,e:n}}}case tn.publicKey.dsa:{const e=Gr.readMPI(t.subarray(r));r+=e.length+2;const n=Gr.readMPI(t.subarray(r));r+=n.length+2;const i=Gr.readMPI(t.subarray(r));r+=i.length+2;const a=Gr.readMPI(t.subarray(r));return r+=a.length+2,{read:r,publicParams:{p:e,q:n,g:i,y:a}}}case tn.publicKey.elgamal:{const e=Gr.readMPI(t.subarray(r));r+=e.length+2;const n=Gr.readMPI(t.subarray(r));r+=n.length+2;const i=Gr.readMPI(t.subarray(r));return r+=i.length+2,{read:r,publicParams:{p:e,g:n,y:i}}}case tn.publicKey.ecdsa:{const e=new Ls;r+=e.read(t);const n=Gr.readMPI(t.subarray(r));return r+=n.length+2,{read:r,publicParams:{oid:e,Q:n}}}case tn.publicKey.eddsa:{const e=new Ls;r+=e.read(t);let n=Gr.readMPI(t.subarray(r));return r+=n.length+2,n=Gr.leftPad(n,33),{read:r,publicParams:{oid:e,Q:n}}}case tn.publicKey.ecdh:{const e=new Ls;r+=e.read(t);const n=Gr.readMPI(t.subarray(r));r+=n.length+2;const i=new To;return r+=i.read(t.subarray(r)),{read:r,publicParams:{oid:e,Q:n,kdfParams:i}}}default:throw Error("Invalid public key encryption algorithm.")}},parsePrivateKeyParams:function(e,t,r){let n=0;switch(e){case tn.publicKey.rsaEncrypt:case tn.publicKey.rsaEncryptSign:case tn.publicKey.rsaSign:{const e=Gr.readMPI(t.subarray(n));n+=e.length+2;const r=Gr.readMPI(t.subarray(n));n+=r.length+2;const i=Gr.readMPI(t.subarray(n));n+=i.length+2;const a=Gr.readMPI(t.subarray(n));return n+=a.length+2,{read:n,privateParams:{d:e,p:r,q:i,u:a}}}case tn.publicKey.dsa:case tn.publicKey.elgamal:{const e=Gr.readMPI(t.subarray(n));return n+=e.length+2,{read:n,privateParams:{x:e}}}case tn.publicKey.ecdsa:case tn.publicKey.ecdh:{const e=new Qs(r.oid);let i=Gr.readMPI(t.subarray(n));return n+=i.length+2,i=Gr.leftPad(i,e.payloadSize),{read:n,privateParams:{d:i}}}case tn.publicKey.eddsa:{let e=Gr.readMPI(t.subarray(n));return n+=e.length+2,e=Gr.leftPad(e,32),{read:n,privateParams:{seed:e}}}default:throw Error("Invalid public key encryption algorithm.")}},parseEncSessionKeyParams:function(e,t){let r=0;switch(e){case tn.publicKey.rsaEncrypt:case tn.publicKey.rsaEncryptSign:return{c:Gr.readMPI(t.subarray(r))};case tn.publicKey.elgamal:{const e=Gr.readMPI(t.subarray(r));return r+=e.length+2,{c1:e,c2:Gr.readMPI(t.subarray(r))}}case tn.publicKey.ecdh:{const e=Gr.readMPI(t.subarray(r));r+=e.length+2;const n=new Ro;return n.read(t.subarray(r)),{V:e,C:n}}default:throw Error("Invalid public key encryption algorithm.")}},serializeParams:function(e,t){const r=Object.keys(t).map(e=>{const r=t[e];return Gr.isUint8Array(r)?Gr.uint8ArrayToMpi(r):r.write()});return Gr.concatUint8Array(r)},generateParams:function(e,t,r){switch(e){case tn.publicKey.rsaEncrypt:case tn.publicKey.rsaEncryptSign:case tn.publicKey.rsaSign:return Co.rsa.generate(t,65537).then(({n:e,e:t,d:r,p:n,q:i,u:a})=>({privateParams:{d:r,p:n,q:i,u:a},publicParams:{n:e,e:t}}));case tn.publicKey.ecdsa:return Co.elliptic.generate(r).then(({oid:e,Q:t,secret:r})=>({privateParams:{d:r},publicParams:{oid:new Ls(e),Q:t}}));case tn.publicKey.eddsa:return Co.elliptic.generate(r).then(({oid:e,Q:t,secret:r})=>({privateParams:{seed:r},publicParams:{oid:new Ls(e),Q:t}}));case tn.publicKey.ecdh:return Co.elliptic.generate(r).then(({oid:e,Q:t,secret:r,hash:n,cipher:i})=>({privateParams:{d:r},publicParams:{oid:new Ls(e),Q:t,kdfParams:new To({hash:n,cipher:i})}}));case tn.publicKey.dsa:case tn.publicKey.elgamal:throw Error("Unsupported algorithm for key generation.");default:throw Error("Invalid public key algorithm.")}},validateParams:async function(e,t,r){if(!t||!r)throw Error("Missing key parameters");switch(e){case tn.publicKey.rsaEncrypt:case tn.publicKey.rsaEncryptSign:case tn.publicKey.rsaSign:{const{n:e,e:n}=t,{d:i,p:a,q:s,u:o}=r;return Co.rsa.validateParams(e,n,i,a,s,o)}case tn.publicKey.dsa:{const{p:e,q:n,g:i,y:a}=t,{x:s}=r;return Co.dsa.validateParams(e,n,i,a,s)}case tn.publicKey.elgamal:{const{p:e,g:n,y:i}=t,{x:a}=r;return Co.elgamal.validateParams(e,n,i,a)}case tn.publicKey.ecdsa:case tn.publicKey.ecdh:{const n=Co.elliptic[tn.read(tn.publicKey,e)],{oid:i,Q:a}=t,{d:s}=r;return n.validateParams(i,a,s)}case tn.publicKey.eddsa:{const{oid:e,Q:n}=t,{seed:i}=r;return Co.elliptic.eddsa.validateParams(e,n,i)}default:throw Error("Invalid public key algorithm.")}},getPrefixRandom:async function(e){const t=await vs(Fn[e].blockSize),r=new Uint8Array([t[t.length-2],t[t.length-1]]);return Gr.concat([t,r])},generateSessionKey:function(e){return vs(Fn[e].keySize)}});const Io={cipher:Fn,hash:Oa,cfb:Ha,gcm:Ya,experimentalGcm:Ya,eax:ds,ocb:ws,publicKey:Co,signature:Uo,random:Ss,pkcs1:Ts,pkcs5:vo,aes_kw:wo};Object.assign(Io,Do);var Bo="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function zo(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)}const Oo={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(let a=0;a<n;a++)e[i+a]=t[r+a]},flattenChunks:function(e){let t,r,n,i,a;for(n=0,t=0,r=e.length;t<r;t++)n+=e[t].length;const s=new Uint8Array(n);for(i=0,t=0,r=e.length;t<r;t++)a=e[t],s.set(a,i),i+=a.length;return s}},qo={arraySet:function(e,t,r,n,i){for(let a=0;a<n;a++)e[i+a]=t[r+a]},flattenChunks:function(e){return[].concat.apply([],e)}};let No=Bo?Uint8Array:Array,Mo=Bo?Uint16Array:Array,Lo=Bo?Int32Array:Array,jo=Bo?Oo.flattenChunks:qo.flattenChunks,Fo=Bo?Oo.arraySet:qo.arraySet;function Ho(e){let t=e.length;for(;--t>=0;)e[t]=0}const Wo=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Go=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Vo=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],$o=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Yo=Array(576);Ho(Yo);const Zo=Array(60);Ho(Zo);const Qo=Array(512);Ho(Qo);const Xo=Array(256);Ho(Xo);const Jo=Array(29);Ho(Jo);const ec=Array(30);function tc(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}let rc,nc,ic;function ac(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function sc(e){return e<256?Qo[e]:Qo[256+(e>>>7)]}function oc(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function cc(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,oc(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function uc(e,t,r){cc(e,r[2*t],r[2*t+1])}function lc(e,t){let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function hc(e,t,r){const n=Array(16);let i,a,s=0;for(i=1;i<=15;i++)n[i]=s=s+r[i-1]<<1;for(a=0;a<=t;a++){const t=e[2*a+1];0!==t&&(e[2*a]=lc(n[t]++,t))}}function dc(e){let t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function fc(e){e.bi_valid>8?oc(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function yc(e,t,r,n){const i=2*t,a=2*r;return e[i]<e[a]||e[i]===e[a]&&n[t]<=n[r]}function pc(e,t,r){const n=e.heap[r];let i=r<<1;for(;i<=e.heap_len&&(i<e.heap_len&&yc(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!yc(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function gc(e,t,r){let n,i,a,s,o=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*o]<<8|e.pending_buf[e.d_buf+2*o+1],i=e.pending_buf[e.l_buf+o],o++,0===n?uc(e,i,t):(a=Xo[i],uc(e,a+256+1,t),s=Wo[a],0!==s&&(i-=Jo[a],cc(e,i,s)),n--,a=sc(n),uc(e,a,r),s=Go[a],0!==s&&(n-=ec[a],cc(e,n,s)))}while(o<e.last_lit);uc(e,256,t)}function mc(e,t){const r=t.dyn_tree,n=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems;let s,o,c,u=-1;for(e.heap_len=0,e.heap_max=573,s=0;s<a;s++)0!==r[2*s]?(e.heap[++e.heap_len]=u=s,e.depth[s]=0):r[2*s+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=u<2?++u:0,r[2*c]=1,e.depth[c]=0,e.opt_len--,i&&(e.static_len-=n[2*c+1]);for(t.max_code=u,s=e.heap_len>>1;s>=1;s--)pc(e,r,s);c=a;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],pc(e,r,1),o=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=o,r[2*c]=r[2*s]+r[2*o],e.depth[c]=(e.depth[s]>=e.depth[o]?e.depth[s]:e.depth[o])+1,r[2*s+1]=r[2*o+1]=c,e.heap[1]=c++,pc(e,r,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){const r=t.dyn_tree,n=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,c=t.stat_desc.max_length;let u,l,h,d,f,y,p=0;for(d=0;d<=15;d++)e.bl_count[d]=0;for(r[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;u<573;u++)l=e.heap[u],d=r[2*r[2*l+1]+1]+1,d>c&&(d=c,p++),r[2*l+1]=d,l>n||(e.bl_count[d]++,f=0,l>=o&&(f=s[l-o]),y=r[2*l],e.opt_len+=y*(d+f),a&&(e.static_len+=y*(i[2*l+1]+f)));if(0!==p){do{for(d=c-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[c]--,p-=2}while(p>0);for(d=c;0!==d;d--)for(l=e.bl_count[d];0!==l;)h=e.heap[--u],h>n||(r[2*h+1]!==d&&(e.opt_len+=(d-r[2*h+1])*r[2*h],r[2*h+1]=d),l--)}}(e,t),hc(r,u,e.bl_count)}function wc(e,t,r){let n,i,a=-1,s=t[1],o=0,c=7,u=4;for(0===s&&(c=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=s,s=t[2*(n+1)+1],++o<c&&i===s||(o<u?e.bl_tree[2*i]+=o:0!==i?(i!==a&&e.bl_tree[2*i]++,e.bl_tree[32]++):o<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=0,a=i,0===s?(c=138,u=3):i===s?(c=6,u=3):(c=7,u=4))}function bc(e,t,r){let n,i,a=-1,s=t[1],o=0,c=7,u=4;for(0===s&&(c=138,u=3),n=0;n<=r;n++)if(i=s,s=t[2*(n+1)+1],!(++o<c&&i===s)){if(o<u)do{uc(e,i,e.bl_tree)}while(0!=--o);else 0!==i?(i!==a&&(uc(e,i,e.bl_tree),o--),uc(e,16,e.bl_tree),cc(e,o-3,2)):o<=10?(uc(e,17,e.bl_tree),cc(e,o-3,3)):(uc(e,18,e.bl_tree),cc(e,o-11,7));o=0,a=i,0===s?(c=138,u=3):i===s?(c=6,u=3):(c=7,u=4)}}Ho(ec);let _c=!1;function vc(e){_c||(!function(){let e,t,r,n,i;const a=Array(16);for(r=0,n=0;n<28;n++)for(Jo[n]=r,e=0;e<1<<Wo[n];e++)Xo[r++]=n;for(Xo[r-1]=n,i=0,n=0;n<16;n++)for(ec[n]=i,e=0;e<1<<Go[n];e++)Qo[i++]=n;for(i>>=7;n<30;n++)for(ec[n]=i<<7,e=0;e<1<<Go[n]-7;e++)Qo[256+i++]=n;for(t=0;t<=15;t++)a[t]=0;for(e=0;e<=143;)Yo[2*e+1]=8,e++,a[8]++;for(;e<=255;)Yo[2*e+1]=9,e++,a[9]++;for(;e<=279;)Yo[2*e+1]=7,e++,a[7]++;for(;e<=287;)Yo[2*e+1]=8,e++,a[8]++;for(hc(Yo,287,a),e=0;e<30;e++)Zo[2*e+1]=5,Zo[2*e]=lc(e,5);rc=new tc(Yo,Wo,257,286,15),nc=new tc(Zo,Go,0,30,15),ic=new tc([],Vo,0,19,7)}(),_c=!0),e.l_desc=new ac(e.dyn_ltree,rc),e.d_desc=new ac(e.dyn_dtree,nc),e.bl_desc=new ac(e.bl_tree,ic),e.bi_buf=0,e.bi_valid=0,dc(e)}function kc(e,t,r,n){cc(e,0+(n?1:0),3),function(e,t,r,n){fc(e),n&&(oc(e,r),oc(e,~r)),Fo(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}function Ac(e){cc(e,2,3),uc(e,256,Yo),function(e){16===e.bi_valid?(oc(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}function Sc(e,t,r,n){let i,a,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){let t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),mc(e,e.l_desc),mc(e,e.d_desc),s=function(e){let t;for(wc(e,e.dyn_ltree,e.l_desc.max_code),wc(e,e.dyn_dtree,e.d_desc.max_code),mc(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*$o[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=i&&(i=a)):i=a=r+5,r+4<=i&&-1!==t?kc(e,t,r,n):4===e.strategy||a===i?(cc(e,2+(n?1:0),3),gc(e,Yo,Zo)):(cc(e,4+(n?1:0),3),function(e,t,r,n){let i;for(cc(e,t-257,5),cc(e,r-1,5),cc(e,n-4,4),i=0;i<n;i++)cc(e,e.bl_tree[2*$o[i]+1],3);bc(e,e.dyn_ltree,t-1),bc(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),gc(e,e.dyn_ltree,e.dyn_dtree)),dc(e),n&&fc(e)}function Ec(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(Xo[r]+256+1)]++,e.dyn_dtree[2*sc(t)]++),e.last_lit===e.lit_bufsize-1}function Pc(e,t,r,n){let i=65535&e|0,a=e>>>16&65535|0,s=0;for(;0!==r;){s=r>2e3?2e3:r,r-=s;do{i=i+t[n++]|0,a=a+i|0}while(--s);i%=65521,a%=65521}return i|a<<16|0}const xc=function(){let e;const t=[];for(let r=0;r<256;r++){e=r;for(let t=0;t<8;t++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();function Kc(e,t,r,n){const i=xc,a=n+r;e^=-1;for(let r=n;r<a;r++)e=e>>>8^i[255&(e^t[r])];return-1^e}var Cc={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function Uc(e,t){return e.msg=Cc[t],t}function Rc(e){return(e<<1)-(e>4?9:0)}function Tc(e){let t=e.length;for(;--t>=0;)e[t]=0}function Dc(e){const t=e.state;let r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(Fo(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function Ic(e,t){Sc(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Dc(e.strm)}function Bc(e,t){e.pending_buf[e.pending++]=t}function zc(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function Oc(e,t,r,n){let i=e.avail_in;return i>n&&(i=n),0===i?0:(e.avail_in-=i,Fo(t,e.input,e.next_in,i,r),1===e.state.wrap?e.adler=Pc(e.adler,t,i,r):2===e.state.wrap&&(e.adler=Kc(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)}function qc(e,t){let r,n,i=e.max_chain_length,a=e.strstart,s=e.prev_length,o=e.nice_match;const c=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,u=e.window,l=e.w_mask,h=e.prev,d=e.strstart+258;let f=u[a+s-1],y=u[a+s];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do{if(r=t,u[r+s]===y&&u[r+s-1]===f&&u[r]===u[a]&&u[++r]===u[a+1]){a+=2,r++;do{}while(u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&u[++a]===u[++r]&&a<d);if(n=258-(d-a),a=d-258,n>s){if(e.match_start=t,s=n,n>=o)break;f=u[a+s-1],y=u[a+s]}}}while((t=h[t&l])>c&&0!=--i);return s<=e.lookahead?s:e.lookahead}function Nc(e){const t=e.w_size;let r,n,i,a,s;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-262)){Fo(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,n=e.hash_size,r=n;do{i=e.head[--r],e.head[r]=i>=t?i-t:0}while(--n);n=t,r=n;do{i=e.prev[--r],e.prev[r]=i>=t?i-t:0}while(--n);a+=t}if(0===e.strm.avail_in)break;if(n=Oc(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=n,e.lookahead+e.insert>=3)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+3-1])&e.hash_mask,e.prev[s&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=s,s++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<262&&0!==e.strm.avail_in)}function Mc(e,t){let r,n;for(;;){if(e.lookahead<262){if(Nc(e),e.lookahead<262&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-262&&(e.match_length=qc(e,r)),e.match_length>=3)if(n=Ec(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=Ec(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(Ic(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(Ic(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(Ic(e,!1),0===e.strm.avail_out)?1:2}function Lc(e,t){let r,n,i;for(;;){if(e.lookahead<262){if(Nc(e),e.lookahead<262&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-262&&(e.match_length=qc(e,r),e.match_length<=5&&(1===e.strategy||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=Ec(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(Ic(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(n=Ec(e,0,e.window[e.strstart-1]),n&&Ic(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Ec(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(Ic(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(Ic(e,!1),0===e.strm.avail_out)?1:2}class jc{constructor(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}}const Fc=[new jc(0,0,0,0,(function(e,t){let r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Nc(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;const n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,Ic(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-262&&(Ic(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(Ic(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(Ic(e,!1),e.strm.avail_out),1)})),new jc(4,4,8,4,Mc),new jc(4,5,16,8,Mc),new jc(4,6,32,32,Mc),new jc(4,4,16,16,Lc),new jc(8,16,32,32,Lc),new jc(8,16,128,128,Lc),new jc(8,32,128,256,Lc),new jc(32,128,258,1024,Lc),new jc(32,258,258,4096,Lc)];class Hc{constructor(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Mo(1146),this.dyn_dtree=new Mo(122),this.bl_tree=new Mo(78),Tc(this.dyn_ltree),Tc(this.dyn_dtree),Tc(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Mo(16),this.heap=new Mo(573),Tc(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Mo(573),Tc(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}}function Wc(e){const t=function(e){let t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:113,e.adler=2===t.wrap?0:1,t.last_flush=0,vc(t),0):Uc(e,-2)}(e);return 0===t&&function(e){e.window_size=2*e.w_size,Tc(e.head),e.max_lazy_match=Fc[e.level].max_lazy,e.good_match=Fc[e.level].good_length,e.nice_match=Fc[e.level].nice_length,e.max_chain_length=Fc[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0}(e.state),t}function Gc(e,t){let r,n,i,a;if(!e||!e.state||t>5||t<0)return e?Uc(e,-2):-2;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||666===n.status&&4!==t)return Uc(e,0===e.avail_out?-5:-2);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,Bc(n,31),Bc(n,139),Bc(n,8),n.gzhead?(Bc(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),Bc(n,255&n.gzhead.time),Bc(n,n.gzhead.time>>8&255),Bc(n,n.gzhead.time>>16&255),Bc(n,n.gzhead.time>>24&255),Bc(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),Bc(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(Bc(n,255&n.gzhead.extra.length),Bc(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Kc(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(Bc(n,0),Bc(n,0),Bc(n,0),Bc(n,0),Bc(n,0),Bc(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),Bc(n,3),n.status=113);else{let t=8+(n.w_bits-8<<4)<<8,r=-1;r=n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=r<<6,0!==n.strstart&&(t|=32),t+=31-t%31,n.status=113,zc(n,t),0!==n.strstart&&(zc(n,e.adler>>>16),zc(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=Kc(e.adler,n.pending_buf,n.pending-i,i)),Dc(e),i=n.pending,n.pending!==n.pending_buf_size));)Bc(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=Kc(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=Kc(e.adler,n.pending_buf,n.pending-i,i)),Dc(e),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}a=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,Bc(n,a)}while(0!==a);n.gzhead.hcrc&&n.pending>i&&(e.adler=Kc(e.adler,n.pending_buf,n.pending-i,i)),0===a&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=Kc(e.adler,n.pending_buf,n.pending-i,i)),Dc(e),i=n.pending,n.pending===n.pending_buf_size)){a=1;break}a=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,Bc(n,a)}while(0!==a);n.gzhead.hcrc&&n.pending>i&&(e.adler=Kc(e.adler,n.pending_buf,n.pending-i,i)),0===a&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&Dc(e),n.pending+2<=n.pending_buf_size&&(Bc(n,255&e.adler),Bc(n,e.adler>>8&255),e.adler=0,n.status=113)):n.status=113),0!==n.pending){if(Dc(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&Rc(t)<=Rc(r)&&4!==t)return Uc(e,-5);if(666===n.status&&0!==e.avail_in)return Uc(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&666!==n.status){var s=2===n.strategy?function(e,t){let r;for(;;){if(0===e.lookahead&&(Nc(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=Ec(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(Ic(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(Ic(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(Ic(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){let r,n,i,a;const s=e.window;for(;;){if(e.lookahead<=258){if(Nc(e),e.lookahead<=258&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=e.strstart-1,n=s[i],n===s[++i]&&n===s[++i]&&n===s[++i])){a=e.strstart+258;do{}while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<a);e.match_length=258-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=Ec(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Ec(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(Ic(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(Ic(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(Ic(e,!1),0===e.strm.avail_out)?1:2}(n,t):Fc[n.level].func(n,t);if(3!==s&&4!==s||(n.status=666),1===s||3===s)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===s&&(1===t?Ac(n):5!==t&&(kc(n,0,0,!1),3===t&&(Tc(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Dc(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(Bc(n,255&e.adler),Bc(n,e.adler>>8&255),Bc(n,e.adler>>16&255),Bc(n,e.adler>>24&255),Bc(n,255&e.total_in),Bc(n,e.total_in>>8&255),Bc(n,e.total_in>>16&255),Bc(n,e.total_in>>24&255)):(zc(n,e.adler>>>16),zc(n,65535&e.adler)),Dc(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)}try{String.fromCharCode.call(null,0)}catch(e){}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){}const Vc=new No(256);for(let e=0;e<256;e++)Vc[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;function $c(e){let t,r,n,i,a=0;const s=e.length;for(n=0;n<s;n++)t=e.charCodeAt(n),55296==(64512&t)&&n+1<s&&(r=e.charCodeAt(n+1),56320==(64512&r)&&(t=65536+(t-55296<<10)+(r-56320),n++)),a+=t<128?1:t<2048?2:t<65536?3:4;const o=new No(a);for(i=0,n=0;i<a;n++)t=e.charCodeAt(n),55296==(64512&t)&&n+1<s&&(r=e.charCodeAt(n+1),56320==(64512&r)&&(t=65536+(t-55296<<10)+(r-56320),n++)),t<128?o[i++]=t:t<2048?(o[i++]=192|t>>>6,o[i++]=128|63&t):t<65536?(o[i++]=224|t>>>12,o[i++]=128|t>>>6&63,o[i++]=128|63&t):(o[i++]=240|t>>>18,o[i++]=128|t>>>12&63,o[i++]=128|t>>>6&63,o[i++]=128|63&t);return o}Vc[254]=Vc[254]=1;class Yc{constructor(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}}class Zc{constructor(e){this.options={level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,...e||{}};const t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Yc,this.strm.avail_out=0;var r,n,i=function(e,t,r,n,i,a){if(!e)return-2;let s=1;if(-1===t&&(t=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),i<1||i>9||8!==r||n<8||n>15||t<0||t>9||a<0||a>4)return Uc(e,-2);8===n&&(n=9);const o=new Hc;return e.state=o,o.strm=e,o.wrap=s,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=i+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new No(2*o.w_size),o.head=new Mo(o.hash_size),o.prev=new Mo(o.w_size),o.lit_bufsize=1<<i+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new No(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=t,o.strategy=a,o.method=r,Wc(e)}(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==i)throw Error(Cc[i]);if(t.header&&(r=this.strm,n=t.header,r&&r.state&&(2!==r.state.wrap||(r.state.gzhead=n))),t.dictionary){let e;if(e="string"==typeof t.dictionary?$c(t.dictionary):t.dictionary instanceof ArrayBuffer?new Uint8Array(t.dictionary):t.dictionary,0!==(i=function(e,t){const r=t.length;let n,i,a,s,o,c,u,l;if(!e||!e.state)return-2;if(n=e.state,s=n.wrap,2===s||1===s&&42!==n.status||n.lookahead)return-2;for(1===s&&(e.adler=Pc(e.adler,t,r,0)),n.wrap=0,r>=n.w_size&&(0===s&&(Tc(n.head),n.strstart=0,n.block_start=0,n.insert=0),l=new No(n.w_size),Fo(l,t,r-n.w_size,n.w_size,0),t=l,r=n.w_size),o=e.avail_in,c=e.next_in,u=e.input,e.avail_in=r,e.next_in=0,e.input=t,Nc(n);n.lookahead>=3;){i=n.strstart,a=n.lookahead-2;do{n.ins_h=(n.ins_h<<n.hash_shift^n.window[i+3-1])&n.hash_mask,n.prev[i&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=i,i++}while(--a);n.strstart=i,n.lookahead=2,Nc(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=c,e.input=u,e.avail_in=o,n.wrap=s,0}(this.strm,e)))throw Error(Cc[i]);this._dict_set=!0}}push(e,t){const{strm:r,options:{chunkSize:n}}=this;var i,a;if(this.ended)return!1;a=t===~~t?t:!0===t?4:0,"string"==typeof e?r.input=$c(e):e instanceof ArrayBuffer?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;do{if(0===r.avail_out&&(r.output=new No(n),r.next_out=0,r.avail_out=n),1!==(i=Gc(r,a))&&0!==i)return this.onEnd(i),this.ended=!0,!1;0!==r.avail_out&&(0!==r.avail_in||4!==a&&2!==a)||this.onData(zo(r.output,r.next_out))}while((r.avail_in>0||0===r.avail_out)&&1!==i);return 4===a?(i=function(e){let t;return e&&e.state?(t=e.state.status,42!==t&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?Uc(e,-2):(e.state=null,113===t?Uc(e,-3):0)):-2}(this.strm),this.onEnd(i),this.ended=!0,0===i):2!==a||(this.onEnd(0),r.avail_out=0,!0)}onData(e){this.chunks.push(e)}onEnd(e){0===e&&(this.result=jo(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg}}function Qc(e,t){let r,n,i,a,s,o,c,u,l,h;const d=e.state;r=e.next_in;const f=e.input,y=r+(e.avail_in-5);n=e.next_out;const p=e.output,g=n-(t-e.avail_out),m=n+(e.avail_out-257),w=d.dmax,b=d.wsize,_=d.whave,v=d.wnext,k=d.window;i=d.hold,a=d.bits;const A=d.lencode,S=d.distcode,E=(1<<d.lenbits)-1,P=(1<<d.distbits)-1;e:do{a<15&&(i+=f[r++]<<a,a+=8,i+=f[r++]<<a,a+=8),s=A[i&E];t:for(;;){if(o=s>>>24,i>>>=o,a-=o,o=s>>>16&255,0===o)p[n++]=65535&s;else{if(!(16&o)){if(0==(64&o)){s=A[(65535&s)+(i&(1<<o)-1)];continue t}if(32&o){d.mode=12;break e}e.msg="invalid literal/length code",d.mode=30;break e}c=65535&s,o&=15,o&&(a<o&&(i+=f[r++]<<a,a+=8),c+=i&(1<<o)-1,i>>>=o,a-=o),a<15&&(i+=f[r++]<<a,a+=8,i+=f[r++]<<a,a+=8),s=S[i&P];r:for(;;){if(o=s>>>24,i>>>=o,a-=o,o=s>>>16&255,!(16&o)){if(0==(64&o)){s=S[(65535&s)+(i&(1<<o)-1)];continue r}e.msg="invalid distance code",d.mode=30;break e}if(u=65535&s,o&=15,a<o&&(i+=f[r++]<<a,a+=8,a<o&&(i+=f[r++]<<a,a+=8)),u+=i&(1<<o)-1,u>w){e.msg="invalid distance too far back",d.mode=30;break e}if(i>>>=o,a-=o,o=n-g,u>o){if(o=u-o,o>_&&d.sane){e.msg="invalid distance too far back",d.mode=30;break e}if(l=0,h=k,0===v){if(l+=b-o,o<c){c-=o;do{p[n++]=k[l++]}while(--o);l=n-u,h=p}}else if(v<o){if(l+=b+v-o,o-=v,o<c){c-=o;do{p[n++]=k[l++]}while(--o);if(l=0,v<c){o=v,c-=o;do{p[n++]=k[l++]}while(--o);l=n-u,h=p}}}else if(l+=v-o,o<c){c-=o;do{p[n++]=k[l++]}while(--o);l=n-u,h=p}for(;c>2;)p[n++]=h[l++],p[n++]=h[l++],p[n++]=h[l++],c-=3;c&&(p[n++]=h[l++],c>1&&(p[n++]=h[l++]))}else{l=n-u;do{p[n++]=p[l++],p[n++]=p[l++],p[n++]=p[l++],c-=3}while(c>2);c&&(p[n++]=p[l++],c>1&&(p[n++]=p[l++]))}break}}break}}while(r<y&&n<m);c=a>>3,r-=c,a-=c<<3,i&=(1<<a)-1,e.next_in=r,e.next_out=n,e.avail_in=r<y?y-r+5:5-(r-y),e.avail_out=n<m?m-n+257:257-(n-m),d.hold=i,d.bits=a}const Xc=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Jc=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],eu=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],tu=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];function ru(e,t,r,n,i,a,s,o){const c=o.bits;let u,l,h,d,f,y=0,p=0,g=0,m=0,w=0,b=0,_=0,v=0,k=0,A=0,S=null,E=0;const P=new Mo(16),x=new Mo(16);let K,C,U,R=null,T=0;for(y=0;y<=15;y++)P[y]=0;for(p=0;p<n;p++)P[t[r+p]]++;for(w=c,m=15;m>=1&&0===P[m];m--);if(w>m&&(w=m),0===m)return i[a++]=20971520,i[a++]=20971520,o.bits=1,0;for(g=1;g<m&&0===P[g];g++);for(w<g&&(w=g),v=1,y=1;y<=15;y++)if(v<<=1,v-=P[y],v<0)return-1;if(v>0&&(0===e||1!==m))return-1;for(x[1]=0,y=1;y<15;y++)x[y+1]=x[y]+P[y];for(p=0;p<n;p++)0!==t[r+p]&&(s[x[t[r+p]]++]=p);0===e?(S=R=s,f=19):1===e?(S=Xc,E-=257,R=Jc,T-=257,f=256):(S=eu,R=tu,f=-1),A=0,p=0,y=g,d=a,b=w,_=0,h=-1,k=1<<w;const D=k-1;if(1===e&&k>852||2===e&&k>592)return 1;for(;;){K=y-_,s[p]<f?(C=0,U=s[p]):s[p]>f?(C=R[T+s[p]],U=S[E+s[p]]):(C=96,U=0),u=1<<y-_,l=1<<b,g=l;do{l-=u,i[d+(A>>_)+l]=K<<24|C<<16|U|0}while(0!==l);for(u=1<<y-1;A&u;)u>>=1;if(0!==u?(A&=u-1,A+=u):A=0,p++,0==--P[y]){if(y===m)break;y=t[r+s[p]]}if(y>w&&(A&D)!==h){for(0===_&&(_=w),d+=g,b=y-_,v=1<<b;b+_<m&&(v-=P[b+_],!(v<=0));)b++,v<<=1;if(k+=1<<b,1===e&&k>852||2===e&&k>592)return 1;h=A&D,i[h]=w<<24|b<<16|d-a|0}}return 0!==A&&(i[d+A]=y-_<<24|64<<16|0),o.bits=w,0}function nu(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}class iu{constructor(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Mo(320),this.work=new Mo(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}}function au(e){let t;return e&&e.state?(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,function(e){let t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Lo(852),t.distcode=t.distdyn=new Lo(592),t.sane=1,t.back=-1,0):-2}(e)):-2}function su(e,t){let r,n;return e?(n=new iu,e.state=n,n.window=null,r=function(e,t){let r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?-2:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,au(e))):-2}(e,t),0!==r&&(e.state=null),r):-2}let ou,cu,uu=!0;function lu(e){if(uu){let t;for(ou=new Lo(512),cu=new Lo(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(ru(1,e.lens,0,288,ou,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ru(2,e.lens,0,32,cu,0,e.work,{bits:5}),uu=!1}e.lencode=ou,e.lenbits=9,e.distcode=cu,e.distbits=5}function hu(e,t,r,n){let i;const a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new No(a.wsize)),n>=a.wsize?(Fo(a.window,t,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>n&&(i=n),Fo(a.window,t,r-n,i,a.wnext),(n-=i)?(Fo(a.window,t,r-n,n,0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0}function du(e,t){let r,n,i,a,s,o,c,u,l,h,d,f,y,p,g,m,w,b,_,v,k,A,S,E,P=0,x=new No(4);const K=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return-2;r=e.state,12===r.mode&&(r.mode=13),s=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,u=r.hold,l=r.bits,h=o,d=c,A=0;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;l<16;){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}if(2&r.wrap&&35615===u){r.check=0,x[0]=255&u,x[1]=u>>>8&255,r.check=Kc(r.check,x,2,0),u=0,l=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=30;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=30;break}if(u>>>=4,l-=4,k=8+(15&u),0===r.wbits)r.wbits=k;else if(k>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<<k,e.adler=r.check=1,r.mode=512&u?10:12,u=0,l=0;break;case 2:for(;l<16;){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}if(r.flags=u,8!=(255&r.flags)){e.msg="unknown compression method",r.mode=30;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=30;break}r.head&&(r.head.text=u>>8&1),512&r.flags&&(x[0]=255&u,x[1]=u>>>8&255,r.check=Kc(r.check,x,2,0)),u=0,l=0,r.mode=3;case 3:for(;l<32;){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}r.head&&(r.head.time=u),512&r.flags&&(x[0]=255&u,x[1]=u>>>8&255,x[2]=u>>>16&255,x[3]=u>>>24&255,r.check=Kc(r.check,x,4,0)),u=0,l=0,r.mode=4;case 4:for(;l<16;){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&r.flags&&(x[0]=255&u,x[1]=u>>>8&255,r.check=Kc(r.check,x,2,0)),u=0,l=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}r.length=u,r.head&&(r.head.extra_len=u),512&r.flags&&(x[0]=255&u,x[1]=u>>>8&255,r.check=Kc(r.check,x,2,0)),u=0,l=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(f=r.length,f>o&&(f=o),f&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=Array(r.head.extra_len)),Fo(r.head.extra,n,a,f,k)),512&r.flags&&(r.check=Kc(r.check,n,f,a)),o-=f,a+=f,r.length-=f),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break e;f=0;do{k=n[a+f++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k))}while(k&&f<o);if(512&r.flags&&(r.check=Kc(r.check,n,f,a)),o-=f,a+=f,k)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===o)break e;f=0;do{k=n[a+f++],r.head&&k&&r.length<65536&&(r.head.comment+=String.fromCharCode(k))}while(k&&f<o);if(512&r.flags&&(r.check=Kc(r.check,n,f,a)),o-=f,a+=f,k)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;l<16;){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}if(u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=30;break}u=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;l<32;){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}e.adler=r.check=nu(u),u=0,l=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=s,e.avail_out=c,e.next_in=a,e.avail_in=o,r.hold=u,r.bits=l,2;e.adler=r.check=1,r.mode=12;case 12:if(5===t||6===t)break e;case 13:if(r.last){u>>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}switch(r.last=1&u,u>>>=1,l-=1,3&u){case 0:r.mode=14;break;case 1:if(lu(r),r.mode=20,6===t){u>>>=2,l-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}u>>>=2,l-=2;break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&u,u=0,l=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(f=r.length,f){if(f>o&&(f=o),f>c&&(f=c),0===f)break e;Fo(i,n,a,f,s),o-=f,a+=f,c-=f,s+=f,r.length-=f;break}r.mode=12;break;case 17:for(;l<14;){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}if(r.nlen=257+(31&u),u>>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;l<3;){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}r.lens[K[r.have++]]=7&u,u>>>=3,l-=3}for(;r.have<19;)r.lens[K[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},A=ru(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,A){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;P=r.lencode[u&(1<<r.lenbits)-1],g=P>>>24,m=P>>>16&255,w=65535&P,!(g<=l);){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}if(w<16)u>>>=g,l-=g,r.lens[r.have++]=w;else{if(16===w){for(E=g+2;l<E;){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}if(u>>>=g,l-=g,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}k=r.lens[r.have-1],f=3+(3&u),u>>>=2,l-=2}else if(17===w){for(E=g+3;l<E;){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}u>>>=g,l-=g,k=0,f=3+(7&u),u>>>=3,l-=3}else{for(E=g+7;l<E;){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}u>>>=g,l-=g,k=0,f=11+(127&u),u>>>=7,l-=7}if(r.have+f>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;f--;)r.lens[r.have++]=k}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,S={bits:r.lenbits},A=ru(1,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,A){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},A=ru(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,A){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(o>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=a,e.avail_in=o,r.hold=u,r.bits=l,Qc(e,d),s=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,u=r.hold,l=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;P=r.lencode[u&(1<<r.lenbits)-1],g=P>>>24,m=P>>>16&255,w=65535&P,!(g<=l);){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}if(m&&0==(240&m)){for(b=g,_=m,v=w;P=r.lencode[v+((u&(1<<b+_)-1)>>b)],g=P>>>24,m=P>>>16&255,w=65535&P,!(b+g<=l);){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}u>>>=b,l-=b,r.back+=b}if(u>>>=g,l-=g,r.back+=g,r.length=w,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=12;break}if(64&m){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(E=r.extra;l<E;){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;P=r.distcode[u&(1<<r.distbits)-1],g=P>>>24,m=P>>>16&255,w=65535&P,!(g<=l);){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}if(0==(240&m)){for(b=g,_=m,v=w;P=r.distcode[v+((u&(1<<b+_)-1)>>b)],g=P>>>24,m=P>>>16&255,w=65535&P,!(b+g<=l);){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}u>>>=b,l-=b,r.back+=b}if(u>>>=g,l-=g,r.back+=g,64&m){e.msg="invalid distance code",r.mode=30;break}r.offset=w,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(E=r.extra;l<E;){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===c)break e;if(f=d-c,r.offset>f){if(f=r.offset-f,f>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}f>r.wnext?(f-=r.wnext,y=r.wsize-f):y=r.wnext-f,f>r.length&&(f=r.length),p=r.window}else p=i,y=s-r.offset,f=r.length;f>c&&(f=c),c-=f,r.length-=f;do{i[s++]=p[y++]}while(--f);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[s++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;l<32;){if(0===o)break e;o--,u|=n[a++]<<l,l+=8}if(d-=c,e.total_out+=d,r.total+=d,d&&(e.adler=r.check=r.flags?Kc(r.check,i,d,s-d):Pc(r.check,i,d,s-d)),d=c,(r.flags?u:nu(u))!==r.check){e.msg="incorrect data check",r.mode=30;break}u=0,l=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;l<32;){if(0===o)break e;o--,u+=n[a++]<<l,l+=8}if(u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=30;break}u=0,l=0}r.mode=29;case 29:A=1;break e;case 30:A=-3;break e;case 32:default:return-2}return e.next_out=s,e.avail_out=c,e.next_in=a,e.avail_in=o,r.hold=u,r.bits=l,(r.wsize||d!==e.avail_out&&r.mode<30&&(r.mode<27||4!==t))&&hu(e,e.output,e.next_out,d-e.avail_out),h-=e.avail_in,d-=e.avail_out,e.total_in+=h,e.total_out+=d,r.total+=d,r.wrap&&d&&(e.adler=r.check=r.flags?Kc(r.check,i,d,e.next_out-d):Pc(r.check,i,d,e.next_out-d)),e.data_type=r.bits+(r.last?64:0)+(12===r.mode?128:0)+(20===r.mode||15===r.mode?256:0),(0===h&&0===d||4===t)&&0===A&&(A=-5),A}function fu(e,t){const r=t.length;let n,i;return e&&e.state?(n=e.state,0!==n.wrap&&11!==n.mode?-2:11===n.mode&&(i=1,i=Pc(i,t,r,0),i!==n.check)?-3:(hu(e,t,r,r),n.havedict=1,0)):-2}class yu{constructor(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}}class pu{constructor(e){this.options={chunkSize:16384,windowBits:0,...e||{}};const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Yc,this.strm.avail_out=0;let r=su(this.strm,t.windowBits);if(0!==r)throw Error(Cc[r]);if(this.header=new yu,function(e,t){let r;e&&e.state&&(r=e.state,0==(2&r.wrap)||(r.head=t,t.done=!1))}(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=$c(t.dictionary):t.dictionary instanceof ArrayBuffer&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=fu(this.strm,t.dictionary),0!==r)))throw Error(Cc[r])}push(e,t){const{strm:r,options:{chunkSize:n,dictionary:i}}=this;let a,s,o=!1;if(this.ended)return!1;s=t===~~t?t:!0===t?4:0,"string"==typeof e?r.input=function(e){const t=new No(e.length);for(let r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t}(e):e instanceof ArrayBuffer?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;do{if(0===r.avail_out&&(r.output=new No(n),r.next_out=0,r.avail_out=n),a=du(r,0),2===a&&i&&(a=fu(this.strm,i)),-5===a&&!0===o&&(a=0,o=!1),1!==a&&0!==a)return this.onEnd(a),this.ended=!0,!1;r.next_out&&(0!==r.avail_out&&1!==a&&(0!==r.avail_in||4!==s&&2!==s)||this.onData(zo(r.output,r.next_out))),0===r.avail_in&&0===r.avail_out&&(o=!0)}while((r.avail_in>0||0===r.avail_out)&&1!==a);return 1===a&&(s=4),4===s?(a=function(e){if(!e||!e.state)return-2;const t=e.state;return t.window&&(t.window=null),e.state=null,0}(this.strm),this.onEnd(a),this.ended=!0,0===a):2!==s||(this.onEnd(0),r.avail_out=0,!0)}onData(e){this.chunks.push(e)}onEnd(e){0===e&&(this.result=jo(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg}}var gu=[0,1,3,7,15,31,63,127,255],mu=function(e){this.stream=e,this.bitOffset=0,this.curByte=0,this.hasByte=!1};mu.prototype._ensureByte=function(){this.hasByte||(this.curByte=this.stream.readByte(),this.hasByte=!0)},mu.prototype.read=function(e){for(var t=0;e>0;){this._ensureByte();var r=8-this.bitOffset;if(e>=r)t<<=r,t|=gu[r]&this.curByte,this.hasByte=!1,this.bitOffset=0,e-=r;else{t<<=e;var n=r-e;t|=(this.curByte&gu[e]<<n)>>n,this.bitOffset+=e,e=0}}return t},mu.prototype.seek=function(e){var t=e%8,r=(e-t)/8;this.bitOffset=t,this.stream.seek(r),this.hasByte=!1},mu.prototype.pi=function(){var e,t=new Uint8Array(6);for(e=0;e<t.length;e++)t[e]=this.read(8);return function(e){return Array.prototype.map.call(e,e=>("00"+e.toString(16)).slice(-2)).join("")}(t)};var wu=mu,bu=function(){};bu.prototype.readByte=function(){throw Error("abstract method readByte() not implemented")},bu.prototype.read=function(e,t,r){for(var n=0;n<r;){var i=this.readByte();if(i<0)return 0===n?-1:n;e[t++]=i,n++}return n},bu.prototype.seek=function(e){throw Error("abstract method seek() not implemented")},bu.prototype.writeByte=function(e){throw Error("abstract method readByte() not implemented")},bu.prototype.write=function(e,t,r){var n;for(n=0;n<r;n++)this.writeByte(e[t++]);return r},bu.prototype.flush=function(){};var _u,vu=bu,ku=(_u=new Uint32Array([0,79764919,159529838,222504665,319059676,398814059,445009330,507990021,638119352,583659535,797628118,726387553,890018660,835552979,1015980042,944750013,1276238704,1221641927,1167319070,1095957929,1595256236,1540665371,1452775106,1381403509,1780037320,1859660671,1671105958,1733955601,2031960084,2111593891,1889500026,1952343757,2552477408,2632100695,2443283854,2506133561,2334638140,2414271883,2191915858,2254759653,3190512472,3135915759,3081330742,3009969537,2905550212,2850959411,2762807018,2691435357,3560074640,3505614887,3719321342,3648080713,3342211916,3287746299,3467911202,3396681109,4063920168,4143685023,4223187782,4286162673,3779000052,3858754371,3904687514,3967668269,881225847,809987520,1023691545,969234094,662832811,591600412,771767749,717299826,311336399,374308984,453813921,533576470,25881363,88864420,134795389,214552010,2023205639,2086057648,1897238633,1976864222,1804852699,1867694188,1645340341,1724971778,1587496639,1516133128,1461550545,1406951526,1302016099,1230646740,1142491917,1087903418,2896545431,2825181984,2770861561,2716262478,3215044683,3143675388,3055782693,3001194130,2326604591,2389456536,2200899649,2280525302,2578013683,2640855108,2418763421,2498394922,3769900519,3832873040,3912640137,3992402750,4088425275,4151408268,4197601365,4277358050,3334271071,3263032808,3476998961,3422541446,3585640067,3514407732,3694837229,3640369242,1762451694,1842216281,1619975040,1682949687,2047383090,2127137669,1938468188,2001449195,1325665622,1271206113,1183200824,1111960463,1543535498,1489069629,1434599652,1363369299,622672798,568075817,748617968,677256519,907627842,853037301,1067152940,995781531,51762726,131386257,177728840,240578815,269590778,349224269,429104020,491947555,4046411278,4126034873,4172115296,4234965207,3794477266,3874110821,3953728444,4016571915,3609705398,3555108353,3735388376,3664026991,3290680682,3236090077,3449943556,3378572211,3174993278,3120533705,3032266256,2961025959,2923101090,2868635157,2813903052,2742672763,2604032198,2683796849,2461293480,2524268063,2284983834,2364738477,2175806836,2238787779,1569362073,1498123566,1409854455,1355396672,1317987909,1246755826,1192025387,1137557660,2072149281,2135122070,1912620623,1992383480,1753615357,1816598090,1627664531,1707420964,295390185,358241886,404320391,483945776,43990325,106832002,186451547,266083308,932423249,861060070,1041341759,986742920,613929101,542559546,756411363,701822548,3316196985,3244833742,3425377559,3370778784,3601682597,3530312978,3744426955,3689838204,3819031489,3881883254,3928223919,4007849240,4037393693,4100235434,4180117107,4259748804,2310601993,2373574846,2151335527,2231098320,2596047829,2659030626,2470359227,2550115596,2947551409,2876312838,2788305887,2733848168,3165939309,3094707162,3040238851,2985771188]),function(){var e=4294967295;this.getCRC=function(){return~e>>>0},this.updateCRC=function(t){e=e<<8^_u[255&(e>>>24^t)]},this.updateCRCRun=function(t,r){for(;r-- >0;)e=e<<8^_u[255&(e>>>24^t)]}}),Au=function(e,t){var r,n=e[t];for(r=t;r>0;r--)e[r]=e[r-1];return e[0]=n,n},Su={OK:0,LAST_BLOCK:-1,NOT_BZIP_DATA:-2,UNEXPECTED_INPUT_EOF:-3,UNEXPECTED_OUTPUT_EOF:-4,DATA_ERROR:-5,OUT_OF_MEMORY:-6,OBSOLETE_INPUT:-7,END_OF_BLOCK:-8},Eu={};Eu[Su.LAST_BLOCK]="Bad file checksum",Eu[Su.NOT_BZIP_DATA]="Not bzip data",Eu[Su.UNEXPECTED_INPUT_EOF]="Unexpected input EOF",Eu[Su.UNEXPECTED_OUTPUT_EOF]="Unexpected output EOF",Eu[Su.DATA_ERROR]="Data error",Eu[Su.OUT_OF_MEMORY]="Out of memory",Eu[Su.OBSOLETE_INPUT]="Obsolete (pre 0.9.5) bzip format not supported.";var Pu=function(e,t){var r=Eu[e]||"unknown error";t&&(r+=": "+t);var n=new TypeError(r);throw n.errorCode=e,n},xu=function(e,t){this.writePos=this.writeCurrent=this.writeCount=0,this._start_bunzip(e,t)};xu.prototype._init_block=function(){return this._get_next_block()?(this.blockCRC=new ku,!0):(this.writeCount=-1,!1)},xu.prototype._start_bunzip=function(e,t){var r=new Uint8Array(4);4===e.read(r,0,4)&&"BZh"===String.fromCharCode(r[0],r[1],r[2])||Pu(Su.NOT_BZIP_DATA,"bad magic");var n=r[3]-48;(n<1||n>9)&&Pu(Su.NOT_BZIP_DATA,"level out of range"),this.reader=new wu(e),this.dbufSize=1e5*n,this.nextoutput=0,this.outputStream=t,this.streamCRC=0},xu.prototype._get_next_block=function(){var e,t,r,n=this.reader,i=n.pi();if("177245385090"===i)return!1;"314159265359"!==i&&Pu(Su.NOT_BZIP_DATA),this.targetBlockCRC=n.read(32)>>>0,this.streamCRC=(this.targetBlockCRC^(this.streamCRC<<1|this.streamCRC>>>31))>>>0,n.read(1)&&Pu(Su.OBSOLETE_INPUT);var a=n.read(24);a>this.dbufSize&&Pu(Su.DATA_ERROR,"initial position out of bounds");var s=n.read(16),o=new Uint8Array(256),c=0;for(e=0;e<16;e++)if(s&1<<15-e){var u=16*e;for(r=n.read(16),t=0;t<16;t++)r&1<<15-t&&(o[c++]=u+t)}var l=n.read(3);(l<2||l>6)&&Pu(Su.DATA_ERROR);var h=n.read(15);0===h&&Pu(Su.DATA_ERROR);var d=new Uint8Array(256);for(e=0;e<l;e++)d[e]=e;var f=new Uint8Array(h);for(e=0;e<h;e++){for(t=0;n.read(1);t++)t>=l&&Pu(Su.DATA_ERROR);f[e]=Au(d,t)}var y,p=c+2,g=[];for(t=0;t<l;t++){var m,w,b=new Uint8Array(p),_=new Uint16Array(21);for(s=n.read(5),e=0;e<p;e++){for(;(s<1||s>20)&&Pu(Su.DATA_ERROR),n.read(1);)n.read(1)?s--:s++;b[e]=s}for(m=w=b[0],e=1;e<p;e++)b[e]>w?w=b[e]:b[e]<m&&(m=b[e]);y={},g.push(y),y.permute=new Uint16Array(258),y.limit=new Uint32Array(22),y.base=new Uint32Array(21),y.minLen=m,y.maxLen=w;var v=0;for(e=m;e<=w;e++)for(_[e]=y.limit[e]=0,s=0;s<p;s++)b[s]===e&&(y.permute[v++]=s);for(e=0;e<p;e++)_[b[e]]++;for(v=s=0,e=m;e<w;e++)v+=_[e],y.limit[e]=v-1,v<<=1,s+=_[e],y.base[e+1]=v-s;y.limit[w+1]=Number.MAX_VALUE,y.limit[w]=v+_[w]-1,y.base[m]=0}var k=new Uint32Array(256);for(e=0;e<256;e++)d[e]=e;var A,S=0,E=0,P=0,x=this.dbuf=new Uint32Array(this.dbufSize);for(p=0;;){for(p--||(p=49,P>=h&&Pu(Su.DATA_ERROR),y=g[f[P++]]),e=y.minLen,t=n.read(e);e>y.maxLen&&Pu(Su.DATA_ERROR),!(t<=y.limit[e]);e++)t=t<<1|n.read(1);((t-=y.base[e])<0||t>=258)&&Pu(Su.DATA_ERROR);var K=y.permute[t];if(0!==K&&1!==K){if(S)for(S=0,E+s>this.dbufSize&&Pu(Su.DATA_ERROR),k[A=o[d[0]]]+=s;s--;)x[E++]=A;if(K>c)break;E>=this.dbufSize&&Pu(Su.DATA_ERROR),k[A=o[A=Au(d,e=K-1)]]++,x[E++]=A}else S||(S=1,s=0),s+=0===K?S:2*S,S<<=1}for((a<0||a>=E)&&Pu(Su.DATA_ERROR),t=0,e=0;e<256;e++)r=t+k[e],k[e]=t,t=r;for(e=0;e<E;e++)x[k[A=255&x[e]]]|=e<<8,k[A]++;var C=0,U=0,R=0;return E&&(U=255&(C=x[a]),C>>=8,R=-1),this.writePos=C,this.writeCurrent=U,this.writeCount=E,this.writeRun=R,!0},xu.prototype._read_bunzip=function(e,t){var r,n,i;if(this.writeCount<0)return 0;var a=this.dbuf,s=this.writePos,o=this.writeCurrent,c=this.writeCount;this.outputsize;for(var u=this.writeRun;c;){for(c--,n=o,o=255&(s=a[s]),s>>=8,3==u++?(r=o,i=n,o=-1):(r=1,i=o),this.blockCRC.updateCRCRun(i,r);r--;)this.outputStream.writeByte(i),this.nextoutput++;o!=n&&(u=0)}return this.writeCount=c,this.blockCRC.getCRC()!==this.targetBlockCRC&&Pu(Su.DATA_ERROR,"Bad block CRC (got "+this.blockCRC.getCRC().toString(16)+" expected "+this.targetBlockCRC.toString(16)+")"),this.nextoutput};var Ku=function(e){if("readByte"in e)return e;var t=new vu;return t.pos=0,t.readByte=function(){return e[this.pos++]},t.seek=function(e){this.pos=e},t.eof=function(){return this.pos>=e.length},t},Cu=function(e){var t=new vu,r=!0;if(e)if("number"==typeof e)t.buffer=new Uint8Array(e),r=!1;else{if("writeByte"in e)return e;t.buffer=e,r=!1}else t.buffer=new Uint8Array(16384);return t.pos=0,t.writeByte=function(e){if(r&&this.pos>=this.buffer.length){var t=new Uint8Array(2*this.buffer.length);t.set(this.buffer),this.buffer=t}this.buffer[this.pos++]=e},t.getBuffer=function(){if(this.pos!==this.buffer.length){if(!r)throw new TypeError("outputsize does not match decoded input");var e=new Uint8Array(this.pos);e.set(this.buffer.subarray(0,this.pos)),this.buffer=e}return this.buffer},t._coerced=!0,t};var Uu=function(e,t,r){for(var n=Ku(e),i=Cu(t),a=new xu(n,i);!("eof"in n)||!n.eof();)if(a._init_block())a._read_bunzip();else{var s=a.reader.read(32)>>>0;if(s!==a.streamCRC&&Pu(Su.DATA_ERROR,"Bad stream CRC (got "+a.streamCRC.toString(16)+" expected "+s.toString(16)+")"),!r||!("eof"in n)||n.eof())break;a._start_bunzip(n,i)}if("getBuffer"in i)return i.getBuffer()};class Ru{constructor(e=rn){this.tag=tn.packet.compressedData,this.packets=null,this.algorithm=tn.read(tn.compression,e.compression),this.compressed=null,this.deflateLevel=e.deflateLevel}async read(e,t,r){await Fr.parse(e,async e=>{this.algorithm=tn.read(tn.compression,await e.readByte()),this.compressed=e.remainder(),await this.decompress(r)})}write(){return null===this.compressed&&this.compress(),Gr.concat([new Uint8Array([tn.write(tn.compression,this.algorithm)]),this.compressed])}async decompress(e){if(!qu[this.algorithm])throw Error(this.algorithm+" decompression not supported");await this.packets.read(qu[this.algorithm](this.compressed),{LiteralDataPacket:Hu,OnePassSignaturePacket:al,SignaturePacket:nl},e)}compress(){if(!Ou[this.algorithm])throw Error(this.algorithm+" compression not supported");this.compressed=Ou[this.algorithm](this.packets.write(),this.deflateLevel)}}const Tu=Gr.getNodeZlib();function Du(e){return e}function Iu(e,t={}){return function(r){return Fr.nodeToWeb(Fr.webToNode(r).pipe(e(t)))}}function Bu(e,t={}){return function(r){const n=new e(t);return Fr.transform(r,e=>{if(e.length)return n.push(e,2),n.result},()=>{if(e===Zc)return n.push([],4),n.result})}}function zu(e){return function(t){return Fr.fromAsync(async()=>e(await Fr.readToEnd(t)))}}const Ou=Tu?{zip:/*#__PURE__*/(e,t)=>Iu(Tu.createDeflateRaw,{level:t})(e),zlib:/*#__PURE__*/(e,t)=>Iu(Tu.createDeflate,{level:t})(e)}:{zip:/*#__PURE__*/(e,t)=>Bu(Zc,{raw:!0,level:t})(e),zlib:/*#__PURE__*/(e,t)=>Bu(Zc,{level:t})(e)},qu=Tu?{uncompressed:Du,zip:/*#__PURE__*/Iu(Tu.createInflateRaw),zlib:/*#__PURE__*/Iu(Tu.createInflate),bzip2:/*#__PURE__*/zu(Uu)}:{uncompressed:Du,zip:/*#__PURE__*/Bu(pu,{raw:!0}),zlib:/*#__PURE__*/Bu(pu),bzip2:/*#__PURE__*/zu(Uu)};class Nu{constructor(){this.tag=tn.packet.symEncryptedIntegrityProtectedData,this.version=1,this.encrypted=null,this.modification=!1,this.packets=null}async read(e){await Fr.parse(e,async e=>{if(1!==await e.readByte())throw Error("Invalid packet version.");this.encrypted=e.remainder()})}write(){return Gr.concat([new Uint8Array([1]),this.encrypted])}async encrypt(e,t,r,n=rn){let i=this.packets.write();r||(i=await Fr.readToEnd(i));const a=await Io.getPrefixRandom(e),s=new Uint8Array([211,20]),o=Gr.concat([a,i,s]),c=await Io.hash.sha1(Fr.passiveClone(o)),u=Gr.concat([o,c]);return this.encrypted=await Io.cfb.encrypt(e,t,u,new Uint8Array(Io.cipher[e].blockSize),n),!0}async decrypt(e,t,r,n=rn){let i=Fr.clone(this.encrypted);r||(i=await Fr.readToEnd(i));const a=await Io.cfb.decrypt(e,t,i,new Uint8Array(Io.cipher[e].blockSize)),s=Fr.slice(Fr.passiveClone(a),-20),o=Fr.slice(a,0,-20),c=Promise.all([Fr.readToEnd(await Io.hash.sha1(Fr.passiveClone(o))),Fr.readToEnd(s)]).then(([e,t])=>{if(!Gr.equalsUint8Array(e,t))throw Error("Modification detected.");return new Uint8Array}),u=Fr.slice(o,Io.cipher[e].blockSize+2);let l=Fr.slice(u,0,-2);return l=Fr.concat([l,Fr.fromAsync(()=>c)]),Gr.isStream(i)&&n.allowUnauthenticatedStream||(l=await Fr.readToEnd(l)),await this.packets.read(l,{LiteralDataPacket:Hu,CompressedDataPacket:Ru,OnePassSignaturePacket:al,SignaturePacket:nl},r),!0}}class Mu{constructor(){this.tag=tn.packet.AEADEncryptedData,this.version=1,this.cipherAlgo=null,this.aeadAlgorithm="eax",this.aeadAlgo=null,this.chunkSizeByte=null,this.iv=null,this.encrypted=null,this.packets=null}async read(e){await Fr.parse(e,async e=>{if(1!==await e.readByte())throw Error("Invalid packet version.");this.cipherAlgo=await e.readByte(),this.aeadAlgo=await e.readByte(),this.chunkSizeByte=await e.readByte();const t=Io[tn.read(tn.aead,this.aeadAlgo)];this.iv=await e.readBytes(t.ivLength),this.encrypted=e.remainder()})}write(){return Gr.concat([new Uint8Array([this.version,this.cipherAlgo,this.aeadAlgo,this.chunkSizeByte]),this.iv,this.encrypted])}async decrypt(e,t,r){await this.packets.read(await this.crypt("decrypt",t,Fr.clone(this.encrypted),r),{LiteralDataPacket:Hu,CompressedDataPacket:Ru,OnePassSignaturePacket:al,SignaturePacket:nl},r)}async encrypt(e,t,r,n=rn){this.cipherAlgo=tn.write(tn.symmetric,e),this.aeadAlgo=tn.write(tn.aead,this.aeadAlgorithm);const i=Io[tn.read(tn.aead,this.aeadAlgo)];this.iv=await Io.random.getRandomBytes(i.ivLength),this.chunkSizeByte=n.aeadChunkSizeByte;const a=this.packets.write();this.encrypted=await this.crypt("encrypt",t,a,r)}async crypt(e,t,r,n){const i=tn.read(tn.symmetric,this.cipherAlgo),a=Io[tn.read(tn.aead,this.aeadAlgo)],s=await a(i,t),o="decrypt"===e?a.tagLength:0,c="encrypt"===e?a.tagLength:0,u=2**(this.chunkSizeByte+6)+o,l=new ArrayBuffer(21),h=new Uint8Array(l,0,13),d=new Uint8Array(l),f=new DataView(l),y=new Uint8Array(l,5,8);h.set([192|this.tag,this.version,this.cipherAlgo,this.aeadAlgo,this.chunkSizeByte],0);let p=0,g=Promise.resolve(),m=0,w=0;const b=this.iv;return Fr.transformPair(r,async(t,r)=>{const i=Fr.getReader(t),l=new Fr.TransformStream({},{highWaterMark:n?Gr.getHardwareConcurrency()*2**(this.chunkSizeByte+6):1/0,size:e=>e.length});Fr.pipe(l.readable,r);const _=Fr.getWriter(l.writable);try{for(;;){let t=await i.readBytes(u+o)||new Uint8Array;const r=t.subarray(t.length-o);let n,l;if(t=t.subarray(0,t.length-o),!p||t.length?(i.unshift(r),n=s[e](t,a.getNonce(b,y),h),w+=t.length-o+c):(f.setInt32(17,m),n=s[e](r,a.getNonce(b,y),d),w+=c,l=!0),m+=t.length-o,g=g.then(()=>n).then(async e=>{await _.ready,await _.write(e),w-=e.length}).catch(e=>_.abort(e)),(l||w>_.desiredSize)&&await g,l){await _.close();break}f.setInt32(9,++p)}}catch(e){await _.abort(e)}})}}class Lu{constructor(){this.tag=tn.packet.publicKeyEncryptedSessionKey,this.version=3,this.publicKeyId=new fn,this.publicKeyAlgorithm=null,this.sessionKey=null,this.sessionKeyAlgorithm=null,this.encrypted={}}read(e){this.version=e[0],this.publicKeyId.read(e.subarray(1,e.length)),this.publicKeyAlgorithm=tn.read(tn.publicKey,e[9]);const t=tn.write(tn.publicKey,this.publicKeyAlgorithm);this.encrypted=Io.parseEncSessionKeyParams(t,e.subarray(10))}write(){const e=tn.write(tn.publicKey,this.publicKeyAlgorithm),t=[new Uint8Array([this.version]),this.publicKeyId.write(),new Uint8Array([tn.write(tn.publicKey,this.publicKeyAlgorithm)]),Io.serializeParams(e,this.encrypted)];return Gr.concatUint8Array(t)}async encrypt(e){const t=Gr.concatUint8Array([new Uint8Array([tn.write(tn.symmetric,this.sessionKeyAlgorithm)]),this.sessionKey,Gr.writeChecksum(this.sessionKey)]),r=tn.write(tn.publicKey,this.publicKeyAlgorithm);return this.encrypted=await Io.publicKeyEncrypt(r,e.publicParams,t,e.getFingerprintBytes()),!0}async decrypt(e){const t=tn.write(tn.publicKey,this.publicKeyAlgorithm);if(t!==tn.write(tn.publicKey,e.algorithm))throw Error("Decryption error");const r=await Io.publicKeyDecrypt(t,e.publicParams,e.privateParams,this.encrypted,e.getFingerprintBytes()),n=r.subarray(r.length-2),i=r.subarray(1,r.length-2);if(!Gr.equalsUint8Array(n,Gr.writeChecksum(i)))throw Error("Decryption error");return this.sessionKey=i,this.sessionKeyAlgorithm=tn.read(tn.symmetric,r[0]),!0}}class ju{constructor(e=rn){this.algorithm="sha256",this.type="iterated",this.c=e.s2kIterationCountByte,this.salt=null}get_count(){return 16+(15&this.c)<<6+(this.c>>4)}read(e){let t=0;switch(this.type=tn.read(tn.s2k,e[t++]),this.algorithm=e[t++],"gnu"!==this.type&&(this.algorithm=tn.read(tn.hash,this.algorithm)),this.type){case"simple":break;case"salted":this.salt=e.subarray(t,t+8),t+=8;break;case"iterated":this.salt=e.subarray(t,t+8),t+=8,this.c=e[t++];break;case"gnu":if("GNU"!==Gr.uint8ArrayToStr(e.subarray(t,t+3)))throw Error("Unknown s2k type.");if(t+=3,1001!==1e3+e[t++])throw Error("Unknown s2k gnu protection mode.");this.type="gnu-dummy";break;default:throw Error("Unknown s2k type.")}return t}write(){if("gnu-dummy"===this.type)return new Uint8Array([101,0,...Gr.strToUint8Array("GNU"),1]);const e=[new Uint8Array([tn.write(tn.s2k,this.type),tn.write(tn.hash,this.algorithm)])];switch(this.type){case"simple":break;case"salted":e.push(this.salt);break;case"iterated":e.push(this.salt),e.push(new Uint8Array([this.c]));break;case"gnu":throw Error("GNU s2k type not supported.");default:throw Error("Unknown s2k type.")}return Gr.concatUint8Array(e)}async produce_key(e,t){e=Gr.encodeUtf8(e);const r=tn.write(tn.hash,this.algorithm),n=[];let i=0,a=0;for(;i<t;){let t;switch(this.type){case"simple":t=Gr.concatUint8Array([new Uint8Array(a),e]);break;case"salted":t=Gr.concatUint8Array([new Uint8Array(a),this.salt,e]);break;case"iterated":{const r=Gr.concatUint8Array([this.salt,e]);let n=r.length;const i=Math.max(this.get_count(),n);t=new Uint8Array(a+i),t.set(r,a);for(let e=a+n;e<i;e+=n,n*=2)t.copyWithin(e,a,e);break}case"gnu":throw Error("GNU s2k type not supported.");default:throw Error("Unknown s2k type.")}const s=await Io.hash.digest(r,t);n.push(s),i+=s.length,a++}return Gr.concatUint8Array(n).subarray(0,t)}}class Fu{constructor(e=rn){this.tag=tn.packet.symEncryptedSessionKey,this.version=e.aeadProtect?5:4,this.sessionKey=null,this.sessionKeyEncryptionAlgorithm=null,this.sessionKeyAlgorithm="aes256",this.aeadAlgorithm=tn.read(tn.aead,e.aeadMode),this.encrypted=null,this.s2k=null,this.iv=null}read(e){let t=0;this.version=e[t++];const r=tn.read(tn.symmetric,e[t++]);if(5===this.version&&(this.aeadAlgorithm=tn.read(tn.aead,e[t++])),this.s2k=new ju,t+=this.s2k.read(e.subarray(t,e.length)),5===this.version){const r=Io[this.aeadAlgorithm];this.iv=e.subarray(t,t+=r.ivLength)}5===this.version||t<e.length?(this.encrypted=e.subarray(t,e.length),this.sessionKeyEncryptionAlgorithm=r):this.sessionKeyAlgorithm=r}write(){const e=null===this.encrypted?this.sessionKeyAlgorithm:this.sessionKeyEncryptionAlgorithm;let t;return 5===this.version?t=Gr.concatUint8Array([new Uint8Array([this.version,tn.write(tn.symmetric,e),tn.write(tn.aead,this.aeadAlgorithm)]),this.s2k.write(),this.iv,this.encrypted]):(t=Gr.concatUint8Array([new Uint8Array([this.version,tn.write(tn.symmetric,e)]),this.s2k.write()]),null!==this.encrypted&&(t=Gr.concatUint8Array([t,this.encrypted]))),t}async decrypt(e){const t=null!==this.sessionKeyEncryptionAlgorithm?this.sessionKeyEncryptionAlgorithm:this.sessionKeyAlgorithm,r=Io.cipher[t].keySize,n=await this.s2k.produce_key(e,r);if(5===this.version){const e=Io[this.aeadAlgorithm],r=new Uint8Array([192|this.tag,this.version,tn.write(tn.symmetric,this.sessionKeyEncryptionAlgorithm),tn.write(tn.aead,this.aeadAlgorithm)]),i=await e(t,n);this.sessionKey=await i.decrypt(this.encrypted,this.iv,r)}else if(null!==this.encrypted){const e=await Io.cfb.decrypt(t,n,this.encrypted,new Uint8Array(Io.cipher[t].blockSize));this.sessionKeyAlgorithm=tn.read(tn.symmetric,e[0]),this.sessionKey=e.subarray(1,e.length)}else this.sessionKey=n}async encrypt(e,t=rn){const r=null!==this.sessionKeyEncryptionAlgorithm?this.sessionKeyEncryptionAlgorithm:this.sessionKeyAlgorithm;this.sessionKeyEncryptionAlgorithm=r,this.s2k=new ju(t),this.s2k.salt=await Io.random.getRandomBytes(8);const n=Io.cipher[r].keySize,i=await this.s2k.produce_key(e,n);if(null===this.sessionKey&&(this.sessionKey=await Io.generateSessionKey(this.sessionKeyAlgorithm)),5===this.version){const e=Io[this.aeadAlgorithm];this.iv=await Io.random.getRandomBytes(e.ivLength);const t=new Uint8Array([192|this.tag,this.version,tn.write(tn.symmetric,this.sessionKeyEncryptionAlgorithm),tn.write(tn.aead,this.aeadAlgorithm)]),n=await e(r,i);this.encrypted=await n.encrypt(this.sessionKey,this.iv,t)}else{const e=new Uint8Array([tn.write(tn.symmetric,this.sessionKeyAlgorithm)]),n=Gr.concatUint8Array([e,this.sessionKey]);this.encrypted=await Io.cfb.encrypt(r,i,n,new Uint8Array(Io.cipher[r].blockSize),t)}}}class Hu{constructor(e=new Date){this.tag=tn.packet.literalData,this.format="utf8",this.date=Gr.normalizeDate(e),this.text=null,this.data=null,this.filename=""}setText(e,t="utf8"){this.format=t,this.text=e,this.data=null}getText(e=!1){return(null===this.text||Gr.isStream(this.text))&&(this.text=Gr.decodeUtf8(Gr.nativeEOL(this.getBytes(e)))),this.text}setBytes(e,t){this.format=t,this.data=e,this.text=null}getBytes(e=!1){return null===this.data&&(this.data=Gr.canonicalizeEOL(Gr.encodeUtf8(this.text))),e?Fr.passiveClone(this.data):this.data}setFilename(e){this.filename=e}getFilename(){return this.filename}async read(e){await Fr.parse(e,async e=>{const t=tn.read(tn.literal,await e.readByte()),r=await e.readByte();this.filename=Gr.decodeUtf8(await e.readBytes(r)),this.date=Gr.readDate(await e.readBytes(4));const n=e.remainder();this.setBytes(n,t)})}writeHeader(){const e=Gr.encodeUtf8(this.filename),t=new Uint8Array([e.length]),r=new Uint8Array([tn.write(tn.literal,this.format)]),n=Gr.writeDate(this.date);return Gr.concatUint8Array([r,t,e,n])}write(){const e=this.writeHeader(),t=this.getBytes();return Gr.concat([e,t])}}class Wu{constructor(e=new Date,t=rn){this.tag=tn.packet.publicKey,this.version=t.v5Keys?5:4,this.created=Gr.normalizeDate(e),this.algorithm=null,this.publicParams=null,this.expirationTimeV3=0,this.fingerprint=null,this.keyid=null}read(e){let t=0;if(this.version=e[t++],4===this.version||5===this.version){this.created=Gr.readDate(e.subarray(t,t+4)),t+=4,this.algorithm=tn.read(tn.publicKey,e[t++]);const r=tn.write(tn.publicKey,this.algorithm);5===this.version&&(t+=4);try{const{read:n,publicParams:i}=Io.parsePublicKeyParams(r,e.subarray(t));this.publicParams=i,t+=n}catch(e){throw Error("Error reading MPIs")}return t}throw Error("Version "+this.version+" of the key packet is unsupported.")}write(){const e=[];e.push(new Uint8Array([this.version])),e.push(Gr.writeDate(this.created));const t=tn.write(tn.publicKey,this.algorithm);e.push(new Uint8Array([t]));const r=Io.serializeParams(t,this.publicParams);return 5===this.version&&e.push(Gr.writeNumber(r.length,4)),e.push(r),Gr.concatUint8Array(e)}writeForHash(e){const t=this.writePublicKey();return 5===e?Gr.concatUint8Array([new Uint8Array([154]),Gr.writeNumber(t.length,4),t]):Gr.concatUint8Array([new Uint8Array([153]),Gr.writeNumber(t.length,2),t])}isDecrypted(){return null}getCreationTime(){return this.created}getKeyId(){return this.keyid||(this.keyid=new fn,5===this.version?this.keyid.read(Gr.hexToUint8Array(this.getFingerprint()).subarray(0,8)):4===this.version&&this.keyid.read(Gr.hexToUint8Array(this.getFingerprint()).subarray(12,20))),this.keyid}getFingerprintBytes(){if(this.fingerprint)return this.fingerprint;const e=this.writeForHash(this.version);return 5===this.version?this.fingerprint=Qn.bytes(e):4===this.version&&(this.fingerprint=$n.bytes(e)),this.fingerprint}getFingerprint(){return Gr.uint8ArrayToHex(this.getFingerprintBytes())}hasSameFingerprintAs(e){return this.version===e.version&&Gr.equalsUint8Array(this.writePublicKey(),e.writePublicKey())}getAlgorithmInfo(){const e={};e.algorithm=this.algorithm;const t=this.publicParams.n||this.publicParams.p;return t?e.bits=8*t.length:e.curve=this.publicParams.oid.getName(),e}}Wu.prototype.readPublicKey=Wu.prototype.read,Wu.prototype.writePublicKey=Wu.prototype.write;class Gu{constructor(){this.tag=tn.packet.symmetricallyEncryptedData,this.encrypted=null,this.packets=null}read(e){this.encrypted=e}write(){return this.encrypted}async decrypt(e,t,r,n=rn){if(!n.allowUnauthenticatedMessages)throw Error("Message is not authenticated.");const i=await Fr.readToEnd(Fr.clone(this.encrypted)),a=await Io.cfb.decrypt(e,t,i.subarray(Io.cipher[e].blockSize+2),i.subarray(2,Io.cipher[e].blockSize+2));await this.packets.read(a,{LiteralDataPacket:Hu,CompressedDataPacket:Ru,OnePassSignaturePacket:al,SignaturePacket:nl},r)}async encrypt(e,t,r,n=rn){const i=this.packets.write(),a=await Io.getPrefixRandom(e),s=await Io.cfb.encrypt(e,t,a,new Uint8Array(Io.cipher[e].blockSize),n),o=await Io.cfb.encrypt(e,t,i,s.subarray(2),n);this.encrypted=Gr.concat([s,o])}}class Vu{constructor(){this.tag=tn.packet.marker}read(e){return 80===e[0]&&71===e[1]&&80===e[2]}}class $u extends Wu{constructor(e,t){super(e,t),this.tag=tn.packet.publicSubkey}}function Yu(e){let t,r=0;const n=e[0];return n<192?([r]=e,t=1):n<255?(r=(e[0]-192<<8)+e[1]+192,t=2):255===n&&(r=Gr.readNumber(e.subarray(1,5)),t=5),{len:r,offset:t}}function Zu(e){return e<192?new Uint8Array([e]):e>191&&e<8384?new Uint8Array([192+(e-192>>8),e-192&255]):Gr.concatUint8Array([new Uint8Array([255]),Gr.writeNumber(e,4)])}function Qu(e){if(e<0||e>30)throw Error("Partial Length power must be between 1 and 30");return new Uint8Array([224+e])}function Xu(e){return new Uint8Array([192|e])}function Ju(e,t){return Gr.concatUint8Array([Xu(e),Zu(t)])}function el(e){return[tn.packet.literalData,tn.packet.compressedData,tn.packet.symmetricallyEncryptedData,tn.packet.symEncryptedIntegrityProtectedData,tn.packet.AEADEncryptedData].includes(e)}async function tl(e,t,r){const n=Fr.getReader(e);let i,a;try{const e=await n.peekBytes(2);if(!e||e.length<2||0==(128&e[0]))throw Error("Error during parsing. This message / key probably does not conform to a valid OpenPGP format.");const s=await n.readByte();let o,c,u=-1,l=-1;l=0,0!=(64&s)&&(l=1),l?u=63&s:(u=(63&s)>>2,c=3&s);const h=el(u);let d,f=null;if(t&&h){const e=new Fr.TransformStream;i=Fr.getWriter(e.writable),f=e.readable,a=r({tag:u,packet:f})}else f=[];do{if(l){const e=await n.readByte();if(d=!1,e<192)o=e;else if(e>=192&&e<224)o=(e-192<<8)+await n.readByte()+192;else if(e>223&&e<255){if(o=1<<(31&e),d=!0,!h)throw new TypeError("This packet type does not support partial lengths.")}else o=await n.readByte()<<24|await n.readByte()<<16|await n.readByte()<<8|await n.readByte()}else switch(c){case 0:o=await n.readByte();break;case 1:o=await n.readByte()<<8|await n.readByte();break;case 2:o=await n.readByte()<<24|await n.readByte()<<16|await n.readByte()<<8|await n.readByte();break;default:o=1/0}if(o>0){let e=0;for(;;){i&&await i.ready;const{done:t,value:r}=await n.read();if(t){if(o===1/0)break;throw Error("Unexpected end of packet")}const a=o===1/0?r:r.subarray(0,o-e);if(i?await i.write(a):f.push(a),e+=r.length,e>=o){n.unshift(r.subarray(o-e+r.length));break}}}}while(d);const y=await n.peekBytes(h?1/0:2);return i?(await i.ready,await i.close()):(f=Gr.concatUint8Array(f),await r({tag:u,packet:f})),!y||!y.length}catch(e){if(i)return await i.abort(e),!0;throw e}finally{i&&await a,n.releaseLock()}}class rl{constructor(){this.tag=tn.packet.userAttribute,this.attributes=[]}read(e){let t=0;for(;t<e.length;){const r=Yu(e.subarray(t,e.length));t+=r.offset,this.attributes.push(Gr.uint8ArrayToStr(e.subarray(t,t+r.len))),t+=r.len}}write(){const e=[];for(let t=0;t<this.attributes.length;t++)e.push(Zu(this.attributes[t].length)),e.push(Gr.strToUint8Array(this.attributes[t]));return Gr.concatUint8Array(e)}equals(e){return!!(e&&e instanceof rl)&&this.attributes.every((function(t,r){return t===e.attributes[r]}))}}class nl{constructor(e=new Date){this.tag=tn.packet.signature,this.version=4,this.signatureType=null,this.hashAlgorithm=null,this.publicKeyAlgorithm=null,this.signatureData=null,this.unhashedSubpackets=[],this.signedHashValue=null,this.created=Gr.normalizeDate(e),this.signatureExpirationTime=null,this.signatureNeverExpires=!0,this.exportable=null,this.trustLevel=null,this.trustAmount=null,this.regularExpression=null,this.revocable=null,this.keyExpirationTime=null,this.keyNeverExpires=null,this.preferredSymmetricAlgorithms=null,this.revocationKeyClass=null,this.revocationKeyAlgorithm=null,this.revocationKeyFingerprint=null,this.issuerKeyId=new fn,this.rawNotations=[],this.notations={},this.preferredHashAlgorithms=null,this.preferredCompressionAlgorithms=null,this.keyServerPreferences=null,this.preferredKeyServer=null,this.isPrimaryUserID=null,this.policyURI=null,this.keyFlags=null,this.signersUserId=null,this.reasonForRevocationFlag=null,this.reasonForRevocationString=null,this.features=null,this.signatureTargetPublicKeyAlgorithm=null,this.signatureTargetHashAlgorithm=null,this.signatureTargetHash=null,this.embeddedSignature=null,this.issuerKeyVersion=null,this.issuerFingerprint=null,this.preferredAeadAlgorithms=null,this.verified=null,this.revoked=null}read(e){let t=0;if(this.version=e[t++],4!==this.version&&5!==this.version)throw Error("Version "+this.version+" of the signature is unsupported.");this.signatureType=e[t++],this.publicKeyAlgorithm=e[t++],this.hashAlgorithm=e[t++],t+=this.read_sub_packets(e.subarray(t,e.length),!0),this.signatureData=e.subarray(0,t),t+=this.read_sub_packets(e.subarray(t,e.length),!1),this.signedHashValue=e.subarray(t,t+2),t+=2,this.params=Io.signature.parseSignatureParams(this.publicKeyAlgorithm,e.subarray(t,e.length))}write_params(){return this.params instanceof Promise?Fr.fromAsync(async()=>Io.serializeParams(this.publicKeyAlgorithm,await this.params)):Io.serializeParams(this.publicKeyAlgorithm,this.params)}write(){const e=[];return e.push(this.signatureData),e.push(this.write_unhashed_sub_packets()),e.push(this.signedHashValue),e.push(this.write_params()),Gr.concat(e)}async sign(e,t,r=!1,n=!1){const i=tn.write(tn.signature,this.signatureType),a=tn.write(tn.publicKey,this.publicKeyAlgorithm),s=tn.write(tn.hash,this.hashAlgorithm);5===e.version&&(this.version=5);const o=[new Uint8Array([this.version,i,a,s])];this.issuerKeyVersion=e.version,this.issuerFingerprint=e.getFingerprintBytes(),this.issuerKeyId=e.getKeyId(),o.push(this.write_hashed_sub_packets()),this.signatureData=Gr.concat(o);const c=this.toHash(i,t,r),u=await this.hash(i,t,c,r);this.signedHashValue=Fr.slice(Fr.clone(u),0,2);const l=async()=>Io.signature.sign(a,s,e.publicParams,e.privateParams,c,await Fr.readToEnd(u));n?this.params=l():(this.params=await l(),this.verified=!0)}write_hashed_sub_packets(){const e=tn.signatureSubpacket,t=[];let r;null!==this.created&&t.push(il(e.signatureCreationTime,Gr.writeDate(this.created))),null!==this.signatureExpirationTime&&t.push(il(e.signatureExpirationTime,Gr.writeNumber(this.signatureExpirationTime,4))),null!==this.exportable&&t.push(il(e.exportableCertification,new Uint8Array([this.exportable?1:0]))),null!==this.trustLevel&&(r=new Uint8Array([this.trustLevel,this.trustAmount]),t.push(il(e.trustSignature,r))),null!==this.regularExpression&&t.push(il(e.regularExpression,this.regularExpression)),null!==this.revocable&&t.push(il(e.revocable,new Uint8Array([this.revocable?1:0]))),null!==this.keyExpirationTime&&t.push(il(e.keyExpirationTime,Gr.writeNumber(this.keyExpirationTime,4))),null!==this.preferredSymmetricAlgorithms&&(r=Gr.strToUint8Array(Gr.uint8ArrayToStr(this.preferredSymmetricAlgorithms)),t.push(il(e.preferredSymmetricAlgorithms,r))),null!==this.revocationKeyClass&&(r=new Uint8Array([this.revocationKeyClass,this.revocationKeyAlgorithm]),r=Gr.concat([r,this.revocationKeyFingerprint]),t.push(il(e.revocationKey,r))),this.rawNotations.forEach(([{name:n,value:i,humanReadable:a}])=>{r=[new Uint8Array([a?128:0,0,0,0])],r.push(Gr.writeNumber(n.length,2)),r.push(Gr.writeNumber(i.length,2)),r.push(Gr.strToUint8Array(n)),r.push(i),r=Gr.concat(r),t.push(il(e.notationData,r))}),null!==this.preferredHashAlgorithms&&(r=Gr.strToUint8Array(Gr.uint8ArrayToStr(this.preferredHashAlgorithms)),t.push(il(e.preferredHashAlgorithms,r))),null!==this.preferredCompressionAlgorithms&&(r=Gr.strToUint8Array(Gr.uint8ArrayToStr(this.preferredCompressionAlgorithms)),t.push(il(e.preferredCompressionAlgorithms,r))),null!==this.keyServerPreferences&&(r=Gr.strToUint8Array(Gr.uint8ArrayToStr(this.keyServerPreferences)),t.push(il(e.keyServerPreferences,r))),null!==this.preferredKeyServer&&t.push(il(e.preferredKeyServer,Gr.strToUint8Array(this.preferredKeyServer))),null!==this.isPrimaryUserID&&t.push(il(e.primaryUserId,new Uint8Array([this.isPrimaryUserID?1:0]))),null!==this.policyURI&&t.push(il(e.policyUri,Gr.strToUint8Array(this.policyURI))),null!==this.keyFlags&&(r=Gr.strToUint8Array(Gr.uint8ArrayToStr(this.keyFlags)),t.push(il(e.keyFlags,r))),null!==this.signersUserId&&t.push(il(e.signersUserId,Gr.strToUint8Array(this.signersUserId))),null!==this.reasonForRevocationFlag&&(r=Gr.strToUint8Array(String.fromCharCode(this.reasonForRevocationFlag)+this.reasonForRevocationString),t.push(il(e.reasonForRevocation,r))),null!==this.features&&(r=Gr.strToUint8Array(Gr.uint8ArrayToStr(this.features)),t.push(il(e.features,r))),null!==this.signatureTargetPublicKeyAlgorithm&&(r=[new Uint8Array([this.signatureTargetPublicKeyAlgorithm,this.signatureTargetHashAlgorithm])],r.push(Gr.strToUint8Array(this.signatureTargetHash)),r=Gr.concat(r),t.push(il(e.signatureTarget,r))),null!==this.preferredAeadAlgorithms&&(r=Gr.strToUint8Array(Gr.uint8ArrayToStr(this.preferredAeadAlgorithms)),t.push(il(e.preferredAeadAlgorithms,r)));const n=Gr.concat(t),i=Gr.writeNumber(n.length,2);return Gr.concat([i,n])}write_unhashed_sub_packets(){const e=tn.signatureSubpacket,t=[];let r;this.issuerKeyId.isNull()||5===this.issuerKeyVersion||t.push(il(e.issuer,this.issuerKeyId.write())),null!==this.embeddedSignature&&t.push(il(e.embeddedSignature,this.embeddedSignature.write())),null!==this.issuerFingerprint&&(r=[new Uint8Array([this.issuerKeyVersion]),this.issuerFingerprint],r=Gr.concat(r),t.push(il(e.issuerFingerprint,r))),this.unhashedSubpackets.forEach(e=>{t.push(Zu(e.length)),t.push(e)});const n=Gr.concat(t),i=Gr.writeNumber(n.length,2);return Gr.concat([i,n])}read_sub_packet(e,t=!0){let r=0;const n=(e,t)=>{this[e]=[];for(let r=0;r<t.length;r++)this[e].push(t[r])},i=128&e[r],a=127&e[r];if(t||[tn.signatureSubpacket.issuer,tn.signatureSubpacket.issuerFingerprint,tn.signatureSubpacket.embeddedSignature].includes(a))switch(r++,a){case 2:this.created=Gr.readDate(e.subarray(r,e.length));break;case 3:{const t=Gr.readNumber(e.subarray(r,e.length));this.signatureNeverExpires=0===t,this.signatureExpirationTime=t;break}case 4:this.exportable=1===e[r++];break;case 5:this.trustLevel=e[r++],this.trustAmount=e[r++];break;case 6:this.regularExpression=e[r];break;case 7:this.revocable=1===e[r++];break;case 9:{const t=Gr.readNumber(e.subarray(r,e.length));this.keyExpirationTime=t,this.keyNeverExpires=0===t;break}case 11:n("preferredSymmetricAlgorithms",e.subarray(r,e.length));break;case 12:this.revocationKeyClass=e[r++],this.revocationKeyAlgorithm=e[r++],this.revocationKeyFingerprint=e.subarray(r,r+20);break;case 16:this.issuerKeyId.read(e.subarray(r,e.length));break;case 20:{const t=!!(128&e[r]);r+=4;const n=Gr.readNumber(e.subarray(r,r+2));r+=2;const a=Gr.readNumber(e.subarray(r,r+2));r+=2;const s=Gr.uint8ArrayToStr(e.subarray(r,r+n)),o=e.subarray(r+n,r+n+a);this.rawNotations.push({name:s,humanReadable:t,value:o,critical:i}),t&&(this.notations[s]=Gr.uint8ArrayToStr(o));break}case 21:n("preferredHashAlgorithms",e.subarray(r,e.length));break;case 22:n("preferredCompressionAlgorithms",e.subarray(r,e.length));break;case 23:n("keyServerPreferences",e.subarray(r,e.length));break;case 24:this.preferredKeyServer=Gr.uint8ArrayToStr(e.subarray(r,e.length));break;case 25:this.isPrimaryUserID=0!==e[r++];break;case 26:this.policyURI=Gr.uint8ArrayToStr(e.subarray(r,e.length));break;case 27:n("keyFlags",e.subarray(r,e.length));break;case 28:this.signersUserId=Gr.uint8ArrayToStr(e.subarray(r,e.length));break;case 29:this.reasonForRevocationFlag=e[r++],this.reasonForRevocationString=Gr.uint8ArrayToStr(e.subarray(r,e.length));break;case 30:n("features",e.subarray(r,e.length));break;case 31:{this.signatureTargetPublicKeyAlgorithm=e[r++],this.signatureTargetHashAlgorithm=e[r++];const t=Io.getHashByteLength(this.signatureTargetHashAlgorithm);this.signatureTargetHash=Gr.uint8ArrayToStr(e.subarray(r,r+t));break}case 32:this.embeddedSignature=new nl,this.embeddedSignature.read(e.subarray(r,e.length));break;case 33:this.issuerKeyVersion=e[r++],this.issuerFingerprint=e.subarray(r,e.length),5===this.issuerKeyVersion?this.issuerKeyId.read(this.issuerFingerprint):this.issuerKeyId.read(this.issuerFingerprint.subarray(-8));break;case 34:n.call(this,"preferredAeadAlgorithms",e.subarray(r,e.length));break;default:{const e=Error("Unknown signature subpacket type "+a+" @:"+r);if(i)throw e;Gr.printDebug(e)}}else this.unhashedSubpackets.push(e.subarray(r,e.length))}read_sub_packets(e,t=!0,r){const n=Gr.readNumber(e.subarray(0,2));let i=2;for(;i<2+n;){const n=Yu(e.subarray(i,e.length));i+=n.offset,this.read_sub_packet(e.subarray(i,i+n.len),t,r),i+=n.len}return i}toSign(e,t){const r=tn.signature;switch(e){case r.binary:return null!==t.text?Gr.encodeUtf8(t.getText(!0)):t.getBytes(!0);case r.text:{const e=t.getBytes(!0);return Gr.canonicalizeEOL(e)}case r.standalone:return new Uint8Array(0);case r.certGeneric:case r.certPersona:case r.certCasual:case r.certPositive:case r.certRevocation:{let e,n;if(t.userId)n=180,e=t.userId;else{if(!t.userAttribute)throw Error("Either a userId or userAttribute packet needs to be supplied for certification.");n=209,e=t.userAttribute}const i=e.write();return Gr.concat([this.toSign(r.key,t),new Uint8Array([n]),Gr.writeNumber(i.length,4),i])}case r.subkeyBinding:case r.subkeyRevocation:case r.keyBinding:return Gr.concat([this.toSign(r.key,t),this.toSign(r.key,{key:t.bind})]);case r.key:if(void 0===t.key)throw Error("Key packet is required for this signature.");return t.key.writeForHash(this.version);case r.keyRevocation:return this.toSign(r.key,t);case r.timestamp:return new Uint8Array(0);case r.thirdParty:throw Error("Not implemented");default:throw Error("Unknown signature type.")}}calculateTrailer(e,t){let r=0;return Fr.transform(Fr.clone(this.signatureData),e=>{r+=e.length},()=>{const n=[];return 5!==this.version||this.signatureType!==tn.signature.binary&&this.signatureType!==tn.signature.text||(t?n.push(new Uint8Array(6)):n.push(e.writeHeader())),n.push(new Uint8Array([this.version,255])),5===this.version&&n.push(new Uint8Array(4)),n.push(Gr.writeNumber(r,4)),Gr.concat(n)})}toHash(e,t,r=!1){const n=this.toSign(e,t);return Gr.concat([n,this.signatureData,this.calculateTrailer(t,r)])}async hash(e,t,r,n=!1,i=!0){const a=tn.write(tn.hash,this.hashAlgorithm);return r||(r=this.toHash(e,t,n)),!i&&Gr.isStream(r)?Fr.fromAsync(async()=>this.hash(e,t,await Fr.readToEnd(r),n)):Io.hash.digest(a,r)}async verify(e,t,r,n=!1,i=!1,a=rn){const s=tn.write(tn.publicKey,this.publicKeyAlgorithm),o=tn.write(tn.hash,this.hashAlgorithm);if(s!==tn.write(tn.publicKey,e.algorithm))throw Error("Public key algorithm used to sign signature does not match issuer key algorithm.");let c,u;if(this.hashed?u=await this.hashed:(c=this.toHash(t,r,n),i||(c=await Fr.readToEnd(c)),u=await this.hash(t,r,c)),u=await Fr.readToEnd(u),this.signedHashValue[0]!==u[0]||this.signedHashValue[1]!==u[1])throw Error("Message digest did not match");if(this.params=await this.params,!await Io.signature.verify(s,o,this.params,e.publicParams,c,u))throw Error("Signature verification failed");if(a.rejectHashAlgorithms.has(o))throw Error("Insecure hash algorithm: "+tn.read(tn.hash,o).toUpperCase());if(a.rejectMessageHashAlgorithms.has(o)&&[tn.signature.binary,tn.signature.text].includes(this.signatureType))throw Error("Insecure message hash algorithm: "+tn.read(tn.hash,o).toUpperCase());if(this.rawNotations.forEach(({name:e,critical:t})=>{if(t&&a.knownNotations.indexOf(e)<0)throw Error("Unknown critical notation: "+e)}),null!==this.revocationKeyClass)throw Error("This key is intended to be revoked with an authorized key, which OpenPGP.js does not support.");this.verified=!0}isExpired(e=new Date){const t=Gr.normalizeDate(e);if(null!==t){const e=this.getExpirationTime();return!(this.created<=t&&t<=e)}return!1}getExpirationTime(){return this.signatureNeverExpires?1/0:new Date(this.created.getTime()+1e3*this.signatureExpirationTime)}}function il(e,t){const r=[];return r.push(Zu(t.length+1)),r.push(new Uint8Array([e])),r.push(t),Gr.concat(r)}class al{constructor(){this.tag=tn.packet.onePassSignature,this.version=null,this.signatureType=null,this.hashAlgorithm=null,this.publicKeyAlgorithm=null,this.issuerKeyId=null,this.flags=null}read(e){let t=0;return this.version=e[t++],this.signatureType=e[t++],this.hashAlgorithm=e[t++],this.publicKeyAlgorithm=e[t++],this.issuerKeyId=new fn,this.issuerKeyId.read(e.subarray(t,t+8)),t+=8,this.flags=e[t++],this}write(){const e=new Uint8Array([3,tn.write(tn.signature,this.signatureType),tn.write(tn.hash,this.hashAlgorithm),tn.write(tn.publicKey,this.publicKeyAlgorithm)]),t=new Uint8Array([this.flags]);return Gr.concatUint8Array([e,this.issuerKeyId.write(),t])}calculateTrailer(...e){return Fr.fromAsync(async()=>nl.prototype.calculateTrailer.apply(await this.correspondingSig,e))}async verify(){const e=await this.correspondingSig;if(!e||e.tag!==tn.packet.signature)throw Error("Corresponding signature packet missing");if(e.signatureType!==this.signatureType||e.hashAlgorithm!==this.hashAlgorithm||e.publicKeyAlgorithm!==this.publicKeyAlgorithm||!e.issuerKeyId.equals(this.issuerKeyId))throw Error("Corresponding signature packet does not match one-pass signature packet");return e.hashed=this.hashed,e.verify.apply(e,arguments)}}al.prototype.hash=nl.prototype.hash,al.prototype.toHash=nl.prototype.toHash,al.prototype.toSign=nl.prototype.toSign;class sl extends Wu{constructor(e=new Date,t=rn){super(e,t),this.tag=tn.packet.secretKey,this.keyMaterial=null,this.isEncrypted=null,this.s2k_usage=0,this.s2k=null,this.symmetric=null,this.aead=null,this.privateParams=null}read(e){let t=this.readPublicKey(e);if(this.s2k_usage=e[t++],5===this.version&&t++,255===this.s2k_usage||254===this.s2k_usage||253===this.s2k_usage){if(this.symmetric=e[t++],this.symmetric=tn.read(tn.symmetric,this.symmetric),253===this.s2k_usage&&(this.aead=e[t++],this.aead=tn.read(tn.aead,this.aead)),this.s2k=new ju,t+=this.s2k.read(e.subarray(t,e.length)),"gnu-dummy"===this.s2k.type)return}else this.s2k_usage&&(this.symmetric=this.s2k_usage,this.symmetric=tn.read(tn.symmetric,this.symmetric));if(this.s2k_usage&&(this.iv=e.subarray(t,t+Io.cipher[this.symmetric].blockSize),t+=this.iv.length),5===this.version&&(t+=4),this.keyMaterial=e.subarray(t),this.isEncrypted=!!this.s2k_usage,!this.isEncrypted){const e=this.keyMaterial.subarray(0,-2);if(!Gr.equalsUint8Array(Gr.writeChecksum(e),this.keyMaterial.subarray(-2)))throw Error("Key checksum mismatch");try{const t=tn.write(tn.publicKey,this.algorithm),{privateParams:r}=Io.parsePrivateKeyParams(t,e,this.publicParams);this.privateParams=r}catch(e){throw Error("Error reading MPIs")}}}write(){const e=[this.writePublicKey()];e.push(new Uint8Array([this.s2k_usage]));const t=[];if(255!==this.s2k_usage&&254!==this.s2k_usage&&253!==this.s2k_usage||(t.push(tn.write(tn.symmetric,this.symmetric)),253===this.s2k_usage&&t.push(tn.write(tn.aead,this.aead)),t.push(...this.s2k.write())),this.s2k_usage&&"gnu-dummy"!==this.s2k.type&&t.push(...this.iv),5===this.version&&e.push(new Uint8Array([t.length])),e.push(new Uint8Array(t)),!this.isDummy()){if(!this.s2k_usage){const e=tn.write(tn.publicKey,this.algorithm),t=Io.serializeParams(e,this.privateParams);this.keyMaterial=Gr.concatUint8Array([t,Gr.writeChecksum(t)])}5===this.version&&e.push(Gr.writeNumber(this.keyMaterial.length,4)),e.push(this.keyMaterial)}return Gr.concatUint8Array(e)}isDecrypted(){return!1===this.isEncrypted}isDummy(){return!(!this.s2k||"gnu-dummy"!==this.s2k.type)}makeDummy(e=rn){this.isDummy()||(this.isDecrypted()&&this.clearPrivateParams(),this.isEncrypted=null,this.keyMaterial=null,this.s2k=new ju(e),this.s2k.algorithm=0,this.s2k.c=0,this.s2k.type="gnu-dummy",this.s2k_usage=254,this.symmetric="aes256")}async encrypt(e,t=rn){if(this.isDummy())return;if(!this.isDecrypted())throw Error("Key packet is already encrypted");if(this.isDecrypted()&&!e)return void(this.s2k_usage=0);if(!e)throw Error("The key must be decrypted before removing passphrase protection.");this.s2k=new ju(t),this.s2k.salt=await Io.random.getRandomBytes(8);const r=tn.write(tn.publicKey,this.algorithm),n=Io.serializeParams(r,this.privateParams);this.symmetric="aes256";const i=await ol(this.s2k,e,this.symmetric),a=Io.cipher[this.symmetric].blockSize;if(this.iv=await Io.random.getRandomBytes(a),t.aeadProtect){this.s2k_usage=253,this.aead="eax";const e=Io[this.aead],t=await e(this.symmetric,i);this.keyMaterial=await t.encrypt(n,this.iv.subarray(0,e.ivLength),new Uint8Array)}else this.s2k_usage=254,this.keyMaterial=await Io.cfb.encrypt(this.symmetric,i,Gr.concatUint8Array([n,await Io.hash.sha1(n,t)]),this.iv,t)}async decrypt(e){if(this.isDummy())return!1;if(this.isDecrypted())throw Error("Key packet is already decrypted.");let t,r;if(254!==this.s2k_usage&&253!==this.s2k_usage)throw 255===this.s2k_usage?Error("Encrypted private key is authenticated using an insecure two-byte hash"):Error("Private key is encrypted using an insecure S2K function: unsalted MD5");if(t=await ol(this.s2k,e,this.symmetric),253===this.s2k_usage){const e=Io[this.aead];try{const n=await e(this.symmetric,t);r=await n.decrypt(this.keyMaterial,this.iv.subarray(0,e.ivLength),new Uint8Array)}catch(e){if("Authentication tag mismatch"===e.message)throw Error("Incorrect key passphrase: "+e.message);throw e}}else{const e=await Io.cfb.decrypt(this.symmetric,t,this.keyMaterial,this.iv);r=e.subarray(0,-20);const n=await Io.hash.sha1(r);if(!Gr.equalsUint8Array(n,e.subarray(-20)))throw Error("Incorrect key passphrase")}try{const e=tn.write(tn.publicKey,this.algorithm),{privateParams:t}=Io.parsePrivateKeyParams(e,r,this.publicParams);this.privateParams=t}catch(e){throw Error("Error reading MPIs")}this.isEncrypted=!1,this.keyMaterial=null,this.s2k_usage=0}async validate(){if(this.isDummy())return;if(!this.isDecrypted())throw Error("Key is not decrypted");const e=tn.write(tn.publicKey,this.algorithm);let t;try{t=await Io.validateParams(e,this.publicParams,this.privateParams)}catch(e){t=!1}if(!t)throw Error("Key is invalid")}async generate(e,t){const r=tn.write(tn.publicKey,this.algorithm),{privateParams:n,publicParams:i}=await Io.generateParams(r,e,t);this.privateParams=n,this.publicParams=i,this.isEncrypted=!1}clearPrivateParams(){this.isDummy()||(Object.keys(this.privateParams).forEach(e=>{this.privateParams[e].fill(0),delete this.privateParams[e]}),this.privateParams=null,this.isEncrypted=!0)}}async function ol(e,t,r){return e.produce_key(t,Io.cipher[r].keySize)}var cl=ti((function(e){!function(t){function r(e){function t(){return Ae<Se}function r(){return Ae}function i(e){Ae=e}function a(){Ae=0,Se=ke.length}function s(e,t){return{name:e,tokens:t||"",semantic:t||"",children:[]}}function o(e,t){var r;return null===t?null:((r=s(e)).tokens=t.tokens,r.semantic=t.semantic,r.children.push(t),r)}function c(e,t){return null!==t&&(e.tokens+=t.tokens,e.semantic+=t.semantic),e.children.push(t),e}function u(e){var r;return t()&&e(r=ke[Ae])?(Ae+=1,s("token",r)):null}function l(e){return function(){return o("literal",u((function(t){return t===e})))}}function h(){var e=arguments;return function(){var t,n,a,o;for(o=r(),n=s("and"),t=0;t<e.length;t+=1){if(null===(a=e[t]()))return i(o),null;c(n,a)}return n}}function d(){var e=arguments;return function(){var t,n,a;for(a=r(),t=0;t<e.length;t+=1){if(null!==(n=e[t]()))return n;i(a)}return null}}function f(e){return function(){var t,n;return n=r(),null!==(t=e())?t:(i(n),s("opt"))}}function y(e){return function(){var t=e();return null!==t&&(t.semantic=""),t}}function p(e){return function(){var t=e();return null!==t&&t.semantic.length>0&&(t.semantic=" "),t}}function g(e,t){return function(){var n,a,o,u,l;for(u=r(),n=s("star"),o=0,l=void 0===t?0:t;null!==(a=e());)o+=1,c(n,a);return o>=l?n:(i(u),null)}}function m(e){return e.charCodeAt(0)>=128}function w(){return o("cr",l("\r")())}function b(){return o("crlf",h(w,k)())}function _(){return o("dquote",l('"')())}function v(){return o("htab",l("\t")())}function k(){return o("lf",l("\n")())}function A(){return o("sp",l(" ")())}function S(){return o("vchar",u((function(t){var r=t.charCodeAt(0),n=33<=r&&r<=126;return e.rfc6532&&(n=n||m(t)),n})))}function E(){return o("wsp",d(A,v)())}function P(){var e=o("quoted-pair",d(h(l("\\"),d(S,E)),ne)());return null===e?null:(e.semantic=e.semantic[1],e)}function x(){return o("fws",d(ae,h(f(h(g(E),y(b))),g(E,1)))())}function K(){return o("ctext",d((function(){return u((function(t){var r=t.charCodeAt(0),n=33<=r&&r<=39||42<=r&&r<=91||93<=r&&r<=126;return e.rfc6532&&(n=n||m(t)),n}))}),te)())}function C(){return o("ccontent",d(K,P,U)())}function U(){return o("comment",h(l("("),g(h(f(x),C)),f(x),l(")"))())}function R(){return o("cfws",d(h(g(h(f(x),U),1),f(x)),x)())}function T(){return o("atext",u((function(t){var r="a"<=t&&t<="z"||"A"<=t&&t<="Z"||"0"<=t&&t<="9"||["!","#","$","%","&","'","*","+","-","/","=","?","^","_","`","{","|","}","~"].indexOf(t)>=0;return e.rfc6532&&(r=r||m(t)),r})))}function D(){return o("atom",h(p(f(R)),g(T,1),p(f(R)))())}function I(){var e,t;return null===(e=o("dot-atom-text",g(T,1)()))||null!==(t=g(h(l("."),g(T,1)))())&&c(e,t),e}function B(){return o("dot-atom",h(y(f(R)),I,y(f(R)))())}function z(){return o("qtext",d((function(){return u((function(t){var r=t.charCodeAt(0),n=33===r||35<=r&&r<=91||93<=r&&r<=126;return e.rfc6532&&(n=n||m(t)),n}))}),re)())}function O(){return o("qcontent",d(z,P)())}function q(){return o("quoted-string",h(y(f(R)),y(_),g(h(f(p(x)),O)),f(y(x)),y(_),y(f(R)))())}function N(){return o("word",d(D,q)())}function M(){return o("address",d(L,H)())}function L(){return o("mailbox",d(j,J)())}function j(){return o("name-addr",h(f(W),F)())}function F(){return o("angle-addr",d(h(y(f(R)),l("<"),J,l(">"),y(f(R))),se)())}function H(){return o("group",h(W,l(":"),f($),l(";"),y(f(R)))())}function W(){return o("display-name",(null!==(e=o("phrase",d(ie,g(N,1))()))&&(e.semantic=function(e){return e.replace(/([ \t]|\r\n)+/g," ").replace(/^\s*/,"").replace(/\s*$/,"")}(e.semantic)),e));var e}function G(){return o("mailbox-list",d(h(L,g(h(l(","),L))),ue)())}function V(){return o("address-list",d(h(M,g(h(l(","),M))),le)())}function $(){return o("group-list",d(G,y(R),he)())}function Y(){return o("local-part",d(de,B,q)())}function Z(){return o("dtext",d((function(){return u((function(t){var r=t.charCodeAt(0),n=33<=r&&r<=90||94<=r&&r<=126;return e.rfc6532&&(n=n||m(t)),n}))}),ye)())}function Q(){return o("domain-literal",h(y(f(R)),l("["),g(h(f(x),Z)),f(x),l("]"),y(f(R)))())}function X(){return o("domain",(t=d(fe,B,Q)(),e.rejectTLD&&t&&t.semantic&&t.semantic.indexOf(".")<0?null:(t&&(t.semantic=t.semantic.replace(/\s+/g,"")),t)));var t}function J(){return o("addr-spec",h(Y,l("@"),X)())}function ee(){return e.strict?null:o("obs-NO-WS-CTL",u((function(e){var t=e.charCodeAt(0);return 1<=t&&t<=8||11===t||12===t||14<=t&&t<=31||127===t})))}function te(){return e.strict?null:o("obs-ctext",ee())}function re(){return e.strict?null:o("obs-qtext",ee())}function ne(){return e.strict?null:o("obs-qp",h(l("\\"),d(l("\0"),ee,k,w))())}function ie(){return e.strict?null:e.atInDisplayName?o("obs-phrase",h(N,g(d(N,l("."),l("@"),p(R))))()):o("obs-phrase",h(N,g(d(N,l("."),p(R))))())}function ae(){return e.strict?null:o("obs-FWS",g(h(y(f(b)),E),1)())}function se(){return e.strict?null:o("obs-angle-addr",h(y(f(R)),l("<"),oe,J,l(">"),y(f(R)))())}function oe(){return e.strict?null:o("obs-route",h(ce,l(":"))())}function ce(){return e.strict?null:o("obs-domain-list",h(g(d(y(R),l(","))),l("@"),X,g(h(l(","),y(f(R)),f(h(l("@"),X)))))())}function ue(){return e.strict?null:o("obs-mbox-list",h(g(h(y(f(R)),l(","))),L,g(h(l(","),f(h(L,y(R))))))())}function le(){return e.strict?null:o("obs-addr-list",h(g(h(y(f(R)),l(","))),M,g(h(l(","),f(h(M,y(R))))))())}function he(){return e.strict?null:o("obs-group-list",h(g(h(y(f(R)),l(",")),1),y(f(R)))())}function de(){return e.strict?null:o("obs-local-part",h(N,g(h(l("."),N)))())}function fe(){return e.strict?null:o("obs-domain",h(D,g(h(l("."),D)))())}function ye(){return e.strict?null:o("obs-dtext",d(ee,P)())}function pe(e,t){var r,n,i;if(null==t)return null;for(n=[t];n.length>0;){if((i=n.pop()).name===e)return i;for(r=i.children.length-1;r>=0;r-=1)n.push(i.children[r])}return null}function ge(e,t){var r,n,i,a,s;if(null==t)return null;for(n=[t],a=[],s={},r=0;r<e.length;r+=1)s[e[r]]=!0;for(;n.length>0;)if((i=n.pop()).name in s)a.push(i);else for(r=i.children.length-1;r>=0;r-=1)n.push(i.children[r]);return a}function me(t){var r,n,i,a,s;if(null===t)return null;for(r=[],n=ge(["group","mailbox"],t),i=0;i<n.length;i+=1)"group"===(a=n[i]).name?r.push(we(a)):"mailbox"===a.name&&r.push(be(a));return s={ast:t,addresses:r},e.simple&&(s=function(e){var t;if(e&&e.addresses)for(t=0;t<e.addresses.length;t+=1)delete e.addresses[t].node;return e}(s)),e.oneResult?function(t){if(!t)return null;if(!e.partial&&t.addresses.length>1)return null;return t.addresses&&t.addresses[0]}(s):e.simple?s&&s.addresses:s}function we(e){var t,r=pe("display-name",e),n=[],i=ge(["mailbox"],e);for(t=0;t<i.length;t+=1)n.push(be(i[t]));return{node:e,parts:{name:r},type:e.name,name:_e(r),addresses:n}}function be(e){var t=pe("display-name",e),r=pe("addr-spec",e),n=function(e,t){var r,n,i,a;if(null==t)return null;for(n=[t],a=[];n.length>0;)for((i=n.pop()).name===e&&a.push(i),r=i.children.length-1;r>=0;r-=1)n.push(i.children[r]);return a}("cfws",e),i=ge(["comment"],e),a=pe("local-part",r),s=pe("domain",r);return{node:e,parts:{name:t,address:r,local:a,domain:s,comments:n},type:e.name,name:_e(t),address:_e(r),local:_e(a),domain:_e(s),comments:ve(i),groupName:_e(e.groupName)}}function _e(e){return null!=e?e.semantic:null}function ve(e){var t="";if(e)for(var r=0;r<e.length;r+=1)t+=_e(e[r]);return t}var ke,Ae,Se,Ee,Pe;if(null===(e=n(e,{})))return null;if(ke=e.input,Pe={address:M,"address-list":V,"angle-addr":F,from:function(){return o("from",d(G,V)())},group:H,mailbox:L,"mailbox-list":G,"reply-to":function(){return o("reply-to",V())},sender:function(){return o("sender",d(L,M)())}}[e.startAt]||V,!e.strict){if(a(),e.strict=!0,Ee=Pe(ke),e.partial||!t())return me(Ee);e.strict=!1}return a(),Ee=Pe(ke),!e.partial&&t()?null:me(Ee)}function n(e,t){function r(e){return"[object String]"===Object.prototype.toString.call(e)}function n(e){return null==e}var i,a;if(r(e))e={input:e};else if(!function(e){return e===Object(e)}(e))return null;if(!r(e.input))return null;if(!t)return null;for(a in i={oneResult:!1,partial:!1,rejectTLD:!1,rfc6532:!1,simple:!1,startAt:"address-list",strict:!1,atInDisplayName:!1})n(e[a])&&(e[a]=n(t[a])?i[a]:t[a]);return e}r.parseOneAddress=function(e){return r(n(e,{oneResult:!0,rfc6532:!0,simple:!0,startAt:"address-list"}))},r.parseAddressList=function(e){return r(n(e,{rfc6532:!0,simple:!0,startAt:"address-list"}))},r.parseFrom=function(e){return r(n(e,{rfc6532:!0,simple:!0,startAt:"from"}))},r.parseSender=function(e){return r(n(e,{oneResult:!0,rfc6532:!0,simple:!0,startAt:"sender"}))},r.parseReplyTo=function(e){return r(n(e,{rfc6532:!0,simple:!0,startAt:"reply-to"}))},e.exports=r}()}));class ul{constructor(){this.tag=tn.packet.userID,this.userid="",this.name="",this.email="",this.comment=""}static fromObject(e){if(Gr.isString(e)||e.name&&!Gr.isString(e.name)||e.email&&!Gr.isEmailAddress(e.email)||e.comment&&!Gr.isString(e.comment))throw Error("Invalid user ID format");const t=new ul;Object.assign(t,e);const r=[];return t.name&&r.push(t.name),t.comment&&r.push(`(${t.comment})`),t.email&&r.push(`<${t.email}>`),t.userid=r.join(" "),t}read(e,t=rn){const r=Gr.decodeUtf8(e);if(r.length>t.maxUseridLength)throw Error("User ID string is too long");try{const{name:e,address:t,comments:n}=cl.parseOneAddress({input:r,atInDisplayName:!0});this.comment=n.replace(/^\(|\)$/g,""),this.name=e,this.email=t}catch(e){}this.userid=r}write(){return Gr.encodeUtf8(this.userid)}}class ll extends sl{constructor(e=new Date,t=rn){super(e,t),this.tag=tn.packet.secretSubkey}}class hl{constructor(){this.tag=tn.packet.trust}read(){}}function dl(e,t){const r=function(e){return e.substr(0,1).toUpperCase()+e.substr(1)+"Packet"}(e);if(!t[r])throw Error("Packet not allowed in this context: "+r);return new t[r]}class fl extends Array{async read(e,t,r,n=rn){this.stream=Fr.transformPair(e,async(e,i)=>{const a=Fr.getWriter(i);try{for(;;){if(await a.ready,await tl(e,r,async e=>{try{const i=dl(tn.read(tn.packet,e.tag),t);i.packets=new fl,i.fromStream=Gr.isStream(e.packet),await i.read(e.packet,n,r),await a.write(i)}catch(t){n.tolerant&&!el(e.tag)||await a.abort(t),Gr.printDebugError(t)}}))return await a.ready,void await a.close()}}catch(e){await a.abort(e)}});const i=Fr.getReader(this.stream);for(;;){const{done:e,value:t}=await i.read();if(e?this.stream=null:this.push(t),e||el(t.tag))break}i.releaseLock()}write(){const e=[];for(let t=0;t<this.length;t++){const r=this[t].write();if(Gr.isStream(r)&&el(this[t].tag)){let n=[],i=0;const a=512;e.push(Xu(this[t].tag)),e.push(Fr.transform(r,e=>{if(n.push(e),i+=e.length,i>=a){const e=Math.min(Math.log(i)/Math.LN2|0,30),t=2**e,r=Gr.concat([Qu(e)].concat(n));return n=[r.subarray(1+t)],i=n[0].length,r.subarray(0,1+t)}},()=>Gr.concat([Zu(i)].concat(n))))}else{if(Gr.isStream(r)){let n=0;e.push(Fr.transform(Fr.clone(r),e=>{n+=e.length},()=>Ju(this[t].tag,n)))}else e.push(Ju(this[t].tag,r.length));e.push(r)}}return Gr.concat(e)}push(e){e&&(e.packets=e.packets||new fl,super.push(e))}filterByTag(...e){const t=new fl,r=e=>t=>e===t;for(let n=0;n<this.length;n++)e.some(r(this[n].tag))&&t.push(this[n]);return t}findPacket(e){return this.find(t=>t.tag===e)}indexOfTag(...e){const t=[],r=this,n=e=>t=>e===t;for(let i=0;i<this.length;i++)e.some(n(r[i].tag))&&t.push(i);return t}concat(e){if(e)for(let t=0;t<e.length;t++)this.push(e[t]);return this}}class yl{constructor(e){this.packets=e||new fl}write(){return this.packets.write()}armor(e=rn){return dn(tn.armor.signature,this.write(),void 0,void 0,void 0,e)}}async function pl({armoredSignature:e,binarySignature:t,config:r}){r={...rn,...r};let n=e||t;if(!n)throw Error("readSignature: must pass options object containing `armoredSignature` or `binarySignature`");if(e){const{type:e,data:t}=await hn(n,r);if(e!==tn.armor.signature)throw Error("Armored text not of type signature");n=t}const i=new fl;return await i.read(n,{SignaturePacket:nl},void 0,r),new yl(i)}const gl={PublicKeyPacket:Wu,PublicSubkeyPacket:$u,SecretKeyPacket:sl,SecretSubkeyPacket:ll,UserIDPacket:ul,UserAttributePacket:rl,SignaturePacket:nl};async function ml(e,t){const r=new ll(e.date,t);return r.packets=null,r.algorithm=tn.read(tn.publicKey,e.algorithm),await r.generate(e.rsaBits,e.curve),r}async function wl(e,t){const r=new sl(e.date,t);return r.packets=null,r.algorithm=tn.read(tn.publicKey,e.algorithm),await r.generate(e.rsaBits,e.curve,e.config),r}async function bl(e,t,r,n,i=new Date,a){let s,o;for(let c=e.length-1;c>=0;c--)try{s&&!(e[c].created>=s.created)||e[c].isExpired(i)||(e[c].verified||await e[c].verify(t,r,n,void 0,void 0,a),s=e[c])}catch(e){o=e}if(!s)throw Gr.wrapError(`Could not find valid ${tn.read(tn.signature,r)} signature in key ${t.getKeyId().toHex()}`.replace("certGeneric ","self-").replace(/([a-z])([A-Z])/g,(e,t,r)=>t+" "+r.toLowerCase()),o);return s}function _l(e,t,r=new Date){const n=Gr.normalizeDate(r);if(null!==n){const i=xl(e,t);return!(e.created<=n&&n<=i)||t&&t.isExpired(r)}return!1}async function vl(e,t,r,n){const i={};i.key=t,i.bind=e;const a=new nl(r.date);return a.signatureType=tn.signature.subkeyBinding,a.publicKeyAlgorithm=t.algorithm,a.hashAlgorithm=await kl(null,e,void 0,void 0,n),r.sign?(a.keyFlags=[tn.keyFlags.signData],a.embeddedSignature=await Sl(i,null,e,{signatureType:tn.signature.keyBinding},r.date,void 0,void 0,void 0,n)):a.keyFlags=[tn.keyFlags.encryptCommunication|tn.keyFlags.encryptStorage],r.keyExpirationTime>0&&(a.keyExpirationTime=r.keyExpirationTime,a.keyNeverExpires=!1),await a.sign(t,i),a}async function kl(e,t,r=new Date,n={},i){let a=i.preferHashAlgorithm,s=a;if(e){const t=await e.getPrimaryUser(r,n,i);t.selfCertification.preferredHashAlgorithms&&([s]=t.selfCertification.preferredHashAlgorithms,a=Io.hash.getHashByteLength(a)<=Io.hash.getHashByteLength(s)?s:a)}switch(Object.getPrototypeOf(t)){case sl.prototype:case Wu.prototype:case ll.prototype:case $u.prototype:switch(t.algorithm){case"ecdh":case"ecdsa":case"eddsa":s=Io.publicKey.elliptic.getPreferredHashAlgo(t.publicParams.oid)}}return Io.hash.getHashByteLength(a)<=Io.hash.getHashByteLength(s)?s:a}async function Al(e,t,r=new Date,n=[],i=rn){const a="symmetric"===e?"preferredSymmetricAlgorithms":"preferredAeadAlgorithms",s="symmetric"===e?tn.symmetric.aes128:tn.aead.eax,o={};await Promise.all(t.map((async function(e,t){const c=await e.getPrimaryUser(r,n[t],i);if(!c.selfCertification[a])return s;c.selfCertification[a].forEach((function(e,t){const r=o[e]||(o[e]={prio:0,count:0,algo:e});r.prio+=64>>t,r.count++}))})));let c={prio:0,algo:s};return Object.values(o).forEach(({prio:r,count:n,algo:i})=>{try{i!==tn[e].plaintext&&i!==tn[e].idea&&tn.read(tn[e],i)&&n===t.length&&r>c.prio&&(c=o[i])}catch(e){}}),c.algo}async function Sl(e,t,r,n,i,a,s=!1,o=!1,c){if(r.isDummy())throw Error("Cannot sign with a gnu-dummy key.");if(!r.isDecrypted())throw Error("Private key is not decrypted.");const u=new nl(i);return Object.assign(u,n),u.publicKeyAlgorithm=r.algorithm,u.hashAlgorithm=await kl(t,r,i,a,c),await u.sign(r,e,s,o),u}async function El(e,t,r,n){(e=e[r])&&(t[r].length?await Promise.all(e.map((async function(e){e.isExpired()||n&&!await n(e)||t[r].some((function(t){return Gr.equalsUint8Array(t.write_params(),e.write_params())}))||t[r].push(e)}))):t[r]=e)}async function Pl(e,t,r,n,i,a,s=new Date,o){a=a||e;const c=Gr.normalizeDate(s),u=[];return await Promise.all(n.map((async function(e){try{i&&!e.issuerKeyId.equals(i.issuerKeyId)||o.revocationsExpire&&e.isExpired(c)||(e.verified||await e.verify(a,t,r,void 0,void 0,o),u.push(e.issuerKeyId))}catch(e){}}))),i?(i.revoked=!!u.some(e=>e.equals(i.issuerKeyId))||(i.revoked||!1),i.revoked):u.length>0}function xl(e,t){let r;return!1===t.keyNeverExpires&&(r=e.created.getTime()+1e3*t.keyExpirationTime),r?new Date(r):1/0}function Kl(e,t={}){switch(e.type=e.type||t.type,e.curve=e.curve||t.curve,e.rsaBits=e.rsaBits||t.rsaBits,e.keyExpirationTime=void 0!==e.keyExpirationTime?e.keyExpirationTime:t.keyExpirationTime,e.passphrase=Gr.isString(e.passphrase)?e.passphrase:t.passphrase,e.date=e.date||t.date,e.sign=e.sign||!1,e.type){case"ecc":try{e.curve=tn.write(tn.curve,e.curve)}catch(e){throw Error("Invalid curve")}e.curve!==tn.curve.ed25519&&e.curve!==tn.curve.curve25519||(e.curve=e.sign?tn.curve.ed25519:tn.curve.curve25519),e.sign?e.algorithm=e.curve===tn.curve.ed25519?tn.publicKey.eddsa:tn.publicKey.ecdsa:e.algorithm=tn.publicKey.ecdh;break;case"rsa":e.algorithm=tn.publicKey.rsaEncryptSign;break;default:throw Error("Unsupported key type "+e.type)}return e}function Cl(e,t){if(!t.verified||!1!==t.revoked)throw Error("Signature not verified");return e.algorithm!==tn.read(tn.publicKey,tn.publicKey.rsaEncrypt)&&e.algorithm!==tn.read(tn.publicKey,tn.publicKey.elgamal)&&e.algorithm!==tn.read(tn.publicKey,tn.publicKey.ecdh)&&(!t.keyFlags||0!=(t.keyFlags[0]&tn.keyFlags.signData))}function Ul(e,t){if(!t.verified||!1!==t.revoked)throw Error("Signature not verified");return e.algorithm!==tn.read(tn.publicKey,tn.publicKey.dsa)&&e.algorithm!==tn.read(tn.publicKey,tn.publicKey.rsaSign)&&e.algorithm!==tn.read(tn.publicKey,tn.publicKey.ecdsa)&&e.algorithm!==tn.read(tn.publicKey,tn.publicKey.eddsa)&&(!t.keyFlags||0!=(t.keyFlags[0]&tn.keyFlags.encryptCommunication)||0!=(t.keyFlags[0]&tn.keyFlags.encryptStorage))}function Rl(e,t){if(!e.verified)throw Error("Signature not verified");return!!t.allowInsecureDecryptionWithSigningKeys||(!e.keyFlags||0!=(e.keyFlags[0]&tn.keyFlags.encryptCommunication)||0!=(e.keyFlags[0]&tn.keyFlags.encryptStorage))}class Tl{constructor(e){if(!(this instanceof Tl))return new Tl(e);this.userId=e.tag===tn.packet.userID?e:null,this.userAttribute=e.tag===tn.packet.userAttribute?e:null,this.selfCertifications=[],this.otherCertifications=[],this.revocationSignatures=[]}toPacketlist(){const e=new fl;return e.push(this.userId||this.userAttribute),e.concat(this.revocationSignatures),e.concat(this.selfCertifications),e.concat(this.otherCertifications),e}async sign(e,t,r){const n={userId:this.userId,userAttribute:this.userAttribute,key:e},i=new Tl(n.userId||n.userAttribute);return i.otherCertifications=await Promise.all(t.map((async function(t){if(t.isPublic())throw Error("Need private key for signing");if(t.hasSameFingerprintAs(e))throw Error("Not implemented for self signing");const i=await t.getSigningKey(void 0,void 0,void 0,r);return Sl(n,t,i.keyPacket,{signatureType:tn.signature.certGeneric,keyFlags:[tn.keyFlags.certifyKeys|tn.keyFlags.signData]},void 0,void 0,void 0,void 0,r)}))),await i.update(this,e),i}async isRevoked(e,t,r,n=new Date,i){return Pl(e,tn.signature.certRevocation,{key:e,userId:this.userId,userAttribute:this.userAttribute},this.revocationSignatures,t,r,n,i)}async verifyCertificate(e,t,r,n=new Date,i){const a=this,s=t.issuerKeyId,o={userId:this.userId,userAttribute:this.userAttribute,key:e};return(await Promise.all(r.map((async function(r){if(!r.getKeyIds().some(e=>e.equals(s)))return null;const c=await r.getSigningKey(s,n,void 0,i);if(t.revoked||await a.isRevoked(e,t,c.keyPacket,n,i))throw Error("User certificate is revoked");try{t.verified||await t.verify(c.keyPacket,tn.signature.certGeneric,o,void 0,void 0,i)}catch(e){throw Gr.wrapError("User certificate is invalid",e)}if(t.isExpired(n))throw Error("User certificate is expired");return!0})))).find(e=>null!==e)||null}async verifyAllCertifications(e,t,r=new Date,n){const i=this,a=this.selfCertifications.concat(this.otherCertifications);return Promise.all(a.map((async function(a){return{keyid:a.issuerKeyId,valid:await i.verifyCertificate(e,a,t,r,n).catch(()=>!1)}})))}async verify(e,t=new Date,r){if(!this.selfCertifications.length)throw Error("No self-certifications");const n=this,i={userId:this.userId,userAttribute:this.userAttribute,key:e};let a;for(let s=this.selfCertifications.length-1;s>=0;s--)try{const a=this.selfCertifications[s];if(a.revoked||await n.isRevoked(e,a,void 0,t,r))throw Error("Self-certification is revoked");try{a.verified||await a.verify(e,tn.signature.certGeneric,i,void 0,void 0,r)}catch(e){throw Gr.wrapError("Self-certification is invalid",e)}if(a.isExpired(t))throw Error("Self-certification is expired");return!0}catch(e){a=e}throw a}async update(e,t,r){const n={userId:this.userId,userAttribute:this.userAttribute,key:t};await El(e,this,"selfCertifications",(async function(e){try{return e.verified||await e.verify(t,tn.signature.certGeneric,n,void 0,void 0,r),!0}catch(e){return!1}})),await El(e,this,"otherCertifications"),await El(e,this,"revocationSignatures",(function(e){return Pl(t,tn.signature.certRevocation,n,[e],void 0,void 0,void 0,r)}))}}class Dl{constructor(e){if(!(this instanceof Dl))return new Dl(e);this.keyPacket=e,this.bindingSignatures=[],this.revocationSignatures=[]}toPacketlist(){const e=new fl;return e.push(this.keyPacket),e.concat(this.revocationSignatures),e.concat(this.bindingSignatures),e}async isRevoked(e,t,r,n=new Date,i=rn){return Pl(e,tn.signature.subkeyRevocation,{key:e,bind:this.keyPacket},this.revocationSignatures,t,r,n,i)}async verify(e,t=new Date,r=rn){const n={key:e,bind:this.keyPacket},i=await bl(this.bindingSignatures,e,tn.signature.subkeyBinding,n,t,r);if(i.revoked||await this.isRevoked(e,i,null,t,r))throw Error("Subkey is revoked");if(_l(this.keyPacket,i,t))throw Error("Subkey is expired");return i}async getExpirationTime(e,t=new Date,r=rn){const n={key:e,bind:this.keyPacket};let i;try{i=await bl(this.bindingSignatures,e,tn.signature.subkeyBinding,n,t,r)}catch(e){return null}const a=xl(this.keyPacket,i),s=i.getExpirationTime();return a<s?a:s}async update(e,t,r=rn){if(!this.hasSameFingerprintAs(e))throw Error("SubKey update method: fingerprints of subkeys not equal");this.keyPacket.tag===tn.packet.publicSubkey&&e.keyPacket.tag===tn.packet.secretSubkey&&(this.keyPacket=e.keyPacket);const n=this,i={key:t,bind:n.keyPacket};await El(e,this,"bindingSignatures",(async function(e){for(let t=0;t<n.bindingSignatures.length;t++)if(n.bindingSignatures[t].issuerKeyId.equals(e.issuerKeyId))return e.created>n.bindingSignatures[t].created&&(n.bindingSignatures[t]=e),!1;try{return e.verified||await e.verify(t,tn.signature.subkeyBinding,i,void 0,void 0,r),!0}catch(e){return!1}})),await El(e,this,"revocationSignatures",(function(e){return Pl(t,tn.signature.subkeyRevocation,i,[e],void 0,void 0,void 0,r)}))}async revoke(e,{flag:t=tn.reasonForRevocation.noReason,string:r=""}={},n=new Date,i=rn){const a={key:e,bind:this.keyPacket},s=new Dl(this.keyPacket);return s.revocationSignatures.push(await Sl(a,null,e,{signatureType:tn.signature.subkeyRevocation,reasonForRevocationFlag:tn.write(tn.reasonForRevocation,t),reasonForRevocationString:r},n,void 0,void 0,void 0,i)),await s.update(this,e),s}hasSameFingerprintAs(e){return this.keyPacket.hasSameFingerprintAs(e.keyPacket||e)}}["getKeyId","getFingerprint","getAlgorithmInfo","getCreationTime","isDecrypted"].forEach(e=>{Dl.prototype[e]=function(){return this.keyPacket[e]()}});class Il{constructor(e){if(!(this instanceof Il))return new Il(e);if(this.keyPacket=null,this.revocationSignatures=[],this.directSignatures=[],this.users=[],this.subKeys=[],this.packetlist2structure(e),!this.keyPacket)throw Error("Invalid key: need at least key packet")}get primaryKey(){return this.keyPacket}packetlist2structure(e){let t,r,n;for(let i=0;i<e.length;i++)switch(e[i].tag){case tn.packet.publicKey:case tn.packet.secretKey:if(this.keyPacket)throw Error("Key block contains multiple keys");this.keyPacket=e[i],r=this.getKeyId();break;case tn.packet.userID:case tn.packet.userAttribute:t=new Tl(e[i]),this.users.push(t);break;case tn.packet.publicSubkey:case tn.packet.secretSubkey:t=null,n=new Dl(e[i]),this.subKeys.push(n);break;case tn.packet.signature:switch(e[i].signatureType){case tn.signature.certGeneric:case tn.signature.certPersona:case tn.signature.certCasual:case tn.signature.certPositive:if(!t){Gr.printDebug("Dropping certification signatures without preceding user packet");continue}e[i].issuerKeyId.equals(r)?t.selfCertifications.push(e[i]):t.otherCertifications.push(e[i]);break;case tn.signature.certRevocation:t?t.revocationSignatures.push(e[i]):this.directSignatures.push(e[i]);break;case tn.signature.key:this.directSignatures.push(e[i]);break;case tn.signature.subkeyBinding:if(!n){Gr.printDebug("Dropping subkey binding signature without preceding subkey packet");continue}n.bindingSignatures.push(e[i]);break;case tn.signature.keyRevocation:this.revocationSignatures.push(e[i]);break;case tn.signature.subkeyRevocation:if(!n){Gr.printDebug("Dropping subkey revocation signature without preceding subkey packet");continue}n.revocationSignatures.push(e[i])}}}toPacketlist(){const e=new fl;return e.push(this.keyPacket),e.concat(this.revocationSignatures),e.concat(this.directSignatures),this.users.map(t=>e.concat(t.toPacketlist())),this.subKeys.map(t=>e.concat(t.toPacketlist())),e}async clone(){return new Il(this.toPacketlist())}getSubkeys(e=null){const t=[];return this.subKeys.forEach(r=>{e&&!r.getKeyId().equals(e,!0)||t.push(r)}),t}getKeys(e=null){const t=[];return e&&!this.getKeyId().equals(e,!0)||t.push(this),t.concat(this.getSubkeys(e))}getKeyIds(){return this.getKeys().map(e=>e.getKeyId())}getUserIds(){return this.users.map(e=>e.userId?e.userId.userid:null).filter(e=>null!==e)}isPublic(){return this.keyPacket.tag===tn.packet.publicKey}isPrivate(){return this.keyPacket.tag===tn.packet.secretKey}toPublic(){const e=new fl,t=this.toPacketlist();let r,n,i;for(let a=0;a<t.length;a++)switch(t[a].tag){case tn.packet.secretKey:r=t[a].writePublicKey(),n=new Wu,n.read(r),e.push(n);break;case tn.packet.secretSubkey:r=t[a].writePublicKey(),i=new $u,i.read(r),e.push(i);break;default:e.push(t[a])}return new Il(e)}armor(e=rn){return dn(this.isPublic()?tn.armor.publicKey:tn.armor.privateKey,this.toPacketlist().write(),void 0,void 0,void 0,e)}async getSigningKey(e=null,t=new Date,r={},n=rn){await this.verifyPrimaryKey(t,r,n);const i=this.keyPacket,a=this.subKeys.slice().sort((e,t)=>t.keyPacket.created-e.keyPacket.created);let s;for(let r=0;r<a.length;r++)if(!e||a[r].getKeyId().equals(e))try{await a[r].verify(i,t,n);const e={key:i,bind:a[r].keyPacket},s=await bl(a[r].bindingSignatures,i,tn.signature.subkeyBinding,e,t,n);if(s&&s.embeddedSignature&&Cl(a[r].keyPacket,s)&&await bl([s.embeddedSignature],a[r].keyPacket,tn.signature.keyBinding,e,t,n))return a[r]}catch(e){s=e}const o=await this.getPrimaryUser(t,r,n);if((!e||i.getKeyId().equals(e))&&Cl(i,o.selfCertification))return this;throw Gr.wrapError("Could not find valid signing key packet in key "+this.getKeyId().toHex(),s)}async getEncryptionKey(e,t=new Date,r={},n=rn){await this.verifyPrimaryKey(t,r,n);const i=this.keyPacket,a=this.subKeys.slice().sort((e,t)=>t.keyPacket.created-e.keyPacket.created);let s;for(let r=0;r<a.length;r++)if(!e||a[r].getKeyId().equals(e))try{await a[r].verify(i,t,n);const e={key:i,bind:a[r].keyPacket},s=await bl(a[r].bindingSignatures,i,tn.signature.subkeyBinding,e,t,n);if(s&&Ul(a[r].keyPacket,s))return a[r]}catch(e){s=e}const o=await this.getPrimaryUser(t,r,n);if((!e||i.getKeyId().equals(e))&&Ul(i,o.selfCertification))return this;throw Gr.wrapError("Could not find valid encryption key packet in key "+this.getKeyId().toHex(),s)}async getDecryptionKeys(e,t=new Date,r={},n=rn){const i=this.keyPacket,a=[];for(let r=0;r<this.subKeys.length;r++)if(!e||this.subKeys[r].getKeyId().equals(e,!0))try{const e={key:i,bind:this.subKeys[r].keyPacket},s=await bl(this.subKeys[r].bindingSignatures,i,tn.signature.subkeyBinding,e,t,n);s&&Rl(s,n)&&a.push(this.subKeys[r])}catch(e){}const s=await this.getPrimaryUser(t,r,n);return e&&!i.getKeyId().equals(e,!0)||!Rl(s.selfCertification,n)||a.push(this),a}async encrypt(e,t=null,r=rn){if(!this.isPrivate())throw Error("Nothing to encrypt in a public key");const n=this.getKeys(t);if((e=Gr.isArray(e)?e:Array(n.length).fill(e)).length!==n.length)throw Error("Invalid number of passphrases for key");await Promise.all(n.map((async function(t,n){const{keyPacket:i}=t;await i.encrypt(e[n],r),i.clearPrivateParams()})))}async decrypt(e,t=null,r=rn){if(!this.isPrivate())throw Error("Nothing to decrypt in a public key");e=Gr.isArray(e)?e:[e],await Promise.all(this.getKeys(t).map((async function(r){let n=!1,i=null;if(await Promise.all(e.map((async function(e){try{await r.keyPacket.decrypt(e),t&&await r.keyPacket.validate(),n=!0}catch(e){i=e}}))),!n)throw i}))),t||await this.validate(r)}isDecrypted(){return this.getKeys().some(({keyPacket:e})=>e.isDecrypted())}async validate(e=rn){if(!this.isPrivate())throw Error("Cannot validate a public key");let t;if(this.primaryKey.isDummy()){const r=await this.getSigningKey(null,null,void 0,e);r&&!r.keyPacket.isDummy()&&(t=r.keyPacket)}else t=this.primaryKey;if(t)return t.validate();{const e=this.getKeys();if(e.map(e=>e.keyPacket.isDummy()).every(Boolean))throw Error("Cannot validate an all-gnu-dummy key");return Promise.all(e.map(async e=>e.keyPacket.validate()))}}clearPrivateParams(){if(!this.isPrivate())throw Error("Can't clear private parameters of a public key");this.getKeys().forEach(({keyPacket:e})=>{e.isDecrypted()&&e.clearPrivateParams()})}async isRevoked(e,t,r=new Date,n=rn){return Pl(this.keyPacket,tn.signature.keyRevocation,{key:this.keyPacket},this.revocationSignatures,e,t,r,n)}async verifyPrimaryKey(e=new Date,t={},r=rn){const n=this.keyPacket;if(await this.isRevoked(null,null,e,r))throw Error("Primary key is revoked");const{selfCertification:i}=await this.getPrimaryUser(e,t,r);if(_l(n,i,e))throw Error("Primary key is expired")}async getExpirationTime(e,t,r,n=rn){const i=(await this.getPrimaryUser(null,r,n)).selfCertification,a=xl(this.keyPacket,i),s=i.getExpirationTime();let o=a<s?a:s;if("encrypt"===e||"encrypt_sign"===e){const e=await this.getEncryptionKey(t,o,r,n).catch(()=>{})||await this.getEncryptionKey(t,null,r,n).catch(()=>{});if(!e)return null;const i=await e.getExpirationTime(this.keyPacket,void 0,n);i<o&&(o=i)}if("sign"===e||"encrypt_sign"===e){const e=await this.getSigningKey(t,o,r,n).catch(()=>{})||await this.getSigningKey(t,null,r,n).catch(()=>{});if(!e)return null;const i=await e.getExpirationTime(this.keyPacket,void 0,n);i<o&&(o=i)}return o}async getPrimaryUser(e=new Date,t={},r=rn){const n=this.keyPacket,i=[];let a;for(let s=0;s<this.users.length;s++)try{const a=this.users[s];if(!a.userId)continue;if(void 0!==t.name&&a.userId.name!==t.name||void 0!==t.email&&a.userId.email!==t.email||void 0!==t.comment&&a.userId.comment!==t.comment)throw Error("Could not find user that matches that user ID");const o={userId:a.userId,key:n},c=await bl(a.selfCertifications,n,tn.signature.certGeneric,o,e,r);i.push({index:s,user:a,selfCertification:c})}catch(e){a=e}if(!i.length)throw a||Error("Could not find primary user");await Promise.all(i.map((async function(t){return t.user.revoked||t.user.isRevoked(n,t.selfCertification,null,e,r)})));const s=i.sort((function(e,t){const r=e.selfCertification,n=t.selfCertification;return n.revoked-r.revoked||r.isPrimaryUserID-n.isPrimaryUserID||r.created-n.created})).pop(),{user:o,selfCertification:c}=s;if(c.revoked||await o.isRevoked(n,c,null,e,r))throw Error("Primary user is revoked");return s}async update(e,t=rn){if(!this.hasSameFingerprintAs(e))throw Error("Key update method: fingerprints of keys not equal");if(this.isPublic()&&e.isPrivate()){if(!(this.subKeys.length===e.subKeys.length&&this.subKeys.every(t=>e.subKeys.some(e=>t.hasSameFingerprintAs(e)))))throw Error("Cannot update public key with private key if subkey mismatch");this.keyPacket=e.keyPacket}await El(e,this,"revocationSignatures",r=>Pl(this.keyPacket,tn.signature.keyRevocation,this,[r],null,e.keyPacket,void 0,t)),await El(e,this,"directSignatures"),await Promise.all(e.users.map(async e=>{let r=!1;await Promise.all(this.users.map(async n=>{(e.userId&&n.userId&&e.userId.userid===n.userId.userid||e.userAttribute&&e.userAttribute.equals(n.userAttribute))&&(await n.update(e,this.keyPacket,t),r=!0)})),r||this.users.push(e)})),await Promise.all(e.subKeys.map(async e=>{let r=!1;await Promise.all(this.subKeys.map(async n=>{n.hasSameFingerprintAs(e)&&(await n.update(e,this.keyPacket,t),r=!0)})),r||this.subKeys.push(e)}))}async revoke({flag:e=tn.reasonForRevocation.noReason,string:t=""}={},r=new Date,n=rn){if(this.isPublic())throw Error("Need private key for revoking");const i={key:this.keyPacket},a=await this.clone();return a.revocationSignatures.push(await Sl(i,null,this.keyPacket,{signatureType:tn.signature.keyRevocation,reasonForRevocationFlag:tn.write(tn.reasonForRevocation,e),reasonForRevocationString:t},r,void 0,void 0,void 0,n)),a}async getRevocationCertificate(e=new Date,t=rn){const r={key:this.keyPacket},n=await bl(this.revocationSignatures,this.keyPacket,tn.signature.keyRevocation,r,e,t),i=new fl;return i.push(n),dn(tn.armor.publicKey,i.write(),null,null,"This is a revocation certificate")}async applyRevocationCertificate(e,t=rn){const r=await hn(e,t),n=new fl;await n.read(r.data,{SignaturePacket:nl},void 0,t);const i=n.findPacket(tn.packet.signature);if(!i||i.signatureType!==tn.signature.keyRevocation)throw Error("Could not find revocation signature packet");if(!i.issuerKeyId.equals(this.getKeyId()))throw Error("Revocation signature does not match key");if(i.isExpired())throw Error("Revocation signature is expired");try{await i.verify(this.keyPacket,tn.signature.keyRevocation,{key:this.keyPacket},void 0,void 0,t)}catch(e){throw Gr.wrapError("Could not verify revocation signature",e)}const a=await this.clone();return a.revocationSignatures.push(i),a}async signPrimaryUser(e,t,r,n=rn){const{index:i,user:a}=await this.getPrimaryUser(t,r,n),s=await a.sign(this.keyPacket,e,n),o=await this.clone();return o.users[i]=s,o}async signAllUsers(e,t=rn){const r=this,n=await this.clone();return n.users=await Promise.all(this.users.map((function(n){return n.sign(r.keyPacket,e,t)}))),n}async verifyPrimaryUser(e,t,r,n=rn){const i=this.keyPacket,{user:a}=await this.getPrimaryUser(t,r,n);return e?await a.verifyAllCertifications(i,e,void 0,n):[{keyid:i.keyid,valid:await a.verify(i,void 0,n).catch(()=>!1)}]}async verifyAllUsers(e,t=rn){const r=[],n=this.keyPacket;return await Promise.all(this.users.map((async function(i){(e?await i.verifyAllCertifications(n,e,void 0,t):[{keyid:n.keyid,valid:await i.verify(n,void 0,t).catch(()=>!1)}]).forEach(e=>{r.push({userid:i.userId.userid,keyid:e.keyid,valid:e.valid})})}))),r}async addSubkey(e={}){const t={...rn,...e.config};if(!this.isPrivate())throw Error("Cannot add a subkey to a public key");if(e.passphrase)throw Error("Subkey could not be encrypted here, please encrypt whole key");if(e.rsaBits<t.minRsaBits)throw Error(`rsaBits should be at least ${t.minRsaBits}, got: ${e.rsaBits}`);const r=this.primaryKey;if(r.isDummy())throw Error("Cannot add subkey to gnu-dummy primary key");if(!r.isDecrypted())throw Error("Key is not decrypted");const n=r.getAlgorithmInfo();n.type=n.curve?"ecc":"rsa",n.rsaBits=n.bits||4096,n.curve=n.curve||"curve25519",e=Kl(e,n);const i=await ml(e),a=await vl(i,r,e,t),s=this.toPacketlist();return s.push(i),s.push(a),new Il(s)}}async function Bl(e,t,r,n){r.passphrase&&await e.encrypt(r.passphrase,n),await Promise.all(t.map((async function(e,t){const i=r.subkeys[t].passphrase;i&&await e.encrypt(i,n)})));const i=new fl;i.push(e),await Promise.all(r.userIds.map((async function(t,i){function a(e,t){if(t){const r=e.indexOf(t);r>=1&&e.splice(r,1),0!==r&&e.unshift(t)}return e}const s=ul.fromObject(t),o={};o.userId=s,o.key=e;const c=new nl(r.date);return c.signatureType=tn.signature.certGeneric,c.publicKeyAlgorithm=e.algorithm,c.hashAlgorithm=await kl(null,e,void 0,void 0,n),c.keyFlags=[tn.keyFlags.certifyKeys|tn.keyFlags.signData],c.preferredSymmetricAlgorithms=a([tn.symmetric.aes256,tn.symmetric.aes128,tn.symmetric.aes192],n.encryptionCipher),n.aeadProtect&&(c.preferredAeadAlgorithms=a([tn.aead.eax,tn.aead.ocb],n.aeadMode)),c.preferredHashAlgorithms=a([tn.hash.sha256,tn.hash.sha512],n.preferHashAlgorithm),c.preferredCompressionAlgorithms=a([tn.compression.zlib,tn.compression.zip,tn.compression.uncompressed],n.compression),0===i&&(c.isPrimaryUserID=!0),c.features=[0],c.features[0]|=tn.features.modificationDetection,n.aeadProtect&&(c.features[0]|=tn.features.aead),n.v5Keys&&(c.features[0]|=tn.features.v5Keys),r.keyExpirationTime>0&&(c.keyExpirationTime=r.keyExpirationTime,c.keyNeverExpires=!1),await c.sign(e,o),{userIdPacket:s,signaturePacket:c}}))).then(e=>{e.forEach(({userIdPacket:e,signaturePacket:t})=>{i.push(e),i.push(t)})}),await Promise.all(t.map((async function(t,i){const a=r.subkeys[i];return{secretSubkeyPacket:t,subkeySignaturePacket:await vl(t,e,a,n)}}))).then(e=>{e.forEach(({secretSubkeyPacket:e,subkeySignaturePacket:t})=>{i.push(e),i.push(t)})});const a={key:e};return i.push(await Sl(a,null,e,{signatureType:tn.signature.keyRevocation,reasonForRevocationFlag:tn.reasonForRevocation.noReason,reasonForRevocationString:""},r.date,void 0,void 0,void 0,n)),r.passphrase&&e.clearPrivateParams(),await Promise.all(t.map((async function(e,t){r.subkeys[t].passphrase&&e.clearPrivateParams()}))),new Il(i)}async function zl({armoredKey:e,binaryKey:t,config:r}){if(r={...rn,...r},!e&&!t)throw Error("readKey: must pass options object containing `armoredKey` or `binaryKey`");let n;if(e){const{type:t,data:i}=await hn(e,r);if(t!==tn.armor.publicKey&&t!==tn.armor.privateKey)throw Error("Armored text not of type key");n=i}else n=t;const i=new fl;return await i.read(n,gl,void 0,r),new Il(i)}async function Ol({armoredKeys:e,binaryKeys:t,config:r}){r={...rn,...r};let n=e||t;if(!n)throw Error("readKeys: must pass options object containing `armoredKeys` or `binaryKeys`");if(e){const{type:t,data:i}=await hn(e,r);if(t!==tn.armor.publicKey&&t!==tn.armor.privateKey)throw Error("Armored text not of type key");n=i}const i=[],a=new fl;await a.read(n,gl,void 0,r);const s=a.indexOfTag(tn.packet.publicKey,tn.packet.secretKey);if(0===s.length)throw Error("No key packet found");for(let e=0;e<s.length;e++){const t=a.slice(s[e],s[e+1]),r=new Il(t);i.push(r)}return i}["getKeyId","getFingerprint","getAlgorithmInfo","getCreationTime","hasSameFingerprintAs"].forEach(e=>{Il.prototype[e]=Dl.prototype[e]});class ql{constructor(e){this.packets=e||new fl}getEncryptionKeyIds(){const e=[];return this.packets.filterByTag(tn.packet.publicKeyEncryptedSessionKey).forEach((function(t){e.push(t.publicKeyId)})),e}getSigningKeyIds(){const e=[],t=this.unwrapCompressed();if(t.packets.filterByTag(tn.packet.onePassSignature).forEach((function(t){e.push(t.issuerKeyId)})),!e.length){t.packets.filterByTag(tn.packet.signature).forEach((function(t){e.push(t.issuerKeyId)}))}return e}async decrypt(e,t,r,n,i=rn){const a=r||await this.decryptSessionKeys(e,t,i),s=this.packets.filterByTag(tn.packet.symmetricallyEncryptedData,tn.packet.symEncryptedIntegrityProtectedData,tn.packet.AEADEncryptedData);if(0===s.length)return this;const o=s[0];let c=null;const u=Promise.all(a.map(async e=>{if(!e||!Gr.isUint8Array(e.data)||!Gr.isString(e.algorithm))throw Error("Invalid session key for decryption.");try{await o.decrypt(e.algorithm,e.data,n,i)}catch(e){Gr.printDebugError(e),c=e}}));if(Fr.cancel(o.encrypted),o.encrypted=null,await u,!o.packets||!o.packets.length)throw c||Error("Decryption failed.");const l=new ql(o.packets);return o.packets=new fl,l}async decryptSessionKeys(e,t,r=rn){let n,i=[];if(t){const e=this.packets.filterByTag(tn.packet.symEncryptedSessionKey);if(!e)throw Error("No symmetrically encrypted session key packet found.");await Promise.all(t.map((async function(t,r){let n;r?(n=new fl,await n.read(e.write(),{SymEncryptedSessionKeyPacket:Fu})):n=e,await Promise.all(n.map((async function(e){try{await e.decrypt(t),i.push(e)}catch(e){Gr.printDebugError(e)}})))})))}else{if(!e)throw Error("No key or password specified.");{const t=this.packets.filterByTag(tn.packet.publicKeyEncryptedSessionKey);if(!t)throw Error("No public key encrypted session key packet found.");await Promise.all(t.map((async function(t){await Promise.all(e.map((async function(e){let a=[tn.symmetric.aes256,tn.symmetric.aes128,tn.symmetric.tripledes,tn.symmetric.cast5];try{const t=await e.getPrimaryUser(void 0,void 0,r);t.selfCertification.preferredSymmetricAlgorithms&&(a=a.concat(t.selfCertification.preferredSymmetricAlgorithms))}catch(e){}const s=(await e.getDecryptionKeys(t.publicKeyId,null,void 0,r)).map(e=>e.keyPacket);await Promise.all(s.map((async function(e){if(e&&!e.isDummy()){if(!e.isDecrypted())throw Error("Private key is not decrypted.");try{if(await t.decrypt(e),!a.includes(tn.write(tn.symmetric,t.sessionKeyAlgorithm)))throw Error("A non-preferred symmetric algorithm was used.");i.push(t)}catch(e){Gr.printDebugError(e),n=e}}})))}))),Fr.cancel(t.encrypted),t.encrypted=null})))}}if(i.length){if(i.length>1){const e={};i=i.filter((function(t){const r=t.sessionKeyAlgorithm+Gr.uint8ArrayToStr(t.sessionKey);return!e.hasOwnProperty(r)&&(e[r]=!0,!0)}))}return i.map(e=>({data:e.sessionKey,algorithm:e.sessionKeyAlgorithm}))}throw n||Error("Session key decryption failed.")}getLiteralData(){const e=this.unwrapCompressed().packets.findPacket(tn.packet.literalData);return e&&e.getBytes()||null}getFilename(){const e=this.unwrapCompressed().packets.findPacket(tn.packet.literalData);return e&&e.getFilename()||null}getText(){const e=this.unwrapCompressed().packets.findPacket(tn.packet.literalData);return e?e.getText():null}static async generateSessionKey(e=[],t=new Date,r=[],n=rn){const i=tn.read(tn.symmetric,await Al("symmetric",e,t,r,n)),a=n.aeadProtect&&await async function(e,t=new Date,r=[],n=rn){let i=!0;return await Promise.all(e.map((async function(e,a){const s=await e.getPrimaryUser(t,r[a],n);s.selfCertification.features&&s.selfCertification.features[0]&tn.features.aead||(i=!1)}))),i}(e,t,r,n)?tn.read(tn.aead,await Al("aead",e,t,r,n)):void 0;return{data:await Io.generateSessionKey(i),algorithm:i,aeadAlgorithm:a}}async encrypt(e,t,r,n=!1,i=[],a=new Date,s=[],o,c=rn){if(r){if(!Gr.isUint8Array(r.data)||!Gr.isString(r.algorithm))throw Error("Invalid session key for encryption.")}else if(e&&e.length)r=await ql.generateSessionKey(e,a,s,c);else{if(!t||!t.length)throw Error("No keys, passwords, or session key provided.");r=await ql.generateSessionKey(void 0,void 0,void 0,c)}const{data:u,algorithm:l,aeadAlgorithm:h}=r,d=await ql.encryptSessionKey(u,l,h,e,t,n,i,a,s,c);let f;return h?(f=new Mu,f.aeadAlgorithm=h):f=new Nu,f.packets=this.packets,await f.encrypt(l,u,o,c),d.packets.push(f),f.packets=new fl,d}static async encryptSessionKey(e,t,r,n,i,a=!1,s=[],o=new Date,c=[],u=rn){const l=new fl;if(n){const r=await Promise.all(n.map((async function(r,n){const i=await r.getEncryptionKey(s[n],o,c,u),l=new Lu;return l.publicKeyId=a?fn.wildcard():i.getKeyId(),l.publicKeyAlgorithm=i.keyPacket.algorithm,l.sessionKey=e,l.sessionKeyAlgorithm=t,await l.encrypt(i.keyPacket),delete l.sessionKey,l})));l.concat(r)}if(i){const n=async function(e,t){try{return await e.decrypt(t),1}catch(e){return 0}},a=(e,t)=>e+t,s=async function(e,t,r,o){const c=new Fu(u);if(c.sessionKey=e,c.sessionKeyAlgorithm=t,r&&(c.aeadAlgorithm=r),await c.encrypt(o,u),u.passwordCollisionCheck){if(1!==(await Promise.all(i.map(e=>n(c,e)))).reduce(a))return s(e,t,o)}return delete c.sessionKey,c},o=await Promise.all(i.map(n=>s(e,t,r,n)));l.concat(o)}return new ql(l)}async sign(e=[],t=null,r=[],n=new Date,i=[],a=!1,s=rn){const o=new fl,c=this.packets.findPacket(tn.packet.literalData);if(!c)throw Error("No literal data packet to sign.");let u,l;const h=null===c.text?tn.signature.binary:tn.signature.text;if(t)for(l=t.packets.filterByTag(tn.packet.signature),u=l.length-1;u>=0;u--){const t=l[u],r=new al;r.signatureType=t.signatureType,r.hashAlgorithm=t.hashAlgorithm,r.publicKeyAlgorithm=t.publicKeyAlgorithm,r.issuerKeyId=t.issuerKeyId,e.length||0!==u||(r.flags=1),o.push(r)}return await Promise.all(Array.from(e).reverse().map((async function(t,a){if(t.isPublic())throw Error("Need private key for signing");const o=r[e.length-1-a],c=await t.getSigningKey(o,n,i,s),u=new al;return u.signatureType=h,u.hashAlgorithm=await kl(t,c.keyPacket,n,i,s),u.publicKeyAlgorithm=c.keyPacket.algorithm,u.issuerKeyId=c.getKeyId(),a===e.length-1&&(u.flags=1),u}))).then(e=>{e.forEach(e=>o.push(e))}),o.push(c),o.concat(await Nl(c,e,t,r,n,i,!1,a,s)),new ql(o)}compress(e=rn){if(e.compression===tn.compression.uncompressed)return this;const t=new Ru(e);t.packets=this.packets;const r=new fl;return r.push(t),new ql(r)}async signDetached(e=[],t=null,r=[],n=new Date,i=[],a=!1,s=rn){const o=this.packets.findPacket(tn.packet.literalData);if(!o)throw Error("No literal data packet to sign.");return new yl(await Nl(o,e,t,r,n,i,!0,a,s))}async verify(e,t=new Date,r,n=rn){const i=this.unwrapCompressed(),a=i.packets.filterByTag(tn.packet.literalData);if(1!==a.length)throw Error("Can only verify message with one literal data packet.");r||i.packets.concat(await Fr.readToEnd(i.packets.stream,e=>e));const s=i.packets.filterByTag(tn.packet.onePassSignature).reverse(),o=i.packets.filterByTag(tn.packet.signature);return r&&s.length&&!o.length&&i.packets.stream?(await Promise.all(s.map(async e=>{e.correspondingSig=new Promise((t,r)=>{e.correspondingSigResolve=t,e.correspondingSigReject=r}),e.signatureData=Fr.fromAsync(async()=>(await e.correspondingSig).signatureData),e.hashed=Fr.readToEnd(await e.hash(e.signatureType,a[0],void 0,!1,r)),e.hashed.catch(()=>{})})),i.packets.stream=Fr.transformPair(i.packets.stream,async(e,t)=>{const r=Fr.getReader(e),n=Fr.getWriter(t);try{for(let e=0;e<s.length;e++){const{value:t}=await r.read();s[e].correspondingSigResolve(t)}await r.readToEnd(),await n.ready,await n.close()}catch(e){s.forEach(t=>{t.correspondingSigReject(e)}),await n.abort(e)}}),Ml(s,a,e,t,!1,r,n)):Ml(o,a,e,t,!1,r,n)}verifyDetached(e,t,r=new Date,n,i=rn){const a=this.unwrapCompressed().packets.filterByTag(tn.packet.literalData);if(1!==a.length)throw Error("Can only verify message with one literal data packet.");return Ml(e.packets,a,t,r,!0,void 0,i)}unwrapCompressed(){const e=this.packets.filterByTag(tn.packet.compressedData);return e.length?new ql(e[0].packets):this}async appendSignature(e){await this.packets.read(Gr.isUint8Array(e)?e:(await hn(e)).data,{SignaturePacket:nl})}write(){return this.packets.write()}armor(e=rn){return dn(tn.armor.message,this.write(),null,null,null,e)}static fromText(e,t,r=new Date,n="utf8"){const i=Gr.isStream(e);"node"===i&&(e=Fr.nodeToWeb(e));const a=new Hu(r);a.setText(e,n),void 0!==t&&a.setFilename(t);const s=new fl;s.push(a);const o=new ql(s);return o.fromStream=i,o}static fromBinary(e,t,r=new Date,n="binary"){const i=Gr.isStream(e);if(!Gr.isUint8Array(e)&&!i)throw Error("Data must be in the form of a Uint8Array or Stream");"node"===i&&(e=Fr.nodeToWeb(e));const a=new Hu(r);a.setBytes(e,n),void 0!==t&&a.setFilename(t);const s=new fl;s.push(a);const o=new ql(s);return o.fromStream=i,o}}async function Nl(e,t,r=null,n=[],i=new Date,a=[],s=!1,o=!1,c=rn){const u=new fl,l=null===e.text?tn.signature.binary:tn.signature.text;if(await Promise.all(t.map(async(t,r)=>{const u=a[r];if(t.isPublic())throw Error("Need private key for signing");const h=await t.getSigningKey(n[r],i,u,c);return Sl(e,t,h.keyPacket,{signatureType:l},i,u,s,o,c)})).then(e=>{e.forEach(e=>u.push(e))}),r){const e=r.packets.filterByTag(tn.packet.signature);u.concat(e)}return u}async function Ml(e,t,r,n=new Date,i=!1,a=!1,s=rn){return Promise.all(e.filter((function(e){return["text","binary"].includes(tn.read(tn.signature,e.signatureType))})).map((async function(e){return async function(e,t,r,n=new Date,i=!1,a=!1,s=rn){let o=null,c=null;await Promise.all(r.map((async function(t){try{c=await t.getSigningKey(e.issuerKeyId,null,void 0,s),o=t}catch(e){}})));const u=e.correspondingSig||e,l={keyid:e.issuerKeyId,verified:(async()=>{if(!c)return null;await e.verify(c.keyPacket,e.signatureType,t[0],i,a,s);const r=await u;if(r.isExpired(n)||!(r.created>=c.getCreationTime()&&r.created<await(c===o?c.getExpirationTime(void 0,void 0,void 0,s):c.getExpirationTime(o,n,void 0,s))))throw Error("Signature is expired");return!0})(),signature:(async()=>{const e=await u,t=new fl;return t.push(e),new yl(t)})()};return l.signature.catch(()=>{}),l.verified.catch(()=>{}),l}(e,t,r,n,i,a,s)})))}async function Ll({armoredMessage:e,binaryMessage:t,config:r}){r={...rn,...r};let n=e||t;if(!n)throw Error("readMessage: must pass options object containing `armoredMessage` or `binaryMessage`");const i=Gr.isStream(n);if("node"===i&&(n=Fr.nodeToWeb(n)),e){const{type:e,data:t}=await hn(n,r);if(e!==tn.armor.message)throw Error("Armored text not of type message");n=t}const a=new fl;await a.read(n,{LiteralDataPacket:Hu,CompressedDataPacket:Ru,AEADEncryptedDataPacket:Mu,SymEncryptedIntegrityProtectedDataPacket:Nu,SymmetricallyEncryptedDataPacket:Gu,PublicKeyEncryptedSessionKeyPacket:Lu,SymEncryptedSessionKeyPacket:Fu,OnePassSignaturePacket:al,SignaturePacket:nl},i,r);const s=new ql(a);return s.fromStream=i,s}class jl{constructor(e,t){if(this.text=Gr.removeTrailingSpaces(e).replace(/\r?\n/g,"\r\n"),t&&!(t instanceof yl))throw Error("Invalid signature input");this.signature=t||new yl(new fl)}getSigningKeyIds(){const e=[];return this.signature.packets.forEach((function(t){e.push(t.issuerKeyId)})),e}async sign(e,t=null,r=[],n=new Date,i=[],a=rn){return new jl(this.text,await this.signDetached(e,t,r,n,i,a))}async signDetached(e,t=null,r=[],n=new Date,i=[],a=rn){const s=new Hu;return s.setText(this.text),new yl(await Nl(s,e,t,r,n,i,!0,void 0,a))}verify(e,t=new Date,r=rn){return this.verifyDetached(this.signature,e,t,r)}verifyDetached(e,t,r=new Date,n=rn){const i=e.packets,a=new Hu;return a.setText(this.text),Ml(i,[a],t,r,!0,void 0,n)}getText(){return this.text.replace(/\r\n/g,"\n")}armor(e=rn){let t=this.signature.packets.map((function(e){return tn.read(tn.hash,e.hashAlgorithm).toUpperCase()}));t=t.filter((function(e,t,r){return r.indexOf(e)===t}));const r={hash:t.join(),text:this.text,data:this.signature.packets.write()};return dn(tn.armor.signed,r,void 0,void 0,void 0,e)}static fromText(e){return new jl(e)}}async function Fl({cleartextMessage:e,config:t}){if(t={...rn,...t},!e)throw Error("readCleartextMessage: must pass options object containing `cleartextMessage`");const r=await hn(e);if(r.type!==tn.armor.signed)throw Error("No cleartext signed message.");const n=new fl;await n.read(r.data,{SignaturePacket:nl},void 0,t),function(e,t){const r=function(e){const r=e=>t=>e.hashAlgorithm===t;for(let n=0;n<t.length;n++)if(t[n].tag===tn.packet.signature&&!e.some(r(t[n])))return!1;return!0};let n=null,i=[];if(e.forEach((function(e){if(n=e.match(/Hash: (.+)/),!n)throw Error('Only "Hash" header allowed in cleartext signed message');n=n[1].replace(/\s/g,""),n=n.split(","),n=n.map((function(e){e=e.toLowerCase();try{return tn.write(tn.hash,e)}catch(t){throw Error("Unknown hash algorithm in armor header: "+e)}})),i=i.concat(n)})),!i.length&&!r([tn.hash.md5]))throw Error('If no "Hash" header in cleartext signed message, then only MD5 signatures allowed');if(i.length&&!r(i))throw Error("Hash algorithm mismatch in armor header and signature")}(r.headers,n);const i=new yl(n);return new jl(r.text,i)}let Hl;if(e.ReadableStream)try{Hl=ar(e.ReadableStream)}catch(e){}function Wl({userIds:e=[],passphrase:t="",type:r="ecc",rsaBits:n=4096,curve:i="curve25519",keyExpirationTime:a=0,date:s=new Date,subkeys:o=[{}],config:c}){c={...rn,...c};const u={userIds:e=ah(e),passphrase:t,type:r,rsaBits:n,curve:i,keyExpirationTime:a,date:s,subkeys:o};if("rsa"===r&&n<c.minRsaBits)throw Error(`rsaBits should be at least ${c.minRsaBits}, got: ${n}`);return async function(e,t){e.sign=!0,(e=Kl(e)).subkeys=e.subkeys.map((t,r)=>Kl(e.subkeys[r],e));let r=[wl(e,t)];return r=r.concat(e.subkeys.map(e=>ml(e,t))),Promise.all(r).then(r=>Bl(r[0],r.slice(1),e,t))}(u,c).then(async e=>{const t=await e.getRevocationCertificate(s,c);return e.revocationSignatures=[],{key:e,privateKeyArmored:e.armor(c),publicKeyArmored:e.toPublic().armor(c),revocationCertificate:t}}).catch(uh.bind(null,"Error generating keypair"))}function Gl({privateKey:e,userIds:t=[],passphrase:r="",keyExpirationTime:n=0,date:i,config:a}){return a={...rn,...a},async function(e,t){if((e=a(e)).privateKey.primaryKey.isDummy())throw Error("Cannot reformat a gnu-dummy primary key");if(!e.privateKey.getKeys().every(({keyPacket:e})=>e.isDecrypted()))throw Error("Key is not decrypted");const r=e.privateKey.toPacketlist();let n;const i=[];for(let e=0;e<r.length;e++)r[e].tag===tn.packet.secretKey?n=r[e]:r[e].tag===tn.packet.secretSubkey&&i.push(r[e]);if(!n)throw Error("Key does not contain a secret key packet");if(e.subkeys||(e.subkeys=await Promise.all(i.map(async r=>({sign:await e.privateKey.getSigningKey(r.getKeyId(),null,void 0,t).catch(()=>{})&&!await e.privateKey.getEncryptionKey(r.getKeyId(),null,void 0,t).catch(()=>{})})))),e.subkeys.length!==i.length)throw Error("Number of subkey options does not match number of subkeys");return e.subkeys=e.subkeys.map((function(t,r){return a(e.subkeys[r],e)})),Bl(n,i,e,t);function a(e,t={}){return e.keyExpirationTime=e.keyExpirationTime||t.keyExpirationTime,e.passphrase=Gr.isString(e.passphrase)?e.passphrase:t.passphrase,e.date=e.date||t.date,e}}({privateKey:e,userIds:t=ah(t),passphrase:r,keyExpirationTime:n,date:i},a).then(async e=>{const t=await e.getRevocationCertificate(i,a);return e.revocationSignatures=[],{key:e,privateKeyArmored:e.armor(a),publicKeyArmored:e.toPublic().armor(a),revocationCertificate:t}}).catch(uh.bind(null,"Error reformatting keypair"))}function Vl({key:e,revocationCertificate:t,reasonForRevocation:r,config:n}){return n={...rn,...n},Promise.resolve().then(()=>t?e.applyRevocationCertificate(t,n):e.revoke(r,void 0,n)).then(async e=>{if(e.isPrivate()){const t=e.toPublic();return{privateKey:e,privateKeyArmored:e.armor(n),publicKey:t,publicKeyArmored:t.armor(n)}}return{publicKey:e,publicKeyArmored:e.armor(n)}}).catch(uh.bind(null,"Error revoking key"))}async function $l({privateKey:e,passphrase:t,config:r}){r={...rn,...r};const n=await e.clone();n.getKeys().forEach(e=>{e.keyPacket=Object.create(Object.getPrototypeOf(e.keyPacket),Object.getOwnPropertyDescriptors(e.keyPacket))});try{return await n.decrypt(t,void 0,r),n}catch(e){return n.clearPrivateParams(),uh("Error decrypting private key",e)}}async function Yl({privateKey:e,passphrase:t,config:r}){r={...rn,...r};const n=await e.clone();n.getKeys().forEach(e=>{if(e.keyPacket=Object.create(Object.getPrototypeOf(e.keyPacket),Object.getOwnPropertyDescriptors(e.keyPacket)),!e.keyPacket.isDecrypted())return;const t={};Object.keys(e.keyPacket.privateParams).forEach(r=>{t[r]=new Uint8Array(e.keyPacket.privateParams[r])}),e.keyPacket.privateParams=t});try{return await n.encrypt(t,void 0,r),n}catch(e){return n.clearPrivateParams(),uh("Error encrypting private key",e)}}function Zl({message:e,publicKeys:t,privateKeys:r,passwords:n,sessionKey:i,armor:a=!0,streaming:s=e&&e.fromStream,detached:o=!1,signature:c=null,wildcard:u=!1,signingKeyIds:l=[],encryptionKeyIds:h=[],date:d=new Date,fromUserIds:f=[],toUserIds:y=[],config:p}){if(p={...rn,...p},nh(e),t=ah(t),r=ah(r),n=ah(n),f=ah(f),y=ah(y),o)throw Error("detached option has been removed from openpgp.encrypt. Separately call openpgp.sign instead. Don't forget to remove privateKeys option as well.");return Promise.resolve().then((async function(){return r||(r=[]),(r.length||c)&&(e=await e.sign(r,c,l,d,f,e.fromStream,p)),e=e.compress(p),e=await e.encrypt(t,n,i,u,h,d,y,s,p),sh(a?e.armor(p):e.write(),s,a?"utf8":"binary")})).catch(uh.bind(null,"Error encrypting message"))}function Ql({message:e,privateKeys:t,passwords:r,sessionKeys:n,publicKeys:i,format:a="utf8",streaming:s=e&&e.fromStream,signature:o=null,date:c=new Date,config:u}){return u={...rn,...u},nh(e),i=ah(i),t=ah(t),r=ah(r),n=ah(n),e.decrypt(t,r,n,s,u).then((async function(t){i||(i=[]);const r={};return r.signatures=o?await t.verifyDetached(o,i,c,s,u):await t.verify(i,c,s,u),r.data="binary"===a?t.getLiteralData():t.getText(),r.filename=t.getFilename(),oh(r,e),r.data=await sh(r.data,s,a),s||await ch(r.signatures),r})).catch(uh.bind(null,"Error decrypting message"))}function Xl({message:e,privateKeys:t,armor:r=!0,streaming:n=e&&e.fromStream,detached:i=!1,signingKeyIds:a=[],date:s=new Date,fromUserIds:o=[],config:c}){if(c={...rn,...c},ih(e),e instanceof jl&&!r)throw Error("Can't sign non-armored cleartext message");if(e instanceof jl&&i)throw Error("Can't sign detached cleartext message");return t=ah(t),o=ah(o),Promise.resolve().then((async function(){let u;return u=e instanceof jl?await e.sign(t,void 0,a,s,o,c):i?await e.signDetached(t,void 0,a,s,o,e.fromStream,c):await e.sign(t,void 0,a,s,o,e.fromStream,c),u=r?u.armor(c):u.write(),i&&(u=Fr.transformPair(e.packets.write(),async(e,t)=>{await Promise.all([Fr.pipe(u,t),Fr.readToEnd(e).catch(()=>{})])})),sh(u,n,r?"utf8":"binary")})).catch(uh.bind(null,"Error signing message"))}function Jl({message:e,publicKeys:t,format:r="utf8",streaming:n=e&&e.fromStream,signature:i=null,date:a=new Date,config:s}){if(s={...rn,...s},ih(e),e instanceof jl&&"binary"===r)throw Error("Can't return cleartext message data as binary");return t=ah(t),Promise.resolve().then((async function(){const o={};return o.signatures=e instanceof jl?i?await e.verifyDetached(i,t,a,s):await e.verify(t,a,s):i?await e.verifyDetached(i,t,a,n,s):await e.verify(t,a,n,s),o.data="binary"===r?e.getLiteralData():e.getText(),n&&oh(o,e),o.data=await sh(o.data,n,r),n||await ch(o.signatures),o})).catch(uh.bind(null,"Error verifying signed message"))}function eh({publicKeys:e,date:t=new Date,toUserIds:r=[],config:n}){return n={...rn,...n},e=ah(e),r=ah(r),Promise.resolve().then((async function(){return ql.generateSessionKey(e,t,r,n)})).catch(uh.bind(null,"Error generating session key"))}function th({data:e,algorithm:t,aeadAlgorithm:r,publicKeys:n,passwords:i,armor:a=!0,wildcard:s=!1,encryptionKeyIds:o=[],date:c=new Date,toUserIds:u=[],config:l}){return l={...rn,...l},function(e,t){if(!Gr.isUint8Array(e))throw Error("Parameter ["+(t||"data")+"] must be of type Uint8Array")}(e),function(e,t){if(!Gr.isString(e))throw Error("Parameter ["+(t||"data")+"] must be of type String")}(t,"algorithm"),n=ah(n),i=ah(i),u=ah(u),Promise.resolve().then((async function(){const h=await ql.encryptSessionKey(e,t,r,n,i,s,o,c,u,l);return a?h.armor(l):h.write()})).catch(uh.bind(null,"Error encrypting session key"))}function rh({message:e,privateKeys:t,passwords:r,config:n}){return n={...rn,...n},nh(e),t=ah(t),r=ah(r),Promise.resolve().then((async function(){return e.decryptSessionKeys(t,r,n)})).catch(uh.bind(null,"Error decrypting session keys"))}function nh(e){if(!(e instanceof ql))throw Error("Parameter [message] needs to be of type Message")}function ih(e){if(!(e instanceof jl||e instanceof ql))throw Error("Parameter [message] needs to be of type Message or CleartextMessage")}function ah(e){return e&&!Gr.isArray(e)&&(e=[e]),e}async function sh(e,t,r="utf8"){let n=Gr.isStream(e);return!t&&n?Fr.readToEnd(e):(t&&!n&&(e=Fr.toStream(e),n=Gr.isStream(e)),"node"===t?(e=Fr.webToNode(e),"binary"!==r&&e.setEncoding(r),e):"web"===t&&"ponyfill"===n&&Hl?Hl(e):e)}function oh(e,t){e.data=Fr.transformPair(t.packets.stream,async(t,r)=>{await Fr.pipe(e.data,r,{preventClose:!0});const n=Fr.getWriter(r);try{await Fr.readToEnd(t,e=>e),await n.close()}catch(e){await n.abort(e)}})}async function ch(e){await Promise.all(e.map(async e=>{e.signature=await e.signature;try{e.valid=await e.verified}catch(t){e.valid=!1,e.error=t,Gr.printDebugError(t)}}))}function uh(e,t){Gr.printDebugError(t);try{t.message=e+": "+t.message}catch(e){}throw t}export{Mu as AEADEncryptedDataPacket,jl as CleartextMessage,Ru as CompressedDataPacket,Il as Key,Hu as LiteralDataPacket,Vu as MarkerPacket,ql as Message,al as OnePassSignaturePacket,fl as PacketList,Lu as PublicKeyEncryptedSessionKeyPacket,Wu as PublicKeyPacket,$u as PublicSubkeyPacket,sl as SecretKeyPacket,ll as SecretSubkeyPacket,yl as Signature,nl as SignaturePacket,Nu as SymEncryptedIntegrityProtectedDataPacket,Fu as SymEncryptedSessionKeyPacket,Gu as SymmetricallyEncryptedDataPacket,hl as TrustPacket,rl as UserAttributePacket,ul as UserIDPacket,Ci as _,ei as a,dn as armor,yi as b,ti as c,rn as config,ui as d,Ql as decrypt,$l as decryptKey,rh as decryptSessionKeys,xi as e,Zl as encrypt,Yl as encryptKey,th as encryptSessionKey,tn as enums,ia as f,Hi as g,Wl as generateKey,eh as generateSessionKey,ri as i,Xn as m,dl as newPacketFromTag,ba as r,Fl as readCleartextMessage,zl as readKey,Ol as readKeys,Ll as readMessage,pl as readSignature,Gl as reformatKey,Vl as revokeKey,Xl as sign,Fr as stream,si as u,hn as unarmor,Jl as verify};
17//# sourceMappingURL=openpgp.min.mjs.map