@smart-cloud/wpsuite-core 2.2.3 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1,7 @@
1
- "use strict";var J=Object.create;var f=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var u=(e,t)=>()=>(e&&(t=e(e=0)),t);var E=(e,t)=>{for(var n in t)f(e,n,{get:t[n],enumerable:!0})},_=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Z(t))!z.call(e,i)&&i!==n&&f(e,i,{get:()=>t[i],enumerable:!(r=$(t,i))||r.enumerable});return e};var q=(e,t,n)=>(n=e!=null?J(j(e)):{},_(t||!e||!e.__esModule?f(n,"default",{value:e,enumerable:!0}):n,e)),Q=e=>_(f({},"__esModule",{value:!0}),e);function d(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";return Uint8Array.from(atob(t),n=>n.charCodeAt(0))}var v,R,y=u(()=>{"use strict";v=(e,t)=>{let r=Uint8Array.from(atob(e),i=>i.charCodeAt(0)).map((i,o)=>i^t+o&255);return new TextDecoder().decode(r)},R=async e=>{let t=globalThis.grecaptcha,n=e?t?.enterprise:void 0,r=n?.ready??t?.ready,i=n?.execute??t?.execute;if(typeof i!="function")return{execute:void 0};try{return typeof r=="function"&&await new Promise(o=>r(()=>o())),{execute:i}}catch{return{execute:void 0}}}});function S(e,t){return`wpsuite:${e}:${t}`}function ee(e,t=8e3){return()=>new Promise(n=>{if(e.status==="available")return n("available");if(e.status==="error")return n("error");!e.status||e.status;let r=S(e.key,"ready"),i=S(e.key,"error"),o=()=>c("available"),s=()=>c("error"),a,c=p=>{window.removeEventListener(r,o),window.removeEventListener(i,s),a!==void 0&&window.clearTimeout(a),n(p)};window.addEventListener(r,o,{once:!0}),window.addEventListener(i,s,{once:!0}),a=window.setTimeout(()=>c("unavailable"),t)})}function te(e){return t=>{window.addEventListener(S(e,"ready"),()=>t(),{once:!0})}}function A(e,t){let n=t?.timeoutMs??8e3;return e.availability??=ee(e,n),e.onReady??=te(e.key),e}var k=u(()=>{"use strict"});async function C(){if(!globalThis.crypto?.subtle)return m||(m=(async()=>{if(await import("webcrypto-liner/build/webcrypto-liner.shim.js"),!globalThis.crypto?.subtle)throw new Error("WebCrypto polyfill loaded but crypto.subtle is still missing")})(),m)}var m,T=u(()=>{"use strict";m=null});var W,L,B=u(()=>{"use strict";y();W=v("0tzTxv3k6uu+qM7k+/Kg8uPJyfPp16zowM+UyvmXwdX/w8XE2f//y+WI1g==",135),L=v("0LzL8Mz/983g9PXT8OHm+dXh697Q0/bG7cSZ7ezF+unDyfHY8+TZ2p/A5A==",135)});var G={};E(G,{getConfig:()=>le});function P(e){try{return new URL(e.includes("://")?e:`http://${e}`).hostname.toLowerCase()}catch{return e.replace(/\/+$/,"").toLowerCase()}}function oe(e){let t=P(e);return t.startsWith("www.")?t.slice(4):t}function X(e){let t=P(e);if(ie.test(t)||re.test(t)||t==="localhost")return!0;let n=(0,O.parse)(t,{allowPrivateDomains:!0});return!!(!n.domain||!n.publicSuffix||ne.includes(n.publicSuffix))}function se(e){let t=P(e);return X(t)||U.test(t)?!0:t.split(".").some(n=>U.test(n))}function ae(e){return X(e)||se(e)}function ce(e,t){return t?oe(e)===t:!1}function ue(e,t){return ae(e)?{free:!0,covered:!0}:{free:!1,covered:ce(e,t)}}var b,O,K,D,l,h,U,ne,ie,re,le,I=u(()=>{"use strict";T();b=require("jose");B();y();M();O=require("tldts"),l=x();l?h=l.siteSettings:h={};U=/\b(dev|test|testing|staging|stage|qa|uat|preview|demo|sandbox|preprod|beta|canary)\b/i,ne=["localhost","local","test","invalid","example","lan","internal"],ie=/^(127\.)|^(10\.)|^(192\.168\.)|^(172\.(1[6-9]|2\d|3[0-1])\.)/,re=/^(::1$)|(^fc00:)|(^fd)/i;le=async()=>{await C();let e=null;if(h.subscriber){let n=await(0,b.importJWK)({kty:"EC",x:K,y:D,crv:"P-256"},"ES256"),r=new Date().getFullYear(),i=Math.floor((Date.now()-new Date(r,0,1).getTime())/(1e3*60*60*24*7)),o=await fetch(l.uploadUrl+"lic.jws?t="+l.siteSettings.lastUpdate+"&y="+r+"&w="+i).then(s=>s.ok?s.text():null).catch(()=>null);if(o)try{let s=location.hostname.split(":")[0],{payload:a}=await(0,b.jwtVerify)(o,n,{algorithms:["ES256"]}),c=ue(s,a.domain);if(!c.free&&!c.covered)throw new Error("Invalid domain in JWT");let p=a.key.split(":"),Y=d(p[0]),N=d(p[1]),w=(await fetch(l.uploadUrl+"config.enc?t="+l.siteSettings.lastUpdate).then(g=>g.ok?g.text():null).catch(()=>null))?.split(":");if(w?.length===2){let g=d(w[0]),V=d(w[1]),F=await crypto.subtle.importKey("raw",Y,{name:"AES-GCM"},!1,["decrypt"]),H=await crypto.subtle.decrypt({name:"AES-GCM",iv:N},F,new Uint8Array([...g,...V]));e=JSON.parse(new TextDecoder().decode(H)),e.subscriptionType=a.subscriptionType}}catch(s){console.error(s.message)}}return e??null};K=W;D=L});var fe={};E(fe,{TEXT_DOMAIN:()=>pe,attachDefaultPluginRuntime:()=>A,getConfig:()=>ge,getPlugin:()=>de,getRecaptcha:()=>R,getWpSuite:()=>x});module.exports=Q(fe);function x(){return globalThis.WpSuite}function de(e){return globalThis.WpSuite?.plugins[e]}var pe,ge,M=u(()=>{y();k();pe="smartcloud-wpsuite",ge=async e=>{let n=await(await Promise.resolve().then(()=>(I(),G))).getConfig();return n&&(n={...n[e],subscriptionType:n.subscriptionType}),n}});M();0&&(module.exports={TEXT_DOMAIN,attachDefaultPluginRuntime,getConfig,getPlugin,getRecaptcha,getWpSuite});
1
+ "use strict";var tc=Object.create;var zt=Object.defineProperty;var nc=Object.getOwnPropertyDescriptor;var ic=Object.getOwnPropertyNames;var ac=Object.getPrototypeOf,oc=Object.prototype.hasOwnProperty;var Fr=(p,w)=>()=>(p&&(w=p(p=0)),w);var uc=(p,w)=>()=>(w||p((w={exports:{}}).exports,w),w.exports),qa=(p,w)=>{for(var B in w)zt(p,B,{get:w[B],enumerable:!0})},Xa=(p,w,B,P)=>{if(w&&typeof w=="object"||typeof w=="function")for(let H of ic(w))!oc.call(p,H)&&H!==B&&zt(p,H,{get:()=>w[H],enumerable:!(P=nc(w,H))||P.enumerable});return p};var sc=(p,w,B)=>(B=p!=null?tc(ac(p)):{},Xa(w||!p||!p.__esModule?zt(B,"default",{value:p,enumerable:!0}):B,p)),cc=p=>Xa(zt({},"__esModule",{value:!0}),p);function ot(p){let w=p.replace(/-/g,"+").replace(/_/g,"/");for(;w.length%4;)w+="=";return Uint8Array.from(atob(w),B=>B.charCodeAt(0))}var Fn,Ya,Wt=Fr(()=>{"use strict";Fn=(p,w)=>{let P=Uint8Array.from(atob(p),H=>H.charCodeAt(0)).map((H,D)=>H^w+D&255);return new TextDecoder().decode(P)},Ya=async p=>{let w=globalThis.grecaptcha,B=p?w?.enterprise:void 0,P=B?.ready??w?.ready,H=B?.execute??w?.execute;if(typeof H!="function")return{execute:void 0};try{return typeof P=="function"&&await new Promise(D=>P(()=>D())),{execute:H}}catch{return{execute:void 0}}}});function Mn(p,w){return`wpsuite:${p}:${w}`}function lc(p,w=8e3){return()=>new Promise(B=>{if(p.status==="available")return B("available");if(p.status==="error")return B("error");!p.status||p.status;let P=Mn(p.key,"ready"),H=Mn(p.key,"error"),D=()=>ne("available"),Z=()=>ne("error"),le,ne=ie=>{window.removeEventListener(P,D),window.removeEventListener(H,Z),le!==void 0&&window.clearTimeout(le),B(ie)};window.addEventListener(P,D,{once:!0}),window.addEventListener(H,Z,{once:!0}),le=window.setTimeout(()=>ne("unavailable"),w)})}function fc(p){return w=>{window.addEventListener(Mn(p,"ready"),()=>w(),{once:!0})}}function Za(p,w){let B=w?.timeoutMs??8e3;return p.availability??=lc(p,B),p.onReady??=fc(p.key),p}var Qa=Fr(()=>{"use strict"});var ao=uc(()=>{"use strict";var hc=["name","optional","primitiveSchema"],vc=["value"],pc=["isHexOnly"],yc=["value","isIndefiniteForm"],dc=["value"],gc=["isConstructed"],mc=["idBlock","lenBlock"],wc=["unusedBits","isConstructed"],kc=["idBlock","lenBlock"],bc=["value"],Ac=["valueDec","isFirstSid"],Sc=["value"],Ec=["valueDec"],Bc=["value"],Kc=["value","valueDate"],Cc=["value"],Nc=["value","local"];function xe(p){return Oc(p)||Uc(p)||no(p)||Pc()}function Pc(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Uc(p){if(typeof Symbol<"u"&&p[Symbol.iterator]!=null||p["@@iterator"]!=null)return Array.from(p)}function Oc(p){if(Array.isArray(p))return Jn(p)}function h(){"use strict";h=function(){return w};var p,w={},B=Object.prototype,P=B.hasOwnProperty,H=Object.defineProperty||function(I,C,U){I[C]=U.value},D=typeof Symbol=="function"?Symbol:{},Z=D.iterator||"@@iterator",le=D.asyncIterator||"@@asyncIterator",ne=D.toStringTag||"@@toStringTag";function ie(I,C,U){return Object.defineProperty(I,C,{value:U,enumerable:!0,configurable:!0,writable:!0}),I[C]}try{ie({},"")}catch{ie=function(U,F,z){return U[F]=z}}function K(I,C,U,F){var z=C&&C.prototype instanceof L?C:L,_=Object.create(z.prototype),se=new tr(F||[]);return H(_,"_invoke",{value:Ir(I,U,se)}),_}function Qe(I,C,U){try{return{type:"normal",arg:I.call(C,U)}}catch(F){return{type:"throw",arg:F}}}w.wrap=K;var _r="suspendedStart",mr="suspendedYield",er="executing",rr="completed",ue={};function L(){}function wr(){}function Ue(){}var Je={};ie(Je,Z,function(){return this});var kr=Object.getPrototypeOf,br=kr&&kr(kr(xr([])));br&&br!==B&&P.call(br,Z)&&(Je=br);var fr=Ue.prototype=L.prototype=Object.create(Je);function ct(I){["next","throw","return"].forEach(function(C){ie(I,C,function(U){return this._invoke(C,U)})})}function me(I,C){function U(z,_,se,we){var Se=Qe(I[z],I,_);if(Se.type!=="throw"){var nr=Se.arg,ce=nr.value;return ce&&oe(ce)=="object"&&P.call(ce,"__await")?C.resolve(ce.__await).then(function(pe){U("next",pe,se,we)},function(pe){U("throw",pe,se,we)}):C.resolve(ce).then(function(pe){nr.value=pe,se(nr)},function(pe){return U("throw",pe,se,we)})}we(Se.arg)}var F;H(this,"_invoke",{value:function(_,se){function we(){return new C(function(Se,nr){U(_,se,Se,nr)})}return F=F?F.then(we,we):we()}})}function Ir(I,C,U){var F=_r;return function(z,_){if(F===er)throw new Error("Generator is already running");if(F===rr){if(z==="throw")throw _;return{value:p,done:!0}}for(U.method=z,U.arg=_;;){var se=U.delegate;if(se){var we=Lr(se,U);if(we){if(we===ue)continue;return we}}if(U.method==="next")U.sent=U._sent=U.arg;else if(U.method==="throw"){if(F===_r)throw F=rr,U.arg;U.dispatchException(U.arg)}else U.method==="return"&&U.abrupt("return",U.arg);F=er;var Se=Qe(I,C,U);if(Se.type==="normal"){if(F=U.done?rr:mr,Se.arg===ue)continue;return{value:Se.arg,done:U.done}}Se.type==="throw"&&(F=rr,U.method="throw",U.arg=Se.arg)}}}function Lr(I,C){var U=C.method,F=I.iterator[U];if(F===p)return C.delegate=null,U==="throw"&&I.iterator.return&&(C.method="return",C.arg=p,Lr(I,C),C.method==="throw")||U!=="return"&&(C.method="throw",C.arg=new TypeError("The iterator does not provide a '"+U+"' method")),ue;var z=Qe(F,I.iterator,C.arg);if(z.type==="throw")return C.method="throw",C.arg=z.arg,C.delegate=null,ue;var _=z.arg;return _?_.done?(C[I.resultName]=_.value,C.next=I.nextLoc,C.method!=="return"&&(C.method="next",C.arg=p),C.delegate=null,ue):_:(C.method="throw",C.arg=new TypeError("iterator result is not an object"),C.delegate=null,ue)}function je(I){var C={tryLoc:I[0]};1 in I&&(C.catchLoc=I[1]),2 in I&&(C.finallyLoc=I[2],C.afterLoc=I[3]),this.tryEntries.push(C)}function hr(I){var C=I.completion||{};C.type="normal",delete C.arg,I.completion=C}function tr(I){this.tryEntries=[{tryLoc:"root"}],I.forEach(je,this),this.reset(!0)}function xr(I){if(I||I===""){var C=I[Z];if(C)return C.call(I);if(typeof I.next=="function")return I;if(!isNaN(I.length)){var U=-1,F=function z(){for(;++U<I.length;)if(P.call(I,U))return z.value=I[U],z.done=!1,z;return z.value=p,z.done=!0,z};return F.next=F}}throw new TypeError(oe(I)+" is not iterable")}return wr.prototype=Ue,H(fr,"constructor",{value:Ue,configurable:!0}),H(Ue,"constructor",{value:wr,configurable:!0}),wr.displayName=ie(Ue,ne,"GeneratorFunction"),w.isGeneratorFunction=function(I){var C=typeof I=="function"&&I.constructor;return!!C&&(C===wr||(C.displayName||C.name)==="GeneratorFunction")},w.mark=function(I){return Object.setPrototypeOf?Object.setPrototypeOf(I,Ue):(I.__proto__=Ue,ie(I,ne,"GeneratorFunction")),I.prototype=Object.create(fr),I},w.awrap=function(I){return{__await:I}},ct(me.prototype),ie(me.prototype,le,function(){return this}),w.AsyncIterator=me,w.async=function(I,C,U,F,z){z===void 0&&(z=Promise);var _=new me(K(I,C,U,F),z);return w.isGeneratorFunction(C)?_:_.next().then(function(se){return se.done?se.value:_.next()})},ct(fr),ie(fr,ne,"Generator"),ie(fr,Z,function(){return this}),ie(fr,"toString",function(){return"[object Generator]"}),w.keys=function(I){var C=Object(I),U=[];for(var F in C)U.push(F);return U.reverse(),function z(){for(;U.length;){var _=U.pop();if(_ in C)return z.value=_,z.done=!1,z}return z.done=!0,z}},w.values=xr,tr.prototype={constructor:tr,reset:function(C){if(this.prev=0,this.next=0,this.sent=this._sent=p,this.done=!1,this.delegate=null,this.method="next",this.arg=p,this.tryEntries.forEach(hr),!C)for(var U in this)U.charAt(0)==="t"&&P.call(this,U)&&!isNaN(+U.slice(1))&&(this[U]=p)},stop:function(){this.done=!0;var C=this.tryEntries[0].completion;if(C.type==="throw")throw C.arg;return this.rval},dispatchException:function(C){if(this.done)throw C;var U=this;function F(nr,ce){return se.type="throw",se.arg=C,U.next=nr,ce&&(U.method="next",U.arg=p),!!ce}for(var z=this.tryEntries.length-1;z>=0;--z){var _=this.tryEntries[z],se=_.completion;if(_.tryLoc==="root")return F("end");if(_.tryLoc<=this.prev){var we=P.call(_,"catchLoc"),Se=P.call(_,"finallyLoc");if(we&&Se){if(this.prev<_.catchLoc)return F(_.catchLoc,!0);if(this.prev<_.finallyLoc)return F(_.finallyLoc)}else if(we){if(this.prev<_.catchLoc)return F(_.catchLoc,!0)}else{if(!Se)throw new Error("try statement without catch or finally");if(this.prev<_.finallyLoc)return F(_.finallyLoc)}}}},abrupt:function(C,U){for(var F=this.tryEntries.length-1;F>=0;--F){var z=this.tryEntries[F];if(z.tryLoc<=this.prev&&P.call(z,"finallyLoc")&&this.prev<z.finallyLoc){var _=z;break}}_&&(C==="break"||C==="continue")&&_.tryLoc<=U&&U<=_.finallyLoc&&(_=null);var se=_?_.completion:{};return se.type=C,se.arg=U,_?(this.method="next",this.next=_.finallyLoc,ue):this.complete(se)},complete:function(C,U){if(C.type==="throw")throw C.arg;return C.type==="break"||C.type==="continue"?this.next=C.arg:C.type==="return"?(this.rval=this.arg=C.arg,this.method="return",this.next="end"):C.type==="normal"&&U&&(this.next=U),ue},finish:function(C){for(var U=this.tryEntries.length-1;U>=0;--U){var F=this.tryEntries[U];if(F.finallyLoc===C)return this.complete(F.completion,F.afterLoc),hr(F),ue}},catch:function(C){for(var U=this.tryEntries.length-1;U>=0;--U){var F=this.tryEntries[U];if(F.tryLoc===C){var z=F.completion;if(z.type==="throw"){var _=z.arg;hr(F)}return _}}throw new Error("illegal catch attempt")},delegateYield:function(C,U,F){return this.delegate={iterator:xr(C),resultName:U,nextLoc:F},this.method==="next"&&(this.arg=p),ue}},w}function eo(p,w,B,P,H,D,Z){try{var le=p[D](Z),ne=le.value}catch(ie){B(ie);return}le.done?w(ne):Promise.resolve(ne).then(P,H)}function re(p){return function(){var w=this,B=arguments;return new Promise(function(P,H){var D=p.apply(w,B);function Z(ne){eo(D,P,H,Z,le,"next",ne)}function le(ne){eo(D,P,H,Z,le,"throw",ne)}Z(void 0)})}}function ut(p){var w=typeof Map=="function"?new Map:void 0;return ut=function(P){if(P===null||!Lc(P))return P;if(typeof P!="function")throw new TypeError("Super expression must either be null or a function");if(typeof w<"u"){if(w.has(P))return w.get(P);w.set(P,H)}function H(){return Ic(P,arguments,M(this).constructor)}return H.prototype=Object.create(P.prototype,{constructor:{value:H,enumerable:!1,writable:!0,configurable:!0}}),st(H,P)},ut(p)}function Ic(p,w,B){if(jn())return Reflect.construct.apply(null,arguments);var P=[null];P.push.apply(P,w);var H=new(p.bind.apply(p,P));return B&&st(H,B.prototype),H}function Lc(p){try{return Function.toString.call(p).indexOf("[native code]")!==-1}catch{return typeof p=="function"}}function qt(p){if(p==null)throw new TypeError("Cannot destructure "+p)}function Ae(p,w){if(p==null)return{};var B=xc(p,w),P,H;if(Object.getOwnPropertySymbols){var D=Object.getOwnPropertySymbols(p);for(H=0;H<D.length;H++)P=D[H],!(w.indexOf(P)>=0)&&Object.prototype.propertyIsEnumerable.call(p,P)&&(B[P]=p[P])}return B}function xc(p,w){if(p==null)return{};var B={},P=Object.keys(p),H,D;for(D=0;D<P.length;D++)H=P[D],!(w.indexOf(H)>=0)&&(B[H]=p[H]);return B}function ro(p,w){var B=Object.keys(p);if(Object.getOwnPropertySymbols){var P=Object.getOwnPropertySymbols(p);w&&(P=P.filter(function(H){return Object.getOwnPropertyDescriptor(p,H).enumerable})),B.push.apply(B,P)}return B}function O(p){for(var w=1;w<arguments.length;w++){var B=arguments[w]!=null?arguments[w]:{};w%2?ro(Object(B),!0).forEach(function(P){lr(p,P,B[P])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(B)):ro(Object(B)).forEach(function(P){Object.defineProperty(p,P,Object.getOwnPropertyDescriptor(B,P))})}return p}function lr(p,w,B){return w=io(w),w in p?Object.defineProperty(p,w,{value:B,enumerable:!0,configurable:!0,writable:!0}):p[w]=B,p}function k(p,w,B){return w=M(w),Rc(p,jn()?Reflect.construct(w,B||[],M(p).constructor):w.apply(p,B))}function Rc(p,w){if(w&&(oe(w)==="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _n(p)}function _n(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function jn(){try{var p=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(jn=function(){return!!p})()}function j(){return typeof Reflect<"u"&&Reflect.get?j=Reflect.get.bind():j=function(w,B,P){var H=Vc(w,B);if(H){var D=Object.getOwnPropertyDescriptor(H,B);return D.get?D.get.call(arguments.length<3?w:P):D.value}},j.apply(this,arguments)}function Vc(p,w){for(;!Object.prototype.hasOwnProperty.call(p,w)&&(p=M(p),p!==null););return p}function M(p){return M=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(B){return B.__proto__||Object.getPrototypeOf(B)},M(p)}function b(p,w){if(typeof w!="function"&&w!==null)throw new TypeError("Super expression must either be null or a function");p.prototype=Object.create(w&&w.prototype,{constructor:{value:p,writable:!0,configurable:!0}}),Object.defineProperty(p,"prototype",{writable:!1}),w&&st(p,w)}function st(p,w){return st=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(P,H){return P.__proto__=H,P},st(p,w)}function oe(p){"@babel/helpers - typeof";return oe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(w){return typeof w}:function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},oe(p)}function he(p,w){var B=typeof Symbol<"u"&&p[Symbol.iterator]||p["@@iterator"];if(!B){if(Array.isArray(p)||(B=no(p))||w&&p&&typeof p.length=="number"){B&&(p=B);var P=0,H=function(){};return{s:H,n:function(){return P>=p.length?{done:!0}:{done:!1,value:p[P++]}},e:function(ie){throw ie},f:H}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
3
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var D=!0,Z=!1,le;return{s:function(){B=B.call(p)},n:function(){var ie=B.next();return D=ie.done,ie},e:function(ie){Z=!0,le=ie},f:function(){try{!D&&B.return!=null&&B.return()}finally{if(Z)throw le}}}}function no(p,w){if(p){if(typeof p=="string")return Jn(p,w);var B=Object.prototype.toString.call(p).slice(8,-1);if(B==="Object"&&p.constructor&&(B=p.constructor.name),B==="Map"||B==="Set")return Array.from(p);if(B==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(B))return Jn(p,w)}}function Jn(p,w){(w==null||w>p.length)&&(w=p.length);for(var B=0,P=new Array(w);B<w;B++)P[B]=p[B];return P}function g(p,w){if(!(p instanceof w))throw new TypeError("Cannot call a class as a function")}function to(p,w){for(var B=0;B<w.length;B++){var P=w[B];P.enumerable=P.enumerable||!1,P.configurable=!0,"value"in P&&(P.writable=!0),Object.defineProperty(p,io(P.key),P)}}function m(p,w,B){return w&&to(p.prototype,w),B&&to(p,B),Object.defineProperty(p,"prototype",{writable:!1}),p}function io(p){var w=Hc(p,"string");return oe(w)=="symbol"?w:String(w)}function Hc(p,w){if(oe(p)!="object"||!p)return p;var B=p[Symbol.toPrimitive];if(B!==void 0){var P=B.call(p,w||"default");if(oe(P)!="object")return P;throw new TypeError("@@toPrimitive must return a primitive value.")}return(w==="string"?String:Number)(p)}var el=(function(p,w,B){"use strict";function P(i){var r=Object.create(null);return i&&Object.keys(i).forEach(function(e){if(e!=="default"){var t=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(r,e,t.get?t:{enumerable:!0,get:function(){return i[e]}})}}),r.default=i,Object.freeze(r)}function H(i,r){return r.forEach(function(e){e&&typeof e!="string"&&!Array.isArray(e)&&Object.keys(e).forEach(function(t){if(t!=="default"&&!(t in i)){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(i,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})}),Object.freeze(i)}var D=P(w),Z=P(B),le={};typeof self<"u"&&(le=self),p.nativeCrypto=le.msCrypto||le.crypto||{},p.nativeSubtle=null;try{p.nativeSubtle=(p.nativeCrypto===null||p.nativeCrypto===void 0?void 0:p.nativeCrypto.subtle)||(p.nativeCrypto===null||p.nativeCrypto===void 0?void 0:p.nativeCrypto.webkitSubtle)||null}catch(i){console.warn("Cannot get subtle from crypto",i)}function ne(i){p.nativeCrypto=i,p.nativeSubtle=i.subtle}var ie="[object ArrayBuffer]",K=(function(){function i(){g(this,i)}return m(i,null,[{key:"isArrayBuffer",value:function(e){return Object.prototype.toString.call(e)===ie}},{key:"toArrayBuffer",value:function(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}},{key:"toUint8Array",value:function(e){return this.toView(e,Uint8Array)}},{key:"toView",value:function(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}},{key:"isBufferSource",value:function(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}},{key:"isArrayBufferView",value:function(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}},{key:"isEqual",value:function(e,t){var n=i.toUint8Array(e),a=i.toUint8Array(t);if(n.length!==a.byteLength)return!1;for(var o=0;o<n.length;o++)if(n[o]!==a[o])return!1;return!0}},{key:"concat",value:function(){for(var e,t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];Array.isArray(n[0])&&!(n[1]instanceof Function)||Array.isArray(n[0])&&n[1]instanceof Function?e=n[0]:n[n.length-1]instanceof Function?e=n.slice(0,n.length-1):e=n;var o=0,s=he(e),u;try{for(s.s();!(u=s.n()).done;){var c=u.value;o+=c.byteLength}}catch(E){s.e(E)}finally{s.f()}var l=new Uint8Array(o),f=0,d=he(e),v;try{for(d.s();!(v=d.n()).done;){var y=v.value,S=this.toUint8Array(y);l.set(S,f),f+=S.length}}catch(E){d.e(E)}finally{d.f()}return n[n.length-1]instanceof Function?this.toView(l,n[n.length-1]):l.buffer}}]),i})(),Qe="string",_r=/^[0-9a-f]+$/i,mr=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,er=/^[a-zA-Z0-9-_]+$/,rr=(function(){function i(){g(this,i)}return m(i,null,[{key:"fromString",value:function(e){for(var t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length),a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n.buffer}},{key:"toString",value:function(e){for(var t=K.toUint8Array(e),n="",a=0;a<t.length;a++)n+=String.fromCharCode(t[a]);var o=decodeURIComponent(escape(n));return o}}]),i})(),ue=(function(){function i(){g(this,i)}return m(i,null,[{key:"toString",value:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=K.toArrayBuffer(e),a=new DataView(n),o="",s=0;s<n.byteLength;s+=2){var u=a.getUint16(s,t);o+=String.fromCharCode(u)}return o}},{key:"fromString",value:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=new ArrayBuffer(e.length*2),a=new DataView(n),o=0;o<e.length;o++)a.setUint16(o*2,e.charCodeAt(o),t);return n}}]),i})(),L=(function(){function i(){g(this,i)}return m(i,null,[{key:"isHex",value:function(e){return oe(e)===Qe&&_r.test(e)}},{key:"isBase64",value:function(e){return oe(e)===Qe&&mr.test(e)}},{key:"isBase64Url",value:function(e){return oe(e)===Qe&&er.test(e)}},{key:"ToString",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"utf8",n=K.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return ue.toString(n,!0);case"utf16":case"utf16be":return ue.toString(n);default:throw new Error("Unknown type of encoding '".concat(t,"'"))}}},{key:"FromString",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"utf8";if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return ue.fromString(e,!0);case"utf16":case"utf16be":return ue.fromString(e);default:throw new Error("Unknown type of encoding '".concat(t,"'"))}}},{key:"ToBase64",value:function(e){var t=K.toUint8Array(e);if(typeof btoa<"u"){var n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}},{key:"FromBase64",value:function(e){var t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!i.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}},{key:"FromBase64Url",value:function(e){var t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!i.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}},{key:"ToBase64Url",value:function(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}},{key:"FromUtf8String",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:i.DEFAULT_UTF8_ENCODING;switch(t){case"ascii":return this.FromBinary(e);case"utf8":return rr.fromString(e);case"utf16":case"utf16be":return ue.fromString(e);case"utf16le":case"usc2":return ue.fromString(e,!0);default:throw new Error("Unknown type of encoding '".concat(t,"'"))}}},{key:"ToUtf8String",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:i.DEFAULT_UTF8_ENCODING;switch(t){case"ascii":return this.ToBinary(e);case"utf8":return rr.toString(e);case"utf16":case"utf16be":return ue.toString(e);case"utf16le":case"usc2":return ue.toString(e,!0);default:throw new Error("Unknown type of encoding '".concat(t,"'"))}}},{key:"FromBinary",value:function(e){for(var t=e.length,n=new Uint8Array(t),a=0;a<t;a++)n[a]=e.charCodeAt(a);return n.buffer}},{key:"ToBinary",value:function(e){for(var t=K.toUint8Array(e),n="",a=0;a<t.length;a++)n+=String.fromCharCode(t[a]);return n}},{key:"ToHex",value:function(e){for(var t=K.toUint8Array(e),n="",a=t.length,o=0;o<a;o++){var s=t[o];s<16&&(n+="0"),n+=s.toString(16)}return n}},{key:"FromHex",value:function(e){var t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!i.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t="0".concat(t));for(var n=new Uint8Array(t.length/2),a=0;a<t.length;a=a+2){var o=t.slice(a,a+2);n[a/2]=parseInt(o,16)}return n.buffer}},{key:"ToUtf16String",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return ue.toString(e,t)}},{key:"FromUtf16String",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return ue.fromString(e,t)}},{key:"Base64Padding",value:function(e){var t=4-e.length%4;if(t<4)for(var n=0;n<t;n++)e+="=";return e}},{key:"formatString",value:function(e){return e?.replace(/[\n\r\t ]/g,"")||""}}]),i})();L.DEFAULT_UTF8_ENCODING="utf8";function wr(){for(var i=arguments.length,r=new Array(i),e=0;e<i;e++)r[e]=arguments[e];var t=r.map(function(o){return o.byteLength}).reduce(function(o,s){return o+s}),n=new Uint8Array(t),a=0;return r.map(function(o){return new Uint8Array(o)}).forEach(function(o){var s=he(o),u;try{for(s.s();!(u=s.n()).done;){var c=u.value;n[a++]=c}}catch(l){s.e(l)}finally{s.f()}}),n.buffer}function Ue(i,r){var e=0;if(i.length===1)return i[0];for(var t=i.length-1;t>=0;t--)e+=i[i.length-1-t]*Math.pow(2,r*t);return e}function Je(i,r){for(var e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:-1,t=e,n=i,a=0,o=Math.pow(2,r),s=1;s<8;s++){if(i<o){var u=void 0;if(t<0)u=new ArrayBuffer(s),a=s;else{if(t<s)return new ArrayBuffer(0);u=new ArrayBuffer(t),a=t}for(var c=new Uint8Array(u),l=s-1;l>=0;l--){var f=Math.pow(2,l*r);c[a-l-1]=Math.floor(n/f),n-=c[a-l-1]*f}return u}o*=Math.pow(2,r)}return new ArrayBuffer(0)}function kr(){for(var i=0,r=0,e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var a=0,o=t;a<o.length;a++){var s=o[a];i+=s.length}for(var u=new ArrayBuffer(i),c=new Uint8Array(u),l=0,f=t;l<f.length;l++){var d=f[l];c.set(d,r),r+=d.length}return c}function br(){var i=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){var r=i[0]===255&&i[1]&128,e=i[0]===0&&(i[1]&128)===0;(r||e)&&this.warnings.push("Needlessly long format")}for(var t=new ArrayBuffer(this.valueHex.byteLength),n=new Uint8Array(t),a=0;a<this.valueHex.byteLength;a++)n[a]=0;n[0]=i[0]&128;for(var o=Ue(n,8),s=new ArrayBuffer(this.valueHex.byteLength),u=new Uint8Array(s),c=0;c<this.valueHex.byteLength;c++)u[c]=i[c];u[0]&=127;var l=Ue(u,8);return l-o}function fr(i){for(var r=i<0?i*-1:i,e=128,t=1;t<8;t++){if(r<=e){if(i<0){var n=e-r,a=Je(n,8,t),o=new Uint8Array(a);return o[0]|=128,a}var s=Je(r,8,t),u=new Uint8Array(s);if(u[0]&128){var c=s.slice(0),l=new Uint8Array(c);s=new ArrayBuffer(s.byteLength+1),u=new Uint8Array(s);for(var f=0;f<c.byteLength;f++)u[f+1]=l[f];u[0]=0}return s}e*=Math.pow(2,8)}return new ArrayBuffer(0)}function ct(i,r){if(i.byteLength!==r.byteLength)return!1;for(var e=new Uint8Array(i),t=new Uint8Array(r),n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function me(i,r){var e=i.toString(10);if(r<e.length)return"";for(var t=r-e.length,n=new Array(t),a=0;a<t;a++)n[a]="0";var o=n.join("");return o.concat(e)}function Ir(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Lr(i){for(var r=0,e=0,t=0;t<i.length;t++){var n=i[t];r+=n.byteLength}for(var a=new Uint8Array(r),o=0;o<i.length;o++){var s=i[o];a.set(new Uint8Array(s),e),e+=s.byteLength}return a.buffer}function je(i,r,e,t){return r instanceof Uint8Array?r.byteLength?e<0?(i.error="Wrong parameter: inputOffset less than zero",!1):t<0?(i.error="Wrong parameter: inputLength less than zero",!1):r.byteLength-e-t<0?(i.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(i.error="Wrong parameter: inputBuffer has zero length",!1):(i.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var hr=(function(){function i(){g(this,i),this.items=[]}return m(i,[{key:"write",value:function(e){this.items.push(e)}},{key:"final",value:function(){return Lr(this.items)}}]),i})(),tr=[new Uint8Array([1])],xr="0123456789",I="name",C="valueHexView",U="isHexOnly",F="idBlock",z="tagClass",_="tagNumber",se="isConstructed",we="fromBER",Se="toBER",nr="local",ce="",pe=new ArrayBuffer(0),lt=new Uint8Array(0),Jr="EndOfContent",qn="OCTET STRING",Xn="BIT STRING";function Xe(i){var r;return r=(function(e){b(t,e);function t(){var n;g(this,t);for(var a,o=arguments.length,s=new Array(o),u=0;u<o;u++)s[u]=arguments[u];n=k(this,t,[].concat(s));var c=s[0]||{};return n.isHexOnly=(a=c.isHexOnly)!==null&&a!==void 0?a:!1,n.valueHexView=c.valueHex?K.toUint8Array(c.valueHex):lt,n}return m(t,[{key:"valueHex",get:function(){return this.valueHexView.slice().buffer},set:function(a){this.valueHexView=new Uint8Array(a)}},{key:"fromBER",value:function(a,o,s){var u=a instanceof ArrayBuffer?new Uint8Array(a):a;if(!je(this,u,o,s))return-1;var c=o+s;return this.valueHexView=u.subarray(o,c),this.valueHexView.length?(this.blockLength=s,c):(this.warnings.push("Zero buffer length"),o)}},{key:"toBER",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;return this.isHexOnly?a?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",pe)}},{key:"toJSON",value:function(){return O(O({},j(M(t.prototype),"toJSON",this).call(this)),{},{isHexOnly:this.isHexOnly,valueHex:L.ToHex(this.valueHexView)})}}]),t})(i),r.NAME="hexBlock",r}var Ar=(function(){function i(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=r.blockLength,t=e===void 0?0:e,n=r.error,a=n===void 0?ce:n,o=r.warnings,s=o===void 0?[]:o,u=r.valueBeforeDecode,c=u===void 0?lt:u;g(this,i),this.blockLength=t,this.error=a,this.warnings=s,this.valueBeforeDecodeView=K.toUint8Array(c)}return m(i,[{key:"valueBeforeDecode",get:function(){return this.valueBeforeDecodeView.slice().buffer},set:function(e){this.valueBeforeDecodeView=new Uint8Array(e)}},{key:"toJSON",value:function(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:L.ToHex(this.valueBeforeDecodeView)}}}],[{key:"blockName",value:function(){return this.NAME}}]),i})();Ar.NAME="baseBlock";var Ce=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"fromBER",value:function(t,n,a){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}},{key:"toBER",value:function(t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}]),r})(Ar);Ce.NAME="valueBlock";var Yn=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.idBlock,a=n===void 0?{}:n;g(this,r);var o,s,u,c;return e=k(this,r),a?(e.isHexOnly=(o=a.isHexOnly)!==null&&o!==void 0?o:!1,e.valueHexView=a.valueHex?K.toUint8Array(a.valueHex):lt,e.tagClass=(s=a.tagClass)!==null&&s!==void 0?s:-1,e.tagNumber=(u=a.tagNumber)!==null&&u!==void 0?u:-1,e.isConstructed=(c=a.isConstructed)!==null&&c!==void 0?c:!1):(e.tagClass=-1,e.tagNumber=-1,e.isConstructed=!1),e}return m(r,[{key:"toBER",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,n=0;switch(this.tagClass){case 1:n|=0;break;case 2:n|=64;break;case 3:n|=128;break;case 4:n|=192;break;default:return this.error="Unknown tag class",pe}if(this.isConstructed&&(n|=32),this.tagNumber<31&&!this.isHexOnly){var a=new Uint8Array(1);if(!t){var o=this.tagNumber;o&=31,n|=o,a[0]=n}return a.buffer}if(!this.isHexOnly){var s=Je(this.tagNumber,7),u=new Uint8Array(s),c=s.byteLength,l=new Uint8Array(c+1);if(l[0]=n|31,!t){for(var f=0;f<c-1;f++)l[f+1]=u[f]|128;l[c]=u[c-1]}return l.buffer}var d=new Uint8Array(this.valueHexView.byteLength+1);if(d[0]=n|31,!t){for(var v=this.valueHexView,y=0;y<v.length-1;y++)d[y+1]=v[y]|128;d[this.valueHexView.byteLength]=v[v.length-1]}return d.buffer}},{key:"fromBER",value:function(t,n,a){var o=K.toUint8Array(t);if(!je(this,o,n,a))return-1;var s=o.subarray(n,n+a);if(s.length===0)return this.error="Zero buffer length",-1;var u=s[0]&192;switch(u){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;var c=s[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{for(var l=1,f=this.valueHexView=new Uint8Array(255),d=255;s[l]&128;){if(f[l-1]=s[l]&127,l++,l>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(l===d){d+=255;for(var v=new Uint8Array(d),y=0;y<f.length;y++)v[y]=f[y];f=this.valueHexView=new Uint8Array(d)}}this.blockLength=l+1,f[l-1]=s[l]&127;for(var S=new Uint8Array(l),E=0;E<l;E++)S[E]=f[E];f=this.valueHexView=new Uint8Array(l),f.set(S),this.blockLength<=9?this.tagNumber=Ue(f,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return n+this.blockLength}},{key:"toJSON",value:function(){return O(O({},j(M(r.prototype),"toJSON",this).call(this)),{},{tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed})}}]),r})(Xe(Ar));Yn.NAME="identificationBlock";var Zn=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.lenBlock,a=n===void 0?{}:n;g(this,r);var o,s,u;return e=k(this,r),e.isIndefiniteForm=(o=a.isIndefiniteForm)!==null&&o!==void 0?o:!1,e.longFormUsed=(s=a.longFormUsed)!==null&&s!==void 0?s:!1,e.length=(u=a.length)!==null&&u!==void 0?u:0,e}return m(r,[{key:"fromBER",value:function(t,n,a){var o=K.toUint8Array(t);if(!je(this,o,n,a))return-1;var s=o.subarray(n,n+a);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,n+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,n+this.blockLength;var u=s[0]&127;if(u>8)return this.error="Too big integer",-1;if(u+1>s.length)return this.error="End of input reached before message was fully decoded",-1;var c=n+1,l=o.subarray(c,c+u);return l[u-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Ue(l,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=u+1,n+this.blockLength}},{key:"toBER",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,n,a;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return n=new ArrayBuffer(1),t===!1&&(a=new Uint8Array(n),a[0]=128),n;if(this.longFormUsed){var o=Je(this.length,8);if(o.byteLength>127)return this.error="Too big length",pe;if(n=new ArrayBuffer(o.byteLength+1),t)return n;var s=new Uint8Array(o);a=new Uint8Array(n),a[0]=o.byteLength|128;for(var u=0;u<o.byteLength;u++)a[u+1]=s[u];return n}return n=new ArrayBuffer(1),t===!1&&(a=new Uint8Array(n),a[0]=this.length),n}},{key:"toJSON",value:function(){return O(O({},j(M(r.prototype),"toJSON",this).call(this)),{},{isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length})}}]),r})(Ar);Zn.NAME="lengthBlock";var R={},ke=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.name,a=n===void 0?ce:n,o=t.optional,s=o===void 0?!1:o,u=t.primitiveSchema,c=Ae(t,hc),l=arguments.length>1?arguments[1]:void 0;return g(this,r),e=k(this,r,[c]),e.name=a,e.optional=s,u&&(e.primitiveSchema=u),e.idBlock=new Yn(c),e.lenBlock=new Zn(c),e.valueBlock=l?new l(c):new Ce(c),e}return m(r,[{key:"fromBER",value:function(t,n,a){var o=this.valueBlock.fromBER(t,n,this.lenBlock.isIndefiniteForm?a:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}},{key:"toBER",value:function(t,n){var a=n||new hr;n||Qn(this);var o=this.idBlock.toBER(t);if(a.write(o),this.lenBlock.isIndefiniteForm)a.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(t,a),a.write(new ArrayBuffer(2));else{var s=this.valueBlock.toBER(t);this.lenBlock.length=s.byteLength;var u=this.lenBlock.toBER(t);a.write(u),a.write(s)}return n?pe:a.final()}},{key:"toJSON",value:function(){var t=O(O({},j(M(r.prototype),"toJSON",this).call(this)),{},{idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional});return this.primitiveSchema&&(t.primitiveSchema=this.primitiveSchema.toJSON()),t}},{key:"toString",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"ascii";return t==="ascii"?this.onAsciiEncoding():L.ToHex(this.toBER())}},{key:"onAsciiEncoding",value:function(){return"".concat(this.constructor.NAME," : ").concat(L.ToHex(this.valueBlock.valueBeforeDecodeView))}},{key:"isEqual",value:function(t){if(this===t)return!0;if(!(t instanceof this.constructor))return!1;var n=this.toBER(),a=t.toBER();return ct(n,a)}}]),r})(Ar);ke.NAME="BaseBlock";function Qn(i){if(i instanceof R.Constructed){var r=he(i.valueBlock.value),e;try{for(r.s();!(e=r.n()).done;){var t=e.value;Qn(t)&&(i.lenBlock.isIndefiniteForm=!0)}}catch(n){r.e(n)}finally{r.f()}}return!!i.lenBlock.isIndefiniteForm}var Zt=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.value,a=n===void 0?ce:n,o=Ae(t,vc),s=arguments.length>1?arguments[1]:void 0;return g(this,r),e=k(this,r,[o,s]),a&&e.fromString(a),e}return m(r,[{key:"getValue",value:function(){return this.valueBlock.value}},{key:"setValue",value:function(t){this.valueBlock.value=t}},{key:"fromBER",value:function(t,n,a){var o=this.valueBlock.fromBER(t,n,this.lenBlock.isIndefiniteForm?a:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}},{key:"onAsciiEncoding",value:function(){return"".concat(this.constructor.NAME," : '").concat(this.valueBlock.value,"'")}}]),r})(ke);Zt.NAME="BaseStringBlock";var ei=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.isHexOnly,a=n===void 0?!0:n,o=Ae(t,pc);return g(this,r),e=k(this,r,[o]),e.isHexOnly=a,e}return m(r)})(Xe(Ce));ei.NAME="PrimitiveValueBlock";var ri,jr=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t,ei]),e.idBlock.isConstructed=!1,e}return m(r)})(ke);ri=jr,(function(){R.Primitive=ri})(),jr.NAME="PRIMITIVE";function ko(i,r){if(i instanceof r)return i;var e=new r;return e.idBlock=i.idBlock,e.lenBlock=i.lenBlock,e.warnings=i.warnings,e.valueBeforeDecodeView=i.valueBeforeDecodeView,e}function Rr(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:i.length,t=r,n=new ke({},Ce),a=new Ar;if(!je(a,i,r,e))return n.error=a.error,{offset:-1,result:n};var o=i.subarray(r,r+e);if(!o.length)return n.error="Zero buffer length",{offset:-1,result:n};var s=n.idBlock.fromBER(i,r,e);if(n.idBlock.warnings.length&&n.warnings.concat(n.idBlock.warnings),s===-1)return n.error=n.idBlock.error,{offset:-1,result:n};if(r=s,e-=n.idBlock.blockLength,s=n.lenBlock.fromBER(i,r,e),n.lenBlock.warnings.length&&n.warnings.concat(n.lenBlock.warnings),s===-1)return n.error=n.lenBlock.error,{offset:-1,result:n};if(r=s,e-=n.lenBlock.blockLength,!n.idBlock.isConstructed&&n.lenBlock.isIndefiniteForm)return n.error="Indefinite length form used for primitive encoding form",{offset:-1,result:n};var u=ke;switch(n.idBlock.tagClass){case 1:if(n.idBlock.tagNumber>=37&&n.idBlock.isHexOnly===!1)return n.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:n};switch(n.idBlock.tagNumber){case 0:if(n.idBlock.isConstructed&&n.lenBlock.length>0)return n.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:n};u=R.EndOfContent;break;case 1:u=R.Boolean;break;case 2:u=R.Integer;break;case 3:u=R.BitString;break;case 4:u=R.OctetString;break;case 5:u=R.Null;break;case 6:u=R.ObjectIdentifier;break;case 10:u=R.Enumerated;break;case 12:u=R.Utf8String;break;case 13:u=R.RelativeObjectIdentifier;break;case 14:u=R.TIME;break;case 15:return n.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:n};case 16:u=R.Sequence;break;case 17:u=R.Set;break;case 18:u=R.NumericString;break;case 19:u=R.PrintableString;break;case 20:u=R.TeletexString;break;case 21:u=R.VideotexString;break;case 22:u=R.IA5String;break;case 23:u=R.UTCTime;break;case 24:u=R.GeneralizedTime;break;case 25:u=R.GraphicString;break;case 26:u=R.VisibleString;break;case 27:u=R.GeneralString;break;case 28:u=R.UniversalString;break;case 29:u=R.CharacterString;break;case 30:u=R.BmpString;break;case 31:u=R.DATE;break;case 32:u=R.TimeOfDay;break;case 33:u=R.DateTime;break;case 34:u=R.Duration;break;default:{var c=n.idBlock.isConstructed?new R.Constructed:new R.Primitive;c.idBlock=n.idBlock,c.lenBlock=n.lenBlock,c.warnings=n.warnings,n=c}}break;case 2:case 3:case 4:default:u=n.idBlock.isConstructed?R.Constructed:R.Primitive}return n=ko(n,u),s=n.fromBER(i,r,n.lenBlock.isIndefiniteForm?e:n.lenBlock.length),n.valueBeforeDecodeView=i.subarray(t,t+n.blockLength),{offset:s,result:n}}function Vr(i){if(!i.byteLength){var r=new ke({},Ce);return r.error="Input buffer has zero length",{offset:-1,result:r}}return Rr(K.toUint8Array(i).slice(),0,i.byteLength)}function bo(i,r){return i?1:r}var vr=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.value,a=n===void 0?[]:n,o=t.isIndefiniteForm,s=o===void 0?!1:o,u=Ae(t,yc);return g(this,r),e=k(this,r,[u]),e.value=a,e.isIndefiniteForm=s,e}return m(r,[{key:"fromBER",value:function(t,n,a){var o=K.toUint8Array(t);if(!je(this,o,n,a))return-1;if(this.valueBeforeDecodeView=o.subarray(n,n+a),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),n;for(var s=n;bo(this.isIndefiniteForm,a)>0;){var u=Rr(o,s,a);if(u.offset===-1)return this.error=u.result.error,this.warnings.concat(u.result.warnings),-1;if(s=u.offset,this.blockLength+=u.result.blockLength,a-=u.result.blockLength,this.value.push(u.result),this.isIndefiniteForm&&u.result.constructor.NAME===Jr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Jr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}},{key:"toBER",value:function(t,n){for(var a=n||new hr,o=0;o<this.value.length;o++)this.value[o].toBER(t,a);return n?pe:a.final()}},{key:"toJSON",value:function(){var t=O(O({},j(M(r.prototype),"toJSON",this).call(this)),{},{isIndefiniteForm:this.isIndefiniteForm,value:[]}),n=he(this.value),a;try{for(n.s();!(a=n.n()).done;){var o=a.value;t.value.push(o.toJSON())}}catch(s){n.e(s)}finally{n.f()}return t}}]),r})(Ce);vr.NAME="ConstructedValueBlock";var ti,Oe=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t,vr]),e.idBlock.isConstructed=!0,e}return m(r,[{key:"fromBER",value:function(t,n,a){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;var o=this.valueBlock.fromBER(t,n,this.lenBlock.isIndefiniteForm?a:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}},{key:"onAsciiEncoding",value:function(){var t=[],n=he(this.valueBlock.value),a;try{for(n.s();!(a=n.n()).done;){var o=a.value;t.push(o.toString("ascii").split(`
4
+ `).map(function(u){return" ".concat(u)}).join(`
5
+ `))}}catch(u){n.e(u)}finally{n.f()}var s=this.idBlock.tagClass===3?"[".concat(this.idBlock.tagNumber,"]"):this.constructor.NAME;return t.length?"".concat(s,` :
6
+ `).concat(t.join(`
7
+ `)):"".concat(s," :")}}]),r})(ke);ti=Oe,(function(){R.Constructed=ti})(),Oe.NAME="CONSTRUCTED";var ni=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"fromBER",value:function(t,n,a){return n}},{key:"toBER",value:function(t){return pe}}]),r})(Ce);ni.override="EndOfContentValueBlock";var ii,Qt=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t,ni]),e.idBlock.tagClass=1,e.idBlock.tagNumber=0,e}return m(r)})(ke);ii=Qt,(function(){R.EndOfContent=ii})(),Qt.NAME=Jr;var ai,Sr=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t,Ce]),e.idBlock.tagClass=1,e.idBlock.tagNumber=5,e}return m(r,[{key:"fromBER",value:function(t,n,a){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=a,n+a>t.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):n+a}},{key:"toBER",value:function(t,n){var a=new ArrayBuffer(2);if(!t){var o=new Uint8Array(a);o[0]=5,o[1]=0}return n&&n.write(a),a}},{key:"onAsciiEncoding",value:function(){return"".concat(this.constructor.NAME)}}]),r})(ke);ai=Sr,(function(){R.Null=ai})(),Sr.NAME="NULL";var oi=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.value,a=Ae(t,dc);return g(this,r),e=k(this,r,[a]),a.valueHex?e.valueHexView=K.toUint8Array(a.valueHex):e.valueHexView=new Uint8Array(1),n&&(e.value=n),e}return m(r,[{key:"value",get:function(){var t=he(this.valueHexView),n;try{for(t.s();!(n=t.n()).done;){var a=n.value;if(a>0)return!0}}catch(o){t.e(o)}finally{t.f()}return!1},set:function(t){this.valueHexView[0]=t?255:0}},{key:"fromBER",value:function(t,n,a){var o=K.toUint8Array(t);return je(this,o,n,a)?(this.valueHexView=o.subarray(n,n+a),a>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,br.call(this),this.blockLength=a,n+a):-1}},{key:"toBER",value:function(){return this.valueHexView.slice()}},{key:"toJSON",value:function(){return O(O({},j(M(r.prototype),"toJSON",this).call(this)),{},{value:this.value})}}]),r})(Xe(Ce));oi.NAME="BooleanValueBlock";var ui,ft=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t,oi]),e.idBlock.tagClass=1,e.idBlock.tagNumber=1,e}return m(r,[{key:"getValue",value:function(){return this.valueBlock.value}},{key:"setValue",value:function(t){this.valueBlock.value=t}},{key:"onAsciiEncoding",value:function(){return"".concat(this.constructor.NAME," : ").concat(this.getValue)}}]),r})(ke);ui=ft,(function(){R.Boolean=ui})(),ft.NAME="BOOLEAN";var si=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.isConstructed,a=n===void 0?!1:n,o=Ae(t,gc);return g(this,r),e=k(this,r,[o]),e.isConstructed=a,e}return m(r,[{key:"fromBER",value:function(t,n,a){var o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=vr.prototype.fromBER.call(this,t,n,a),o===-1)return o;for(var s=0;s<this.value.length;s++){var u=this.value[s].constructor.NAME;if(u===Jr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(u!==qn)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=j(M(r.prototype),"fromBER",this).call(this,t,n,a),this.blockLength=a;return o}},{key:"toBER",value:function(t,n){return this.isConstructed?vr.prototype.toBER.call(this,t,n):t?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}},{key:"toJSON",value:function(){return O(O({},j(M(r.prototype),"toJSON",this).call(this)),{},{isConstructed:this.isConstructed})}}]),r})(Xe(vr));si.NAME="OctetStringValueBlock";var ci,Er=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.idBlock,a=n===void 0?{}:n,o=t.lenBlock,s=o===void 0?{}:o,u=Ae(t,mc);g(this,r);var c,l;return(c=u.isConstructed)!==null&&c!==void 0||(u.isConstructed=!!(!((l=u.value)===null||l===void 0)&&l.length)),e=k(this,r,[O({idBlock:O({isConstructed:u.isConstructed},a),lenBlock:O(O({},s),{},{isIndefiniteForm:!!u.isIndefiniteForm})},u),si]),e.idBlock.tagClass=1,e.idBlock.tagNumber=4,e}return m(r,[{key:"fromBER",value:function(t,n,a){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,a===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),n;if(!this.valueBlock.isConstructed){var o=t instanceof ArrayBuffer?new Uint8Array(t):t,s=o.subarray(n,n+a);try{if(s.byteLength){var u=Rr(s,0,s.byteLength);u.offset!==-1&&u.offset===a&&(this.valueBlock.value=[u.result])}}catch{}}return j(M(r.prototype),"fromBER",this).call(this,t,n,a)}},{key:"onAsciiEncoding",value:function(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Oe.prototype.onAsciiEncoding.call(this):"".concat(this.constructor.NAME," : ").concat(L.ToHex(this.valueBlock.valueHexView))}},{key:"getValue",value:function(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;var t=[],n=he(this.valueBlock.value),a;try{for(n.s();!(a=n.n()).done;){var o=a.value;o instanceof r&&t.push(o.valueBlock.valueHexView)}}catch(s){n.e(s)}finally{n.f()}return K.concat(t)}}]),r})(ke);ci=Er,(function(){R.OctetString=ci})(),Er.NAME=qn;var li=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.unusedBits,a=n===void 0?0:n,o=t.isConstructed,s=o===void 0?!1:o,u=Ae(t,wc);return g(this,r),e=k(this,r,[u]),e.unusedBits=a,e.isConstructed=s,e.blockLength=e.valueHexView.byteLength,e}return m(r,[{key:"fromBER",value:function(t,n,a){if(!a)return n;var o=-1;if(this.isConstructed){if(o=vr.prototype.fromBER.call(this,t,n,a),o===-1)return o;var s=he(this.value),u;try{for(s.s();!(u=s.n()).done;){var c=u.value,l=c.constructor.NAME;if(l===Jr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(l!==Xn)return this.error="BIT STRING may consists of BIT STRINGs only",-1;var f=c.valueBlock;if(this.unusedBits>0&&f.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=f.unusedBits}}catch(E){s.e(E)}finally{s.f()}return o}var d=K.toUint8Array(t);if(!je(this,d,n,a))return-1;var v=d.subarray(n,n+a);if(this.unusedBits=v[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){var y=v.subarray(1);try{if(y.byteLength){var S=Rr(y,0,y.byteLength);S.offset!==-1&&S.offset===a-1&&(this.value=[S.result])}}catch{}}return this.valueHexView=v.subarray(1),this.blockLength=v.length,n+a}},{key:"toBER",value:function(t,n){if(this.isConstructed)return vr.prototype.toBER.call(this,t,n);if(t)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return pe;var a=new Uint8Array(this.valueHexView.length+1);return a[0]=this.unusedBits,a.set(this.valueHexView,1),a.buffer}},{key:"toJSON",value:function(){return O(O({},j(M(r.prototype),"toJSON",this).call(this)),{},{unusedBits:this.unusedBits,isConstructed:this.isConstructed})}}]),r})(Xe(vr));li.NAME="BitStringValueBlock";var fi,ht=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.idBlock,a=n===void 0?{}:n,o=t.lenBlock,s=o===void 0?{}:o,u=Ae(t,kc);g(this,r);var c,l;return(c=u.isConstructed)!==null&&c!==void 0||(u.isConstructed=!!(!((l=u.value)===null||l===void 0)&&l.length)),e=k(this,r,[O({idBlock:O({isConstructed:u.isConstructed},a),lenBlock:O(O({},s),{},{isIndefiniteForm:!!u.isIndefiniteForm})},u),li]),e.idBlock.tagClass=1,e.idBlock.tagNumber=3,e}return m(r,[{key:"fromBER",value:function(t,n,a){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,j(M(r.prototype),"fromBER",this).call(this,t,n,a)}},{key:"onAsciiEncoding",value:function(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Oe.prototype.onAsciiEncoding.call(this);var t=[],n=this.valueBlock.valueHexView,a=he(n),o;try{for(a.s();!(o=a.n()).done;){var s=o.value;t.push(s.toString(2).padStart(8,"0"))}}catch(c){a.e(c)}finally{a.f()}var u=t.join("");return"".concat(this.constructor.NAME," : ").concat(u.substring(0,u.length-this.valueBlock.unusedBits))}}]),r})(ke);fi=ht,(function(){R.BitString=fi})(),ht.NAME=Xn;var hi;function Ao(i,r){for(var e=new Uint8Array([0]),t=new Uint8Array(i),n=new Uint8Array(r),a=t.slice(0),o=a.length-1,s=n.slice(0),u=s.length-1,c=0,l=u<o?o:u,f=0,d=l;d>=0;d--,f++){switch(!0){case f<s.length:c=a[o-f]+s[u-f]+e[0];break;default:c=a[o-f]+e[0]}switch(e[0]=c/10,!0){case f>=a.length:a=kr(new Uint8Array([c%10]),a);break;default:a[o-f]=c%10}}return e[0]>0&&(a=kr(e,a)),a}function vi(i){if(i>=tr.length)for(var r=tr.length;r<=i;r++){for(var e=new Uint8Array([0]),t=tr[r-1].slice(0),n=t.length-1;n>=0;n--){var a=new Uint8Array([(t[n]<<1)+e[0]]);e[0]=a[0]/10,t[n]=a[0]%10}e[0]>0&&(t=kr(e,t)),tr.push(t)}return tr[i]}function So(i,r){for(var e=0,t=new Uint8Array(i),n=new Uint8Array(r),a=t.slice(0),o=a.length-1,s=n.slice(0),u=s.length-1,c,l=0,f=u;f>=0;f--,l++)switch(c=a[o-l]-s[u-l]-e,!0){case c<0:e=1,a[o-l]=c+10;break;default:e=0,a[o-l]=c}if(e>0)for(var d=o-u+1;d>=0;d--,l++)if(c=a[o-l]-e,c<0)e=1,a[o-l]=c+10;else{e=0,a[o-l]=c;break}return a.slice()}var en=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.value,a=Ae(t,bc);return g(this,r),e=k(this,r,[a]),e._valueDec=0,a.valueHex&&e.setValueHex(),n!==void 0&&(e.valueDec=n),e}return m(r,[{key:"setValueHex",value:function(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=br.call(this)))}},{key:"valueDec",get:function(){return this._valueDec},set:function(t){this._valueDec=t,this.isHexOnly=!1,this.valueHexView=new Uint8Array(fr(t))}},{key:"fromDER",value:function(t,n,a){var o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=this.fromBER(t,n,a);if(s===-1)return s;var u=this.valueHexView;return u[0]===0&&(u[1]&128)!==0?this.valueHexView=u.subarray(1):o!==0&&u.length<o&&(o-u.length>1&&(o=u.length+1),this.valueHexView=u.subarray(o-u.length)),s}},{key:"toDER",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,n=this.valueHexView;switch(!0){case(n[0]&128)!==0:{var a=new Uint8Array(this.valueHexView.length+1);a[0]=0,a.set(n,1),this.valueHexView=a}break;case(n[0]===0&&(n[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(t)}},{key:"fromBER",value:function(t,n,a){var o=j(M(r.prototype),"fromBER",this).call(this,t,n,a);return o===-1||this.setValueHex(),o}},{key:"toBER",value:function(t){return t?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}},{key:"toJSON",value:function(){return O(O({},j(M(r.prototype),"toJSON",this).call(this)),{},{valueDec:this.valueDec})}},{key:"toString",value:function(){for(var t=this.valueHexView.length*8-1,n=new Uint8Array(this.valueHexView.length*8/3),a=0,o,s=this.valueHexView,u="",c=!1,l=s.byteLength-1;l>=0;l--){o=s[l];for(var f=0;f<8;f++){if((o&1)===1)switch(a){case t:n=So(vi(a),n),u="-";break;default:n=Ao(n,vi(a))}a++,o>>=1}}for(var d=0;d<n.length;d++)n[d]&&(c=!0),c&&(u+=xr.charAt(n[d]));return c===!1&&(u+=xr.charAt(0)),u}}]),r})(Xe(Ce));hi=en,en.NAME="IntegerValueBlock",(function(){Object.defineProperty(hi.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}})})();var pi,pr=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t,en]),e.idBlock.tagClass=1,e.idBlock.tagNumber=2,e}return m(r,[{key:"toBigInt",value:function(){return Ir(),BigInt(this.valueBlock.toString())}},{key:"convertToDER",value:function(){var t=new r({valueHex:this.valueBlock.valueHexView});return t.valueBlock.toDER(),t}},{key:"convertFromDER",value:function(){return new r({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}},{key:"onAsciiEncoding",value:function(){return"".concat(this.constructor.NAME," : ").concat(this.valueBlock.toString())}}],[{key:"fromBigInt",value:function(t){Ir();var n=BigInt(t),a=new hr,o=n.toString(16).replace(/^-/,""),s=new Uint8Array(L.FromHex(o));if(n<0){var u=new Uint8Array(s.length+(s[0]&128?1:0));u[0]|=128;var c=BigInt("0x".concat(L.ToHex(u))),l=c+n,f=K.toUint8Array(L.FromHex(l.toString(16)));f[0]|=128,a.write(f)}else s[0]&128&&a.write(new Uint8Array([0])),a.write(s);var d=new r({valueHex:a.final()});return d}}]),r})(ke);pi=pr,(function(){R.Integer=pi})(),pr.NAME="INTEGER";var yi,vt=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=10,e}return m(r)})(pr);yi=vt,(function(){R.Enumerated=yi})(),vt.NAME="ENUMERATED";var rn=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.valueDec,a=n===void 0?-1:n,o=t.isFirstSid,s=o===void 0?!1:o,u=Ae(t,Ac);return g(this,r),e=k(this,r,[u]),e.valueDec=a,e.isFirstSid=s,e}return m(r,[{key:"fromBER",value:function(t,n,a){if(!a)return n;var o=K.toUint8Array(t);if(!je(this,o,n,a))return-1;var s=o.subarray(n,n+a);this.valueHexView=new Uint8Array(a);for(var u=0;u<a&&(this.valueHexView[u]=s[u]&127,this.blockLength++,(s[u]&128)!==0);u++);for(var c=new Uint8Array(this.blockLength),l=0;l<this.blockLength;l++)c[l]=this.valueHexView[l];return this.valueHexView=c,(s[this.blockLength-1]&128)!==0?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Ue(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}},{key:"valueBigInt",set:function(t){Ir();for(var n=BigInt(t).toString(2);n.length%7;)n="0"+n;for(var a=new Uint8Array(n.length/7),o=0;o<a.length;o++)a[o]=parseInt(n.slice(o*7,o*7+7),2)+(o+1<a.length?128:0);this.fromBER(a.buffer,0,a.length)}},{key:"toBER",value:function(t){if(this.isHexOnly){if(t)return new ArrayBuffer(this.valueHexView.byteLength);for(var n=this.valueHexView,a=new Uint8Array(this.blockLength),o=0;o<this.blockLength-1;o++)a[o]=n[o]|128;return a[this.blockLength-1]=n[this.blockLength-1],a.buffer}var s=Je(this.valueDec,7);if(s.byteLength===0)return this.error="Error during encoding SID value",pe;var u=new Uint8Array(s.byteLength);if(!t){for(var c=new Uint8Array(s),l=s.byteLength-1,f=0;f<l;f++)u[f]=c[f]|128;u[l]=c[l]}return u}},{key:"toString",value:function(){var t="";if(this.isHexOnly)t=L.ToHex(this.valueHexView);else if(this.isFirstSid){var n=this.valueDec;this.valueDec<=39?t="0.":this.valueDec<=79?(t="1.",n-=40):(t="2.",n-=80),t+=n.toString()}else t=this.valueDec.toString();return t}},{key:"toJSON",value:function(){return O(O({},j(M(r.prototype),"toJSON",this).call(this)),{},{valueDec:this.valueDec,isFirstSid:this.isFirstSid})}}]),r})(Xe(Ce));rn.NAME="sidBlock";var di=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.value,a=n===void 0?ce:n,o=Ae(t,Sc);return g(this,r),e=k(this,r,[o]),e.value=[],a&&e.fromString(a),e}return m(r,[{key:"fromBER",value:function(t,n,a){for(var o=n;a>0;){var s=new rn;if(o=s.fromBER(t,o,a),o===-1)return this.blockLength=0,this.error=s.error,o;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,a-=s.blockLength,this.value.push(s)}return o}},{key:"toBER",value:function(t){for(var n=[],a=0;a<this.value.length;a++){var o=this.value[a].toBER(t);if(o.byteLength===0)return this.error=this.value[a].error,pe;n.push(o)}return Lr(n)}},{key:"fromString",value:function(t){this.value=[];var n=0,a=0,o="",s=!1;do if(a=t.indexOf(".",n),a===-1?o=t.substring(n):o=t.substring(n,a),n=a+1,s){var u=this.value[0],c=0;switch(u.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}var l=parseInt(o,10);if(isNaN(l))return;u.valueDec=l+c,s=!1}else{var f=new rn;if(o>Number.MAX_SAFE_INTEGER){Ir();var d=BigInt(o);f.valueBigInt=d}else if(f.valueDec=parseInt(o,10),isNaN(f.valueDec))return;this.value.length||(f.isFirstSid=!0,s=!0),this.value.push(f)}while(a!==-1)}},{key:"toString",value:function(){for(var t="",n=!1,a=0;a<this.value.length;a++){n=this.value[a].isHexOnly;var o=this.value[a].toString();a!==0&&(t="".concat(t,".")),n?(o="{".concat(o,"}"),this.value[a].isFirstSid?t="2.{".concat(o," - 80}"):t+=o):t+=o}return t}},{key:"toJSON",value:function(){for(var t=O(O({},j(M(r.prototype),"toJSON",this).call(this)),{},{value:this.toString(),sidArray:[]}),n=0;n<this.value.length;n++)t.sidArray.push(this.value[n].toJSON());return t}}]),r})(Ce);di.NAME="ObjectIdentifierValueBlock";var gi,pt=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t,di]),e.idBlock.tagClass=1,e.idBlock.tagNumber=6,e}return m(r,[{key:"getValue",value:function(){return this.valueBlock.toString()}},{key:"setValue",value:function(t){this.valueBlock.fromString(t)}},{key:"onAsciiEncoding",value:function(){return"".concat(this.constructor.NAME," : ").concat(this.valueBlock.toString()||"empty")}},{key:"toJSON",value:function(){return O(O({},j(M(r.prototype),"toJSON",this).call(this)),{},{value:this.getValue()})}}]),r})(ke);gi=pt,(function(){R.ObjectIdentifier=gi})(),pt.NAME="OBJECT IDENTIFIER";var tn=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.valueDec,a=n===void 0?0:n,o=Ae(t,Ec);return g(this,r),e=k(this,r,[o]),e.valueDec=a,e}return m(r,[{key:"fromBER",value:function(t,n,a){if(a===0)return n;var o=K.toUint8Array(t);if(!je(this,o,n,a))return-1;var s=o.subarray(n,n+a);this.valueHexView=new Uint8Array(a);for(var u=0;u<a&&(this.valueHexView[u]=s[u]&127,this.blockLength++,(s[u]&128)!==0);u++);for(var c=new Uint8Array(this.blockLength),l=0;l<this.blockLength;l++)c[l]=this.valueHexView[l];return this.valueHexView=c,(s[this.blockLength-1]&128)!==0?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Ue(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}},{key:"toBER",value:function(t){if(this.isHexOnly){if(t)return new ArrayBuffer(this.valueHexView.byteLength);for(var n=this.valueHexView,a=new Uint8Array(this.blockLength),o=0;o<this.blockLength-1;o++)a[o]=n[o]|128;return a[this.blockLength-1]=n[this.blockLength-1],a.buffer}var s=Je(this.valueDec,7);if(s.byteLength===0)return this.error="Error during encoding SID value",pe;var u=new Uint8Array(s.byteLength);if(!t){for(var c=new Uint8Array(s),l=s.byteLength-1,f=0;f<l;f++)u[f]=c[f]|128;u[l]=c[l]}return u.buffer}},{key:"toString",value:function(){var t="";return this.isHexOnly?t=L.ToHex(this.valueHexView):t=this.valueDec.toString(),t}},{key:"toJSON",value:function(){return O(O({},j(M(r.prototype),"toJSON",this).call(this)),{},{valueDec:this.valueDec})}}]),r})(Xe(Ar));tn.NAME="relativeSidBlock";var mi=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.value,a=n===void 0?ce:n,o=Ae(t,Bc);return g(this,r),e=k(this,r,[o]),e.value=[],a&&e.fromString(a),e}return m(r,[{key:"fromBER",value:function(t,n,a){for(var o=n;a>0;){var s=new tn;if(o=s.fromBER(t,o,a),o===-1)return this.blockLength=0,this.error=s.error,o;this.blockLength+=s.blockLength,a-=s.blockLength,this.value.push(s)}return o}},{key:"toBER",value:function(t,n){for(var a=[],o=0;o<this.value.length;o++){var s=this.value[o].toBER(t);if(s.byteLength===0)return this.error=this.value[o].error,pe;a.push(s)}return Lr(a)}},{key:"fromString",value:function(t){this.value=[];var n=0,a=0,o="";do{a=t.indexOf(".",n),a===-1?o=t.substring(n):o=t.substring(n,a),n=a+1;var s=new tn;if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(a!==-1);return!0}},{key:"toString",value:function(){for(var t="",n=!1,a=0;a<this.value.length;a++){n=this.value[a].isHexOnly;var o=this.value[a].toString();a!==0&&(t="".concat(t,".")),n&&(o="{".concat(o,"}")),t+=o}return t}},{key:"toJSON",value:function(){for(var t=O(O({},j(M(r.prototype),"toJSON",this).call(this)),{},{value:this.toString(),sidArray:[]}),n=0;n<this.value.length;n++)t.sidArray.push(this.value[n].toJSON());return t}}]),r})(Ce);mi.NAME="RelativeObjectIdentifierValueBlock";var wi,nn=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t,mi]),e.idBlock.tagClass=1,e.idBlock.tagNumber=13,e}return m(r,[{key:"getValue",value:function(){return this.valueBlock.toString()}},{key:"setValue",value:function(t){this.valueBlock.fromString(t)}},{key:"onAsciiEncoding",value:function(){return"".concat(this.constructor.NAME," : ").concat(this.valueBlock.toString()||"empty")}},{key:"toJSON",value:function(){return O(O({},j(M(r.prototype),"toJSON",this).call(this)),{},{value:this.getValue()})}}]),r})(ke);wi=nn,(function(){R.RelativeObjectIdentifier=wi})(),nn.NAME="RelativeObjectIdentifier";var ki,ir=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=16,e}return m(r)})(Oe);ki=ir,(function(){R.Sequence=ki})(),ir.NAME="SEQUENCE";var bi,ar=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=17,e}return m(r)})(Oe);bi=ar,(function(){R.Set=bi})(),ar.NAME="SET";var Ai=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=Object.assign({},(qt(t),t));return g(this,r),e=k(this,r,[n]),e.isHexOnly=!0,e.value=ce,e}return m(r,[{key:"toJSON",value:function(){return O(O({},j(M(r.prototype),"toJSON",this).call(this)),{},{value:this.value})}}]),r})(Xe(Ce));Ai.NAME="StringValueBlock";var Si=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r)})(Ai);Si.NAME="SimpleStringValueBlock";var Ie=(function(i){b(r,i);function r(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=Object.assign({},(qt(e),e));return g(this,r),k(this,r,[t,Si])}return m(r,[{key:"fromBuffer",value:function(t){this.valueBlock.value=String.fromCharCode.apply(null,K.toUint8Array(t))}},{key:"fromString",value:function(t){for(var n=t.length,a=this.valueBlock.valueHexView=new Uint8Array(n),o=0;o<n;o++)a[o]=t.charCodeAt(o);this.valueBlock.value=t}}]),r})(Zt);Ie.NAME="SIMPLE STRING";var Ei=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"fromBuffer",value:function(t){this.valueBlock.valueHexView=K.toUint8Array(t);try{this.valueBlock.value=L.ToUtf8String(t)}catch(n){this.warnings.push('Error during "decodeURIComponent": '.concat(n,", using raw string")),this.valueBlock.value=L.ToBinary(t)}}},{key:"fromString",value:function(t){this.valueBlock.valueHexView=new Uint8Array(L.FromUtf8String(t)),this.valueBlock.value=t}}]),r})(Ie);Ei.NAME="Utf8StringValueBlock";var Bi,or=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=12,e}return m(r)})(Ei);Bi=or,(function(){R.Utf8String=Bi})(),or.NAME="UTF8String";var Ki=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"fromBuffer",value:function(t){this.valueBlock.value=L.ToUtf16String(t),this.valueBlock.valueHexView=K.toUint8Array(t)}},{key:"fromString",value:function(t){this.valueBlock.value=t,this.valueBlock.valueHexView=new Uint8Array(L.FromUtf16String(t))}}]),r})(Ie);Ki.NAME="BmpStringValueBlock";var Ci,yt=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=Object.assign({},(qt(t),t));return g(this,r),e=k(this,r,[n]),e.idBlock.tagClass=1,e.idBlock.tagNumber=30,e}return m(r)})(Ki);Ci=yt,(function(){R.BmpString=Ci})(),yt.NAME="BMPString";var Ni=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"fromBuffer",value:function(t){for(var n=ArrayBuffer.isView(t)?t.slice().buffer:t.slice(0),a=new Uint8Array(n),o=0;o<a.length;o+=4)a[o]=a[o+3],a[o+1]=a[o+2],a[o+2]=0,a[o+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(n))}},{key:"fromString",value:function(t){for(var n=t.length,a=this.valueBlock.valueHexView=new Uint8Array(n*4),o=0;o<n;o++){var s=Je(t.charCodeAt(o),8),u=new Uint8Array(s);if(!(u.length>4))for(var c=4-u.length,l=u.length-1;l>=0;l--)a[o*4+l+c]=u[l]}this.valueBlock.value=t}}]),r})(Ie);Ni.NAME="UniversalStringValueBlock";var Pi,dt=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=Object.assign({},(qt(t),t));return g(this,r),e=k(this,r,[n]),e.idBlock.tagClass=1,e.idBlock.tagNumber=28,e}return m(r)})(Ni);Pi=dt,(function(){R.UniversalString=Pi})(),dt.NAME="UniversalString";var Ui,gt=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=18,e}return m(r)})(Ie);Ui=gt,(function(){R.NumericString=Ui})(),gt.NAME="NumericString";var Oi,mt=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=19,e}return m(r)})(Ie);Oi=mt,(function(){R.PrintableString=Oi})(),mt.NAME="PrintableString";var Ii,wt=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=20,e}return m(r)})(Ie);Ii=wt,(function(){R.TeletexString=Ii})(),wt.NAME="TeletexString";var Li,kt=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=21,e}return m(r)})(Ie);Li=kt,(function(){R.VideotexString=Li})(),kt.NAME="VideotexString";var xi,bt=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=22,e}return m(r)})(Ie);xi=bt,(function(){R.IA5String=xi})(),bt.NAME="IA5String";var Ri,At=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=25,e}return m(r)})(Ie);Ri=At,(function(){R.GraphicString=Ri})(),At.NAME="GraphicString";var Vi,Gr=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=26,e}return m(r)})(Ie);Vi=Gr,(function(){R.VisibleString=Vi})(),Gr.NAME="VisibleString";var Hi,St=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=27,e}return m(r)})(Ie);Hi=St,(function(){R.GeneralString=Hi})(),St.NAME="GeneralString";var Di,Et=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=29,e}return m(r)})(Ie);Di=Et,(function(){R.CharacterString=Di})(),Et.NAME="CharacterString";var Ti,zr=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.value,a=t.valueDate,o=Ae(t,Kc);if(g(this,r),e=k(this,r,[o]),e.year=0,e.month=0,e.day=0,e.hour=0,e.minute=0,e.second=0,n){e.fromString(n),e.valueBlock.valueHexView=new Uint8Array(n.length);for(var s=0;s<n.length;s++)e.valueBlock.valueHexView[s]=n.charCodeAt(s)}return a&&(e.fromDate(a),e.valueBlock.valueHexView=new Uint8Array(e.toBuffer())),e.idBlock.tagClass=1,e.idBlock.tagNumber=23,e}return m(r,[{key:"fromBuffer",value:function(t){this.fromString(String.fromCharCode.apply(null,K.toUint8Array(t)))}},{key:"toBuffer",value:function(){for(var t=this.toString(),n=new ArrayBuffer(t.length),a=new Uint8Array(n),o=0;o<t.length;o++)a[o]=t.charCodeAt(o);return n}},{key:"fromDate",value:function(t){this.year=t.getUTCFullYear(),this.month=t.getUTCMonth()+1,this.day=t.getUTCDate(),this.hour=t.getUTCHours(),this.minute=t.getUTCMinutes(),this.second=t.getUTCSeconds()}},{key:"toDate",value:function(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}},{key:"fromString",value:function(t){var n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig,a=n.exec(t);if(a===null){this.error="Wrong input string for conversion";return}var o=parseInt(a[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(a[2],10),this.day=parseInt(a[3],10),this.hour=parseInt(a[4],10),this.minute=parseInt(a[5],10),this.second=parseInt(a[6],10)}},{key:"toString",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"iso";if(t==="iso"){var n=new Array(7);return n[0]=me(this.year<2e3?this.year-1900:this.year-2e3,2),n[1]=me(this.month,2),n[2]=me(this.day,2),n[3]=me(this.hour,2),n[4]=me(this.minute,2),n[5]=me(this.second,2),n[6]="Z",n.join("")}return j(M(r.prototype),"toString",this).call(this,t)}},{key:"onAsciiEncoding",value:function(){return"".concat(this.constructor.NAME," : ").concat(this.toDate().toISOString())}},{key:"toJSON",value:function(){return O(O({},j(M(r.prototype),"toJSON",this).call(this)),{},{year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second})}}]),r})(Gr);Ti=zr,(function(){R.UTCTime=Ti})(),zr.NAME="UTCTime";var $i,Bt=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};g(this,r);var n;return e=k(this,r,[t]),(n=e.millisecond)!==null&&n!==void 0||(e.millisecond=0),e.idBlock.tagClass=1,e.idBlock.tagNumber=24,e}return m(r,[{key:"fromDate",value:function(t){j(M(r.prototype),"fromDate",this).call(this,t),this.millisecond=t.getUTCMilliseconds()}},{key:"toDate",value:function(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}},{key:"fromString",value:function(t){var n=!1,a="",o="",s=0,u,c=0,l=0;if(t[t.length-1]==="Z")a=t.substring(0,t.length-1),n=!0;else{var f=new Number(t[t.length-1]);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");a=t}if(n){if(a.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(a.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{var d=1,v=a.indexOf("+"),y="";if(v===-1&&(v=a.indexOf("-"),d=-1),v!==-1){if(y=a.substring(v+1),a=a.substring(0,v),y.length!==2&&y.length!==4)throw new Error("Wrong input string for conversion");var S=parseInt(y.substring(0,2),10);if(isNaN(S.valueOf()))throw new Error("Wrong input string for conversion");if(c=d*S,y.length===4){if(S=parseInt(y.substring(2,4),10),isNaN(S.valueOf()))throw new Error("Wrong input string for conversion");l=d*S}}}var E=a.indexOf(".");if(E===-1&&(E=a.indexOf(",")),E!==-1){var x=new Number("0".concat(a.substring(E)));if(isNaN(x.valueOf()))throw new Error("Wrong input string for conversion");s=x.valueOf(),o=a.substring(0,E)}else o=a;switch(!0){case o.length===8:if(u=/(\d{4})(\d{2})(\d{2})/ig,E!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(u=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,E!==-1){var N=60*s;this.minute=Math.floor(N),N=60*(N-this.minute),this.second=Math.floor(N),N=1e3*(N-this.second),this.millisecond=Math.floor(N)}break;case o.length===12:if(u=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,E!==-1){var $=60*s;this.second=Math.floor($),$=1e3*($-this.second),this.millisecond=Math.floor($)}break;case o.length===14:if(u=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,E!==-1){var G=1e3*s;this.millisecond=Math.floor(G)}break;default:throw new Error("Wrong input string for conversion")}var Y=u.exec(o);if(Y===null)throw new Error("Wrong input string for conversion");for(var Q=1;Q<Y.length;Q++)switch(Q){case 1:this.year=parseInt(Y[Q],10);break;case 2:this.month=parseInt(Y[Q],10);break;case 3:this.day=parseInt(Y[Q],10);break;case 4:this.hour=parseInt(Y[Q],10)+c;break;case 5:this.minute=parseInt(Y[Q],10)+l;break;case 6:this.second=parseInt(Y[Q],10);break;default:throw new Error("Wrong input string for conversion")}if(n===!1){var ge=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=ge.getUTCFullYear(),this.month=ge.getUTCMonth(),this.day=ge.getUTCDay(),this.hour=ge.getUTCHours(),this.minute=ge.getUTCMinutes(),this.second=ge.getUTCSeconds(),this.millisecond=ge.getUTCMilliseconds()}}},{key:"toString",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"iso";if(t==="iso"){var n=[];return n.push(me(this.year,4)),n.push(me(this.month,2)),n.push(me(this.day,2)),n.push(me(this.hour,2)),n.push(me(this.minute,2)),n.push(me(this.second,2)),this.millisecond!==0&&(n.push("."),n.push(me(this.millisecond,3))),n.push("Z"),n.join("")}return j(M(r.prototype),"toString",this).call(this,t)}},{key:"toJSON",value:function(){return O(O({},j(M(r.prototype),"toJSON",this).call(this)),{},{millisecond:this.millisecond})}}]),r})(zr);$i=Bt,(function(){R.GeneralizedTime=$i})(),Bt.NAME="GeneralizedTime";var Fi,an=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=31,e}return m(r)})(or);Fi=an,(function(){R.DATE=Fi})(),an.NAME="DATE";var Mi,on=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=32,e}return m(r)})(or);Mi=on,(function(){R.TimeOfDay=Mi})(),on.NAME="TimeOfDay";var _i,un=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=33,e}return m(r)})(or);_i=un,(function(){R.DateTime=_i})(),un.NAME="DateTime";var Ji,sn=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=34,e}return m(r)})(or);Ji=sn,(function(){R.Duration=Ji})(),sn.NAME="Duration";var ji,cn=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return g(this,r),e=k(this,r,[t]),e.idBlock.tagClass=1,e.idBlock.tagNumber=14,e}return m(r)})(or);ji=cn,(function(){R.TIME=ji})(),cn.NAME="TIME";var Br=m(function i(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=r.name,t=e===void 0?ce:e,n=r.optional,a=n===void 0?!1:n;g(this,i),this.name=t,this.optional=a}),ln=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.value,a=n===void 0?[]:n,o=Ae(t,Cc);return g(this,r),e=k(this,r,[o]),e.value=a,e}return m(r)})(Br),Kt=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.value,a=n===void 0?new Br:n,o=t.local,s=o===void 0?!1:o,u=Ae(t,Nc);return g(this,r),e=k(this,r,[u]),e.value=a,e.local=s,e}return m(r)})(Br),Eo=(function(){function i(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=r.data,t=e===void 0?lt:e;g(this,i),this.dataView=K.toUint8Array(t)}return m(i,[{key:"data",get:function(){return this.dataView.slice().buffer},set:function(e){this.dataView=K.toUint8Array(e)}},{key:"fromBER",value:function(e,t,n){var a=t+n;return this.dataView=K.toUint8Array(e).subarray(t,a),a}},{key:"toBER",value:function(e){return this.dataView.slice().buffer}}]),i})();function Kr(i,r,e){if(e instanceof ln){for(var t=0;t<e.value.length;t++){var n=Kr(i,r,e.value[t]);if(n.verified)return{verified:!0,result:i}}{var a={verified:!1,result:{error:"Wrong values for Choice type"}};return e.hasOwnProperty(I)&&(a.name=e.name),a}}if(e instanceof Br)return e.hasOwnProperty(I)&&(i[e.name]=r),{verified:!0,result:i};if(!(i instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(F in e))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(we in e.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Se in e.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};var o=e.idBlock.toBER(!1);if(o.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};var s=e.idBlock.fromBER(o,0,o.byteLength);if(s===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(e.idBlock.hasOwnProperty(z)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(e.idBlock.tagClass!==r.idBlock.tagClass)return{verified:!1,result:i};if(e.idBlock.hasOwnProperty(_)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(e.idBlock.tagNumber!==r.idBlock.tagNumber)return{verified:!1,result:i};if(e.idBlock.hasOwnProperty(se)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(e.idBlock.isConstructed!==r.idBlock.isConstructed)return{verified:!1,result:i};if(!(U in e.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(e.idBlock.isHexOnly!==r.idBlock.isHexOnly)return{verified:!1,result:i};if(e.idBlock.isHexOnly){if(!(C in e.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};var u=e.idBlock.valueHexView,c=r.idBlock.valueHexView;if(u.length!==c.length)return{verified:!1,result:i};for(var l=0;l<u.length;l++)if(u[l]!==c[1])return{verified:!1,result:i}}if(e.name&&(e.name=e.name.replace(/^\s+|\s+$/g,ce),e.name&&(i[e.name]=r)),e instanceof R.Constructed){var f=0,d={verified:!1,result:{error:"Unknown error"}},v=e.valueBlock.value.length;if(v>0&&e.valueBlock.value[0]instanceof Kt&&(v=r.valueBlock.value.length),v===0)return{verified:!0,result:i};if(r.valueBlock.value.length===0&&e.valueBlock.value.length!==0){for(var y=!0,S=0;S<e.valueBlock.value.length;S++)y=y&&(e.valueBlock.value[S].optional||!1);return y?{verified:!0,result:i}:(e.name&&(e.name=e.name.replace(/^\s+|\s+$/g,ce),e.name&&delete i[e.name]),i.error="Inconsistent object length",{verified:!1,result:i})}for(var E=0;E<v;E++)if(E-f>=r.valueBlock.value.length){if(e.valueBlock.value[E].optional===!1){var x={verified:!1,result:i};return i.error="Inconsistent length between ASN.1 data and schema",e.name&&(e.name=e.name.replace(/^\s+|\s+$/g,ce),e.name&&(delete i[e.name],x.name=e.name)),x}}else if(e.valueBlock.value[0]instanceof Kt){if(d=Kr(i,r.valueBlock.value[E],e.valueBlock.value[0].value),d.verified===!1)if(e.valueBlock.value[0].optional)f++;else return e.name&&(e.name=e.name.replace(/^\s+|\s+$/g,ce),e.name&&delete i[e.name]),d;if(I in e.valueBlock.value[0]&&e.valueBlock.value[0].name.length>0){var N={};nr in e.valueBlock.value[0]&&e.valueBlock.value[0].local?N=r:N=i,typeof N[e.valueBlock.value[0].name]>"u"&&(N[e.valueBlock.value[0].name]=[]),N[e.valueBlock.value[0].name].push(r.valueBlock.value[E])}}else if(d=Kr(i,r.valueBlock.value[E-f],e.valueBlock.value[E]),d.verified===!1)if(e.valueBlock.value[E].optional)f++;else return e.name&&(e.name=e.name.replace(/^\s+|\s+$/g,ce),e.name&&delete i[e.name]),d;if(d.verified===!1){var $={verified:!1,result:i};return e.name&&(e.name=e.name.replace(/^\s+|\s+$/g,ce),e.name&&(delete i[e.name],$.name=e.name)),$}return{verified:!0,result:i}}if(e.primitiveSchema&&C in r.valueBlock){var G=Rr(r.valueBlock.valueHexView);if(G.offset===-1){var Y={verified:!1,result:G.result};return e.name&&(e.name=e.name.replace(/^\s+|\s+$/g,ce),e.name&&(delete i[e.name],Y.name=e.name)),Y}return Kr(i,G.result,e.primitiveSchema)}return{verified:!0,result:i}}function Bo(i,r){if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};var e=Rr(K.toUint8Array(i));return e.offset===-1?{verified:!1,result:e.result}:Kr(e.result,e.result,r)}var Gi=Object.freeze({__proto__:null,Any:Br,BaseBlock:ke,BaseStringBlock:Zt,BitString:ht,BmpString:yt,Boolean:ft,CharacterString:Et,Choice:ln,Constructed:Oe,DATE:an,DateTime:un,Duration:sn,EndOfContent:Qt,Enumerated:vt,GeneralString:St,GeneralizedTime:Bt,GraphicString:At,HexBlock:Xe,IA5String:bt,Integer:pr,Null:Sr,NumericString:gt,ObjectIdentifier:pt,OctetString:Er,Primitive:jr,PrintableString:mt,RawData:Eo,RelativeObjectIdentifier:nn,Repeated:Kt,Sequence:ir,Set:ar,TIME:cn,TeletexString:wt,TimeOfDay:on,UTCTime:zr,UniversalString:dt,Utf8String:or,ValueBlock:Ce,VideotexString:kt,ViewWriter:hr,VisibleString:Gr,compareSchema:Kr,fromBER:Vr,verifySchema:Bo}),Ee;(function(i){i[i.Sequence=0]="Sequence",i[i.Set=1]="Set",i[i.Choice=2]="Choice"})(Ee||(Ee={}));var T;(function(i){i[i.Any=1]="Any",i[i.Boolean=2]="Boolean",i[i.OctetString=3]="OctetString",i[i.BitString=4]="BitString",i[i.Integer=5]="Integer",i[i.Enumerated=6]="Enumerated",i[i.ObjectIdentifier=7]="ObjectIdentifier",i[i.Utf8String=8]="Utf8String",i[i.BmpString=9]="BmpString",i[i.UniversalString=10]="UniversalString",i[i.NumericString=11]="NumericString",i[i.PrintableString=12]="PrintableString",i[i.TeletexString=13]="TeletexString",i[i.VideotexString=14]="VideotexString",i[i.IA5String=15]="IA5String",i[i.GraphicString=16]="GraphicString",i[i.VisibleString=17]="VisibleString",i[i.GeneralString=18]="GeneralString",i[i.CharacterString=19]="CharacterString",i[i.UTCTime=20]="UTCTime",i[i.GeneralizedTime=21]="GeneralizedTime",i[i.DATE=22]="DATE",i[i.TimeOfDay=23]="TimeOfDay",i[i.DateTime=24]="DateTime",i[i.Duration=25]="Duration",i[i.TIME=26]="TIME",i[i.Null=27]="Null"})(T||(T={}));var Ko=(function(){function i(r){g(this,i),typeof r=="number"?this.buffer=new ArrayBuffer(r):K.isBufferSource(r)?this.buffer=K.toArrayBuffer(r):Array.isArray(r)?this.buffer=new Uint8Array(r):this.buffer=new ArrayBuffer(0)}return m(i,[{key:"byteLength",get:function(){return this.buffer.byteLength}},{key:"byteOffset",get:function(){return 0}},{key:"fromASN",value:function(e){if(!(e instanceof Er))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}},{key:"toASN",value:function(){return new Er({valueHex:this.buffer})}},{key:"toSchema",value:function(e){return new Er({name:e})}}]),i})(),Co={fromASN:function(r){return r instanceof Sr?null:r.valueBeforeDecodeView},toASN:function(r){if(r===null)return new Sr;var e=Vr(r);if(e.result.error)throw new Error(e.result.error);return e.result}},fn={fromASN:function(r){return r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec},toASN:function(r){return new pr({value:+r})}},No={fromASN:function(r){return r.valueBlock.valueDec},toASN:function(r){return new vt({value:r})}},Po={fromASN:function(r){return r.valueBlock.valueHexView},toASN:function(r){return new ht({valueHex:r})}},Uo={fromASN:function(r){return r.valueBlock.toString()},toASN:function(r){return new pt({value:r})}},Oo={fromASN:function(r){return r.valueBlock.value},toASN:function(r){return new ft({value:r})}},Io={fromASN:function(r){return r.valueBlock.valueHexView},toASN:function(r){return new Er({valueHex:r})}};function Re(i){return{fromASN:function(e){return e.valueBlock.value},toASN:function(e){return new i({value:e})}}}var Lo=Re(or),xo=Re(yt),Ro=Re(dt),Vo=Re(gt),Ho=Re(mt),Do=Re(wt),To=Re(kt),$o=Re(bt),Fo=Re(At),Mo=Re(Gr),_o=Re(St),Jo=Re(Et),jo={fromASN:function(r){return r.toDate()},toASN:function(r){return new zr({valueDate:r})}},Go={fromASN:function(r){return r.toDate()},toASN:function(r){return new Bt({valueDate:r})}},zo={fromASN:function(){return null},toASN:function(){return new Sr}};function hn(i){switch(i){case T.Any:return Co;case T.BitString:return Po;case T.BmpString:return xo;case T.Boolean:return Oo;case T.CharacterString:return Jo;case T.Enumerated:return No;case T.GeneralString:return _o;case T.GeneralizedTime:return Go;case T.GraphicString:return Fo;case T.IA5String:return $o;case T.Integer:return fn;case T.Null:return zo;case T.NumericString:return Vo;case T.ObjectIdentifier:return Uo;case T.OctetString:return Io;case T.PrintableString:return Ho;case T.TeletexString:return Do;case T.UTCTime:return jo;case T.UniversalString:return Ro;case T.Utf8String:return Lo;case T.VideotexString:return To;case T.VisibleString:return Mo;default:return null}}function ur(i){return typeof i=="function"&&i.prototype?i.prototype.toASN&&i.prototype.fromASN?!0:ur(i.prototype):!!(i&&oe(i)==="object"&&"toASN"in i&&"fromASN"in i)}function zi(i){var r;if(i){var e=Object.getPrototypeOf(i);return((r=e?.prototype)===null||r===void 0?void 0:r.constructor)===Array?!0:zi(e)}return!1}function Wo(i,r){if(!(i&&r)||i.byteLength!==r.byteLength)return!1;for(var e=new Uint8Array(i),t=new Uint8Array(r),n=0;n<i.byteLength;n++)if(e[n]!==t[n])return!1;return!0}var qo=(function(){function i(){g(this,i),this.items=new WeakMap}return m(i,[{key:"has",value:function(e){return this.items.has(e)}},{key:"get",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=this.items.get(e);if(!n)throw new Error("Cannot get schema for '".concat(e.prototype.constructor.name,"' target"));if(t&&!n.schema)throw new Error("Schema '".concat(e.prototype.constructor.name,"' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'."));return n}},{key:"cache",value:function(e){var t=this.get(e);t.schema||(t.schema=this.create(e,!0))}},{key:"createDefault",value:function(e){var t={type:Ee.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(t,n),t.items=Object.assign({},t.items,n.items)),t}},{key:"create",value:function(e,t){var n=this.items.get(e)||this.createDefault(e),a=[];for(var o in n.items){var s=n.items[o],u=t?o:"",c=void 0;if(typeof s.type=="number"){var l=T[s.type],f=Gi[l];if(!f)throw new Error("Cannot get ASN1 class by name '".concat(l,"'"));c=new f({name:u})}else if(ur(s.type)){var d=new s.type;c=d.toSchema(u)}else if(s.optional){var v=this.get(s.type);v.type===Ee.Choice?c=new Br({name:u}):(c=this.create(s.type,!1),c.name=u)}else c=new Br({name:u});var y=!!s.optional||s.defaultValue!==void 0;if(s.repeated){c.name="";var S=s.repeated==="set"?ar:ir;c=new S({name:"",value:[new Kt({name:u,value:c})]})}if(s.context!==null&&s.context!==void 0)if(s.implicit)if(typeof s.type=="number"||ur(s.type)){var E=s.repeated?Oe:jr;a.push(new E({name:u,optional:y,idBlock:{tagClass:3,tagNumber:s.context}}))}else{this.cache(s.type);var x=!!s.repeated,N=x?c:this.get(s.type,!0).schema;N="valueBlock"in N?N.valueBlock.value:N.value,a.push(new Oe({name:x?"":u,optional:y,idBlock:{tagClass:3,tagNumber:s.context},value:N}))}else a.push(new Oe({optional:y,idBlock:{tagClass:3,tagNumber:s.context},value:[c]}));else c.optional=y,a.push(c)}switch(n.type){case Ee.Sequence:return new ir({value:a,name:""});case Ee.Set:return new ar({value:a,name:""});case Ee.Choice:return new ln({value:a,name:""});default:throw new Error("Unsupported ASN1 type in use")}}},{key:"set",value:function(e,t){return this.items.set(e,t),this}},{key:"findParentSchema",value:function(e){var t=Object.getPrototypeOf(e);if(t){var n=this.items.get(t);return n||this.findParentSchema(t)}return null}}]),i})(),Ve=new qo,Wr=function(r){return function(e){var t;Ve.has(e)?t=Ve.get(e):(t=Ve.createDefault(e),Ve.set(e,t)),Object.assign(t,r)}},ee=function(r){return function(e,t){var n;Ve.has(e.constructor)?n=Ve.get(e.constructor):(n=Ve.createDefault(e.constructor),Ve.set(e.constructor,n));var a=Object.assign({},r);if(typeof a.type=="number"&&!a.converter){var o=hn(r.type);if(!o)throw new Error("Cannot get default converter for property '".concat(t,"' of ").concat(e.constructor.name));a.converter=o}n.items[t]=a}},Wi=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.schemas=[],e}return m(r)})(ut(Error)),Xo=(function(){function i(){g(this,i)}return m(i,null,[{key:"parse",value:function(e,t){var n=Vr(e);if(n.result.error)throw new Error(n.result.error);var a=this.fromASN(n.result,t);return a}},{key:"fromASN",value:function(e,t){var n=this,a;try{if(ur(t)){var o=new t;return o.fromASN(e)}var s=Ve.get(t);Ve.cache(t);var u=s.schema;if(e.constructor===Oe&&s.type!==Ee.Choice){u=new Oe({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:s.schema.valueBlock.value});for(var c in s.items)delete e[c]}var l=Kr({},e,u);if(!l.verified)throw new Wi("Data does not match to ".concat(t.name," ASN1 schema. ").concat(l.result.error));var f=new t;if(zi(t)){if(!("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");var d=s.itemType;if(typeof d=="number"){var v=hn(d);if(!v)throw new Error("Cannot get default converter for array item of ".concat(t.name," ASN1 schema"));return t.from(e.valueBlock.value,function(E){return v.fromASN(E)})}else return t.from(e.valueBlock.value,function(E){return n.fromASN(E,d)})}var y=function(){var x=l.result[S];if(!x)return 1;var N=s.items[S],$=N.type;if(typeof $=="number"||ur($)){var G=(a=N.converter)!==null&&a!==void 0?a:ur($)?new $:null;if(!G)throw new Error("Converter is empty");if(N.repeated)if(N.implicit){var Y=N.repeated==="sequence"?ir:ar,Q=new Y;Q.valueBlock=x.valueBlock;var ge=Vr(Q.toBER(!1));if(ge.offset===-1)throw new Error("Cannot parse the child item. ".concat(ge.result.error));if(!("value"in ge.result.valueBlock&&Array.isArray(ge.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");var nt=ge.result.valueBlock.value;f[S]=Array.from(nt,function(at){return G.fromASN(at)})}else f[S]=Array.from(x,function(at){return G.fromASN(at)});else{var Or=x;if(N.implicit){var it;if(ur($))it=new $().toSchema("");else{var V=T[$],Gt=Gi[V];if(!Gt)throw new Error("Cannot get '".concat(V,"' class from asn1js module"));it=new Gt}it.valueBlock=Or.valueBlock,Or=Vr(it.toBER(!1)).result}f[S]=G.fromASN(Or)}}else if(N.repeated){if(!Array.isArray(x))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");f[S]=Array.from(x,function(at){return n.fromASN(at,$)})}else f[S]=n.fromASN(x,$)};for(var S in s.items)y();return f}catch(E){throw E instanceof Wi&&E.schemas.push(t.name),E}}}]),i})(),qi=(function(){function i(){g(this,i)}return m(i,null,[{key:"serialize",value:function(e){return e instanceof ke?e.toBER(!1):this.toASN(e).toBER(!1)}},{key:"toASN",value:function(e){var t=this;if(e&&oe(e)==="object"&&ur(e))return e.toASN();if(!(e&&oe(e)==="object"))throw new TypeError("Parameter 1 should be type of Object.");var n=e.constructor,a=Ve.get(n);Ve.cache(n);var o=[];if(a.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof a.itemType=="number"){var s=hn(a.itemType);if(!s)throw new Error("Cannot get default converter for array item of ".concat(n.name," ASN1 schema"));o=e.map(function(y){return s.toASN(y)})}else o=e.map(function(y){return t.toAsnItem({type:a.itemType},"[]",n,y)})}else for(var u in a.items){var c=a.items[u],l=e[u];if(!(l===void 0||c.defaultValue===l||oe(c.defaultValue)==="object"&&oe(l)==="object"&&Wo(this.serialize(c.defaultValue),this.serialize(l)))){var f=i.toAsnItem(c,u,n,l);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||ur(c.type))){var d={};d.valueHex=f instanceof Sr?f.valueBeforeDecodeView:f.valueBlock.toBER(),o.push(new jr(O({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context}},d)))}else o.push(new Oe({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:f.valueBlock.value}));else o.push(new Oe({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[f]}));else c.repeated?o=o.concat(f):o.push(f)}}var v;switch(a.type){case Ee.Sequence:v=new ir({value:o});break;case Ee.Set:v=new ar({value:o});break;case Ee.Choice:if(!o[0])throw new Error("Schema '".concat(n.name,"' has wrong data. Choice cannot be empty."));v=o[0];break}return v}},{key:"toAsnItem",value:function(e,t,n,a){var o=this,s;if(typeof e.type=="number"){var u=e.converter;if(!u)throw new Error("Property '".concat(t,"' doesn't have converter for type ").concat(T[e.type]," in schema '").concat(n.name,"'"));if(e.repeated){if(!Array.isArray(a))throw new TypeError("Parameter 'objProp' should be type of Array.");var c=Array.from(a,function(v){return u.toASN(v)}),l=e.repeated==="sequence"?ir:ar;s=new l({value:c})}else s=u.toASN(a)}else if(e.repeated){if(!Array.isArray(a))throw new TypeError("Parameter 'objProp' should be type of Array.");var f=Array.from(a,function(v){return o.toASN(v)}),d=e.repeated==="sequence"?ir:ar;s=new d({value:f})}else s=this.toASN(a);return s}}]),i})(),te=(function(){function i(){g(this,i)}return m(i,null,[{key:"serialize",value:function(e){return qi.serialize(e)}},{key:"parse",value:function(e,t){return Xo.parse(e,t)}},{key:"toString",value:function(e){var t=K.isBufferSource(e)?K.toArrayBuffer(e):i.serialize(e),n=Vr(t);if(n.offset===-1)throw new Error("Cannot decode ASN.1 data. ".concat(n.result.error));return n.result.toString()}}]),i})();function W(i,r,e,t){var n=arguments.length,a=n<3?r:t===null?t=Object.getOwnPropertyDescriptor(r,e):t,o;if((typeof Reflect>"u"?"undefined":oe(Reflect))==="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,r,e,t);else for(var s=i.length-1;s>=0;s--)(o=i[s])&&(a=(n<3?o(a):n>3?o(r,e,a):o(r,e))||a);return n>3&&a&&Object.defineProperty(r,e,a),a}function A(i,r,e,t){function n(a){return a instanceof e?a:new e(function(o){o(a)})}return new(e||(e=Promise))(function(a,o){function s(l){try{c(t.next(l))}catch(f){o(f)}}function u(l){try{c(t.throw(l))}catch(f){o(f)}}function c(l){l.done?a(l.value):n(l.value).then(s,u)}c((t=t.apply(i,r||[])).next())})}function Yo(i,r,e,t){if(e==="a"&&!t)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?i!==r||!t:!r.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?t:e==="a"?t.call(i):t?t.value:r.get(i)}function Zo(i,r,e,t,n){if(t==="m")throw new TypeError("Private method is not writable");if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?i!==r||!n:!r.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t==="a"?n.call(i,e):n?n.value=e:r.set(i,e),e}typeof SuppressedError=="function"&&SuppressedError;var Ct=(function(i){b(r,i);function r(e,t){var n;return g(this,r),n=k(this,r,[t?"".concat(e,". See the inner exception for more details."):e]),n.message=e,n.innerError=t,n}return m(r)})(ut(Error)),Qo=(function(i){b(r,i);function r(e,t,n){var a;return g(this,r),a=k(this,r,[t,n]),a.schema=e,a}return m(r)})(Ct),Nt=(function(i){b(r,i);function r(e,t,n){return g(this,r),k(this,r,[e,"JSON doesn't match to '".concat(e.target.name,"' schema. ").concat(t),n])}return m(r)})(Qo),yr=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r)})(Ct),vn=(function(i){b(r,i);function r(e,t,n){var a;return g(this,r),a=k(this,r,["Cannot serialize by '".concat(e,"' schema. ").concat(t),n]),a.schemaName=e,a}return m(r)})(Ct),Xi=(function(i){b(r,i);function r(e,t){var n,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return g(this,r),n=k(this,r,[e,"Some keys doesn't match to schema"]),n.keys=t,n.errors=a,n}return m(r)})(Nt),ye;(function(i){i[i.Any=0]="Any",i[i.Boolean=1]="Boolean",i[i.Number=2]="Number",i[i.String=3]="String"})(ye||(ye={}));function eu(i,r){switch(r){case ye.Boolean:return typeof i=="boolean";case ye.Number:return typeof i=="number";case ye.String:return typeof i=="string"}return!0}function Pt(i,r){if(!eu(i,r))throw new TypeError("Value must be ".concat(ye[r]))}function Ut(i){return i&&i.prototype?i.prototype.toJSON&&i.prototype.fromJSON?!0:Ut(i.prototype):!!(i&&i.toJSON&&i.fromJSON)}var ru=(function(){function i(){g(this,i),this.items=new Map}return m(i,[{key:"has",value:function(e){return this.items.has(e)||!!this.findParentSchema(e)}},{key:"get",value:function(e){var t=this.items.get(e)||this.findParentSchema(e);if(!t)throw new Error("Cannot get schema for current target");return t}},{key:"create",value:function(e){var t={names:{}},n=this.findParentSchema(e);if(n){Object.assign(t,n),t.names={};for(var a in n.names)t.names[a]=Object.assign({},n.names[a])}return t.target=e,t}},{key:"set",value:function(e,t){return this.items.set(e,t),this}},{key:"findParentSchema",value:function(e){var t=e.__proto__;if(t){var n=this.items.get(t);return n||this.findParentSchema(t)}return null}}]),i})(),qr="default",Ge=new ru,tu=(function(){function i(r){g(this,i),this.pattern=new RegExp(r)}return m(i,[{key:"validate",value:function(e){var t=new RegExp(this.pattern.source,this.pattern.flags);if(typeof e!="string")throw new yr("Incoming value must be string");if(!t.exec(e))throw new yr("Value doesn't match to pattern '".concat(t.toString(),"'"))}}]),i})(),nu=(function(){function i(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Number.MIN_VALUE,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE;g(this,i),this.min=r,this.max=e}return m(i,[{key:"validate",value:function(e){if(Pt(e,ye.Number),!(this.min<=e&&e<=this.max)){var t=this.min===Number.MIN_VALUE?"MIN":this.min,n=this.max===Number.MAX_VALUE?"MAX":this.max;throw new yr("Value doesn't match to diapason [".concat(t,",").concat(n,"]"))}}}]),i})(),iu=(function(){function i(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Number.MIN_VALUE,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE;g(this,i),this.min=r,this.max=e}return m(i,[{key:"validate",value:function(e){if(Pt(e,ye.Number),!(this.min<e&&e<this.max)){var t=this.min===Number.MIN_VALUE?"MIN":this.min,n=this.max===Number.MAX_VALUE?"MAX":this.max;throw new yr("Value doesn't match to diapason (".concat(t,",").concat(n,")"))}}}]),i})(),Yi=(function(){function i(r,e,t){g(this,i),this.length=r,this.minLength=e,this.maxLength=t}return m(i,[{key:"validate",value:function(e){if(this.length!==void 0){if(e.length!==this.length)throw new yr("Value length must be exactly ".concat(this.length,"."));return}if(this.minLength!==void 0&&e.length<this.minLength)throw new yr("Value length must be more than ".concat(this.minLength,"."));if(this.maxLength!==void 0&&e.length>this.maxLength)throw new yr("Value length must be less than ".concat(this.maxLength,"."))}}]),i})(),au=(function(){function i(r){g(this,i),this.enumeration=r}return m(i,[{key:"validate",value:function(e){if(Pt(e,ye.String),!this.enumeration.includes(e))throw new yr("Value must be one of ".concat(this.enumeration.map(function(t){return"'".concat(t,"'")}).join(", ")))}}]),i})(),Zi=(function(){function i(){g(this,i)}return m(i,null,[{key:"checkValues",value:function(e,t){var n=Array.isArray(e)?e:[e],a=he(n),o;try{for(a.s();!(o=a.n()).done;){var s=o.value,u=he(t.validations),c;try{for(u.s();!(c=u.n()).done;){var l=c.value;l instanceof Yi&&t.repeated?l.validate(e):l.validate(s)}}catch(f){u.e(f)}finally{u.f()}}}catch(f){a.e(f)}finally{a.f()}}},{key:"checkTypes",value:function(e,t){if(t.repeated&&!Array.isArray(e))throw new TypeError("Value must be Array");if(typeof t.type=="number"){var n=Array.isArray(e)?e:[e],a=he(n),o;try{for(a.s();!(o=a.n()).done;){var s=o.value;Pt(s,t.type)}}catch(u){a.e(u)}finally{a.f()}}}},{key:"getSchemaByName",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:qr;return O(O({},e.names[qr]),e.names[t])}}]),i})(),Xr=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,null,[{key:"serialize",value:function(t,n,a,o){var s=this.toJSON(t,n);return JSON.stringify(s,a,o)}},{key:"toJSON",value:function(t){var n=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o,s=a.targetSchema,u=a.schemaName||qr;if(Ut(t))return t.toJSON();if(Array.isArray(t)){o=[];var c=he(t),l;try{for(c.s();!(l=c.n()).done;){var f=l.value;o.push(this.toJSON(f,a))}}catch(x){c.e(x)}finally{c.f()}}else if(oe(t)==="object"){if(s&&!Ge.has(s))throw new Ct("Cannot get schema for `targetSchema` param");if(s=s||t.constructor,Ge.has(s)){var d=Ge.get(s);o={};var v=this.getSchemaByName(d,u),y=function(){try{var N=v[S],$=t[S],G;if(N.optional&&$===void 0||N.defaultValue!==void 0&&$===N.defaultValue)return 1;if(!N.optional&&$===void 0)throw new vn(s.name,"Property '".concat(S,"' is required."));typeof N.type=="number"?N.converter?N.repeated?G=$.map(function(Y){return N.converter.toJSON(Y,t)}):G=N.converter.toJSON($,t):G=$:N.repeated?G=$.map(function(Y){return n.toJSON(Y,{schemaName:u})}):G=n.toJSON($,{schemaName:u}),n.checkTypes(G,N),n.checkValues(G,N),o[N.name||S]=G}catch(Y){throw Y instanceof vn?Y:new vn(d.target.name,"Property '".concat(S,"' is wrong. ").concat(Y.message),Y)}};for(var S in v)y()}else{o={};for(var E in t)o[E]=this.toJSON(t[E],{schemaName:u})}}else o=t;return o}}]),r})(Zi),Cr=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,null,[{key:"parse",value:function(t,n){var a=JSON.parse(t);return this.fromJSON(a,n)}},{key:"fromJSON",value:function(t,n){var a=this,o=n.targetSchema,s=n.schemaName||qr,u=new o;if(Ut(u))return u.fromJSON(t);var c=Ge.get(o),l=this.getSchemaByName(c,s),f={};n.strictProperty&&!Array.isArray(t)&&r.checkStrictProperty(t,l,c);var d=function(){try{var E=l[v],x=E.name||v,N=t[x];if(N===void 0&&(E.optional||E.defaultValue!==void 0))return 1;if(!E.optional&&N===void 0)throw new Nt(c,"Property '".concat(x,"' is required."));if(a.checkTypes(N,E),a.checkValues(N,E),typeof E.type=="number")E.converter?E.repeated?u[v]=N.map(function(G){return E.converter.fromJSON(G,u)}):u[v]=E.converter.fromJSON(N,u):u[v]=N;else{var $=O(O({},n),{},{targetSchema:E.type,schemaName:s});E.repeated?u[v]=N.map(function(G){return a.fromJSON(G,$)}):u[v]=a.fromJSON(N,$)}}catch(G){if(G instanceof Nt||(G=new Nt(c,"Property '".concat(v,"' is wrong. ").concat(G.message),G)),n.strictAllKeys)f[v]=G;else throw G}};for(var v in l)d();var y=Object.keys(f);if(y.length)throw new Xi(c,y,f);return u}},{key:"checkStrictProperty",value:function(t,n,a){for(var o=Object.keys(t),s=Object.keys(n),u=[],c=0,l=o;c<l.length;c++){var f=l[c];s.indexOf(f)===-1&&u.push(f)}if(u.length)throw new Xi(a,u)}}]),r})(Zi);function ou(i){var r=[];return i.pattern&&r.push(new tu(i.pattern)),(i.type===ye.Number||i.type===ye.Any)&&((i.minInclusive!==void 0||i.maxInclusive!==void 0)&&r.push(new nu(i.minInclusive,i.maxInclusive)),(i.minExclusive!==void 0||i.maxExclusive!==void 0)&&r.push(new iu(i.minExclusive,i.maxExclusive)),i.enumeration!==void 0&&r.push(new au(i.enumeration))),(i.type===ye.String||i.repeated||i.type===ye.Any)&&(i.length!==void 0||i.minLength!==void 0||i.maxLength!==void 0)&&r.push(new Yi(i.length,i.minLength,i.maxLength)),r}var Be=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return function(e,t){var n="Cannot set type for ".concat(t," property of ").concat(e.constructor.name," schema"),a;Ge.has(e.constructor)?(a=Ge.get(e.constructor),a.target!==e.constructor&&(a=Ge.create(e.constructor),Ge.set(e.constructor,a))):(a=Ge.create(e.constructor),Ge.set(e.constructor,a));var o={type:ye.Any,validations:[]},s=Object.assign(o,r);if(s.validations=ou(s),typeof s.type!="number"&&!Ge.has(s.type)&&!Ut(s.type))throw new Error("".concat(n,". Assigning type doesn't have schema."));var u;Array.isArray(r.schema)?u=r.schema:u=[r.schema||qr];var c=he(u),l;try{for(c.s();!(l=c.n()).done;){var f=l.value;a.names[f]||(a.names[f]={});var d=a.names[f];d[t]=s}}catch(v){c.e(v)}finally{c.f()}}},He=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r)})(ut(Error)),Yr=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r)})(He),sr=(function(i){b(r,i);function r(e){return g(this,r),k(this,r,["Unsupported operation: ".concat(e?"".concat(e):"")])}return m(r)})(He),X=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r)})(He),uu=(function(i){b(r,i);function r(e){return g(this,r),k(this,r,["".concat(e,": Missing required property")])}return m(r)})(He);function pn(i){return oe(i)==="object"&&"kty"in i}var De=(function(){function i(){g(this,i)}return m(i,[{key:"digest",value:(function(){var r=re(h().mark(function t(){var n,a,o,s=arguments;return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:for(n=s.length,a=new Array(n),o=0;o<n;o++)a[o]=s[o];return this.checkDigest.apply(this,a),c.abrupt("return",this.onDigest.apply(this,a));case 3:case"end":return c.stop()}},t,this)}));function e(){return r.apply(this,arguments)}return e})()},{key:"checkDigest",value:function(e,t){this.checkAlgorithmName(e)}},{key:"onDigest",value:(function(){var r=re(h().mark(function t(n,a){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:throw new sr("digest");case 1:case"end":return s.stop()}},t)}));function e(t,n){return r.apply(this,arguments)}return e})()},{key:"generateKey",value:(function(){var r=re(h().mark(function t(){var n,a,o,s=arguments;return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:for(n=s.length,a=new Array(n),o=0;o<n;o++)a[o]=s[o];return this.checkGenerateKey.apply(this,a),c.abrupt("return",this.onGenerateKey.apply(this,a));case 3:case"end":return c.stop()}},t,this)}));function e(){return r.apply(this,arguments)}return e})()},{key:"checkGenerateKey",value:function(e,t,n){if(this.checkAlgorithmName(e),this.checkGenerateKeyParams(e),!(n&&n.length))throw new TypeError("Usages cannot be empty when creating a key.");var a;Array.isArray(this.usages)?a=this.usages:a=this.usages.privateKey.concat(this.usages.publicKey),this.checkKeyUsages(n,a)}},{key:"checkGenerateKeyParams",value:function(e){}},{key:"onGenerateKey",value:(function(){var r=re(h().mark(function t(n,a,o){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:throw new sr("generateKey");case 1:case"end":return u.stop()}},t)}));function e(t,n,a){return r.apply(this,arguments)}return e})()},{key:"sign",value:(function(){var r=re(h().mark(function t(){var n,a,o,s=arguments;return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:for(n=s.length,a=new Array(n),o=0;o<n;o++)a[o]=s[o];return this.checkSign.apply(this,a),c.abrupt("return",this.onSign.apply(this,a));case 3:case"end":return c.stop()}},t,this)}));function e(){return r.apply(this,arguments)}return e})()},{key:"checkSign",value:function(e,t,n){this.checkAlgorithmName(e),this.checkAlgorithmParams(e),this.checkCryptoKey(t,"sign")}},{key:"onSign",value:(function(){var r=re(h().mark(function t(n,a,o){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:throw new sr("sign");case 1:case"end":return u.stop()}},t)}));function e(t,n,a){return r.apply(this,arguments)}return e})()},{key:"verify",value:(function(){var r=re(h().mark(function t(){var n,a,o,s=arguments;return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:for(n=s.length,a=new Array(n),o=0;o<n;o++)a[o]=s[o];return this.checkVerify.apply(this,a),c.abrupt("return",this.onVerify.apply(this,a));case 3:case"end":return c.stop()}},t,this)}));function e(){return r.apply(this,arguments)}return e})()},{key:"checkVerify",value:function(e,t,n,a){this.checkAlgorithmName(e),this.checkAlgorithmParams(e),this.checkCryptoKey(t,"verify")}},{key:"onVerify",value:(function(){var r=re(h().mark(function t(n,a,o,s){return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:throw new sr("verify");case 1:case"end":return c.stop()}},t)}));function e(t,n,a,o){return r.apply(this,arguments)}return e})()},{key:"encrypt",value:(function(){var r=re(h().mark(function t(){var n,a,o,s=arguments;return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:for(n=s.length,a=new Array(n),o=0;o<n;o++)a[o]=s[o];return this.checkEncrypt.apply(this,a),c.abrupt("return",this.onEncrypt.apply(this,a));case 3:case"end":return c.stop()}},t,this)}));function e(){return r.apply(this,arguments)}return e})()},{key:"checkEncrypt",value:function(e,t,n){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};this.checkAlgorithmName(e),this.checkAlgorithmParams(e),this.checkCryptoKey(t,a.keyUsage?"encrypt":void 0)}},{key:"onEncrypt",value:(function(){var r=re(h().mark(function t(n,a,o){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:throw new sr("encrypt");case 1:case"end":return u.stop()}},t)}));function e(t,n,a){return r.apply(this,arguments)}return e})()},{key:"decrypt",value:(function(){var r=re(h().mark(function t(){var n,a,o,s=arguments;return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:for(n=s.length,a=new Array(n),o=0;o<n;o++)a[o]=s[o];return this.checkDecrypt.apply(this,a),c.abrupt("return",this.onDecrypt.apply(this,a));case 3:case"end":return c.stop()}},t,this)}));function e(){return r.apply(this,arguments)}return e})()},{key:"checkDecrypt",value:function(e,t,n){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};this.checkAlgorithmName(e),this.checkAlgorithmParams(e),this.checkCryptoKey(t,a.keyUsage?"decrypt":void 0)}},{key:"onDecrypt",value:(function(){var r=re(h().mark(function t(n,a,o){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:throw new sr("decrypt");case 1:case"end":return u.stop()}},t)}));function e(t,n,a){return r.apply(this,arguments)}return e})()},{key:"deriveBits",value:(function(){var r=re(h().mark(function t(){var n,a,o,s=arguments;return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:for(n=s.length,a=new Array(n),o=0;o<n;o++)a[o]=s[o];return this.checkDeriveBits.apply(this,a),c.abrupt("return",this.onDeriveBits.apply(this,a));case 3:case"end":return c.stop()}},t,this)}));function e(){return r.apply(this,arguments)}return e})()},{key:"checkDeriveBits",value:function(e,t,n){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};if(this.checkAlgorithmName(e),this.checkAlgorithmParams(e),this.checkCryptoKey(t,a.keyUsage?"deriveBits":void 0),n%8!==0)throw new X("length: Is not multiple of 8")}},{key:"onDeriveBits",value:(function(){var r=re(h().mark(function t(n,a,o){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:throw new sr("deriveBits");case 1:case"end":return u.stop()}},t)}));function e(t,n,a){return r.apply(this,arguments)}return e})()},{key:"exportKey",value:(function(){var r=re(h().mark(function t(){var n,a,o,s=arguments;return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:for(n=s.length,a=new Array(n),o=0;o<n;o++)a[o]=s[o];return this.checkExportKey.apply(this,a),c.abrupt("return",this.onExportKey.apply(this,a));case 3:case"end":return c.stop()}},t,this)}));function e(){return r.apply(this,arguments)}return e})()},{key:"checkExportKey",value:function(e,t){if(this.checkKeyFormat(e),this.checkCryptoKey(t),!t.extractable)throw new He("key: Is not extractable")}},{key:"onExportKey",value:(function(){var r=re(h().mark(function t(n,a){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:throw new sr("exportKey");case 1:case"end":return s.stop()}},t)}));function e(t,n){return r.apply(this,arguments)}return e})()},{key:"importKey",value:(function(){var r=re(h().mark(function t(){var n,a,o,s=arguments;return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:for(n=s.length,a=new Array(n),o=0;o<n;o++)a[o]=s[o];return this.checkImportKey.apply(this,a),c.abrupt("return",this.onImportKey.apply(this,a));case 3:case"end":return c.stop()}},t,this)}));function e(){return r.apply(this,arguments)}return e})()},{key:"checkImportKey",value:function(e,t,n,a,o){this.checkKeyFormat(e),this.checkKeyData(e,t),this.checkAlgorithmName(n),this.checkImportParams(n),Array.isArray(this.usages)&&this.checkKeyUsages(o,this.usages)}},{key:"onImportKey",value:(function(){var r=re(h().mark(function t(n,a,o,s,u){return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:throw new sr("importKey");case 1:case"end":return l.stop()}},t)}));function e(t,n,a,o,s){return r.apply(this,arguments)}return e})()},{key:"checkAlgorithmName",value:function(e){if(e.name.toLowerCase()!==this.name.toLowerCase())throw new Yr("Unrecognized name")}},{key:"checkAlgorithmParams",value:function(e){}},{key:"checkDerivedKeyParams",value:function(e){}},{key:"checkKeyUsages",value:function(e,t){var n=he(e),a;try{for(n.s();!(a=n.n()).done;){var o=a.value;if(t.indexOf(o)===-1)throw new TypeError("Cannot create a key using the specified key usages")}}catch(s){n.e(s)}finally{n.f()}}},{key:"checkCryptoKey",value:function(e,t){if(this.checkAlgorithmName(e.algorithm),t&&e.usages.indexOf(t)===-1)throw new He("key does not match that of operation")}},{key:"checkRequiredProperty",value:function(e,t){if(!(t in e))throw new uu(t)}},{key:"checkHashAlgorithm",value:function(e,t){var n=he(t),a;try{for(n.s();!(a=n.n()).done;){var o=a.value;if(o.toLowerCase()===e.name.toLowerCase())return}}catch(s){n.e(s)}finally{n.f()}throw new X("hash: Must be one of ".concat(t.join(", ")))}},{key:"checkImportParams",value:function(e){}},{key:"checkKeyFormat",value:function(e){switch(e){case"raw":case"pkcs8":case"spki":case"jwk":break;default:throw new TypeError("format: Is invalid value. Must be 'jwk', 'raw', 'spki', or 'pkcs8'")}}},{key:"checkKeyData",value:function(e,t){if(!t)throw new TypeError("keyData: Cannot be empty on empty on key importing");if(e==="jwk"){if(!pn(t))throw new TypeError("keyData: Is not JsonWebToken")}else if(!K.isBufferSource(t))throw new TypeError("keyData: Is not ArrayBufferView or ArrayBuffer")}},{key:"prepareData",value:function(e){return K.toArrayBuffer(e)}}]),i})(),Zr=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"checkGenerateKeyParams",value:function(t){if(this.checkRequiredProperty(t,"length"),typeof t.length!="number")throw new TypeError("length: Is not of type Number");switch(t.length){case 128:case 192:case 256:break;default:throw new TypeError("length: Must be 128, 192, or 256")}}},{key:"checkDerivedKeyParams",value:function(t){this.checkGenerateKeyParams(t)}}]),r})(De),su=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="AES-CBC",e.usages=["encrypt","decrypt","wrapKey","unwrapKey"],e}return m(r,[{key:"checkAlgorithmParams",value:function(t){if(this.checkRequiredProperty(t,"iv"),!(t.iv instanceof ArrayBuffer||ArrayBuffer.isView(t.iv)))throw new TypeError("iv: Is not of type '(ArrayBuffer or ArrayBufferView)'");if(t.iv.byteLength!==16)throw new TypeError("iv: Must have length 16 bytes")}}]),r})(Zr),cu=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="AES-CTR",e.usages=["encrypt","decrypt","wrapKey","unwrapKey"],e}return m(r,[{key:"checkAlgorithmParams",value:function(t){if(this.checkRequiredProperty(t,"counter"),!(t.counter instanceof ArrayBuffer||ArrayBuffer.isView(t.counter)))throw new TypeError("counter: Is not of type '(ArrayBuffer or ArrayBufferView)'");if(t.counter.byteLength!==16)throw new TypeError("iv: Must have length 16 bytes");if(this.checkRequiredProperty(t,"length"),typeof t.length!="number")throw new TypeError("length: Is not a Number");if(t.length<1)throw new X("length: Must be more than 0")}}]),r})(Zr),lu=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="AES-ECB",e.usages=["encrypt","decrypt","wrapKey","unwrapKey"],e}return m(r)})(Zr),fu=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="AES-GCM",e.usages=["encrypt","decrypt","wrapKey","unwrapKey"],e}return m(r,[{key:"checkAlgorithmParams",value:function(t){if(this.checkRequiredProperty(t,"iv"),!(t.iv instanceof ArrayBuffer||ArrayBuffer.isView(t.iv)))throw new TypeError("iv: Is not of type '(ArrayBuffer or ArrayBufferView)'");if(t.iv.byteLength<1)throw new X("iv: Must have length more than 0 and less than 2^64 - 1");switch("tagLength"in t||(t.tagLength=128),t.tagLength){case 32:case 64:case 96:case 104:case 112:case 120:case 128:break;default:throw new X("tagLength: Must be one of 32, 64, 96, 104, 112, 120 or 128")}}}]),r})(Zr),hu=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="AES-KW",e.usages=["wrapKey","unwrapKey"],e}return m(r)})(Zr),Qi=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.usages=["encrypt","decrypt","wrapKey","unwrapKey"],e}return m(r,[{key:"checkAlgorithmParams",value:function(t){if(this.ivSize){if(this.checkRequiredProperty(t,"iv"),!(t.iv instanceof ArrayBuffer||ArrayBuffer.isView(t.iv)))throw new TypeError("iv: Is not of type '(ArrayBuffer or ArrayBufferView)'");if(t.iv.byteLength!==this.ivSize)throw new TypeError("iv: Must have length ".concat(this.ivSize," bytes"))}}},{key:"checkGenerateKeyParams",value:function(t){if(this.checkRequiredProperty(t,"length"),typeof t.length!="number")throw new TypeError("length: Is not of type Number");if(t.length!==this.keySizeBits)throw new X("algorithm.length: Must be ".concat(this.keySizeBits))}},{key:"checkDerivedKeyParams",value:function(t){this.checkGenerateKeyParams(t)}}]),r})(De),yn=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512"],e}return m(r,[{key:"checkGenerateKeyParams",value:function(t){if(this.checkRequiredProperty(t,"hash"),this.checkHashAlgorithm(t.hash,this.hashAlgorithms),this.checkRequiredProperty(t,"publicExponent"),!(t.publicExponent&&t.publicExponent instanceof Uint8Array))throw new TypeError("publicExponent: Missing or not a Uint8Array");var n=L.ToBase64(t.publicExponent);if(!(n==="Aw=="||n==="AQAB"))throw new TypeError("publicExponent: Must be [3] or [1,0,1]");if(this.checkRequiredProperty(t,"modulusLength"),t.modulusLength%8||t.modulusLength<256||t.modulusLength>16384)throw new TypeError("The modulus length must be a multiple of 8 bits and >= 256 and <= 16384")}},{key:"checkImportParams",value:function(t){this.checkRequiredProperty(t,"hash"),this.checkHashAlgorithm(t.hash,this.hashAlgorithms)}}]),r})(De),vu=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="RSASSA-PKCS1-v1_5",e.usages={privateKey:["sign"],publicKey:["verify"]},e}return m(r)})(yn),pu=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="RSA-PSS",e.usages={privateKey:["sign"],publicKey:["verify"]},e}return m(r,[{key:"checkAlgorithmParams",value:function(t){if(this.checkRequiredProperty(t,"saltLength"),typeof t.saltLength!="number")throw new TypeError("saltLength: Is not a Number");if(t.saltLength<0)throw new RangeError("saltLength: Must be positive number")}}]),r})(yn),yu=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="RSA-OAEP",e.usages={privateKey:["decrypt","unwrapKey"],publicKey:["encrypt","wrapKey"]},e}return m(r,[{key:"checkAlgorithmParams",value:function(t){if(t.label&&!(t.label instanceof ArrayBuffer||ArrayBuffer.isView(t.label)))throw new TypeError("label: Is not of type '(ArrayBuffer or ArrayBufferView)'")}}]),r})(yn),dn=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"checkGenerateKeyParams",value:function(t){this.checkRequiredProperty(t,"namedCurve"),this.checkNamedCurve(t.namedCurve)}},{key:"checkNamedCurve",value:function(t){var n=he(this.namedCurves),a;try{for(n.s();!(a=n.n()).done;){var o=a.value;if(o.toLowerCase()===t.toLowerCase())return}}catch(s){n.e(s)}finally{n.f()}throw new X("namedCurve: Must be one of ".concat(this.namedCurves.join(", ")))}}]),r})(De),du=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="ECDSA",e.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512"],e.usages={privateKey:["sign"],publicKey:["verify"]},e.namedCurves=["P-256","P-384","P-521","K-256"],e}return m(r,[{key:"checkAlgorithmParams",value:function(t){this.checkRequiredProperty(t,"hash"),this.checkHashAlgorithm(t.hash,this.hashAlgorithms)}}]),r})(dn),gu=["secret","private","public"],gn=(function(i){function r(){g(this,r)}return m(r,[{key:i,get:function(){return"CryptoKey"}}],[{key:"create",value:function(t,n,a,o){var s=new this;return s.algorithm=t,s.type=n,s.extractable=a,s.usages=o,s}},{key:"isKeyType",value:function(t){return gu.indexOf(t)!==-1}}]),r})(Symbol.toStringTag),ea=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="ECDH",e.usages={privateKey:["deriveBits","deriveKey"],publicKey:[]},e.namedCurves=["P-256","P-384","P-521","K-256"],e}return m(r,[{key:"checkAlgorithmParams",value:function(t){if(this.checkRequiredProperty(t,"public"),!(t.public instanceof gn))throw new TypeError("public: Is not a CryptoKey");if(t.public.type!=="public")throw new X("public: Is not a public key");if(t.public.algorithm.name!==this.name)throw new X("public: Is not ".concat(this.name," key"))}}]),r})(dn),mu=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="ECDH-ES",e.namedCurves=["X25519","X448"],e}return m(r)})(ea),wu=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="EdDSA",e.usages={privateKey:["sign"],publicKey:["verify"]},e.namedCurves=["Ed25519","Ed448"],e}return m(r)})(dn),Qr=m(function i(r){g(this,i),r&&(this.value=r)});W([ee({type:T.ObjectIdentifier})],Qr.prototype,"value",void 0),Qr=W([Wr({type:Ee.Choice})],Qr);var Nr=m(function i(r){g(this,i),Object.assign(this,r)});W([ee({type:T.ObjectIdentifier})],Nr.prototype,"algorithm",void 0),W([ee({type:T.Any,optional:!0})],Nr.prototype,"parameters",void 0);var Hr=m(function i(){g(this,i),this.version=0,this.privateKeyAlgorithm=new Nr,this.privateKey=new ArrayBuffer(0)});W([ee({type:T.Integer})],Hr.prototype,"version",void 0),W([ee({type:Nr})],Hr.prototype,"privateKeyAlgorithm",void 0),W([ee({type:T.OctetString})],Hr.prototype,"privateKey",void 0),W([ee({type:T.Any,optional:!0})],Hr.prototype,"attributes",void 0);var mn=m(function i(){g(this,i),this.publicKeyAlgorithm=new Nr,this.publicKey=new ArrayBuffer(0)});W([ee({type:Nr})],mn.prototype,"publicKeyAlgorithm",void 0),W([ee({type:T.BitString})],mn.prototype,"publicKey",void 0);var ze={fromJSON:function(r){return L.FromBase64Url(r)},toJSON:function(r){return L.ToBase64Url(new Uint8Array(r))}},Ye={fromASN:function(r){var e=r.valueBlock.valueHex;return new Uint8Array(e)[0]?r.valueBlock.valueHex:r.valueBlock.valueHex.slice(1)},toASN:function(r){var e=new Uint8Array(r)[0]>127?wr(new Uint8Array([0]).buffer,r):r;return new pr({valueHex:e})}},We=m(function i(){g(this,i),this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0)});W([ee({type:T.Integer,converter:fn})],We.prototype,"version",void 0),W([ee({type:T.Integer,converter:Ye}),Be({name:"n",converter:ze})],We.prototype,"modulus",void 0),W([ee({type:T.Integer,converter:Ye}),Be({name:"e",converter:ze})],We.prototype,"publicExponent",void 0),W([ee({type:T.Integer,converter:Ye}),Be({name:"d",converter:ze})],We.prototype,"privateExponent",void 0),W([ee({type:T.Integer,converter:Ye}),Be({name:"p",converter:ze})],We.prototype,"prime1",void 0),W([ee({type:T.Integer,converter:Ye}),Be({name:"q",converter:ze})],We.prototype,"prime2",void 0),W([ee({type:T.Integer,converter:Ye}),Be({name:"dp",converter:ze})],We.prototype,"exponent1",void 0),W([ee({type:T.Integer,converter:Ye}),Be({name:"dq",converter:ze})],We.prototype,"exponent2",void 0),W([ee({type:T.Integer,converter:Ye}),Be({name:"qi",converter:ze})],We.prototype,"coefficient",void 0),W([ee({type:T.Any,optional:!0})],We.prototype,"otherPrimeInfos",void 0);var wn=m(function i(){g(this,i),this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0)});W([ee({type:T.Integer,converter:Ye}),Be({name:"n",converter:ze})],wn.prototype,"modulus",void 0),W([ee({type:T.Integer,converter:Ye}),Be({name:"e",converter:ze})],wn.prototype,"publicExponent",void 0);var Dr=(function(){function i(r){g(this,i),this.value=new ArrayBuffer(0),r&&(this.value=r)}return m(i,[{key:"toJSON",value:function(){var e=new Uint8Array(this.value);if(e[0]!==4)throw new He("Wrong ECPoint. Current version supports only Uncompressed (0x04) point");e=new Uint8Array(this.value.slice(1));var t=e.length/2,n=0,a={x:L.ToBase64Url(e.buffer.slice(n,n+t)),y:L.ToBase64Url(e.buffer.slice(n+t,n+t+t))};return a}},{key:"fromJSON",value:function(e){if(!("x"in e))throw new Error("x: Missing required property");if(!("y"in e))throw new Error("y: Missing required property");var t=L.FromBase64Url(e.x),n=L.FromBase64Url(e.y),a=wr(new Uint8Array([4]).buffer,t,n);return this.value=new Uint8Array(a).buffer,this}}]),i})();W([ee({type:T.OctetString})],Dr.prototype,"value",void 0),Dr=W([Wr({type:Ee.Choice})],Dr);var et=(function(){function i(){g(this,i),this.version=1,this.privateKey=new ArrayBuffer(0)}return m(i,[{key:"fromJSON",value:function(e){if(!("d"in e))throw new Error("d: Missing required property");if(this.privateKey=L.FromBase64Url(e.d),"x"in e){var t=new Dr;t.fromJSON(e);var n=qi.toASN(t);"valueHex"in n.valueBlock&&(this.publicKey=n.valueBlock.valueHex)}return this}},{key:"toJSON",value:function(){var e={};return e.d=L.ToBase64Url(this.privateKey),this.publicKey&&Object.assign(e,new Dr(this.publicKey).toJSON()),e}}]),i})();W([ee({type:T.Integer,converter:fn})],et.prototype,"version",void 0),W([ee({type:T.OctetString})],et.prototype,"privateKey",void 0),W([ee({context:0,type:T.Any,optional:!0})],et.prototype,"parameters",void 0),W([ee({context:1,type:T.BitString,optional:!0})],et.prototype,"publicKey",void 0);var kn={fromASN:function(r){var e=new Uint8Array(r.valueBlock.valueHex);return e[0]===0?e.buffer.slice(1):e.buffer},toASN:function(r){var e=new Uint8Array(r);if(e[0]>127){var t=new Uint8Array(e.length+1);return t.set(e,1),new pr({valueHex:t.buffer})}return new pr({valueHex:r})}},ku=Object.freeze({__proto__:null,AsnIntegerWithoutPaddingConverter:kn}),ra=(function(){function i(){g(this,i)}return m(i,null,[{key:"decodePoint",value:function(e,t){var n=K.toUint8Array(e);if(n.length===0||n[0]!==4)throw new Error("Only uncompressed point format supported");var a=(n.length-1)/2;if(a!==Math.ceil(t/8))throw new Error("Point does not match field size");var o=n.slice(1,a+1),s=n.slice(a+1,a+1+a);return{x:o,y:s}}},{key:"encodePoint",value:function(e,t){var n=Math.ceil(t/8);if(e.x.byteLength!==n||e.y.byteLength!==n)throw new Error("X,Y coordinates don't match point size criteria");var a=K.toUint8Array(e.x),o=K.toUint8Array(e.y),s=new Uint8Array(n*2+1);return s[0]=4,s.set(a,1),s.set(o,n+1),s}},{key:"getSize",value:function(e){return Math.ceil(e/8)}},{key:"encodeSignature",value:function(e,t){var n=this.getSize(t),a=K.toUint8Array(e.r),o=K.toUint8Array(e.s),s=new Uint8Array(n*2);return s.set(this.padStart(a,n)),s.set(this.padStart(o,n),n),s}},{key:"decodeSignature",value:function(e,t){var n=this.getSize(t),a=K.toUint8Array(e);if(a.length!==n*2)throw new Error("Incorrect size of the signature");var o=a.slice(0,n),s=a.slice(n);return{r:this.trimStart(o),s:this.trimStart(s)}}},{key:"trimStart",value:function(e){for(var t=0;t<e.length-1&&e[t]===0;)t++;return t===0?e:e.slice(t,e.length)}},{key:"padStart",value:function(e,t){if(t===e.length)return e;var n=new Uint8Array(t);return n.set(e,t-e.length),n}}]),i})(),bn=(function(){function i(){g(this,i),this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0)}return m(i,[{key:"toWebCryptoSignature",value:function(e){e??(e=Math.max(this.r.byteLength,this.s.byteLength)*8);var t=ra.encodeSignature(this,e);return t.buffer}}],[{key:"fromWebCryptoSignature",value:function(e){var t=e.byteLength/2,n=ra.decodeSignature(e,t*8),a=new i;return a.r=K.toArrayBuffer(n.r),a.s=K.toArrayBuffer(n.s),a}}]),i})();W([ee({type:T.Integer,converter:kn})],bn.prototype,"r",void 0),W([ee({type:T.Integer,converter:kn})],bn.prototype,"s",void 0);var ta=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r)})(Hr);W([ee({context:1,implicit:!0,type:T.BitString,optional:!0})],ta.prototype,"publicKey",void 0);var Ot=(function(){function i(){g(this,i),this.value=new ArrayBuffer(0)}return m(i,[{key:"fromJSON",value:function(e){if(!e.d)throw new Error("d: Missing required property");return this.value=L.FromBase64Url(e.d),this}},{key:"toJSON",value:function(){var e={d:L.ToBase64Url(this.value)};return e}}]),i})();W([ee({type:T.OctetString})],Ot.prototype,"value",void 0),Ot=W([Wr({type:Ee.Choice})],Ot);var It=(function(){function i(r){g(this,i),this.value=new ArrayBuffer(0),r&&(this.value=r)}return m(i,[{key:"toJSON",value:function(){var e={x:L.ToBase64Url(this.value)};return e}},{key:"fromJSON",value:function(e){if(!("x"in e))throw new Error("x: Missing required property");return this.value=L.FromBase64Url(e.x),this}}]),i})();W([ee({type:T.BitString})],It.prototype,"value",void 0),It=W([Wr({type:Ee.Choice})],It);var Lt=m(function i(){g(this,i)});W([ee({type:T.OctetString}),Be({type:ye.String,converter:ze})],Lt.prototype,"d",void 0),Lt=W([Wr({type:Ee.Choice})],Lt);var na="1.2.840.10045.3.1.7",xt="1.3.132.0",ia="".concat(xt,".34"),aa="".concat(xt,".35"),oa="".concat(xt,".10"),Ne="1.3.36.3.3.2.8.1.1",ua="".concat(Ne,".1"),sa="".concat(Ne,".2"),ca="".concat(Ne,".3"),la="".concat(Ne,".4"),fa="".concat(Ne,".5"),ha="".concat(Ne,".6"),va="".concat(Ne,".7"),pa="".concat(Ne,".8"),ya="".concat(Ne,".9"),da="".concat(Ne,".10"),ga="".concat(Ne,".11"),ma="".concat(Ne,".12"),wa="".concat(Ne,".13"),ka="".concat(Ne,".14"),bu="1.3.101.110",Au="1.3.101.111",Su="1.3.101.112",Eu="1.3.101.113",J=Object.freeze({__proto__:null,AlgorithmIdentifier:Nr,get CurvePrivateKey(){return Lt},EcDsaSignature:bn,EcPrivateKey:et,get EcPublicKey(){return Dr},get EdPrivateKey(){return Ot},get EdPublicKey(){return It},get ObjectIdentifier(){return Qr},OneAsymmetricKey:ta,PrivateKeyInfo:Hr,PublicKeyInfo:mn,RsaPrivateKey:We,RsaPublicKey:wn,converters:ku,idBrainpoolP160r1:ua,idBrainpoolP160t1:sa,idBrainpoolP192r1:ca,idBrainpoolP192t1:la,idBrainpoolP224r1:fa,idBrainpoolP224t1:ha,idBrainpoolP256r1:va,idBrainpoolP256t1:pa,idBrainpoolP320r1:ya,idBrainpoolP320t1:da,idBrainpoolP384r1:ga,idBrainpoolP384t1:ma,idBrainpoolP512r1:wa,idBrainpoolP512t1:ka,idEd25519:Su,idEd448:Eu,idEllipticCurve:xt,idSecp256k1:oa,idSecp256r1:na,idSecp384r1:ia,idSecp521r1:aa,idVersionOne:Ne,idX25519:bu,idX448:Au}),ve=(function(){function i(){g(this,i)}return m(i,null,[{key:"register",value:function(e){var t=new Qr;t.value=e.id;var n=te.serialize(t);this.items.push(O(O({},e),{},{raw:n})),this.names.push(e.name)}},{key:"find",value:function(e){e=e.toUpperCase();var t=he(this.items),n;try{for(t.s();!(n=t.n()).done;){var a=n.value;if(a.name.toUpperCase()===e||a.id.toUpperCase()===e)return a}}catch(o){t.e(o)}finally{t.f()}return null}},{key:"get",value:function(e){var t=this.find(e);if(!t)throw new Error("Unsupported EC named curve '".concat(e,"'"));return t}}]),i})();ve.items=[],ve.names=[],ve.register({name:"P-256",id:na,size:256}),ve.register({name:"P-384",id:ia,size:384}),ve.register({name:"P-521",id:aa,size:521}),ve.register({name:"K-256",id:oa,size:256}),ve.register({name:"brainpoolP160r1",id:ua,size:160}),ve.register({name:"brainpoolP160t1",id:sa,size:160}),ve.register({name:"brainpoolP192r1",id:ca,size:192}),ve.register({name:"brainpoolP192t1",id:la,size:192}),ve.register({name:"brainpoolP224r1",id:fa,size:224}),ve.register({name:"brainpoolP224t1",id:ha,size:224}),ve.register({name:"brainpoolP256r1",id:va,size:256}),ve.register({name:"brainpoolP256t1",id:pa,size:256}),ve.register({name:"brainpoolP320r1",id:ya,size:320}),ve.register({name:"brainpoolP320t1",id:da,size:320}),ve.register({name:"brainpoolP384r1",id:ga,size:384}),ve.register({name:"brainpoolP384t1",id:ma,size:384}),ve.register({name:"brainpoolP512r1",id:wa,size:512}),ve.register({name:"brainpoolP512t1",id:ka,size:512});var Bu=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="HMAC",e.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512"],e.usages=["sign","verify"],e}return m(r,[{key:"getDefaultLength",value:function(t){switch(t.toUpperCase()){case"SHA-1":case"SHA-256":case"SHA-384":case"SHA-512":return 512;default:throw new Error("Unknown algorithm name '".concat(t,"'"))}}},{key:"checkGenerateKeyParams",value:function(t){if(this.checkRequiredProperty(t,"hash"),this.checkHashAlgorithm(t.hash,this.hashAlgorithms),"length"in t){if(typeof t.length!="number")throw new TypeError("length: Is not a Number");if(t.length<1)throw new RangeError("length: Number is out of range")}}},{key:"checkImportParams",value:function(t){this.checkRequiredProperty(t,"hash"),this.checkHashAlgorithm(t.hash,this.hashAlgorithms)}}]),r})(De),Ku=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="PBKDF2",e.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512"],e.usages=["deriveBits","deriveKey"],e}return m(r,[{key:"checkAlgorithmParams",value:function(t){if(this.checkRequiredProperty(t,"hash"),this.checkHashAlgorithm(t.hash,this.hashAlgorithms),this.checkRequiredProperty(t,"salt"),!(t.salt instanceof ArrayBuffer||ArrayBuffer.isView(t.salt)))throw new TypeError("salt: Is not of type '(ArrayBuffer or ArrayBufferView)'");if(this.checkRequiredProperty(t,"iterations"),typeof t.iterations!="number")throw new TypeError("iterations: Is not a Number");if(t.iterations<1)throw new TypeError("iterations: Is less than 1")}},{key:"checkImportKey",value:function(t,n,a,o,s){for(var u,c=arguments.length,l=new Array(c>5?c-5:0),f=5;f<c;f++)l[f-5]=arguments[f];if((u=j(M(r.prototype),"checkImportKey",this)).call.apply(u,[this,t,n,a,o,s].concat(l)),o)throw new SyntaxError("extractable: Must be 'false'")}}]),r})(De),ba=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.usages=[],e.defaultLength=0,e}return m(r,[{key:"digest",value:function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return n[0]=O({length:this.defaultLength},n[0]),j(M(r.prototype),"digest",this).apply(this,n)}},{key:"checkDigest",value:function(t,n){j(M(r.prototype),"checkDigest",this).call(this,t,n);var a=t.length||0;if(typeof a!="number")throw new TypeError("length: Is not a Number");if(a<0)throw new TypeError("length: Is negative")}}]),r})(De),Cu=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="shake128",e.defaultLength=16,e}return m(r)})(ba),Nu=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="shake256",e.defaultLength=32,e}return m(r)})(ba),Pu=(function(i){function r(){g(this,r)}return m(r,[{key:i,get:function(){return"Crypto"}},{key:"randomUUID",value:function(){var t=this.getRandomValues(new Uint8Array(16));t[6]=t[6]&15|64,t[8]=t[8]&63|128;var n=L.ToHex(t).toLowerCase();return"".concat(n.substring(0,8),"-").concat(n.substring(8,12),"-").concat(n.substring(12,16),"-").concat(n.substring(16,20),"-").concat(n.substring(20))}}]),r})(Symbol.toStringTag),Uu=(function(){function i(){g(this,i),this.items={}}return m(i,[{key:"get",value:function(e){return this.items[e.toLowerCase()]||null}},{key:"set",value:function(e){this.items[e.name.toLowerCase()]=e}},{key:"removeAt",value:function(e){var t=this.get(e.toLowerCase());return t&&delete this.items[e],t}},{key:"has",value:function(e){return!!this.get(e)}},{key:"length",get:function(){return Object.keys(this.items).length}},{key:"algorithms",get:function(){var e=[];for(var t in this.items){var n=this.items[t];e.push(n.name)}return e.sort()}}]),i})(),Aa=(function(i){function r(){g(this,r),this.providers=new Uu}return m(r,[{key:i,get:function(){return"SubtleCrypto"}},{key:"digest",value:(function(){var e=re(h().mark(function n(){var a,o,s,u,c,l,f,d,v,y,S=arguments;return h().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:for(a=S.length,o=new Array(a),s=0;s<a;s++)o[s]=S[s];return this.checkRequiredArguments(o,2,"digest"),u=o[0],c=o[1],l=o.slice(2),f=this.prepareAlgorithm(u),d=K.toArrayBuffer(c),v=this.getProvider(f.name),x.next=8,v.digest.apply(v,[f,d].concat(xe(l)));case 8:return y=x.sent,x.abrupt("return",y);case 10:case"end":return x.stop()}},n,this)}));function t(){return e.apply(this,arguments)}return t})()},{key:"generateKey",value:(function(){var e=re(h().mark(function n(){var a,o,s,u,c,l,f,d,v,y,S=arguments;return h().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:for(a=S.length,o=new Array(a),s=0;s<a;s++)o[s]=S[s];return this.checkRequiredArguments(o,3,"generateKey"),u=o[0],c=o[1],l=o[2],f=o.slice(3),d=this.prepareAlgorithm(u),v=this.getProvider(d.name),x.next=7,v.generateKey.apply(v,[O(O({},d),{},{name:v.name}),c,l].concat(xe(f)));case 7:return y=x.sent,x.abrupt("return",y);case 9:case"end":return x.stop()}},n,this)}));function t(){return e.apply(this,arguments)}return t})()},{key:"sign",value:(function(){var e=re(h().mark(function n(){var a,o,s,u,c,l,f,d,v,y,S,E=arguments;return h().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:for(a=E.length,o=new Array(a),s=0;s<a;s++)o[s]=E[s];return this.checkRequiredArguments(o,3,"sign"),u=o[0],c=o[1],l=o[2],f=o.slice(3),this.checkCryptoKey(c),d=this.prepareAlgorithm(u),v=K.toArrayBuffer(l),y=this.getProvider(d.name),N.next=9,y.sign.apply(y,[O(O({},d),{},{name:y.name}),c,v].concat(xe(f)));case 9:return S=N.sent,N.abrupt("return",S);case 11:case"end":return N.stop()}},n,this)}));function t(){return e.apply(this,arguments)}return t})()},{key:"verify",value:(function(){var e=re(h().mark(function n(){var a,o,s,u,c,l,f,d,v,y,S,E,x,N=arguments;return h().wrap(function(G){for(;;)switch(G.prev=G.next){case 0:for(a=N.length,o=new Array(a),s=0;s<a;s++)o[s]=N[s];return this.checkRequiredArguments(o,4,"verify"),u=o[0],c=o[1],l=o[2],f=o[3],d=o.slice(4),this.checkCryptoKey(c),v=this.prepareAlgorithm(u),y=K.toArrayBuffer(f),S=K.toArrayBuffer(l),E=this.getProvider(v.name),G.next=10,E.verify.apply(E,[O(O({},v),{},{name:E.name}),c,S,y].concat(xe(d)));case 10:return x=G.sent,G.abrupt("return",x);case 12:case"end":return G.stop()}},n,this)}));function t(){return e.apply(this,arguments)}return t})()},{key:"encrypt",value:(function(){var e=re(h().mark(function n(){var a,o,s,u,c,l,f,d,v,y,S,E=arguments;return h().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:for(a=E.length,o=new Array(a),s=0;s<a;s++)o[s]=E[s];return this.checkRequiredArguments(o,3,"encrypt"),u=o[0],c=o[1],l=o[2],f=o.slice(3),this.checkCryptoKey(c),d=this.prepareAlgorithm(u),v=K.toArrayBuffer(l),y=this.getProvider(d.name),N.next=9,y.encrypt.apply(y,[O(O({},d),{},{name:y.name}),c,v,{keyUsage:!0}].concat(xe(f)));case 9:return S=N.sent,N.abrupt("return",S);case 11:case"end":return N.stop()}},n,this)}));function t(){return e.apply(this,arguments)}return t})()},{key:"decrypt",value:(function(){var e=re(h().mark(function n(){var a,o,s,u,c,l,f,d,v,y,S,E=arguments;return h().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:for(a=E.length,o=new Array(a),s=0;s<a;s++)o[s]=E[s];return this.checkRequiredArguments(o,3,"decrypt"),u=o[0],c=o[1],l=o[2],f=o.slice(3),this.checkCryptoKey(c),d=this.prepareAlgorithm(u),v=K.toArrayBuffer(l),y=this.getProvider(d.name),N.next=9,y.decrypt.apply(y,[O(O({},d),{},{name:y.name}),c,v,{keyUsage:!0}].concat(xe(f)));case 9:return S=N.sent,N.abrupt("return",S);case 11:case"end":return N.stop()}},n,this)}));function t(){return e.apply(this,arguments)}return t})()},{key:"deriveBits",value:(function(){var e=re(h().mark(function n(){var a,o,s,u,c,l,f,d,v,y,S=arguments;return h().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:for(a=S.length,o=new Array(a),s=0;s<a;s++)o[s]=S[s];return this.checkRequiredArguments(o,3,"deriveBits"),u=o[0],c=o[1],l=o[2],f=o.slice(3),this.checkCryptoKey(c),d=this.prepareAlgorithm(u),v=this.getProvider(d.name),x.next=8,v.deriveBits.apply(v,[O(O({},d),{},{name:v.name}),c,l,{keyUsage:!0}].concat(xe(f)));case 8:return y=x.sent,x.abrupt("return",y);case 10:case"end":return x.stop()}},n,this)}));function t(){return e.apply(this,arguments)}return t})()},{key:"deriveKey",value:(function(){var e=re(h().mark(function n(){var a,o,s,u,c,l,f,d,v,y,S,E,x,N,$=arguments;return h().wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:for(a=$.length,o=new Array(a),s=0;s<a;s++)o[s]=$[s];return this.checkRequiredArguments(o,5,"deriveKey"),u=o[0],c=o[1],l=o[2],f=o[3],d=o[4],v=o.slice(5),y=this.prepareAlgorithm(l),S=this.getProvider(y.name),S.checkDerivedKeyParams(y),E=this.prepareAlgorithm(u),x=this.getProvider(E.name),x.checkCryptoKey(c,"deriveKey"),Y.next=11,x.deriveBits.apply(x,[O(O({},E),{},{name:x.name}),c,l.length||512,{keyUsage:!1}].concat(xe(v)));case 11:return N=Y.sent,Y.abrupt("return",this.importKey.apply(this,["raw",N,l,f,d].concat(xe(v))));case 13:case"end":return Y.stop()}},n,this)}));function t(){return e.apply(this,arguments)}return t})()},{key:"exportKey",value:(function(){var e=re(h().mark(function n(){var a,o,s,u,c,l,f,d,v=arguments;return h().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:for(a=v.length,o=new Array(a),s=0;s<a;s++)o[s]=v[s];return this.checkRequiredArguments(o,2,"exportKey"),u=o[0],c=o[1],l=o.slice(2),this.checkCryptoKey(c),f=this.getProvider(c.algorithm.name),S.next=7,f.exportKey.apply(f,[u,c].concat(xe(l)));case 7:return d=S.sent,S.abrupt("return",d);case 9:case"end":return S.stop()}},n,this)}));function t(){return e.apply(this,arguments)}return t})()},{key:"importKey",value:(function(){var e=re(h().mark(function n(){var a,o,s,u,c,l,f,d,v,y,S,E,x=arguments;return h().wrap(function($){for(;;)switch($.prev=$.next){case 0:for(a=x.length,o=new Array(a),s=0;s<a;s++)o[s]=x[s];if(this.checkRequiredArguments(o,5,"importKey"),u=o[0],c=o[1],l=o[2],f=o[3],d=o[4],v=o.slice(5),y=this.prepareAlgorithm(l),S=this.getProvider(y.name),["pkcs8","spki","raw"].indexOf(u)===-1){$.next=10;break}return E=K.toArrayBuffer(c),$.abrupt("return",S.importKey.apply(S,[u,E,O(O({},y),{},{name:S.name}),f,d].concat(xe(v))));case 10:if(c.kty){$.next=12;break}throw new TypeError("keyData: Is not JSON");case 12:return $.abrupt("return",S.importKey.apply(S,[u,c,O(O({},y),{},{name:S.name}),f,d].concat(xe(v))));case 13:case"end":return $.stop()}},n,this)}));function t(){return e.apply(this,arguments)}return t})()},{key:"wrapKey",value:(function(){var e=re(h().mark(function n(a,o,s,u){var c,l,f,d,v,y,S,E,x=arguments;return h().wrap(function($){for(;;)switch($.prev=$.next){case 0:for(c=x.length,l=new Array(c>4?c-4:0),f=4;f<c;f++)l[f-4]=x[f];return $.next=3,this.exportKey.apply(this,[a,o].concat(l));case 3:return d=$.sent,a==="jwk"&&(v=JSON.stringify(d),d=L.FromUtf8String(v)),y=this.prepareAlgorithm(u),S=K.toArrayBuffer(d),E=this.getProvider(y.name),$.abrupt("return",E.encrypt.apply(E,[O(O({},y),{},{name:E.name}),s,S,{keyUsage:!1}].concat(l)));case 9:case"end":return $.stop()}},n,this)}));function t(n,a,o,s){return e.apply(this,arguments)}return t})()},{key:"unwrapKey",value:(function(){var e=re(h().mark(function n(a,o,s,u,c,l,f){var d,v,y,S,E,x,N,$,G=arguments;return h().wrap(function(Q){for(;;)switch(Q.prev=Q.next){case 0:for(d=this.prepareAlgorithm(u),v=K.toArrayBuffer(o),y=this.getProvider(d.name),S=G.length,E=new Array(S>7?S-7:0),x=7;x<S;x++)E[x-7]=G[x];return Q.next=6,y.decrypt.apply(y,[O(O({},d),{},{name:y.name}),s,v,{keyUsage:!1}].concat(E));case 6:if(N=Q.sent,a!=="jwk"){Q.next=17;break}Q.prev=8,N=JSON.parse(L.ToUtf8String(N)),Q.next=17;break;case 12:throw Q.prev=12,Q.t0=Q.catch(8),$=new TypeError("wrappedKey: Is not a JSON"),$.internal=Q.t0,$;case 17:return Q.abrupt("return",this.importKey.apply(this,[a,N,c,l,f].concat(E)));case 18:case"end":return Q.stop()}},n,this,[[8,12]])}));function t(n,a,o,s,u,c,l){return e.apply(this,arguments)}return t})()},{key:"checkRequiredArguments",value:function(t,n,a){if(t.length<n)throw new TypeError("Failed to execute '".concat(a,"' on 'SubtleCrypto': ").concat(n," arguments required, but only ").concat(t.length," present"))}},{key:"prepareAlgorithm",value:function(t){if(typeof t=="string")return{name:t};if(r.isHashedAlgorithm(t)){var n=O({},t);return n.hash=this.prepareAlgorithm(t.hash),n}return O({},t)}},{key:"getProvider",value:function(t){var n=this.providers.get(t);if(!n)throw new Yr("Unrecognized name");return n}},{key:"checkCryptoKey",value:function(t){if(!(t instanceof gn))throw new TypeError("Key is not of type 'CryptoKey'")}}],[{key:"isHashedAlgorithm",value:function(t){return!!(t&&oe(t)==="object"&&"name"in t&&"hash"in t)}}]),r})(Symbol.toStringTag),Te=(function(){function i(){g(this,i)}return m(i,null,[{key:"enabled",get:function(){return typeof self<"u"&&self.PV_WEBCRYPTO_LINER_LOG}},{key:"log",value:function(){if(this.enabled){var e;(e=console).log.apply(e,arguments)}}},{key:"error",value:function(){if(this.enabled){var e;(e=console).error.apply(e,arguments)}}},{key:"info",value:function(){if(this.enabled){var e;(e=console).info.apply(e,arguments)}}},{key:"warn",value:function(){if(this.enabled){var e;(e=console).warn.apply(e,arguments)}}},{key:"trace",value:function(){if(this.enabled){var e;(e=console).trace.apply(e,arguments)}}}]),i})(),be;(function(i){i.Unknown="Unknown",i.IE="Internet Explorer",i.Safari="Safari",i.Edge="Edge",i.Chrome="Chrome",i.Firefox="Firefox Mozilla",i.Mobile="Mobile"})(be||(be={}));function Ou(){var i={name:be.Unknown,version:"0"};if(typeof self>"u")return i;var r=self.navigator.userAgent,e=/edge\/([\d.]+)/i.exec(r);return e?(i.name=be.Edge,i.version=e[1]):/msie/i.test(r)?(i.name=be.IE,i.version=/msie ([\d.]+)/i.exec(r)[1]):/Trident/i.test(r)?(i.name=be.IE,i.version=/rv:([\d.]+)/i.exec(r)[1]):/chrome/i.test(r)?(i.name=be.Chrome,i.version=/chrome\/([\d.]+)/i.exec(r)[1]):/firefox/i.test(r)?(i.name=be.Firefox,i.version=/firefox\/([\d.]+)/i.exec(r)[1]):/mobile/i.test(r)?(i.name=be.Mobile,i.version=/mobile\/([\w]+)/i.exec(r)[1]):/safari/i.test(r)&&(i.name=be.Safari,i.version=/version\/([\d.]+)/i.exec(r)[1]),i}function Sa(){for(var i=arguments.length,r=new Array(i),e=0;e<i;e++)r[e]=arguments[e];var t=new Uint8Array(r.map(function(a){return a.length}).reduce(function(a,o){return a+o})),n=0;return r.forEach(function(a){for(var o=0;o<a.length;o++)t[n+o]=a[o];n+=a.length}),t}var $e=(function(i){b(r,i);function r(e,t,n,a){var o;return g(this,r),o=k(this,r),o.extractable=t,o.type=n,o.usages=a,o.algorithm=Object.assign({},e),o}return m(r)})(gn);function An(i,r){return i.name.toUpperCase()===r.toUpperCase()}var Sn=(function(i){b(r,i);function r(e,t,n,a){var o;return g(this,r),o=k(this,r,[e,t,"secret",n]),o.raw=a,o}return m(r,[{key:"toJSON",value:function(){var t={kty:"oct",alg:this.getJwkAlgorithm(),k:L.ToBase64Url(this.raw),ext:this.extractable,key_ops:this.usages};return t}},{key:"getJwkAlgorithm",value:function(){switch(this.algorithm.name.toUpperCase()){case"AES-CBC":return"A".concat(this.algorithm.length,"CBC");case"AES-CTR":return"A".concat(this.algorithm.length,"CTR");case"AES-GCM":return"A".concat(this.algorithm.length,"GCM");case"AES-ECB":return"A".concat(this.algorithm.length,"ECB");default:throw new Yr("Unsupported algorithm name")}}}]),r})($e),ae=(function(){function i(){g(this,i)}return m(i,null,[{key:"checkCryptoKey",value:function(e){if(!(e instanceof Sn))throw new TypeError("key: Is not AesCryptoKey")}},{key:"generateKey",value:function(e,t,n){return A(this,void 0,void 0,h().mark(function a(){var o;return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return o=p.nativeCrypto.getRandomValues(new Uint8Array(e.length/8)),u.abrupt("return",new Sn(e,t,n,o));case 2:case"end":return u.stop()}},a)}))}},{key:"encrypt",value:function(e,t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",this.cipher(e,t,K.toUint8Array(n),!0));case 1:case"end":return s.stop()}},a,this)}))}},{key:"decrypt",value:function(e,t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",this.cipher(e,t,K.toUint8Array(n),!1));case 1:case"end":return s.stop()}},a,this)}))}},{key:"exportKey",value:function(e,t){return A(this,void 0,void 0,h().mark(function n(){return h().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:o.t0=e,o.next=o.t0==="jwk"?3:o.t0==="raw"?4:5;break;case 3:return o.abrupt("return",t.toJSON());case 4:return o.abrupt("return",t.raw.buffer);case 5:throw new X("format: Must be 'jwk' or 'raw'");case 6:case"end":return o.stop()}},n)}))}},{key:"importKey",value:function(e,t,n,a,o){return A(this,void 0,void 0,h().mark(function s(){var u,c;return h().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:pn(t)?u=L.FromBase64Url(t.k):u=K.toArrayBuffer(t),f.t0=u.byteLength<<3,f.next=f.t0===128||f.t0===192||f.t0===256?4:5;break;case 4:return f.abrupt("break",6);case 5:throw new X("keyData: Is wrong key length");case 6:return c=new Sn({name:n.name,length:u.byteLength<<3},a,o,new Uint8Array(u)),f.abrupt("return",c);case 8:case"end":return f.stop()}},s)}))}},{key:"cipher",value:function(e,t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s,u,c,l,f,d;return h().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(s=a?"encrypt":"decrypt",!An(e,i.AesCBC)){y.next=6;break}c=K.toUint8Array(e.iv),u=D.AES_CBC[s](n,t.raw,void 0,c),y.next=18;break;case 6:if(!An(e,i.AesGCM)){y.next=13;break}l=K.toUint8Array(e.iv),e.additionalData&&(f=K.toUint8Array(e.additionalData)),d=(e.tagLength||128)/8,u=D.AES_GCM[s](n,t.raw,l,f,d),y.next=18;break;case 13:if(!An(e,i.AesECB)){y.next=17;break}u=D.AES_ECB[s](n,t.raw,!0),y.next=18;break;case 17:throw new X("algorithm: Is not recognized");case 18:return y.abrupt("return",K.toArrayBuffer(u));case 19:case"end":return y.stop()}},o)}))}}]),i})();ae.AesCBC="AES-CBC",ae.AesECB="AES-ECB",ae.AesGCM="AES-GCM";var Iu=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"onGenerateKey",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",ae.generateKey(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onEncrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",ae.encrypt(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onDecrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",ae.decrypt(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onExportKey",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",ae.exportKey(t,n));case 1:case"end":return s.stop()}},a)}))}},{key:"onImportKey",value:function(t,n,a,o,s){return A(this,void 0,void 0,h().mark(function u(){return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",ae.importKey(t,n,a,o,s));case 1:case"end":return l.stop()}},u)}))}},{key:"checkCryptoKey",value:function(t,n){j(M(r.prototype),"checkCryptoKey",this).call(this,t,n),ae.checkCryptoKey(t)}}]),r})(su),Lu=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"onGenerateKey",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",ae.generateKey(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onEncrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",ae.encrypt(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onDecrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",ae.decrypt(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onExportKey",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",ae.exportKey(t,n));case 1:case"end":return s.stop()}},a)}))}},{key:"onImportKey",value:function(t,n,a,o,s){return A(this,void 0,void 0,h().mark(function u(){return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",ae.importKey(t,n,a,o,s));case 1:case"end":return l.stop()}},u)}))}},{key:"checkCryptoKey",value:function(t,n){j(M(r.prototype),"checkCryptoKey",this).call(this,t,n),ae.checkCryptoKey(t)}}]),r})(lu),xu=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"onGenerateKey",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",ae.generateKey(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onEncrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",ae.encrypt(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onDecrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",ae.decrypt(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onExportKey",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",ae.exportKey(t,n));case 1:case"end":return s.stop()}},a)}))}},{key:"onImportKey",value:function(t,n,a,o,s){return A(this,void 0,void 0,h().mark(function u(){return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",ae.importKey(t,n,a,o,s));case 1:case"end":return l.stop()}},u)}))}},{key:"checkCryptoKey",value:function(t,n){j(M(r.prototype),"checkCryptoKey",this).call(this,t,n),ae.checkCryptoKey(t)}}]),r})(fu),Ru=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"onEncrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s;return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return s=new D.AES_CTR(n.raw,K.toUint8Array(t.counter)).encrypt(K.toUint8Array(a)),c.abrupt("return",K.toArrayBuffer(s));case 2:case"end":return c.stop()}},o)}))}},{key:"onDecrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s;return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return s=new D.AES_CTR(n.raw,K.toUint8Array(t.counter)).decrypt(K.toUint8Array(a)),c.abrupt("return",K.toArrayBuffer(s));case 2:case"end":return c.stop()}},o)}))}},{key:"onGenerateKey",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",ae.generateKey(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onExportKey",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",ae.exportKey(t,n));case 1:case"end":return s.stop()}},a)}))}},{key:"onImportKey",value:function(t,n,a,o,s){return A(this,void 0,void 0,h().mark(function u(){return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",ae.importKey(t,n,a,o,s));case 1:case"end":return l.stop()}},u)}))}},{key:"checkCryptoKey",value:function(t,n){j(M(r.prototype),"checkCryptoKey",this).call(this,t,n),ae.checkCryptoKey(t)}}]),r})(cu),Vu=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"onEncrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:throw new Error("Method not implemented.");case 1:case"end":return u.stop()}},o)}))}},{key:"onDecrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:throw new Error("Method not implemented.");case 1:case"end":return u.stop()}},o)}))}},{key:"onGenerateKey",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:throw new Error("Method not implemented.");case 1:case"end":return u.stop()}},o)}))}},{key:"onExportKey",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:throw new Error("Method not implemented.");case 1:case"end":return s.stop()}},a)}))}},{key:"onImportKey",value:function(t,n,a,o,s){return A(this,void 0,void 0,h().mark(function u(){return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:throw new Error("Method not implemented.");case 1:case"end":return l.stop()}},u)}))}},{key:"checkCryptoKey",value:function(t,n){j(M(r.prototype),"checkCryptoKey",this).call(this,t,n),ae.checkCryptoKey(t)}}]),r})(hu),Ea=(function(i){b(r,i);function r(e,t,n,a,o){var s;return g(this,r),s=k(this,r,[e,t,n,a]),s.data=o,s}return m(r)})($e),fe=(function(){function i(){g(this,i)}return m(i,null,[{key:"checkCryptoKey",value:function(e){if(!(e instanceof Ea))throw new TypeError("key: Is not RsaCryptoKey")}},{key:"generateKey",value:function(e,t,n){return A(this,void 0,void 0,h().mark(function a(){var o=this,s,u,c,l,f,d,v;return h().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return s={name:"RSA-PSS",hash:"SHA-256",publicExponent:e.publicExponent,modulusLength:e.modulusLength},S.next=3,p.nativeSubtle.generateKey(s,!0,["sign","verify"]);case 3:return u=S.sent,c=new tt,S.next=7,c.subtle.exportKey("pkcs8",u.privateKey);case 7:return l=S.sent,S.next=10,c.subtle.importKey("pkcs8",l,e,t,n.filter(function(E){return o.privateUsages.includes(E)}));case 10:return f=S.sent,S.next=13,c.subtle.exportKey("spki",u.publicKey);case 13:return d=S.sent,S.next=16,c.subtle.importKey("spki",d,e,!0,n.filter(function(E){return o.publicUsages.includes(E)}));case 16:return v=S.sent,S.abrupt("return",{privateKey:f,publicKey:v});case 18:case"end":return S.stop()}},a)}))}},{key:"exportKey",value:function(e,t){return A(this,void 0,void 0,h().mark(function n(){return h().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:o.t0=e,o.next=o.t0==="pkcs8"?3:o.t0==="spki"?4:o.t0==="jwk"?5:6;break;case 3:return o.abrupt("return",this.exportPkcs8Key(t));case 4:return o.abrupt("return",this.exportSpkiKey(t));case 5:return o.abrupt("return",this.exportJwkKey(t));case 6:throw new X("format: Must be 'jwk', 'pkcs8' or 'spki'");case 7:case"end":return o.stop()}},n,this)}))}},{key:"importKey",value:function(e,t,n,a,o){return A(this,void 0,void 0,h().mark(function s(){var u,c;return h().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:f.t0=e,f.next=f.t0==="pkcs8"?3:f.t0==="spki"?5:f.t0==="jwk"?7:9;break;case 3:return u=this.importPkcs8Key(t),f.abrupt("break",10);case 5:return u=this.importSpkiKey(t),f.abrupt("break",10);case 7:return u=this.importJwkKey(t),f.abrupt("break",10);case 9:throw new X("format: Must be 'jwk', 'pkcs8' or 'spki'");case 10:return c=new Ea(Object.assign({publicExponent:u[1][1]===1?u[1].slice(1):u[1].slice(3),modulusLength:u[0].byteLength<<3},n),a,u.length===2?"public":"private",o,u),f.abrupt("return",c);case 12:case"end":return f.stop()}},s,this)}))}},{key:"randomNonZeroValues",value:function(e){return e=p.nativeCrypto.getRandomValues(e),e.map(function(t){for(;!t;)t=p.nativeCrypto.getRandomValues(new Uint8Array(1))[0];return t})}},{key:"exportPkcs8Key",value:function(e){var t=new J.PrivateKeyInfo;return t.privateKeyAlgorithm.algorithm="1.2.840.113549.1.1.1",t.privateKeyAlgorithm.parameters=null,t.privateKey=te.serialize(this.exportAsmKey(e.data)),te.serialize(t)}},{key:"importPkcs8Key",value:function(e){var t=te.parse(e,J.PrivateKeyInfo),n=te.parse(t.privateKey,J.RsaPrivateKey);return this.importAsmKey(n)}},{key:"importSpkiKey",value:function(e){var t=te.parse(e,J.PublicKeyInfo),n=te.parse(t.publicKey,J.RsaPublicKey);return this.importAsmKey(n)}},{key:"exportSpkiKey",value:function(e){var t=new J.RsaPublicKey;t.modulus=e.data[0].buffer,t.publicExponent=e.data[1][1]===1?e.data[1].buffer.slice(1):e.data[1].buffer.slice(3);var n=new J.PublicKeyInfo;return n.publicKeyAlgorithm.algorithm="1.2.840.113549.1.1.1",n.publicKeyAlgorithm.parameters=null,n.publicKey=te.serialize(t),te.serialize(n)}},{key:"importJwkKey",value:function(e){var t;return e.d?t=Cr.fromJSON(e,{targetSchema:J.RsaPrivateKey}):t=Cr.fromJSON(e,{targetSchema:J.RsaPublicKey}),this.importAsmKey(t)}},{key:"exportJwkKey",value:function(e){var t=this.exportAsmKey(e.data),n=Xr.toJSON(t);return n.ext=!0,n.key_ops=e.usages,n.kty="RSA",n.alg=this.getJwkAlgorithm(e.algorithm),n}},{key:"getJwkAlgorithm",value:function(e){switch(e.name.toUpperCase()){case"RSA-OAEP":{var t=/(\d+)$/.exec(e.hash.name)[1];return"RSA-OAEP".concat(t!=="1"?"-".concat(t):"")}case"RSASSA-PKCS1-V1_5":return"RS".concat(/(\d+)$/.exec(e.hash.name)[1]);case"RSA-PSS":return"PS".concat(/(\d+)$/.exec(e.hash.name)[1]);case"RSAES-PKCS1-V1_5":return"PS1";default:throw new X("algorithm: Is not recognized")}}},{key:"exportAsmKey",value:function(e){var t;if(e.length>2){var n=new J.RsaPrivateKey;n.privateExponent=e[2].buffer,n.prime1=e[3].buffer,n.prime2=e[4].buffer,n.exponent1=e[5].buffer,n.exponent2=e[6].buffer,n.coefficient=e[7].buffer,t=n}else t=new J.RsaPublicKey;return t.modulus=e[0].buffer,t.publicExponent=e[1][1]===1?e[1].buffer.slice(1):e[1].buffer.slice(3),t}},{key:"importAsmKey",value:function(e){var t=new Uint8Array(4-e.publicExponent.byteLength),n=[new Uint8Array(e.modulus),Sa(t,new Uint8Array(e.publicExponent))];return e instanceof J.RsaPrivateKey&&(n.push(new Uint8Array(e.privateExponent)),n.push(new Uint8Array(e.prime1)),n.push(new Uint8Array(e.prime2)),n.push(new Uint8Array(e.exponent1)),n.push(new Uint8Array(e.exponent2)),n.push(new Uint8Array(e.coefficient))),n}}]),i})();fe.RsaSsa="RSASSA-PKCS1-v1_5",fe.RsaPss="RSA-PSS",fe.RsaOaep="RSA-OAEP",fe.privateUsages=["sign","decrypt","unwrapKey"],fe.publicUsages=["verify","encrypt","wrapKey"];var Tr=(function(){function i(){g(this,i)}return m(i,null,[{key:"getDigest",value:function(e){switch(e){case"SHA-1":return new D.Sha1;case"SHA-256":return new D.Sha256;case"SHA-512":return new D.Sha512;default:throw new Yr("keyAlgorithm.hash: Is not recognized")}}},{key:"digest",value:function(e,t){return A(this,void 0,void 0,h().mark(function n(){var a,o;return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return a=this.getDigest(e.name),o=a.process(K.toUint8Array(t)).finish().result,u.abrupt("return",K.toArrayBuffer(o));case 3:case"end":return u.stop()}},n,this)}))}}]),i})(),Hu=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"onGenerateKey",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",fe.generateKey(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onExportKey",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",fe.exportKey(t,n));case 1:case"end":return s.stop()}},a)}))}},{key:"onImportKey",value:function(t,n,a,o,s){return A(this,void 0,void 0,h().mark(function u(){return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",fe.importKey(t,n,a,o,s));case 1:case"end":return l.stop()}},u)}))}},{key:"onEncrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.cipher(t,n,a));case 1:case"end":return u.stop()}},o,this)}))}},{key:"onDecrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.cipher(t,n,a));case 1:case"end":return u.stop()}},o,this)}))}},{key:"checkCryptoKey",value:function(t,n){j(M(r.prototype),"checkCryptoKey",this).call(this,t,n),fe.checkCryptoKey(t)}},{key:"cipher",value:function(t,n,a){var o=Tr.getDigest(n.algorithm.hash.name),s;t.label&&(s=K.toUint8Array(t.label));var u=new D.RSA_OAEP(n.data,o,s),c,l=K.toUint8Array(a);return n.type==="public"?c=u.encrypt(l):c=u.decrypt(l),K.toArrayBuffer(c)}}]),r})(yu),Du=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"onGenerateKey",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",fe.generateKey(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onExportKey",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",fe.exportKey(t,n));case 1:case"end":return s.stop()}},a)}))}},{key:"onImportKey",value:function(t,n,a,o,s){return A(this,void 0,void 0,h().mark(function u(){return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",fe.importKey(t,n,a,o,s));case 1:case"end":return l.stop()}},u)}))}},{key:"onSign",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s,u;return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return s=new D.RSA_PSS(n.data,Tr.getDigest(n.algorithm.hash.name),t.saltLength),u=s.sign(K.toUint8Array(a)),l.abrupt("return",K.toArrayBuffer(u));case 3:case"end":return l.stop()}},o)}))}},{key:"onVerify",value:function(t,n,a,o){return A(this,void 0,void 0,h().mark(function s(){var u;return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:u=new D.RSA_PSS(n.data,Tr.getDigest(n.algorithm.hash.name),t.saltLength),l.prev=1,u.verify(K.toUint8Array(a),K.toUint8Array(o)),l.next=8;break;case 5:return l.prev=5,l.t0=l.catch(1),l.abrupt("return",!1);case 8:return l.abrupt("return",!0);case 9:case"end":return l.stop()}},s,null,[[1,5]])}))}},{key:"checkCryptoKey",value:function(t,n){j(M(r.prototype),"checkCryptoKey",this).call(this,t,n),fe.checkCryptoKey(t)}}]),r})(pu),Tu=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"onGenerateKey",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",fe.generateKey(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onExportKey",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",fe.exportKey(t,n));case 1:case"end":return s.stop()}},a)}))}},{key:"onImportKey",value:function(t,n,a,o,s){return A(this,void 0,void 0,h().mark(function u(){return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",fe.importKey(t,n,a,o,s));case 1:case"end":return l.stop()}},u)}))}},{key:"onSign",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s,u;return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return s=new D.RSA_PKCS1_v1_5(n.data,Tr.getDigest(n.algorithm.hash.name)),u=s.sign(K.toUint8Array(a)),l.abrupt("return",K.toArrayBuffer(u));case 3:case"end":return l.stop()}},o)}))}},{key:"onVerify",value:function(t,n,a,o){return A(this,void 0,void 0,h().mark(function s(){var u;return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:u=new D.RSA_PKCS1_v1_5(n.data,Tr.getDigest(n.algorithm.hash.name)),l.prev=1,u.verify(K.toUint8Array(a),K.toUint8Array(o)),l.next=8;break;case 5:return l.prev=5,l.t0=l.catch(1),l.abrupt("return",!1);case 8:return l.abrupt("return",!0);case 9:case"end":return l.stop()}},s,null,[[1,5]])}))}},{key:"checkCryptoKey",value:function(t,n){j(M(r.prototype),"checkCryptoKey",this).call(this,t,n),fe.checkCryptoKey(t)}}]),r})(vu),$u=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="RSAES-PKCS1-v1_5",e.usages={publicKey:["encrypt","wrapKey"],privateKey:["decrypt","unwrapKey"]},e.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512"],e}return m(r,[{key:"onGenerateKey",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",fe.generateKey(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"checkGenerateKeyParams",value:function(t){if(this.checkRequiredProperty(t,"publicExponent"),!(t.publicExponent&&t.publicExponent instanceof Uint8Array))throw new TypeError("publicExponent: Missing or not a Uint8Array");var n=L.ToBase64(t.publicExponent);if(!(n==="Aw=="||n==="AQAB"))throw new TypeError("publicExponent: Must be [3] or [1,0,1]");switch(this.checkRequiredProperty(t,"modulusLength"),t.modulusLength){case 1024:case 2048:case 4096:break;default:throw new TypeError("modulusLength: Must be 1024, 2048, or 4096")}}},{key:"onDecrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s,u,c;return h().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(s=new D.RSA(n.data).decrypt(new D.BigNumber(K.toUint8Array(a))).result,u=n.algorithm.modulusLength>>3,a.byteLength===u){f.next=4;break}throw new He("Decryption error. Encrypted message size doesn't match to key length");case 4:if(c=0,!(s[c++]||s[c++]!==2)){f.next=7;break}throw new He("Decryption error");case 7:if(s[c++]!==0){f.next=9;break}return f.abrupt("break",10);case 9:if(c<s.length){f.next=7;break}case 10:if(!(c<11)){f.next=12;break}throw new He("Decryption error. PS is less than 8 octets.");case 12:if(c!==s.length){f.next=14;break}throw new He("Decryption error. There is no octet with hexadecimal value 0x00 to separate PS from M");case 14:return f.abrupt("return",s.buffer.slice(c));case 15:case"end":return f.stop()}},o)}))}},{key:"onEncrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s,u,c,l,f;return h().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(s=n.algorithm.modulusLength>>3,!(a.byteLength>s-11)){v.next=3;break}throw new He("Message too long");case 3:return u=s-a.byteLength-3,c=fe.randomNonZeroValues(new Uint8Array(u)),l=new Uint8Array(s),l[0]=0,l[1]=2,l.set(c,2),l[2+u]=0,l.set(new Uint8Array(a),3+u),f=new D.RSA(n.data).encrypt(new D.BigNumber(l)).result,v.abrupt("return",K.toArrayBuffer(f));case 13:case"end":return v.stop()}},o)}))}},{key:"onExportKey",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",fe.exportKey(t,n));case 1:case"end":return s.stop()}},a)}))}},{key:"onImportKey",value:function(t,n,a,o,s){return A(this,void 0,void 0,h().mark(function u(){var c;return h().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,fe.importKey(t,n,Object.assign(Object.assign({},a),{name:this.name}),o,s);case 2:return c=f.sent,f.abrupt("return",c);case 4:case"end":return f.stop()}},u,this)}))}},{key:"checkCryptoKey",value:function(t,n){j(M(r.prototype),"checkCryptoKey",this).call(this,t,n),fe.checkCryptoKey(t)}}]),r})(De),Fu={"1.2.840.10045.3.1.7":"P-256","P-256":"1.2.840.10045.3.1.7","1.3.132.0.34":"P-384","P-384":"1.3.132.0.34","1.3.132.0.35":"P-521","P-521":"1.3.132.0.35","1.3.132.0.10":"K-256","K-256":"1.3.132.0.10","1.3.36.3.3.2.8.1.1.7":"brainpoolP256r1",brainpoolP256r1:"1.3.36.3.3.2.8.1.1.7","1.3.36.3.3.2.8.1.1.11":"brainpoolP384r1",brainpoolP384r1:"1.3.36.3.3.2.8.1.1.11","1.3.36.3.3.2.8.1.1.13":"brainpoolP512r1",brainpoolP512r1:"1.3.36.3.3.2.8.1.1.13"};function En(i){var r=Fu[i];if(!r)throw new X("Cannot convert WebCrypto named curve '".concat(i,"' to OID"));return r}var Rt=(function(i){b(r,i);function r(e,t,n,a,o){var s;return g(this,r),s=k(this,r,[e,t,n,a]),s.data=o,s}return m(r)})($e),Ke=(function(){function i(){g(this,i)}return m(i,null,[{key:"checkLib",value:function(){if(typeof Z>"u")throw new X("Cannot implement EC mechanism. Add 'https://peculiarventures.github.io/pv-webcrypto-tests/src/elliptic.js' script to your project")}},{key:"generateKey",value:function(e,t,n){return A(this,void 0,void 0,h().mark(function a(){var o=this,s,u,c,l;return h().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return this.checkLib(),s=this.initEcKey(e.namedCurve),u=s.genKeyPair(),u.getPublic(),c=new Rt(Object.assign({},e),t,"private",n.filter(function(v){return~o.privateUsages.indexOf(v)}),u),l=new Rt(Object.assign({},e),!0,"public",n.filter(function(v){return~o.publicUsages.indexOf(v)}),u),d.abrupt("return",{privateKey:c,publicKey:l});case 7:case"end":return d.stop()}},a,this)}))}},{key:"checkCryptoKey",value:function(e){if(!(e instanceof Rt))throw new TypeError("key: Is not EcCryptoKey")}},{key:"concat",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var a=new Uint8Array(t.map(function(s){return s.length}).reduce(function(s,u){return s+u})),o=0;return t.forEach(function(s){for(var u=0;u<s.length;u++)a[o+u]=s[u];o+=s.length}),a}},{key:"exportKey",value:function(e,t){return A(this,void 0,void 0,h().mark(function n(){return h().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:this.checkLib(),o.t0=e,o.next=o.t0==="pkcs8"?4:o.t0==="spki"?5:o.t0==="jwk"?6:o.t0==="raw"?7:8;break;case 4:return o.abrupt("return",this.exportPkcs8Key(t));case 5:return o.abrupt("return",this.exportSpkiKey(t));case 6:return o.abrupt("return",this.exportJwkKey(t));case 7:return o.abrupt("return",new Uint8Array(t.data.getPublic("der")).buffer);case 8:throw new X("format: Must be 'jwk', 'raw, 'pkcs8' or 'spki'");case 9:case"end":return o.stop()}},n,this)}))}},{key:"importKey",value:function(e,t,n,a,o){return A(this,void 0,void 0,h().mark(function s(){var u,c;return h().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:this.checkLib(),f.t0=e,f.next=f.t0==="pkcs8"?4:f.t0==="spki"?6:f.t0==="raw"?8:f.t0==="jwk"?10:12;break;case 4:return u=this.importPkcs8Key(t,n.namedCurve),f.abrupt("break",13);case 6:return u=this.importSpkiKey(t,n.namedCurve),f.abrupt("break",13);case 8:return u=this.importEcKey(new J.EcPublicKey(t),n.namedCurve),f.abrupt("break",13);case 10:return u=this.importJwkKey(t),f.abrupt("break",13);case 12:throw new X("format: Must be 'jwk', 'raw', 'pkcs8' or 'spki'");case 13:return c=new Rt(Object.assign({},n),a,u.priv?"private":"public",o,u),f.abrupt("return",c);case 15:case"end":return f.stop()}},s,this)}))}},{key:"getNamedCurve",value:function(e){var t=e.toUpperCase(),n="";if(["P-256","P-384","P-521"].indexOf(t)>-1)n=t.replace("-","").toLowerCase();else if(t==="K-256")n="secp256k1";else if(["brainpoolP256r1","brainpoolP384r1","brainpoolP512r1"].includes(e))n=e;else throw new X("Unsupported named curve '".concat(e,"'"));return n}},{key:"initEcKey",value:function(e){return Z.ec(this.getNamedCurve(e))}},{key:"exportPkcs8Key",value:function(e){var t=new J.PrivateKeyInfo;return t.privateKeyAlgorithm.algorithm=this.ASN_ALGORITHM,t.privateKeyAlgorithm.parameters=te.serialize(new J.ObjectIdentifier(En(e.algorithm.namedCurve))),t.privateKey=te.serialize(this.exportEcKey(e)),te.serialize(t)}},{key:"importPkcs8Key",value:function(e,t){var n=te.parse(e,J.PrivateKeyInfo),a=te.parse(n.privateKey,J.EcPrivateKey);return this.importEcKey(a,t)}},{key:"importSpkiKey",value:function(e,t){var n=te.parse(e,J.PublicKeyInfo),a=new J.EcPublicKey(n.publicKey);return this.importEcKey(a,t)}},{key:"exportSpkiKey",value:function(e){var t=new J.EcPublicKey(new Uint8Array(e.data.getPublic("der")).buffer),n=new J.PublicKeyInfo;return n.publicKeyAlgorithm.algorithm=this.ASN_ALGORITHM,n.publicKeyAlgorithm.parameters=te.serialize(new J.ObjectIdentifier(En(e.algorithm.namedCurve))),n.publicKey=t.value,te.serialize(n)}},{key:"importJwkKey",value:function(e){var t;return e.d?t=Cr.fromJSON(e,{targetSchema:J.EcPrivateKey}):t=Cr.fromJSON(e,{targetSchema:J.EcPublicKey}),this.importEcKey(t,e.crv)}},{key:"exportJwkKey",value:function(e){var t=this.exportEcKey(e),n=Xr.toJSON(t);return n.ext=!0,n.key_ops=e.usages,n.crv=e.algorithm.namedCurve,n.kty="EC",n}},{key:"exportEcKey",value:function(e){if(e.type==="private"){var t=new J.EcPrivateKey,n=new Uint8Array(e.data.getPrivate("der").toArray()),a=new Uint8Array(this.getPointSize(e.algorithm.namedCurve)-n.length);return t.privateKey=Sa(a,n),t.publicKey=new Uint8Array(e.data.getPublic("der")),t}else{if(e.data.pub)return new J.EcPublicKey(new Uint8Array(e.data.getPublic("der")).buffer);throw new Error("Cannot get private or public key")}}},{key:"importEcKey",value:function(e,t){var n=this.initEcKey(t);return e instanceof J.EcPublicKey?n.keyFromPublic(new Uint8Array(e.value)):n.keyFromPrivate(new Uint8Array(e.privateKey))}},{key:"getPointSize",value:function(e){switch(e){case"P-256":case"K-256":return 32;case"P-384":return 48;case"P-521":return 66}throw new Error("namedCurve: Is not recognized")}}]),i})();Ke.privateUsages=["sign","deriveKey","deriveBits"],Ke.publicUsages=["verify"],Ke.ASN_ALGORITHM="1.2.840.10045.2.1";var Mu=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.namedCurves=["P-256","P-384","P-521","K-256","brainpoolP256r1","brainpoolP384r1","brainpoolP512r1"],e}return m(r,[{key:"onGenerateKey",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",Ke.generateKey(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onExportKey",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",Ke.exportKey(t,n));case 1:case"end":return s.stop()}},a)}))}},{key:"onImportKey",value:function(t,n,a,o,s){return A(this,void 0,void 0,h().mark(function u(){return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",Ke.importKey(t,n,a,o,s));case 1:case"end":return l.stop()}},u)}))}},{key:"onDeriveBits",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s,u,c,l;return h().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return Ke.checkLib(),s=n.data.derive(t.public.data.getPublic()),u=new Uint8Array(s.toArray()),c=u.length,c=c>32?c>48?66:48:32,u.length<c&&(u=Ke.concat(new Uint8Array(c-u.length),u)),l=u.slice(0,a/8).buffer,d.abrupt("return",l);case 8:case"end":return d.stop()}},o)}))}},{key:"checkCryptoKey",value:function(t,n){j(M(r.prototype),"checkCryptoKey",this).call(this,t,n),Ke.checkCryptoKey(t)}}]),r})(ea);function Vt(i){for(var r=new Uint8Array(i),e=[],t=0;t<r.length;t++)e.push(r[t]);return e}var _u=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512","SHA3-256","SHA3-384","SHA3-512"],e.namedCurves=["P-256","P-384","P-521","K-256","brainpoolP256r1","brainpoolP384r1","brainpoolP512r1"],e}return m(r,[{key:"onGenerateKey",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",Ke.generateKey(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onExportKey",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",Ke.exportKey(t,n));case 1:case"end":return s.stop()}},a)}))}},{key:"onImportKey",value:function(t,n,a,o,s){return A(this,void 0,void 0,h().mark(function u(){return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",Ke.importKey(t,n,a,o,s));case 1:case"end":return l.stop()}},u)}))}},{key:"onSign",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s,u,c,l,f;return h().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return Ke.checkLib(),s=new tt,v.next=4,s.subtle.digest(t.hash,a);case 4:return u=v.sent,c=Vt(u),v.next=8,n.data.sign(c);case 8:return l=v.sent,f=new J.EcDsaSignature,f.r=new Uint8Array(l.r.toArray()).buffer,f.s=new Uint8Array(l.s.toArray()).buffer,v.abrupt("return",f.toWebCryptoSignature());case 13:case"end":return v.stop()}},o)}))}},{key:"onVerify",value:function(t,n,a,o){return A(this,void 0,void 0,h().mark(function s(){var u,c,l,f;return h().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return Ke.checkLib(),u=new tt,c={r:new Uint8Array(a.slice(0,a.byteLength/2)),s:new Uint8Array(a.slice(a.byteLength/2))},v.next=5,u.subtle.digest(t.hash,o);case 5:return l=v.sent,f=Vt(l),v.abrupt("return",n.data.verify(f,c));case 8:case"end":return v.stop()}},s)}))}},{key:"checkCryptoKey",value:function(t,n){j(M(r.prototype),"checkCryptoKey",this).call(this,t,n),Ke.checkCryptoKey(t)}}]),r})(du),Ju=lr(lr(lr(lr(lr(lr(lr(lr({},J.idEd448,"Ed448"),"ed448",J.idEd448),J.idX448,"X448"),"x448",J.idX448),J.idEd25519,"Ed25519"),"ed25519",J.idEd25519),J.idX25519,"X25519"),"x25519",J.idX25519);function Ba(i){var r=Ju[i.toLowerCase()];if(!r)throw new X("Cannot convert WebCrypto named curve '".concat(i,"' to OID"));return r}var Ka=(function(i){b(r,i);function r(e,t,n,a){var o;return g(this,r),o=k(this,r,[e,t,"private",n]),o.data=a,o}return m(r,[{key:"toJSON",value:function(){var t={kty:"OKP",crv:this.algorithm.namedCurve,key_ops:this.usages,ext:this.extractable};return Object.assign(t,{d:L.ToBase64Url(L.FromHex(/^ed/i.test(t.crv)?this.data.getSecret("hex"):this.data.getPrivate("hex")))})}},{key:"fromJSON",value:function(t){if(!t.d)throw new X("Cannot get private data from JWK. Property 'd' is required");if(!t.crv)throw new X("Cannot get named curve from JWK. Property 'crv' is required");var n=L.ToHex(L.FromBase64Url(t.d));if(/^ed/i.test(t.crv)){var a=new Z.eddsa("ed25519");this.data=a.keyFromSecret(n)}else{var o=Z.ec(t.crv.replace(/^x/i,"curve"));this.data=o.keyFromPrivate(n,"hex")}return this}}]),r})($e),Ca=(function(i){b(r,i);function r(e,t,n,a){var o;return g(this,r),o=k(this,r,[e,t,"public",n]),o.data=a,o}return m(r,[{key:"toJSON",value:function(){var t={kty:"OKP",crv:this.algorithm.namedCurve,key_ops:this.usages,ext:this.extractable};return Object.assign(t,{x:L.ToBase64Url(L.FromHex(this.data.getPublic("hex")))})}},{key:"fromJSON",value:function(t){if(!t.crv)throw new X("Cannot get named curve from JWK. Property 'crv' is required");if(!t.x)throw new X("Cannot get property from JWK. Property 'x' is required");var n=L.ToHex(L.FromBase64Url(t.x));if(/^ed/i.test(t.crv)){var a=new Z.eddsa(t.crv.toLowerCase());this.data=a.keyFromPublic(n,"hex")}else{var o=Z.ec(t.crv.replace(/^x/i,"curve"));this.data=o.keyFromPublic(n,"hex")}return this}}]),r})($e),qe=(function(){function i(){g(this,i)}return m(i,null,[{key:"checkLib",value:function(){if(typeof Z>"u")throw new X("Cannot implement EC mechanism. Add 'https://peculiarventures.github.io/pv-webcrypto-tests/src/elliptic.js' script to your project")}},{key:"concat",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var a=new Uint8Array(t.map(function(s){return s.length}).reduce(function(s,u){return s+u})),o=0;return t.forEach(function(s){for(var u=0;u<s.length;u++)a[o+u]=s[u];o+=s.length}),a}},{key:"generateKey",value:function(e,t,n){return A(this,void 0,void 0,h().mark(function a(){var o=this,s,u,c,l,f,d;return h().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return this.checkLib(),s="ed25519",c=p.nativeCrypto.getRandomValues(new Uint8Array(32)),l=new Z.eddsa(s),u=l.keyFromSecret(c),f=new Ka(e,t,n.filter(function(S){return o.privateKeyUsages.indexOf(S)!==-1}),u),d=new Ca(e,!0,n.filter(function(S){return o.publicKeyUsages.indexOf(S)!==-1}),u),y.abrupt("return",{privateKey:f,publicKey:d});case 8:case"end":return y.stop()}},a,this)}))}},{key:"sign",value:function(e,t,n){return A(this,void 0,void 0,h().mark(function a(){var o,s;return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.checkLib(),o=Vt(n),s=t.data.sign(o).toHex(),c.abrupt("return",L.FromHex(s));case 4:case"end":return c.stop()}},a,this)}))}},{key:"verify",value:function(e,t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s,u;return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.checkLib(),s=Vt(a),u=t.data.verify(s,L.ToHex(n)),l.abrupt("return",u);case 4:case"end":return l.stop()}},o,this)}))}},{key:"deriveBits",value:function(e,t,n){return A(this,void 0,void 0,h().mark(function a(){var o,s,u,c,l,f,d,v,y;return h().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return this.checkLib(),o=new Uint8Array(L.FromHex(t.data.getSecret("hex"))),s=new Z.ec("curve25519"),u=s.keyFromPrivate(L.ToHex(o),"hex"),c=e.public.data.getPublic("hex"),new Uint8Array(L.FromHex(c)),l=e.public.data.getPublic(),f=u.derive(l),d=new Uint8Array(f.toArray()),v=d.length,v=v>32?v>48?66:48:32,d.length<v&&(d=i.concat(new Uint8Array(v-d.length),d)),y=d.slice(0,n/8).buffer,E.abrupt("return",y);case 14:case"end":return E.stop()}},a,this)}))}},{key:"exportKey",value:function(e,t){return A(this,void 0,void 0,h().mark(function n(){var a,o,s,u;return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:this.checkLib(),l.t0=e.toLowerCase(),l.next=l.t0==="jwk"?4:l.t0==="pkcs8"?5:l.t0==="spki"?10:l.t0==="raw"?15:16;break;case 4:return l.abrupt("return",Xr.toJSON(t));case 5:return a=L.FromHex(t.data.getSecret("hex")),o=new J.PrivateKeyInfo,o.privateKeyAlgorithm.algorithm=Ba(t.algorithm.namedCurve),o.privateKey=te.serialize(new Ko(a)),l.abrupt("return",te.serialize(o));case 10:return s=L.FromHex(t.data.getPublic("hex")),u=new J.PublicKeyInfo,u.publicKeyAlgorithm.algorithm=Ba(t.algorithm.namedCurve),u.publicKey=s,l.abrupt("return",te.serialize(u));case 15:return l.abrupt("return",L.FromHex(t.data.getPublic("hex")));case 16:throw new X("format: Must be 'jwk', 'raw', pkcs8' or 'spki'");case 17:case"end":return l.stop()}},n,this)}))}},{key:"importKey",value:function(e,t,n,a,o){return A(this,void 0,void 0,h().mark(function s(){var u,c,l,f,d;return h().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:this.checkLib(),y.t0=e.toLowerCase(),y.next=y.t0==="jwk"?4:y.t0==="raw"?13:y.t0==="spki"?14:y.t0==="pkcs8"?16:19;break;case 4:if(u=t,!u.d){y.next=10;break}return c=Cr.fromJSON(t,{targetSchema:J.CurvePrivateKey}),y.abrupt("return",this.importPrivateKey(c,n,a,o));case 10:if(u.x){y.next=12;break}throw new TypeError("keyData: Cannot get required 'x' field");case 12:return y.abrupt("return",this.importPublicKey(L.FromBase64Url(u.x),n,a,o));case 13:return y.abrupt("return",this.importPublicKey(t,n,a,o));case 14:return l=te.parse(new Uint8Array(t),J.PublicKeyInfo),y.abrupt("return",this.importPublicKey(l.publicKey,n,a,o));case 16:return f=te.parse(new Uint8Array(t),J.PrivateKeyInfo),d=te.parse(f.privateKey,J.CurvePrivateKey),y.abrupt("return",this.importPrivateKey(d,n,a,o));case 19:throw new X("format: Must be 'jwk', 'raw', 'pkcs8' or 'spki'");case 20:case"end":return y.stop()}},s,this)}))}},{key:"importPrivateKey",value:function(e,t,n,a){var o=new Ka(Object.assign({},t),n,a,null);return o.fromJSON({crv:t.namedCurve,d:L.ToBase64Url(e.d)}),o}},{key:"importPublicKey",value:function(e,t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s;return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return s=new Ca(Object.assign({},t),n,a,null),s.fromJSON({crv:t.namedCurve,x:L.ToBase64Url(e)}),c.abrupt("return",s);case 3:case"end":return c.stop()}},o)}))}}]),i})();qe.publicKeyUsages=["verify"],qe.privateKeyUsages=["sign","deriveKey","deriveBits"];var ju=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.namedCurves=["Ed25519"],e}return m(r,[{key:"onGenerateKey",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s;return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,qe.generateKey({name:this.name,namedCurve:t.namedCurve.replace(/^ed/i,"Ed")},n,a);case 2:return s=c.sent,c.abrupt("return",s);case 4:case"end":return c.stop()}},o,this)}))}},{key:"onSign",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",qe.sign(t,n,new Uint8Array(a)));case 1:case"end":return u.stop()}},o)}))}},{key:"onVerify",value:function(t,n,a,o){return A(this,void 0,void 0,h().mark(function s(){return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.abrupt("return",qe.verify(t,n,new Uint8Array(a),new Uint8Array(o)));case 1:case"end":return c.stop()}},s)}))}},{key:"onExportKey",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",qe.exportKey(t,n));case 1:case"end":return s.stop()}},a)}))}},{key:"onImportKey",value:function(t,n,a,o,s){return A(this,void 0,void 0,h().mark(function u(){var c;return h().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,qe.importKey(t,n,Object.assign(Object.assign({},a),{name:this.name}),o,s);case 2:return c=f.sent,f.abrupt("return",c);case 4:case"end":return f.stop()}},u,this)}))}}]),r})(wu),Gu=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.namedCurves=["X25519"],e}return m(r,[{key:"onGenerateKey",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s;return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,qe.generateKey({name:this.name,namedCurve:t.namedCurve.replace(/^x/i,"X")},n,a);case 2:return s=c.sent,c.abrupt("return",s);case 4:case"end":return c.stop()}},o,this)}))}},{key:"onDeriveBits",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s;return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,qe.deriveBits(Object.assign(Object.assign({},t),{public:t.public}),n,a);case 2:return s=c.sent,c.abrupt("return",s);case 4:case"end":return c.stop()}},o)}))}},{key:"onExportKey",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",qe.exportKey(t,n));case 1:case"end":return s.stop()}},a)}))}},{key:"onImportKey",value:function(t,n,a,o,s){return A(this,void 0,void 0,h().mark(function u(){var c;return h().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,qe.importKey(t,n,Object.assign(Object.assign({},a),{name:this.name}),o,s);case 2:return c=f.sent,f.abrupt("return",c);case 4:case"end":return f.stop()}},u,this)}))}}]),r})(mu),Bn=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="SHA-1",e.usages=[],e}return m(r,[{key:"onDigest",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",Tr.digest(t,n));case 1:case"end":return s.stop()}},a)}))}}]),r})(De),zu=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="SHA-256",e}return m(r)})(Bn),Wu=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="SHA-512",e}return m(r)})(Bn),Na=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Pe={},q={},Pa={};(function(i){Object.defineProperty(i,"__esModule",{value:!0});function r(s,u){var c=s>>>16&65535,l=s&65535,f=u>>>16&65535,d=u&65535;return l*d+(c*d+l*f<<16>>>0)|0}i.mul=Math.imul||r;function e(s,u){return s+u|0}i.add=e;function t(s,u){return s-u|0}i.sub=t;function n(s,u){return s<<u|s>>>32-u}i.rotl=n;function a(s,u){return s<<32-u|s>>>u}i.rotr=a;function o(s){return typeof s=="number"&&isFinite(s)&&Math.floor(s)===s}i.isInteger=Number.isInteger||o,i.MAX_SAFE_INTEGER=9007199254740991,i.isSafeInteger=function(s){return i.isInteger(s)&&s>=-i.MAX_SAFE_INTEGER&&s<=i.MAX_SAFE_INTEGER}})(Pa),Object.defineProperty(q,"__esModule",{value:!0});var Ua=Pa;function qu(i,r){return r===void 0&&(r=0),(i[r+0]<<8|i[r+1])<<16>>16}q.readInt16BE=qu;function Xu(i,r){return r===void 0&&(r=0),(i[r+0]<<8|i[r+1])>>>0}q.readUint16BE=Xu;function Yu(i,r){return r===void 0&&(r=0),(i[r+1]<<8|i[r])<<16>>16}q.readInt16LE=Yu;function Zu(i,r){return r===void 0&&(r=0),(i[r+1]<<8|i[r])>>>0}q.readUint16LE=Zu;function Oa(i,r,e){return r===void 0&&(r=new Uint8Array(2)),e===void 0&&(e=0),r[e+0]=i>>>8,r[e+1]=i>>>0,r}q.writeUint16BE=Oa,q.writeInt16BE=Oa;function Ia(i,r,e){return r===void 0&&(r=new Uint8Array(2)),e===void 0&&(e=0),r[e+0]=i>>>0,r[e+1]=i>>>8,r}q.writeUint16LE=Ia,q.writeInt16LE=Ia;function Kn(i,r){return r===void 0&&(r=0),i[r]<<24|i[r+1]<<16|i[r+2]<<8|i[r+3]}q.readInt32BE=Kn;function Cn(i,r){return r===void 0&&(r=0),(i[r]<<24|i[r+1]<<16|i[r+2]<<8|i[r+3])>>>0}q.readUint32BE=Cn;function Nn(i,r){return r===void 0&&(r=0),i[r+3]<<24|i[r+2]<<16|i[r+1]<<8|i[r]}q.readInt32LE=Nn;function Pn(i,r){return r===void 0&&(r=0),(i[r+3]<<24|i[r+2]<<16|i[r+1]<<8|i[r])>>>0}q.readUint32LE=Pn;function Ht(i,r,e){return r===void 0&&(r=new Uint8Array(4)),e===void 0&&(e=0),r[e+0]=i>>>24,r[e+1]=i>>>16,r[e+2]=i>>>8,r[e+3]=i>>>0,r}q.writeUint32BE=Ht,q.writeInt32BE=Ht;function Dt(i,r,e){return r===void 0&&(r=new Uint8Array(4)),e===void 0&&(e=0),r[e+0]=i>>>0,r[e+1]=i>>>8,r[e+2]=i>>>16,r[e+3]=i>>>24,r}q.writeUint32LE=Dt,q.writeInt32LE=Dt;function Qu(i,r){r===void 0&&(r=0);var e=Kn(i,r),t=Kn(i,r+4);return e*4294967296+t-(t>>31)*4294967296}q.readInt64BE=Qu;function es(i,r){r===void 0&&(r=0);var e=Cn(i,r),t=Cn(i,r+4);return e*4294967296+t}q.readUint64BE=es;function rs(i,r){r===void 0&&(r=0);var e=Nn(i,r),t=Nn(i,r+4);return t*4294967296+e-(e>>31)*4294967296}q.readInt64LE=rs;function ts(i,r){r===void 0&&(r=0);var e=Pn(i,r),t=Pn(i,r+4);return t*4294967296+e}q.readUint64LE=ts;function La(i,r,e){return r===void 0&&(r=new Uint8Array(8)),e===void 0&&(e=0),Ht(i/4294967296>>>0,r,e),Ht(i>>>0,r,e+4),r}q.writeUint64BE=La,q.writeInt64BE=La;function xa(i,r,e){return r===void 0&&(r=new Uint8Array(8)),e===void 0&&(e=0),Dt(i>>>0,r,e),Dt(i/4294967296>>>0,r,e+4),r}q.writeUint64LE=xa,q.writeInt64LE=xa;function ns(i,r,e){if(e===void 0&&(e=0),i%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(i/8>r.length-e)throw new Error("readUintBE: array is too short for the given bitLength");for(var t=0,n=1,a=i/8+e-1;a>=e;a--)t+=r[a]*n,n*=256;return t}q.readUintBE=ns;function is(i,r,e){if(e===void 0&&(e=0),i%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(i/8>r.length-e)throw new Error("readUintLE: array is too short for the given bitLength");for(var t=0,n=1,a=e;a<e+i/8;a++)t+=r[a]*n,n*=256;return t}q.readUintLE=is;function as(i,r,e,t){if(e===void 0&&(e=new Uint8Array(i/8)),t===void 0&&(t=0),i%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!Ua.isSafeInteger(r))throw new Error("writeUintBE value must be an integer");for(var n=1,a=i/8+t-1;a>=t;a--)e[a]=r/n&255,n*=256;return e}q.writeUintBE=as;function os(i,r,e,t){if(e===void 0&&(e=new Uint8Array(i/8)),t===void 0&&(t=0),i%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!Ua.isSafeInteger(r))throw new Error("writeUintLE value must be an integer");for(var n=1,a=t;a<t+i/8;a++)e[a]=r/n&255,n*=256;return e}q.writeUintLE=os;function us(i,r){r===void 0&&(r=0);var e=new DataView(i.buffer,i.byteOffset,i.byteLength);return e.getFloat32(r)}q.readFloat32BE=us;function ss(i,r){r===void 0&&(r=0);var e=new DataView(i.buffer,i.byteOffset,i.byteLength);return e.getFloat32(r,!0)}q.readFloat32LE=ss;function cs(i,r){r===void 0&&(r=0);var e=new DataView(i.buffer,i.byteOffset,i.byteLength);return e.getFloat64(r)}q.readFloat64BE=cs;function ls(i,r){r===void 0&&(r=0);var e=new DataView(i.buffer,i.byteOffset,i.byteLength);return e.getFloat64(r,!0)}q.readFloat64LE=ls;function fs(i,r,e){r===void 0&&(r=new Uint8Array(4)),e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.setFloat32(e,i),r}q.writeFloat32BE=fs;function hs(i,r,e){r===void 0&&(r=new Uint8Array(4)),e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.setFloat32(e,i,!0),r}q.writeFloat32LE=hs;function vs(i,r,e){r===void 0&&(r=new Uint8Array(8)),e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.setFloat64(e,i),r}q.writeFloat64BE=vs;function ps(i,r,e){r===void 0&&(r=new Uint8Array(8)),e===void 0&&(e=0);var t=new DataView(r.buffer,r.byteOffset,r.byteLength);return t.setFloat64(e,i,!0),r}q.writeFloat64LE=ps;var Un={};Object.defineProperty(Un,"__esModule",{value:!0});function ys(i){for(var r=0;r<i.length;r++)i[r]=0;return i}Un.wipe=ys;var dr=Na&&Na.__extends||(function(){var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,a){n.__proto__=a}||function(n,a){for(var o in a)a.hasOwnProperty(o)&&(n[o]=a[o])},i(e,t)};return function(r,e){i(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}})();Object.defineProperty(Pe,"__esModule",{value:!0});var Tt=q,$t=Un,On=(function(){function i(r){if(r===void 0&&(r=32),this.capacity=r,this._sh=new Int32Array(25),this._sl=new Int32Array(25),this._state=new Uint8Array(200),this._pos=0,this._finished=!1,this.clean=this.reset,r<=0||r>128)throw new Error("SHA3: incorrect capacity");this.blockSize=200-r}return i.prototype.reset=function(){return $t.wipe(this._sh),$t.wipe(this._sl),$t.wipe(this._state),this._pos=0,this._finished=!1,this},i.prototype.update=function(r){if(this._finished)throw new Error("SHA3: can't update because hash was finished");for(var e=0;e<r.length;e++)this._state[this._pos++]^=r[e],this._pos>=this.blockSize&&(Ln(this._sh,this._sl,this._state),this._pos=0);return this},i.prototype._padAndPermute=function(r){this._state[this._pos]^=r,this._state[this.blockSize-1]^=128,Ln(this._sh,this._sl,this._state),this._finished=!0,this._pos=0},i.prototype._squeeze=function(r){if(!this._finished)throw new Error("SHA3: squeezing before padAndPermute");for(var e=0;e<r.length;e++)this._pos===this.blockSize&&(Ln(this._sh,this._sl,this._state),this._pos=0),r[e]=this._state[this._pos++]},i})();Pe.Keccak=On;var $r=(function(i){dr(r,i);function r(e){e===void 0&&(e=32);var t=i.call(this,e*2)||this;return t.digestLength=e,t}return r.prototype.finish=function(e){return this._finished?this._pos=0:this._padAndPermute(6),this._squeeze(e),this},r.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},r.prototype.saveState=function(){if(this._finished)throw new Error("SHA3: cannot save finished state");return new Uint8Array(this._state.subarray(0,this._pos))},r.prototype.restoreState=function(e){return this._state.set(e),this._pos=e.length,this._finished=!1,this},r.prototype.cleanSavedState=function(e){$t.wipe(e)},r})(On);Pe.SHA3=$r;var ds=(function(i){dr(r,i);function r(){return i.call(this,224/8)||this}return r})($r);Pe.SHA3224=ds;var gs=(function(i){dr(r,i);function r(){return i.call(this,256/8)||this}return r})($r);Pe.SHA3256=gs;var ms=(function(i){dr(r,i);function r(){return i.call(this,384/8)||this}return r})($r);Pe.SHA3384=ms;var ws=(function(i){dr(r,i);function r(){return i.call(this,512/8)||this}return r})($r);Pe.SHA3512=ws;function rt(i,r){var e=new $r(i);e.update(r);var t=e.digest();return e.clean(),t}Pe.hash=rt,Pe.hash224=function(i){return rt(224/8,i)};var ks=Pe.hash256=function(i){return rt(256/8,i)},bs=Pe.hash384=function(i){return rt(384/8,i)},As=Pe.hash512=function(i){return rt(512/8,i)},In=(function(i){dr(r,i);function r(e){var t=i.call(this,e/8*2)||this;return t.bitSize=e,t}return r.prototype.stream=function(e){this._finished||this._padAndPermute(31),this._squeeze(e)},r})(On);Pe.SHAKE=In;var Ss=(function(i){dr(r,i);function r(){return i.call(this,128)||this}return r})(In),Es=Pe.SHAKE128=Ss,Bs=(function(i){dr(r,i);function r(){return i.call(this,256)||this}return r})(In),Ks=Pe.SHAKE256=Bs,Cs=new Int32Array([0,0,2147483648,2147483648,0,0,2147483648,2147483648,0,0,0,0,0,2147483648,2147483648,2147483648,2147483648,2147483648,0,2147483648,2147483648,2147483648,0,2147483648]),Ns=new Int32Array([1,32898,32906,2147516416,32907,2147483649,2147516545,32777,138,136,2147516425,2147483658,2147516555,139,32905,32771,32770,128,32778,2147483658,2147516545,32896,2147483649,2147516424]);function Ln(i,r,e){for(var t,n,a,o,s,u,c,l,f,d,v,y,S=0;S<25;S++)r[S]=Tt.readUint32LE(e,S*8),i[S]=Tt.readUint32LE(e,S*8+4);for(var E=0;E<24;E++)t=i[0]^i[5]^i[10]^i[15]^i[20],n=i[1]^i[6]^i[11]^i[16]^i[21],a=i[2]^i[7]^i[12]^i[17]^i[22],o=i[3]^i[8]^i[13]^i[18]^i[23],s=i[4]^i[9]^i[14]^i[19]^i[24],u=r[0]^r[5]^r[10]^r[15]^r[20],c=r[1]^r[6]^r[11]^r[16]^r[21],l=r[2]^r[7]^r[12]^r[17]^r[22],f=r[3]^r[8]^r[13]^r[18]^r[23],d=r[4]^r[9]^r[14]^r[19]^r[24],v=s^(n<<1|c>>>31),y=d^(c<<1|n>>>31),i[0]^=v,i[5]^=v,i[10]^=v,i[15]^=v,i[20]^=v,r[0]^=y,r[5]^=y,r[10]^=y,r[15]^=y,r[20]^=y,v=t^(a<<1|l>>>31),y=u^(l<<1|a>>>31),i[1]^=v,i[6]^=v,i[11]^=v,i[16]^=v,i[21]^=v,r[1]^=y,r[6]^=y,r[11]^=y,r[16]^=y,r[21]^=y,v=n^(o<<1|f>>>31),y=c^(f<<1|o>>>31),i[2]^=v,i[7]^=v,i[12]^=v,i[17]^=v,i[22]^=v,r[2]^=y,r[7]^=y,r[12]^=y,r[17]^=y,r[22]^=y,v=a^(s<<1|d>>>31),y=l^(d<<1|s>>>31),i[3]^=v,r[3]^=y,i[8]^=v,r[8]^=y,i[13]^=v,r[13]^=y,i[18]^=v,r[18]^=y,i[23]^=v,r[23]^=y,v=o^(t<<1|u>>>31),y=f^(u<<1|t>>>31),i[4]^=v,i[9]^=v,i[14]^=v,i[19]^=v,i[24]^=v,r[4]^=y,r[9]^=y,r[14]^=y,r[19]^=y,r[24]^=y,v=i[1],y=r[1],t=i[10],u=r[10],i[10]=v<<1|y>>>31,r[10]=y<<1|v>>>31,v=t,y=u,t=i[7],u=r[7],i[7]=v<<3|y>>>29,r[7]=y<<3|v>>>29,v=t,y=u,t=i[11],u=r[11],i[11]=v<<6|y>>>26,r[11]=y<<6|v>>>26,v=t,y=u,t=i[17],u=r[17],i[17]=v<<10|y>>>22,r[17]=y<<10|v>>>22,v=t,y=u,t=i[18],u=r[18],i[18]=v<<15|y>>>17,r[18]=y<<15|v>>>17,v=t,y=u,t=i[3],u=r[3],i[3]=v<<21|y>>>11,r[3]=y<<21|v>>>11,v=t,y=u,t=i[5],u=r[5],i[5]=v<<28|y>>>4,r[5]=y<<28|v>>>4,v=t,y=u,t=i[16],u=r[16],i[16]=y<<4|v>>>28,r[16]=v<<4|y>>>28,v=t,y=u,t=i[8],u=r[8],i[8]=y<<13|v>>>19,r[8]=v<<13|y>>>19,v=t,y=u,t=i[21],u=r[21],i[21]=y<<23|v>>>9,r[21]=v<<23|y>>>9,v=t,y=u,t=i[24],u=r[24],i[24]=v<<2|y>>>30,r[24]=y<<2|v>>>30,v=t,y=u,t=i[4],u=r[4],i[4]=v<<14|y>>>18,r[4]=y<<14|v>>>18,v=t,y=u,t=i[15],u=r[15],i[15]=v<<27|y>>>5,r[15]=y<<27|v>>>5,v=t,y=u,t=i[23],u=r[23],i[23]=y<<9|v>>>23,r[23]=v<<9|y>>>23,v=t,y=u,t=i[19],u=r[19],i[19]=y<<24|v>>>8,r[19]=v<<24|y>>>8,v=t,y=u,t=i[13],u=r[13],i[13]=v<<8|y>>>24,r[13]=y<<8|v>>>24,v=t,y=u,t=i[12],u=r[12],i[12]=v<<25|y>>>7,r[12]=y<<25|v>>>7,v=t,y=u,t=i[2],u=r[2],i[2]=y<<11|v>>>21,r[2]=v<<11|y>>>21,v=t,y=u,t=i[20],u=r[20],i[20]=y<<30|v>>>2,r[20]=v<<30|y>>>2,v=t,y=u,t=i[14],u=r[14],i[14]=v<<18|y>>>14,r[14]=y<<18|v>>>14,v=t,y=u,t=i[22],u=r[22],i[22]=y<<7|v>>>25,r[22]=v<<7|y>>>25,v=t,y=u,t=i[9],u=r[9],i[9]=y<<29|v>>>3,r[9]=v<<29|y>>>3,v=t,y=u,t=i[6],u=r[6],i[6]=v<<20|y>>>12,r[6]=y<<20|v>>>12,v=t,y=u,t=i[1],u=r[1],i[1]=y<<12|v>>>20,r[1]=v<<12|y>>>20,v=t,y=u,t=i[0],n=i[1],a=i[2],o=i[3],s=i[4],i[0]^=~n&a,i[1]^=~a&o,i[2]^=~o&s,i[3]^=~s&t,i[4]^=~t&n,u=r[0],c=r[1],l=r[2],f=r[3],d=r[4],r[0]^=~c&l,r[1]^=~l&f,r[2]^=~f&d,r[3]^=~d&u,r[4]^=~u&c,t=i[5],n=i[6],a=i[7],o=i[8],s=i[9],i[5]^=~n&a,i[6]^=~a&o,i[7]^=~o&s,i[8]^=~s&t,i[9]^=~t&n,u=r[5],c=r[6],l=r[7],f=r[8],d=r[9],r[5]^=~c&l,r[6]^=~l&f,r[7]^=~f&d,r[8]^=~d&u,r[9]^=~u&c,t=i[10],n=i[11],a=i[12],o=i[13],s=i[14],i[10]^=~n&a,i[11]^=~a&o,i[12]^=~o&s,i[13]^=~s&t,i[14]^=~t&n,u=r[10],c=r[11],l=r[12],f=r[13],d=r[14],r[10]^=~c&l,r[11]^=~l&f,r[12]^=~f&d,r[13]^=~d&u,r[14]^=~u&c,t=i[15],n=i[16],a=i[17],o=i[18],s=i[19],i[15]^=~n&a,i[16]^=~a&o,i[17]^=~o&s,i[18]^=~s&t,i[19]^=~t&n,u=r[15],c=r[16],l=r[17],f=r[18],d=r[19],r[15]^=~c&l,r[16]^=~l&f,r[17]^=~f&d,r[18]^=~d&u,r[19]^=~u&c,t=i[20],n=i[21],a=i[22],o=i[23],s=i[24],i[20]^=~n&a,i[21]^=~a&o,i[22]^=~o&s,i[23]^=~s&t,i[24]^=~t&n,u=r[20],c=r[21],l=r[22],f=r[23],d=r[24],r[20]^=~c&l,r[21]^=~l&f,r[22]^=~f&d,r[23]^=~d&u,r[24]^=~u&c,i[0]^=Cs[E],r[0]^=Ns[E];for(var S=0;S<25;S++)Tt.writeUint32LE(r[S],e,S*8),Tt.writeUint32LE(i[S],e,S*8+4)}var Ps=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="SHA3-256",e.usages=[],e}return m(r,[{key:"onDigest",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",ks(new Uint8Array(n)).buffer);case 1:case"end":return s.stop()}},a)}))}}]),r})(De),Us=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="SHA3-384",e.usages=[],e}return m(r,[{key:"onDigest",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",bs(new Uint8Array(n)).buffer);case 1:case"end":return s.stop()}},a)}))}}]),r})(De),Os=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.name="SHA3-512",e.usages=[],e}return m(r,[{key:"onDigest",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",As(new Uint8Array(n)).buffer);case 1:case"end":return s.stop()}},a)}))}}]),r})(De),Is=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"onDigest",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){var o;return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return o=new Uint8Array(t.length),new Es().update(new Uint8Array(n)).stream(o),u.abrupt("return",o.buffer);case 3:case"end":return u.stop()}},a)}))}}]),r})(Cu),Ls=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"onDigest",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){var o;return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return o=new Uint8Array(t.length),new Ks().update(new Uint8Array(n)).stream(o),u.abrupt("return",o.buffer);case 3:case"end":return u.stop()}},a)}))}}]),r})(Nu),Ra=(function(i){b(r,i);function r(e,t,n,a){var o;return g(this,r),o=k(this,r,[e,t,"secret",n]),o.raw=a,o}return m(r)})($e),xs=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"onImportKey",value:function(t,n,a,o,s){return A(this,void 0,void 0,h().mark(function u(){return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",new Ra(a,o,s,K.toUint8Array(n)));case 1:case"end":return l.stop()}},u)}))}},{key:"onDeriveBits",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s,u,c;return h().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:u=K.toUint8Array(t.salt),c=n.raw,f.t0=t.hash.name.toUpperCase(),f.next=f.t0==="SHA-1"?5:f.t0==="SHA-256"?7:f.t0==="SHA-512"?9:11;break;case 5:return s=D.Pbkdf2HmacSha1(c,u,t.iterations,a>>3),f.abrupt("break",12);case 7:return s=D.Pbkdf2HmacSha256(c,u,t.iterations,a>>3),f.abrupt("break",12);case 9:return s=D.Pbkdf2HmacSha512(c,u,t.iterations,a>>3),f.abrupt("break",12);case 11:throw new X("algorithm.hash: '".concat(t.hash.name,"' hash algorithm is not supported"));case 12:return f.abrupt("return",K.toArrayBuffer(s));case 13:case"end":return f.stop()}},o)}))}},{key:"checkCryptoKey",value:function(t,n){if(j(M(r.prototype),"checkCryptoKey",this).call(this,t,n),!(t instanceof Ra))throw new TypeError("key: Is not PbkdfCryptoKey")}}]),r})(Ku),Pr={},Le={};Le.readUInt32BE=function(r,e){var t=r[0+e]<<24|r[1+e]<<16|r[2+e]<<8|r[3+e];return t>>>0},Le.writeUInt32BE=function(r,e,t){r[0+t]=e>>>24,r[1+t]=e>>>16&255,r[2+t]=e>>>8&255,r[3+t]=e&255},Le.ip=function(r,e,t,n){for(var a=0,o=0,s=6;s>=0;s-=2){for(var u=0;u<=24;u+=8)a<<=1,a|=e>>>u+s&1;for(var u=0;u<=24;u+=8)a<<=1,a|=r>>>u+s&1}for(var s=6;s>=0;s-=2){for(var u=1;u<=25;u+=8)o<<=1,o|=e>>>u+s&1;for(var u=1;u<=25;u+=8)o<<=1,o|=r>>>u+s&1}t[n+0]=a>>>0,t[n+1]=o>>>0},Le.rip=function(r,e,t,n){for(var a=0,o=0,s=0;s<4;s++)for(var u=24;u>=0;u-=8)a<<=1,a|=e>>>u+s&1,a<<=1,a|=r>>>u+s&1;for(var s=4;s<8;s++)for(var u=24;u>=0;u-=8)o<<=1,o|=e>>>u+s&1,o<<=1,o|=r>>>u+s&1;t[n+0]=a>>>0,t[n+1]=o>>>0},Le.pc1=function(r,e,t,n){for(var a=0,o=0,s=7;s>=5;s--){for(var u=0;u<=24;u+=8)a<<=1,a|=e>>u+s&1;for(var u=0;u<=24;u+=8)a<<=1,a|=r>>u+s&1}for(var u=0;u<=24;u+=8)a<<=1,a|=e>>u+s&1;for(var s=1;s<=3;s++){for(var u=0;u<=24;u+=8)o<<=1,o|=e>>u+s&1;for(var u=0;u<=24;u+=8)o<<=1,o|=r>>u+s&1}for(var u=0;u<=24;u+=8)o<<=1,o|=r>>u+s&1;t[n+0]=a>>>0,t[n+1]=o>>>0},Le.r28shl=function(r,e){return r<<e&268435455|r>>>28-e};var Ft=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];Le.pc2=function(r,e,t,n){for(var a=0,o=0,s=Ft.length>>>1,u=0;u<s;u++)a<<=1,a|=r>>>Ft[u]&1;for(var u=s;u<Ft.length;u++)o<<=1,o|=e>>>Ft[u]&1;t[n+0]=a>>>0,t[n+1]=o>>>0},Le.expand=function(r,e,t){var n=0,a=0;n=(r&1)<<5|r>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=r>>>o&63;for(var o=11;o>=3;o-=4)a|=r>>>o&63,a<<=6;a|=(r&31)<<1|r>>>31,e[t+0]=n>>>0,e[t+1]=a>>>0};var Va=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];Le.substitute=function(r,e){for(var t=0,n=0;n<4;n++){var a=r>>>18-n*6&63,o=Va[n*64+a];t<<=4,t|=o}for(var n=0;n<4;n++){var a=e>>>18-n*6&63,o=Va[256+n*64+a];t<<=4,t|=o}return t>>>0};var Ha=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];Le.permute=function(r){for(var e=0,t=0;t<Ha.length;t++)e<<=1,e|=r>>>Ha[t]&1;return e>>>0},Le.padSplit=function(r,e,t){for(var n=r.toString(2);n.length<e;)n="0"+n;for(var a=[],o=0;o<e;o+=t)a.push(n.slice(o,o+t));return a.join(" ")};var Mt=Da;function Da(i,r){if(!i)throw new Error(r||"Assertion failed")}Da.equal=function(r,e,t){if(r!=e)throw new Error(t||"Assertion failed: "+r+" != "+e)};var Rs=Mt;function Fe(i){this.options=i,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0,this.padding=i.padding!==!1}var xn=Fe;Fe.prototype._init=function(){},Fe.prototype.update=function(r){return r.length===0?[]:this.type==="decrypt"?this._updateDecrypt(r):this._updateEncrypt(r)},Fe.prototype._buffer=function(r,e){for(var t=Math.min(this.buffer.length-this.bufferOff,r.length-e),n=0;n<t;n++)this.buffer[this.bufferOff+n]=r[e+n];return this.bufferOff+=t,t},Fe.prototype._flushBuffer=function(r,e){return this._update(this.buffer,0,r,e),this.bufferOff=0,this.blockSize},Fe.prototype._updateEncrypt=function(r){var e=0,t=0,n=(this.bufferOff+r.length)/this.blockSize|0,a=new Array(n*this.blockSize);this.bufferOff!==0&&(e+=this._buffer(r,e),this.bufferOff===this.buffer.length&&(t+=this._flushBuffer(a,t)));for(var o=r.length-(r.length-e)%this.blockSize;e<o;e+=this.blockSize)this._update(r,e,a,t),t+=this.blockSize;for(;e<r.length;e++,this.bufferOff++)this.buffer[this.bufferOff]=r[e];return a},Fe.prototype._updateDecrypt=function(r){for(var e=0,t=0,n=Math.ceil((this.bufferOff+r.length)/this.blockSize)-1,a=new Array(n*this.blockSize);n>0;n--)e+=this._buffer(r,e),t+=this._flushBuffer(a,t);return e+=this._buffer(r,e),a},Fe.prototype.final=function(r){var e;r&&(e=this.update(r));var t;return this.type==="encrypt"?t=this._finalEncrypt():t=this._finalDecrypt(),e?e.concat(t):t},Fe.prototype._pad=function(r,e){if(e===0)return!1;for(;e<r.length;)r[e++]=0;return!0},Fe.prototype._finalEncrypt=function(){if(!this._pad(this.buffer,this.bufferOff))return[];var r=new Array(this.blockSize);return this._update(this.buffer,0,r,0),r},Fe.prototype._unpad=function(r){return r},Fe.prototype._finalDecrypt=function(){Rs.equal(this.bufferOff,this.blockSize,"Not enough data to decrypt");var r=new Array(this.blockSize);return this._flushBuffer(r,0),this._unpad(r)};var Rn={exports:{}},_t={exports:{}},Ta;function Vs(){return Ta||(Ta=1,typeof Object.create=="function"?_t.exports=function(r,e){e&&(r.super_=e,r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:_t.exports=function(r,e){if(e){r.super_=e;var t=function(){};t.prototype=e.prototype,r.prototype=new t,r.prototype.constructor=r}}),_t.exports}try{var $a=require("util");if(typeof $a.inherits!="function")throw"";Rn.exports=$a.inherits}catch{Rn.exports=Vs()}var Vn=Rn.exports,Fa=Mt,Hs=Vn,de=Le,Ma=xn;function Ds(){this.tmp=new Array(2),this.keys=null}function Ze(i){Ma.call(this,i);var r=new Ds;this._desState=r,this.deriveKeys(r,i.key)}Hs(Ze,Ma);var _a=Ze;Ze.create=function(r){return new Ze(r)};var Ts=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];Ze.prototype.deriveKeys=function(r,e){r.keys=new Array(32),Fa.equal(e.length,this.blockSize,"Invalid key length");var t=de.readUInt32BE(e,0),n=de.readUInt32BE(e,4);de.pc1(t,n,r.tmp,0),t=r.tmp[0],n=r.tmp[1];for(var a=0;a<r.keys.length;a+=2){var o=Ts[a>>>1];t=de.r28shl(t,o),n=de.r28shl(n,o),de.pc2(t,n,r.keys,a)}},Ze.prototype._update=function(r,e,t,n){var a=this._desState,o=de.readUInt32BE(r,e),s=de.readUInt32BE(r,e+4);de.ip(o,s,a.tmp,0),o=a.tmp[0],s=a.tmp[1],this.type==="encrypt"?this._encrypt(a,o,s,a.tmp,0):this._decrypt(a,o,s,a.tmp,0),o=a.tmp[0],s=a.tmp[1],de.writeUInt32BE(t,o,n),de.writeUInt32BE(t,s,n+4)},Ze.prototype._pad=function(r,e){if(this.padding===!1)return!1;for(var t=r.length-e,n=e;n<r.length;n++)r[n]=t;return!0},Ze.prototype._unpad=function(r){if(this.padding===!1)return r;for(var e=r[r.length-1],t=r.length-e;t<r.length;t++)Fa.equal(r[t],e);return r.slice(0,r.length-e)},Ze.prototype._encrypt=function(r,e,t,n,a){for(var o=e,s=t,u=0;u<r.keys.length;u+=2){var c=r.keys[u],l=r.keys[u+1];de.expand(s,r.tmp,0),c^=r.tmp[0],l^=r.tmp[1];var f=de.substitute(c,l),d=de.permute(f),v=s;s=(o^d)>>>0,o=v}de.rip(s,o,n,a)},Ze.prototype._decrypt=function(r,e,t,n,a){for(var o=t,s=e,u=r.keys.length-2;u>=0;u-=2){var c=r.keys[u],l=r.keys[u+1];de.expand(o,r.tmp,0),c^=r.tmp[0],l^=r.tmp[1];var f=de.substitute(c,l),d=de.permute(f),v=o;o=(s^d)>>>0,s=v}de.rip(o,s,n,a)};var Ja={},$s=Mt,Fs=Vn,Jt={};function Ms(i){$s.equal(i.length,8,"Invalid IV length"),this.iv=new Array(8);for(var r=0;r<this.iv.length;r++)this.iv[r]=i[r]}function _s(i){function r(a){i.call(this,a),this._cbcInit()}Fs(r,i);for(var e=Object.keys(Jt),t=0;t<e.length;t++){var n=e[t];r.prototype[n]=Jt[n]}return r.create=function(o){return new r(o)},r}Ja.instantiate=_s,Jt._cbcInit=function(){var r=new Ms(this.options.iv);this._cbcState=r},Jt._update=function(r,e,t,n){var a=this._cbcState,o=this.constructor.super_.prototype,s=a.iv;if(this.type==="encrypt"){for(var u=0;u<this.blockSize;u++)s[u]^=r[e+u];o._update.call(this,s,0,t,n);for(var u=0;u<this.blockSize;u++)s[u]=t[n+u]}else{o._update.call(this,r,e,t,n);for(var u=0;u<this.blockSize;u++)t[n+u]^=s[u];for(var u=0;u<this.blockSize;u++)s[u]=r[e+u]}};var Js=Mt,js=Vn,ja=xn,gr=_a;function Gs(i,r){Js.equal(r.length,24,"Invalid key length");var e=r.slice(0,8),t=r.slice(8,16),n=r.slice(16,24);i==="encrypt"?this.ciphers=[gr.create({type:"encrypt",key:e}),gr.create({type:"decrypt",key:t}),gr.create({type:"encrypt",key:n})]:this.ciphers=[gr.create({type:"decrypt",key:n}),gr.create({type:"encrypt",key:t}),gr.create({type:"decrypt",key:e})]}function Ur(i){ja.call(this,i);var r=new Gs(this.type,this.options.key);this._edeState=r}js(Ur,ja);var zs=Ur;Ur.create=function(r){return new Ur(r)},Ur.prototype._update=function(r,e,t,n){var a=this._edeState;a.ciphers[0]._update(r,e,t,n),a.ciphers[1]._update(t,n,t,n),a.ciphers[2]._update(t,n,t,n)},Ur.prototype._pad=gr.prototype._pad,Ur.prototype._unpad=gr.prototype._unpad;var Ws=Pr.utils=Le,qs=Pr.Cipher=xn,Ga=Pr.DES=_a,Hn=Pr.CBC=Ja,za=Pr.EDE=zs,Xs=H({__proto__:null,CBC:Hn,Cipher:qs,DES:Ga,EDE:za,default:Pr,utils:Ws},[Pr]),Dn=(function(i){b(r,i);function r(e,t,n,a){var o;return g(this,r),o=k(this,r,[e,t,"secret",n]),o.raw=a,o}return m(r,[{key:"toJSON",value:function(){var t={kty:"oct",alg:this.getJwkAlgorithm(),k:L.ToBase64Url(this.raw),ext:this.extractable,key_ops:this.usages};return t}},{key:"getJwkAlgorithm",value:function(){switch(this.algorithm.name.toUpperCase()){case"DES-CBC":return"DES-CBC";case"DES-EDE3-CBC":return"3DES-CBC";default:throw new Yr("Unsupported algorithm name")}}}]),r})($e),Me=(function(){function i(){g(this,i)}return m(i,null,[{key:"checkLib",value:function(){if(typeof Xs>"u")throw new X("Cannot implement DES mechanism. Add 'https://peculiarventures.github.io/pv-webcrypto-tests/src/des.js' script to your project")}},{key:"checkCryptoKey",value:function(e){if(!(e instanceof Dn))throw new TypeError("key: Is not DesCryptoKey")}},{key:"generateKey",value:function(e,t,n){return A(this,void 0,void 0,h().mark(function a(){var o;return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.checkLib(),o=p.nativeCrypto.getRandomValues(new Uint8Array(e.length/8)),u.abrupt("return",new Dn(e,t,n,o));case 3:case"end":return u.stop()}},a,this)}))}},{key:"exportKey",value:function(e,t){return A(this,void 0,void 0,h().mark(function n(){return h().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:this.checkLib(),o.t0=e,o.next=o.t0==="jwk"?4:o.t0==="raw"?5:6;break;case 4:return o.abrupt("return",t.toJSON());case 5:return o.abrupt("return",t.raw.buffer);case 6:throw new X("format: Must be 'jwk' or 'raw'");case 7:case"end":return o.stop()}},n,this)}))}},{key:"importKey",value:function(e,t,n,a,o){return A(this,void 0,void 0,h().mark(function s(){var u,c;return h().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(this.checkLib(),pn(t)?u=L.FromBase64Url(t.k):u=K.toArrayBuffer(t),!(n.name==="DES-CBC"&&u.byteLength!==8||n.name==="DES-EDE3-CBC"&&u.byteLength!==24)){f.next=4;break}throw new X("keyData: Is wrong key length");case 4:return c=new Dn({name:n.name,length:u.byteLength<<3},a,o,new Uint8Array(u)),f.abrupt("return",c);case 6:case"end":return f.stop()}},s,this)}))}},{key:"encrypt",value:function(e,t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",this.cipher(e,t,n,!0));case 1:case"end":return s.stop()}},a,this)}))}},{key:"decrypt",value:function(e,t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",this.cipher(e,t,n,!1));case 1:case"end":return s.stop()}},a,this)}))}},{key:"cipher",value:function(e,t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s,u,c,l;return h().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:this.checkLib(),s=a?"encrypt":"decrypt",c=K.toUint8Array(e.iv),d.t0=e.name.toUpperCase(),d.next=d.t0==="DES-CBC"?6:d.t0==="DES-EDE3-CBC"?8:10;break;case 6:return u=Hn.instantiate(Ga).create({key:t.raw,type:s,iv:c}),d.abrupt("break",11);case 8:return u=Hn.instantiate(za).create({key:t.raw,type:s,iv:c}),d.abrupt("break",11);case 10:throw new X("algorithm: Is not recognized");case 11:return l=u.update(new Uint8Array(n)).concat(u.final()),d.abrupt("return",new Uint8Array(l).buffer);case 13:case"end":return d.stop()}},o,this)}))}}]),i})(),Ys=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.keySizeBits=64,e.ivSize=8,e.name="DES-CBC",e}return m(r,[{key:"onGenerateKey",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",Me.generateKey(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onExportKey",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",Me.exportKey(t,n));case 1:case"end":return s.stop()}},a)}))}},{key:"onImportKey",value:function(t,n,a,o,s){return A(this,void 0,void 0,h().mark(function u(){return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",Me.importKey(t,n,a,o,s));case 1:case"end":return l.stop()}},u)}))}},{key:"onEncrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",Me.encrypt(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onDecrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",Me.decrypt(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"checkCryptoKey",value:function(t,n){j(M(r.prototype),"checkCryptoKey",this).call(this,t,n),Me.checkCryptoKey(t)}}]),r})(Qi),Zs=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.keySizeBits=192,e.ivSize=8,e.name="DES-EDE3-CBC",e}return m(r,[{key:"onGenerateKey",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",Me.generateKey(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onExportKey",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){return h().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return s.abrupt("return",Me.exportKey(t,n));case 1:case"end":return s.stop()}},a)}))}},{key:"onImportKey",value:function(t,n,a,o,s){return A(this,void 0,void 0,h().mark(function u(){return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",Me.importKey(t,n,a,o,s));case 1:case"end":return l.stop()}},u)}))}},{key:"onEncrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",Me.encrypt(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"onDecrypt",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",Me.decrypt(t,n,a));case 1:case"end":return u.stop()}},o)}))}},{key:"checkCryptoKey",value:function(t,n){j(M(r.prototype),"checkCryptoKey",this).call(this,t,n),Me.checkCryptoKey(t)}}]),r})(Qi),Qs={fromJSON:function(r){return Buffer.from(L.FromBase64Url(r))},toJSON:function(r){return L.ToBase64Url(r)}},cr=(function(i){b(r,i);function r(){var e,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{name:"HMAC"},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:new Uint8Array(0);return g(this,r),e=k(this,r,[t,n,"secret",a]),e.kty="oct",e.data=o,e}return m(r,[{key:"alg",get:function(){var t=this.algorithm.hash.name.toUpperCase();return"HS".concat(t.replace("SHA-",""))},set:function(t){}}]),r})($e);W([Be({name:"ext",type:ye.Boolean,optional:!0})],cr.prototype,"extractable",void 0),W([Be({name:"key_ops",type:ye.String,repeated:!0,optional:!0})],cr.prototype,"usages",void 0),W([Be({name:"k",converter:Qs})],cr.prototype,"data",void 0),W([Be({type:ye.String})],cr.prototype,"kty",void 0),W([Be({type:ye.String})],cr.prototype,"alg",null);var ec=(function(i){b(r,i);function r(){return g(this,r),k(this,r,arguments)}return m(r,[{key:"onGenerateKey",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s,u,c;return h().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return s=t.length||this.getDefaultLength(t.hash.name),u=p.nativeCrypto.getRandomValues(new Uint8Array(s>>3)),c=new cr(t,n,a,u),f.abrupt("return",c);case 4:case"end":return f.stop()}},o,this)}))}},{key:"onSign",value:function(t,n,a){return A(this,void 0,void 0,h().mark(function o(){var s,u;return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:l.t0=n.algorithm.hash.name.toUpperCase(),l.next=l.t0==="SHA-1"?3:l.t0==="SHA-256"?5:l.t0==="SHA-512"?7:9;break;case 3:return s=D.HmacSha1,l.abrupt("break",10);case 5:return s=D.HmacSha256,l.abrupt("break",10);case 7:return s=D.HmacSha512,l.abrupt("break",10);case 9:throw new X("key.algorithm.hash: Is not recognized");case 10:return u=new s(n.data).process(K.toUint8Array(a)).finish().result,l.abrupt("return",K.toArrayBuffer(u));case 12:case"end":return l.stop()}},o)}))}},{key:"onVerify",value:function(t,n,a,o){return A(this,void 0,void 0,h().mark(function s(){var u;return h().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,this.onSign(t,n,o);case 2:return u=l.sent,l.abrupt("return",L.ToHex(u)===L.ToHex(a));case 4:case"end":return l.stop()}},s,this)}))}},{key:"onImportKey",value:function(t,n,a,o,s){return A(this,void 0,void 0,h().mark(function u(){var c;return h().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:f.t0=t.toLowerCase(),f.next=f.t0==="jwk"?3:f.t0==="raw"?5:9;break;case 3:return c=Cr.fromJSON(n,{targetSchema:cr}),f.abrupt("break",10);case 5:if(K.isBufferSource(n)){f.next=7;break}throw new TypeError("keyData: Is not ArrayBuffer or ArrayBufferView");case 7:return c=new cr(a,o,s,K.toUint8Array(n)),f.abrupt("break",10);case 9:throw new X("format: Must be 'jwk' or 'raw'");case 10:return c.algorithm={hash:{name:a.hash.name},name:this.name,length:c.data.length<<3},c.extractable=o,c.usages=s,f.abrupt("return",c);case 14:case"end":return f.stop()}},u,this)}))}},{key:"onExportKey",value:function(t,n){return A(this,void 0,void 0,h().mark(function a(){var o;return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:u.t0=t.toLowerCase(),u.next=u.t0==="jwk"?3:u.t0==="raw"?5:6;break;case 3:return o=Xr.toJSON(n),u.abrupt("return",o);case 5:return u.abrupt("return",new Uint8Array(n.data).buffer);case 6:throw new X("format: Must be 'jwk' or 'raw'");case 7:case"end":return u.stop()}},a)}))}},{key:"checkCryptoKey",value:function(t,n){if(j(M(r.prototype),"checkCryptoKey",this).call(this,t,n),!(t instanceof cr))throw new TypeError("key: Is not HMAC CryptoKey")}}]),r})(Bu),jt,Tn=(function(i){b(r,i);function r(e,t,n,a,o){var s;return g(this,r),s=k(this,r,[e,t,n,a]),jt.set(_n(s),void 0),Zo(_n(s),jt,o,"f"),s}return m(r,[{key:"getNative",value:function(){return Yo(this,jt,"f")}}]),r})($e);jt=new WeakMap;var Wa=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r),e.browserInfo=Ou(),e.providers.set(new Iu),e.providers.set(new Ru),e.providers.set(new Lu),e.providers.set(new xu),e.providers.set(new Vu),e.providers.set(new Ys),e.providers.set(new Zs),e.providers.set(new Tu),e.providers.set(new Du),e.providers.set(new Hu),e.providers.set(new $u),e.providers.set(new _u),e.providers.set(new Mu),e.providers.set(new Bn),e.providers.set(new zu),e.providers.set(new Wu),e.providers.set(new xs),e.providers.set(new ec),e.providers.set(new ju),e.providers.set(new Gu),e.providers.set(new Ps),e.providers.set(new Us),e.providers.set(new Os),e.providers.set(new Is),e.providers.set(new Ls),e}return m(r,[{key:"digest",value:function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.wrapNative.apply(this,["digest"].concat(n)));case 1:case"end":return u.stop()}},o,this)}))}},{key:"importKey",value:function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.fixFirefoxEcImportPkcs8(n),u.abrupt("return",this.wrapNative.apply(this,["importKey"].concat(n)));case 2:case"end":return u.stop()}},o,this)}))}},{key:"exportKey",value:function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,this.fixFirefoxEcExportPkcs8(n);case 2:if(u.t0=u.sent,u.t0){u.next=7;break}return u.next=6,this.wrapNative.apply(this,["exportKey"].concat(n));case 6:u.t0=u.sent;case 7:return u.abrupt("return",u.t0);case 8:case"end":return u.stop()}},o,this)}))}},{key:"generateKey",value:function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.wrapNative.apply(this,["generateKey"].concat(n)));case 1:case"end":return u.stop()}},o,this)}))}},{key:"sign",value:function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.wrapNative.apply(this,["sign"].concat(n)));case 1:case"end":return u.stop()}},o,this)}))}},{key:"verify",value:function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.wrapNative.apply(this,["verify"].concat(n)));case 1:case"end":return u.stop()}},o,this)}))}},{key:"encrypt",value:function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.wrapNative.apply(this,["encrypt"].concat(n)));case 1:case"end":return u.stop()}},o,this)}))}},{key:"decrypt",value:function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.wrapNative.apply(this,["decrypt"].concat(n)));case 1:case"end":return u.stop()}},o,this)}))}},{key:"wrapKey",value:function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.wrapNative.apply(this,["wrapKey"].concat(n)));case 1:case"end":return u.stop()}},o,this)}))}},{key:"unwrapKey",value:function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.wrapNative.apply(this,["unwrapKey"].concat(n)));case 1:case"end":return u.stop()}},o,this)}))}},{key:"deriveBits",value:function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.wrapNative.apply(this,["deriveBits"].concat(n)));case 1:case"end":return u.stop()}},o,this)}))}},{key:"deriveKey",value:function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return A(this,void 0,void 0,h().mark(function o(){return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.wrapNative.apply(this,["deriveKey"].concat(n)));case 1:case"end":return u.stop()}},o,this)}))}},{key:"wrapNative",value:function(t){for(var n=this,a=arguments.length,o=new Array(a>1?a-1:0),s=1;s<a;s++)o[s-1]=arguments[s];var u=function(l){return j(M(r.prototype),l,n)};return A(this,void 0,void 0,h().mark(function c(){var l,f,d,v,y,S,E,x,N,$,G,Y,Q,ge,nt,Or;return h().wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(~["generateKey","unwrapKey","deriveKey","importKey"].indexOf(t)&&this.fixAlgorithmName(o),V.prev=1,!(t!=="digest"||!o.some(function(Gt){return Gt instanceof $e}))){V.next=9;break}return l=this.fixNativeArguments(t,o),Te.info("Call native '".concat(t,"' method"),l),V.next=7,p.nativeSubtle[t].apply(p.nativeSubtle,l);case 7:return f=V.sent,V.abrupt("return",this.fixNativeResult(t,o,f));case 9:V.next=14;break;case 11:V.prev=11,V.t0=V.catch(1),Te.warn("Error on native '".concat(t,"' calling. ").concat(V.t0.message),V.t0);case 14:if(t!=="wrapKey"){V.next=30;break}return V.prev=15,Te.info("Trying to wrap key by using native functions",o),V.next=19,this.exportKey(o[0],o[1]);case 19:return d=V.sent,v=o[0]==="jwk"?L.FromUtf8String(JSON.stringify(d)):d,V.next=23,this.encrypt(o[3],o[2],v);case 23:return y=V.sent,V.abrupt("return",y);case 27:V.prev=27,V.t1=V.catch(15),Te.warn("Cannot wrap key by native functions. ".concat(V.t1.message),V.t1);case 30:if(t!=="unwrapKey"){V.next=46;break}return V.prev=31,Te.info("Trying to unwrap key by using native functions",o),V.next=35,this.decrypt(o[3],o[2],o[1]);case 35:return S=V.sent,E=o[0]==="jwk"?JSON.parse(L.ToUtf8String(S)):S,V.next=39,this.importKey(o[0],E,o[4],o[5],o[6]);case 39:return x=V.sent,V.abrupt("return",x);case 43:V.prev=43,V.t2=V.catch(31),Te.warn("Cannot unwrap key by native functions. ".concat(V.t2.message),V.t2);case 46:if(t!=="deriveKey"){V.next=61;break}return V.prev=47,Te.info("Trying to derive key by using native functions",o),V.next=51,this.deriveBits(o[0],o[1],o[2].length);case 51:return N=V.sent,V.next=54,this.importKey("raw",N,o[2],o[3],o[4]);case 54:return $=V.sent,V.abrupt("return",$);case 58:V.prev=58,V.t3=V.catch(47),Te.warn("Cannot derive key by native functions. ".concat(V.t3.message),V.t3);case 61:if(!(t==="deriveBits"||t==="deriveKey")){V.next=72;break}G=0,Y=o;case 63:if(!(G<Y.length)){V.next=72;break}if(Q=Y[G],!(oe(Q)==="object"&&Q.public&&r.isAnotherKey(Q.public))){V.next=69;break}return V.next=68,this.castKey(Q.public);case 68:Q.public=V.sent;case 69:G++,V.next=63;break;case 72:ge=0;case 73:if(!(ge<o.length)){V.next=82;break}if(nt=o[ge],!r.isAnotherKey(nt)){V.next=79;break}return V.next=78,this.castKey(nt);case 78:o[ge]=V.sent;case 79:ge++,V.next=73;break;case 82:if(Or=u(t),typeof Or!="function"){V.next=85;break}return V.abrupt("return",Or.apply(this,o));case 85:throw new Error("Incorrect type of 'method'. Must be 'function'.");case 86:case"end":return V.stop()}},c,this,[[1,11],[15,27],[31,43],[47,58]])}))}},{key:"fixNativeArguments",value:function(t,n){var a,o,s,u,c,l,f,d,v=xe(n);if(t==="importKey"&&this.browserInfo.name===be.IE&&((o=(a=v[0])===null||a===void 0?void 0:a.toLowerCase)===null||o===void 0?void 0:o.call(a))==="jwk"&&!K.isBufferSource(v[1])&&(v[1]=L.FromUtf8String(JSON.stringify(v[1]))),this.browserInfo.name===be.IE&&n[1]instanceof Tn)switch(t){case"sign":case"verify":case"encrypt":case"decrypt":v[0]=Object.assign(Object.assign({},this.prepareAlgorithm(v[0])),{hash:(c=(u=(s=v[1])===null||s===void 0?void 0:s.algorithm)===null||u===void 0?void 0:u.hash)===null||c===void 0?void 0:c.name});break;case"wrapKey":case"unwrapKey":v[4]=Object.assign(Object.assign({},this.prepareAlgorithm(v[4])),{hash:(d=(f=(l=v[3])===null||l===void 0?void 0:l.algorithm)===null||f===void 0?void 0:f.hash)===null||d===void 0?void 0:d.name});break}for(var y=0;y<v.length;y++){var S=v[y];S instanceof Tn&&(v[y]=S.getNative())}return v}},{key:"fixNativeResult",value:function(t,n,a){var o,s;if(this.browserInfo.name===be.IE){if(t==="exportKey"&&((s=(o=n[0])===null||o===void 0?void 0:o.toLowerCase)===null||s===void 0?void 0:s.call(o))==="jwk"&&a instanceof ArrayBuffer)return JSON.parse(L.ToUtf8String(a));if("privateKey"in a){var u=["sign","decrypt","unwrapKey","deriveKey","deriveBits"],c=["verify","encrypt","wrapKey"];return{privateKey:this.wrapNativeKey(a.privateKey,n[0],n[1],n[2].filter(function(d){return u.includes(d)})),publicKey:this.wrapNativeKey(a.publicKey,n[0],n[1],n[2].filter(function(d){return c.includes(d)}))}}else if("extractable"in a){var l,f;switch(t){case"importKey":l=n[2],f=n[4];break;case"unwrapKey":l=n[4],f=n[6];break;case"generateKey":l=n[0],f=n[2];break;default:throw new X("Cannot wrap native key. Unsupported method in use")}return this.wrapNativeKey(a,l,a.extractable,f)}}return a}},{key:"wrapNativeKey",value:function(t,n,a,o){if(this.browserInfo.name===be.IE){var s=["RSASSA-PKCS1-v1_5","RSA-PSS","RSA-OAEP","AES-CBC","AES-CTR","AES-KW","HMAC"],u=s.map(function(f){return f.toLowerCase()}).indexOf(t.algorithm.name.toLowerCase());if(u!==-1){var c=this.prepareAlgorithm(n),l=Object.assign(Object.assign({},t.algorithm),{name:s[u]});return Aa.isHashedAlgorithm(c)&&(l.hash={name:c.hash.name.toUpperCase()}),Te.info("Wrapping ".concat(s[u]," crypto key to WrappedNativeCryptoKey")),new Tn(l,a,t.type,o,t)}}return t}},{key:"castKey",value:function(t){return A(this,void 0,void 0,h().mark(function n(){var a,o;return h().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(Te.info("Cast native CryptoKey to linter key.",t),t.extractable){u.next=3;break}throw new Error("Cannot cast unextractable crypto key");case 3:return a=this.getProvider(t.algorithm.name),u.next=6,this.exportKey("jwk",t);case 6:return o=u.sent,u.abrupt("return",a.importKey("jwk",o,t.algorithm,!0,t.usages));case 8:case"end":return u.stop()}},n,this)}))}},{key:"fixAlgorithmName",value:function(t){if(this.browserInfo.name===be.Edge)for(var n=0;n<t.length;n++){var a=t[0];if(typeof a=="string"){var o=he(this.providers.algorithms),s;try{for(o.s();!(s=o.n()).done;){var u=s.value;if(u.toLowerCase()===a.toLowerCase()){t[n]=u;break}}}catch(d){o.e(d)}finally{o.f()}}else if(oe(a)==="object"&&typeof a.name=="string"){var c=he(this.providers.algorithms),l;try{for(c.s();!(l=c.n()).done;){var f=l.value;f.toLowerCase()===a.name.toLowerCase()&&(a.name=f),(typeof a.hash=="string"&&f.toLowerCase()===a.hash.toLowerCase()||oe(a.hash)==="object"&&typeof a.hash.name=="string"&&f.toLowerCase()===a.hash.name.toLowerCase())&&(a.hash={name:f})}}catch(d){c.e(d)}finally{c.f()}}}}},{key:"fixFirefoxEcImportPkcs8",value:function(t){var n=this.prepareAlgorithm(t[2]),a=n.name.toUpperCase();if(this.browserInfo.name===be.Firefox&&t[0]==="pkcs8"&&~["ECDSA","ECDH"].indexOf(a)&&~["P-256","P-384","P-521"].indexOf(n.namedCurve)){if(!K.isBufferSource(t[1]))throw new TypeError("data: Is not ArrayBuffer or ArrayBufferView");var o=K.toArrayBuffer(t[1]),s=te.parse(o,J.PrivateKeyInfo),u=te.parse(s.privateKey,J.EcPrivateKey),c=Xr.toJSON(u);c.ext=!0,c.key_ops=t[4],c.crv=n.namedCurve,c.kty="EC",t[0]="jwk",t[1]=c}}},{key:"fixFirefoxEcExportPkcs8",value:function(t){return A(this,void 0,void 0,h().mark(function n(){var a,o,s;return h().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(c.prev=0,!(this.browserInfo.name===be.Firefox&&t[0]==="pkcs8"&&~["ECDSA","ECDH"].indexOf(t[1].algorithm.name)&&~["P-256","P-384","P-521"].indexOf(t[1].algorithm.namedCurve))){c.next=11;break}return c.next=4,this.exportKey("jwk",t[1]);case 4:return a=c.sent,o=Cr.fromJSON(a,{targetSchema:J.EcPrivateKey}),s=new J.PrivateKeyInfo,s.privateKeyAlgorithm.algorithm=Ke.ASN_ALGORITHM,s.privateKeyAlgorithm.parameters=te.serialize(new J.ObjectIdentifier(En(t[1].algorithm.namedCurve))),s.privateKey=te.serialize(o),c.abrupt("return",te.serialize(s));case 11:c.next=17;break;case 13:return c.prev=13,c.t0=c.catch(0),Te.error(c.t0),c.abrupt("return",null);case 17:case"end":return c.stop()}},n,this,[[0,13]])}))}}],[{key:"isAnotherKey",value:function(t){return oe(t)==="object"&&typeof t.type=="string"&&typeof t.extractable=="boolean"&&oe(t.algorithm)==="object"?!(t instanceof $e):!1}}]),r})(Aa);Wa.methods=["digest","importKey","exportKey","sign","verify","generateKey","encrypt","decrypt","deriveBits","deriveKey","wrapKey","unwrapKey"];var tt=(function(i){b(r,i);function r(){var e;return g(this,r),e=k(this,r,arguments),e.subtle=new Wa,e}return m(r,[{key:"nativeCrypto",get:function(){return p.nativeCrypto}},{key:"getRandomValues",value:function(t){return p.nativeCrypto.getRandomValues(t)}}]),r})(Pu);function _e(i,r){var e=i[r];i[r]=function(){var t=arguments;return new Promise(function(n,a){var o=e.apply(i,t);o.oncomplete=function(s){n(s.target.result)},o.onerror=function(s){a("Error on running '".concat(r,"' function"))}})}}typeof self<"u"&&self.msCrypto&&(_e(p.nativeSubtle,"generateKey"),_e(p.nativeSubtle,"digest"),_e(p.nativeSubtle,"sign"),_e(p.nativeSubtle,"verify"),_e(p.nativeSubtle,"encrypt"),_e(p.nativeSubtle,"decrypt"),_e(p.nativeSubtle,"importKey"),_e(p.nativeSubtle,"exportKey"),_e(p.nativeSubtle,"wrapKey"),_e(p.nativeSubtle,"unwrapKey"),_e(p.nativeSubtle,"deriveKey"),_e(p.nativeSubtle,"deriveBits")),Math.imul||(Math.imul=function(r,e){var t=r>>>16&65535,n=r&65535,a=e>>>16&65535,o=e&65535;return n*o+(t*o+n*a<<16>>>0)|0});var $n=self;p.nativeCrypto&&Object.freeze(p.nativeCrypto.getRandomValues);try{delete self.crypto,$n.crypto=new tt,Object.freeze($n.crypto)}catch(i){Te.error(i)}var rc=$n.crypto;return p.Crypto=tt,p.CryptoKey=$e,p.crypto=rc,p.setCrypto=ne,p})({},self.asmCrypto,self.elliptic)});async function oo(){if(!globalThis.crypto?.subtle)return Xt||(Xt=(async()=>{if(await Promise.resolve().then(()=>sc(ao(),1)),!globalThis.crypto?.subtle)throw new Error("WebCrypto polyfill loaded but crypto.subtle is still missing")})(),Xt)}var Xt,uo=Fr(()=>{"use strict";Xt=null});var so,co,lo=Fr(()=>{"use strict";Wt();so=Fn("0NLdxP/i7Om8ttDm+fSm8OHHx/Hr0arqwvGqyPuRx9f9zcvG2/n5yeeWyA==",133),co=Fn("0rLF8s758c/i6uvR8ufg+9fv5dzS1fDE7/qn7+7D/OvBx//a8eLf2J3e+g==",133)});var go={};qa(go,{getConfig:()=>Gc});function zn(p){try{return new URL(p.includes("://")?p:`http://${p}`).hostname.toLowerCase()}catch{return p.replace(/\/+$/,"").toLowerCase()}}function Fc(p){let w=zn(p);return w.startsWith("www.")?w.slice(4):w}function yo(p){let w=zn(p);if(Tc.test(w)||$c.test(w)||w==="localhost")return!0;let B=(0,po.parse)(w,{allowPrivateDomains:!0});return!!(!B.domain||!B.publicSuffix||Dc.includes(B.publicSuffix))}function Mc(p){let w=zn(p);return yo(w)||fo.test(w)?!0:w.split(".").some(B=>fo.test(B))}function _c(p){return yo(p)||Mc(p)}function Jc(p,w){return w?Fc(p)===w:!1}function jc(p,w){return _c(p)?{free:!0,covered:!0}:{free:!1,covered:Jc(p,w)}}var Yt,po,ho,vo,Mr,Gn,fo,Dc,Tc,$c,Gc,mo=Fr(()=>{"use strict";uo();Yt=require("jose");lo();Wt();wo();po=require("tldts"),Mr=Wn();Mr?Gn=Mr.siteSettings:Gn={};fo=/\b(dev|test|testing|staging|stage|qa|uat|preview|demo|sandbox|preprod|beta|canary)\b/i,Dc=["localhost","local","test","invalid","example","lan","internal"],Tc=/^(127\.)|^(10\.)|^(192\.168\.)|^(172\.(1[6-9]|2\d|3[0-1])\.)/,$c=/^(::1$)|(^fc00:)|(^fd)/i;Gc=async()=>{await oo();let p=null;if(Gn.subscriber){let B=await(0,Yt.importJWK)({kty:"EC",x:ho,y:vo,crv:"P-256"},"ES256"),P=new Date().getFullYear(),H=Math.floor((Date.now()-new Date(P,0,1).getTime())/(1e3*60*60*24*7)),D=await fetch(Mr.uploadUrl+"lic.jws?t="+Mr.siteSettings.lastUpdate+"&y="+P+"&w="+H).then(Z=>Z.ok?Z.text():null).catch(()=>null);if(D)try{let Z=location.hostname.split(":")[0],{payload:le}=await(0,Yt.jwtVerify)(D,B,{algorithms:["ES256"]}),ne=jc(Z,le.domain);if(!ne.free&&!ne.covered)throw new Error("Invalid domain in JWT");let ie=le.key.split(":"),K=ot(ie[0]),Qe=ot(ie[1]),mr=(await fetch(Mr.uploadUrl+"config.enc?t="+Mr.siteSettings.lastUpdate).then(er=>er.ok?er.text():null).catch(()=>null))?.split(":");if(mr?.length===2){let er=ot(mr[0]),rr=ot(mr[1]),ue=await crypto.subtle.importKey("raw",K,{name:"AES-GCM"},!1,["decrypt"]),L=await crypto.subtle.decrypt({name:"AES-GCM",iv:Qe},ue,new Uint8Array([...er,...rr]));p=JSON.parse(new TextDecoder().decode(L)),p.subscriptionType=le.subscriptionType}}catch(Z){console.error(Z.message)}}return p??null};ho=so;vo=co});var Xc={};qa(Xc,{TEXT_DOMAIN:()=>Wc,attachDefaultPluginRuntime:()=>Za,getConfig:()=>qc,getPlugin:()=>zc,getRecaptcha:()=>Ya,getWpSuite:()=>Wn});module.exports=cc(Xc);function Wn(){return globalThis.WpSuite}function zc(p){return globalThis.WpSuite?.plugins[p]}var Wc,qc,wo=Fr(()=>{Wt();Qa();Wc="smartcloud-wpsuite",qc=async p=>{let B=await(await Promise.resolve().then(()=>(mo(),go))).getConfig();return B&&(B={...B[p],subscriptionType:B.subscriptionType}),B}});wo();0&&(module.exports={TEXT_DOMAIN,attachDefaultPluginRuntime,getConfig,getPlugin,getRecaptcha,getWpSuite});