authhero 0.42.0 → 0.43.0

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/authhero.cjs CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";var kh=Object.defineProperty;var xh=(n,e,t)=>e in n?kh(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var te=(n,e,t)=>xh(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@hono/zod-openapi"),X=n=>typeof n=="string",Qn=()=>{let n,e;const t=new Promise((i,r)=>{n=i,e=r});return t.resolve=n,t.reject=e,t},sl=n=>n==null?"":""+n,Sh=(n,e,t)=>{n.forEach(i=>{e[i]&&(t[i]=e[i])})},Ah=/###/g,ol=n=>n&&n.indexOf("###")>-1?n.replace(Ah,"."):n,al=n=>!n||X(n),ri=(n,e,t)=>{const i=X(e)?e.split("."):e;let r=0;for(;r<i.length-1;){if(al(n))return{};const s=ol(i[r]);!n[s]&&t&&(n[s]=new t),Object.prototype.hasOwnProperty.call(n,s)?n=n[s]:n={},++r}return al(n)?{}:{obj:n,k:ol(i[r])}},cl=(n,e,t)=>{const{obj:i,k:r}=ri(n,e,Object);if(i!==void 0||e.length===1){i[r]=t;return}let s=e[e.length-1],o=e.slice(0,e.length-1),c=ri(n,o,Object);for(;c.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),c=ri(n,o,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${s}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${s}`]=t},Ih=(n,e,t,i)=>{const{obj:r,k:s}=ri(n,e,Object);r[s]=r[s]||[],r[s].push(t)},or=(n,e)=>{const{obj:t,k:i}=ri(n,e);if(t&&Object.prototype.hasOwnProperty.call(t,i))return t[i]},Eh=(n,e,t)=>{const i=or(n,t);return i!==void 0?i:or(e,t)},vd=(n,e,t)=>{for(const i in e)i!=="__proto__"&&i!=="constructor"&&(i in n?X(n[i])||n[i]instanceof String||X(e[i])||e[i]instanceof String?t&&(n[i]=e[i]):vd(n[i],e[i],t):n[i]=e[i]);return n},wn=n=>n.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var $h={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Ch=n=>X(n)?n.replace(/[&<>"'\/]/g,e=>$h[e]):n;class jh{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(t!==void 0)return t;const i=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,i),this.regExpQueue.push(e),i}}const zh=[" ",",","?","!",";"],Nh=new jh(20),Oh=(n,e,t)=>{e=e||"",t=t||"";const i=zh.filter(o=>e.indexOf(o)<0&&t.indexOf(o)<0);if(i.length===0)return!0;const r=Nh.getRegExp(`(${i.map(o=>o==="?"?"\\?":o).join("|")})`);let s=!r.test(n);if(!s){const o=n.indexOf(t);o>0&&!r.test(n.substring(0,o))&&(s=!0)}return s},mo=function(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!n)return;if(n[e])return Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0;const i=e.split(t);let r=n;for(let s=0;s<i.length;){if(!r||typeof r!="object")return;let o,c="";for(let l=s;l<i.length;++l)if(l!==s&&(c+=t),c+=i[l],o=r[c],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&l<i.length-1)continue;s+=l-s+1;break}r=o}return r},ar=n=>n==null?void 0:n.replace("_","-"),Bh={type:"logger",log(n){this.output("log",n)},warn(n){this.output("warn",n)},error(n){this.output("error",n)},output(n,e){var t,i;(i=(t=console==null?void 0:console[n])==null?void 0:t.apply)==null||i.call(t,console,e)}};class cr{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(e,t)}init(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||Bh,this.options=t,this.debug=t.debug}log(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.forward(t,"log","",!0)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.forward(t,"warn","",!0)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.forward(t,"error","")}deprecate(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,i,r){return r&&!this.debug?null:(X(e[0])&&(e[0]=`${i}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new cr(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new cr(this.logger,e)}}var ht=new cr;class ts{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(i=>{this.observers[i]||(this.observers[i]=new Map);const r=this.observers[i].get(t)||0;this.observers[i].set(t,r+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}emit(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];this.observers[e]&&Array.from(this.observers[e].entries()).forEach(o=>{let[c,l]=o;for(let u=0;u<l;u++)c(...i)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(o=>{let[c,l]=o;for(let u=0;u<l;u++)c.apply(c,[e,...i])})}}class ll extends ts{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,i){var u,p;let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,o=r.ignoreJSONStructure!==void 0?r.ignoreJSONStructure:this.options.ignoreJSONStructure;let c;e.indexOf(".")>-1?c=e.split("."):(c=[e,t],i&&(Array.isArray(i)?c.push(...i):X(i)&&s?c.push(...i.split(s)):c.push(i)));const l=or(this.data,c);return!l&&!t&&!i&&e.indexOf(".")>-1&&(e=c[0],t=c[1],i=c.slice(2).join(".")),l||!o||!X(i)?l:mo((p=(u=this.data)==null?void 0:u[e])==null?void 0:p[t],i,s)}addResource(e,t,i,r){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let c=[e,t];i&&(c=c.concat(o?i.split(o):i)),e.indexOf(".")>-1&&(c=e.split("."),r=t,t=c[1]),this.addNamespaces(t),cl(this.data,c,r),s.silent||this.emit("added",e,t,i,r)}addResources(e,t,i){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const s in i)(X(i[s])||Array.isArray(i[s]))&&this.addResource(e,t,s,i[s],{silent:!0});r.silent||this.emit("added",e,t,i)}addResourceBundle(e,t,i,r,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},c=[e,t];e.indexOf(".")>-1&&(c=e.split("."),r=i,i=t,t=c[1]),this.addNamespaces(t);let l=or(this.data,c)||{};o.skipCopy||(i=JSON.parse(JSON.stringify(i))),r?vd(l,i,s):l={...l,...i},cl(this.data,c,l),o.silent||this.emit("added",e,t,i)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(r=>t[r]&&Object.keys(t[r]).length>0)}toJSON(){return this.data}}var wd={processors:{},addPostProcessor(n){this.processors[n.name]=n},handle(n,e,t,i,r){return n.forEach(s=>{var o;e=((o=this.processors[s])==null?void 0:o.process(e,t,i,r))??e}),e}};const ul={};class lr extends ts{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Sh(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=ht.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(e==null)return!1;const i=this.resolve(e,t);return(i==null?void 0:i.res)!==void 0}extractFromKey(e,t){let i=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;i===void 0&&(i=":");const r=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let s=t.ns||this.options.defaultNS||[];const o=i&&e.indexOf(i)>-1,c=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!Oh(e,i,r);if(o&&!c){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:X(s)?[s]:s};const u=e.split(i);(i!==r||i===r&&this.options.ns.indexOf(u[0])>-1)&&(s=u.shift()),e=u.join(r)}return{key:e,namespaces:X(s)?[s]:s}}translate(e,t,i){if(typeof t!="object"&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),typeof t=="object"&&(t={...t}),t||(t={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const r=t.returnDetails!==void 0?t.returnDetails:this.options.returnDetails,s=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator,{key:o,namespaces:c}=this.extractFromKey(e[e.length-1],t),l=c[c.length-1],u=t.lng||this.language,p=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((u==null?void 0:u.toLowerCase())==="cimode"){if(p){const K=t.nsSeparator||this.options.nsSeparator;return r?{res:`${l}${K}${o}`,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(t)}:`${l}${K}${o}`}return r?{res:o,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(t)}:o}const g=this.resolve(e,t);let m=g==null?void 0:g.res;const x=(g==null?void 0:g.usedKey)||o,h=(g==null?void 0:g.exactUsedKey)||o,_=Object.prototype.toString.apply(m),b=["[object Number]","[object Function]","[object RegExp]"],S=t.joinArrays!==void 0?t.joinArrays:this.options.joinArrays,N=!this.i18nFormat||this.i18nFormat.handleAsObject,T=!X(m)&&typeof m!="boolean"&&typeof m!="number";if(N&&m&&T&&b.indexOf(_)<0&&!(X(S)&&Array.isArray(m))){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const K=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,m,{...t,ns:c}):`key '${o} (${this.language})' returned an object instead of string.`;return r?(g.res=K,g.usedParams=this.getUsedParamsDetails(t),g):K}if(s){const K=Array.isArray(m),oe=K?[]:{},pe=K?h:x;for(const ce in m)if(Object.prototype.hasOwnProperty.call(m,ce)){const Re=`${pe}${s}${ce}`;oe[ce]=this.translate(Re,{...t,joinArrays:!1,ns:c}),oe[ce]===Re&&(oe[ce]=m[ce])}m=oe}}else if(N&&X(S)&&Array.isArray(m))m=m.join(S),m&&(m=this.extendTranslation(m,e,t,i));else{let K=!1,oe=!1;const pe=t.count!==void 0&&!X(t.count),ce=lr.hasDefaultValue(t),Re=pe?this.pluralResolver.getSuffix(u,t.count,t):"",nt=t.ordinal&&pe?this.pluralResolver.getSuffix(u,t.count,{ordinal:!1}):"",De=pe&&!t.ordinal&&t.count===0,$=De&&t[`defaultValue${this.options.pluralSeparator}zero`]||t[`defaultValue${Re}`]||t[`defaultValue${nt}`]||t.defaultValue;!this.isValidLookup(m)&&ce&&(K=!0,m=$),this.isValidLookup(m)||(oe=!0,m=o);const A=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&oe?void 0:m,w=ce&&$!==m&&this.options.updateMissing;if(oe||K||w){if(this.logger.log(w?"updateKey":"missingKey",u,l,o,w?$:m),s){const Z=this.resolve(o,{...t,keySeparator:!1});Z&&Z.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let v=[];const C=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if(this.options.saveMissingTo==="fallback"&&C&&C[0])for(let Z=0;Z<C.length;Z++)v.push(C[Z]);else this.options.saveMissingTo==="all"?v=this.languageUtils.toResolveHierarchy(t.lng||this.language):v.push(t.lng||this.language);const R=(Z,q,ee)=>{var M;const se=ce&&ee!==m?ee:A;this.options.missingKeyHandler?this.options.missingKeyHandler(Z,l,q,se,w,t):(M=this.backendConnector)!=null&&M.saveMissing&&this.backendConnector.saveMissing(Z,l,q,se,w,t),this.emit("missingKey",Z,l,q,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&pe?v.forEach(Z=>{const q=this.pluralResolver.getSuffixes(Z,t);De&&t[`defaultValue${this.options.pluralSeparator}zero`]&&q.indexOf(`${this.options.pluralSeparator}zero`)<0&&q.push(`${this.options.pluralSeparator}zero`),q.forEach(ee=>{R([Z],o+ee,t[`defaultValue${ee}`]||$)})}):R(v,o,$))}m=this.extendTranslation(m,e,t,g,i),oe&&m===o&&this.options.appendNamespaceToMissingKey&&(m=`${l}:${o}`),(oe||K)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${o}`:o,K?m:void 0))}return r?(g.res=m,g.usedParams=this.getUsedParamsDetails(t),g):m}extendTranslation(e,t,i,r,s){var u,p;var o=this;if((u=this.i18nFormat)!=null&&u.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...i},i.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init({...i,interpolation:{...this.options.interpolation,...i.interpolation}});const g=X(e)&&(((p=i==null?void 0:i.interpolation)==null?void 0:p.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let m;if(g){const h=e.match(this.interpolator.nestingRegexp);m=h&&h.length}let x=i.replace&&!X(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(x={...this.options.interpolation.defaultVariables,...x}),e=this.interpolator.interpolate(e,x,i.lng||this.language||r.usedLng,i),g){const h=e.match(this.interpolator.nestingRegexp),_=h&&h.length;m<_&&(i.nest=!1)}!i.lng&&r&&r.res&&(i.lng=this.language||r.usedLng),i.nest!==!1&&(e=this.interpolator.nest(e,function(){for(var h=arguments.length,_=new Array(h),b=0;b<h;b++)_[b]=arguments[b];return(s==null?void 0:s[0])===_[0]&&!i.context?(o.logger.warn(`It seems you are nesting recursively key: ${_[0]} in key: ${t[0]}`),null):o.translate(..._,t)},i)),i.interpolation&&this.interpolator.reset()}const c=i.postProcess||this.options.postProcess,l=X(c)?[c]:c;return e!=null&&(l!=null&&l.length)&&i.applyPostProcessor!==!1&&(e=wd.handle(l,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(i)},...i}:i,this)),e}resolve(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i,r,s,o,c;return X(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(i))return;const u=this.extractFromKey(l,t),p=u.key;r=p;let g=u.namespaces;this.options.fallbackNS&&(g=g.concat(this.options.fallbackNS));const m=t.count!==void 0&&!X(t.count),x=m&&!t.ordinal&&t.count===0,h=t.context!==void 0&&(X(t.context)||typeof t.context=="number")&&t.context!=="",_=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);g.forEach(b=>{var S,N;this.isValidLookup(i)||(c=b,!ul[`${_[0]}-${b}`]&&((S=this.utils)!=null&&S.hasLoadedNamespace)&&!((N=this.utils)!=null&&N.hasLoadedNamespace(c))&&(ul[`${_[0]}-${b}`]=!0,this.logger.warn(`key "${r}" for languages "${_.join(", ")}" won't get resolved as namespace "${c}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),_.forEach(T=>{var pe;if(this.isValidLookup(i))return;o=T;const K=[p];if((pe=this.i18nFormat)!=null&&pe.addLookupKeys)this.i18nFormat.addLookupKeys(K,p,T,b,t);else{let ce;m&&(ce=this.pluralResolver.getSuffix(T,t.count,t));const Re=`${this.options.pluralSeparator}zero`,nt=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(K.push(p+ce),t.ordinal&&ce.indexOf(nt)===0&&K.push(p+ce.replace(nt,this.options.pluralSeparator)),x&&K.push(p+Re)),h){const De=`${p}${this.options.contextSeparator}${t.context}`;K.push(De),m&&(K.push(De+ce),t.ordinal&&ce.indexOf(nt)===0&&K.push(De+ce.replace(nt,this.options.pluralSeparator)),x&&K.push(De+Re))}}let oe;for(;oe=K.pop();)this.isValidLookup(i)||(s=oe,i=this.getResource(T,b,oe,t))}))})}),{res:i,usedKey:r,exactUsedKey:s,usedLng:o,usedNS:c}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,i){var s;let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return(s=this.i18nFormat)!=null&&s.getResource?this.i18nFormat.getResource(e,t,i,r):this.resourceStore.getResource(e,t,i,r)}getUsedParamsDetails(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=e.replace&&!X(e.replace);let r=i?e.replace:e;if(i&&typeof e.count<"u"&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!i){r={...r};for(const s of t)delete r[s]}return r}static hasDefaultValue(e){const t="defaultValue";for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t===i.substring(0,t.length)&&e[i]!==void 0)return!0;return!1}}class dl{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ht.create("languageUtils")}getScriptPartFromCode(e){if(e=ar(e),!e||e.indexOf("-")<0)return null;const t=e.split("-");return t.length===2||(t.pop(),t[t.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(e=ar(e),!e||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(X(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(i=>{if(t)return;const r=this.formatLanguageCode(i);(!this.options.supportedLngs||this.isSupportedCode(r))&&(t=r)}),!t&&this.options.supportedLngs&&e.forEach(i=>{if(t)return;const r=this.getLanguagePartFromCode(i);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(s=>{if(s===r)return s;if(!(s.indexOf("-")<0&&r.indexOf("-")<0)&&(s.indexOf("-")>0&&r.indexOf("-")<0&&s.substring(0,s.indexOf("-"))===r||s.indexOf(r)===0&&r.length>1))return s})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),X(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let i=e[t];return i||(i=e[this.getScriptPartFromCode(t)]),i||(i=e[this.formatLanguageCode(t)]),i||(i=e[this.getLanguagePartFromCode(t)]),i||(i=e.default),i||[]}toResolveHierarchy(e,t){const i=this.getFallbackCodes(t||this.options.fallbackLng||[],e),r=[],s=o=>{o&&(this.isSupportedCode(o)?r.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return X(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):X(e)&&s(this.formatLanguageCode(e)),i.forEach(o=>{r.indexOf(o)<0&&s(this.formatLanguageCode(o))}),r}}const pl={zero:0,one:1,two:2,few:3,many:4,other:5},fl={select:n=>n===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Th{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=t,this.logger=ht.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=ar(e==="dev"?"en":e),r=t.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:i,type:r});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let o;try{o=new Intl.PluralRules(i,{type:r})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),fl;if(!e.match(/-|_/))return fl;const l=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(l,t)}return this.pluralRulesCache[s]=o,o}needsPlural(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),(i==null?void 0:i.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,i).map(r=>`${t}${r}`)}getSuffixes(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),i?i.resolvedOptions().pluralCategories.sort((r,s)=>pl[r]-pl[s]).map(r=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${r}`):[]}getSuffix(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=this.getRule(e,i);return r?`${this.options.prepend}${i.ordinal?`ordinal${this.options.prepend}`:""}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,i))}}const hl=function(n,e,t){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",r=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=Eh(n,e,t);return!s&&r&&X(t)&&(s=mo(n,t,i),s===void 0&&(s=mo(e,t,i))),s},to=n=>n.replace(/\$/g,"$$$$");class Rh{constructor(){var t;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=ht.create("interpolator"),this.options=e,this.format=((t=e==null?void 0:e.interpolation)==null?void 0:t.format)||(i=>i),this.init(e)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:i,useRawValueToEscape:r,prefix:s,prefixEscaped:o,suffix:c,suffixEscaped:l,formatSeparator:u,unescapeSuffix:p,unescapePrefix:g,nestingPrefix:m,nestingPrefixEscaped:x,nestingSuffix:h,nestingSuffixEscaped:_,nestingOptionsSeparator:b,maxReplaces:S,alwaysFormat:N}=e.interpolation;this.escape=t!==void 0?t:Ch,this.escapeValue=i!==void 0?i:!0,this.useRawValueToEscape=r!==void 0?r:!1,this.prefix=s?wn(s):o||"{{",this.suffix=c?wn(c):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=p?"":g||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=m?wn(m):x||wn("$t("),this.nestingSuffix=h?wn(h):_||wn(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=S||1e3,this.alwaysFormat=N!==void 0?N:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,i)=>(t==null?void 0:t.source)===i?(t.lastIndex=0,t):new RegExp(i,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(e,t,i,r){var x;let s,o,c;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=h=>{if(h.indexOf(this.formatSeparator)<0){const N=hl(t,l,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(N,void 0,i,{...r,...t,interpolationkey:h}):N}const _=h.split(this.formatSeparator),b=_.shift().trim(),S=_.join(this.formatSeparator).trim();return this.format(hl(t,l,b,this.options.keySeparator,this.options.ignoreJSONStructure),S,i,{...r,...t,interpolationkey:b})};this.resetRegExp();const p=(r==null?void 0:r.missingInterpolationHandler)||this.options.missingInterpolationHandler,g=((x=r==null?void 0:r.interpolation)==null?void 0:x.skipOnVariables)!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>to(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?to(this.escape(h)):to(h)}].forEach(h=>{for(c=0;s=h.regex.exec(e);){const _=s[1].trim();if(o=u(_),o===void 0)if(typeof p=="function"){const S=p(e,s,r);o=X(S)?S:""}else if(r&&Object.prototype.hasOwnProperty.call(r,_))o="";else if(g){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${_} for interpolating ${e}`),o="";else!X(o)&&!this.useRawValueToEscape&&(o=sl(o));const b=h.safeValue(o);if(e=e.replace(s[0],b),g?(h.regex.lastIndex+=o.length,h.regex.lastIndex-=s[0].length):h.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),e}nest(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r,s,o;const c=(l,u)=>{const p=this.nestingOptionsSeparator;if(l.indexOf(p)<0)return l;const g=l.split(new RegExp(`${p}[ ]*{`));let m=`{${g[1]}`;l=g[0],m=this.interpolate(m,o);const x=m.match(/'/g),h=m.match(/"/g);(((x==null?void 0:x.length)??0)%2===0&&!h||h.length%2!==0)&&(m=m.replace(/'/g,'"'));try{o=JSON.parse(m),u&&(o={...u,...o})}catch(_){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,_),`${l}${p}${m}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,l};for(;r=this.nestingRegexp.exec(e);){let l=[];o={...i},o=o.replace&&!X(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;let u=!1;if(r[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(r[1])){const p=r[1].split(this.formatSeparator).map(g=>g.trim());r[1]=p.shift(),l=p,u=!0}if(s=t(c.call(this,r[1].trim(),o),o),s&&r[0]===e&&!X(s))return s;X(s)||(s=sl(s)),s||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),s=""),u&&(s=l.reduce((p,g)=>this.format(p,g,i.lng,{...i,interpolationkey:r[1].trim()}),s.trim())),e=e.replace(r[0],s),this.regexp.lastIndex=0}return e}}const Ph=n=>{let e=n.toLowerCase().trim();const t={};if(n.indexOf("(")>-1){const i=n.split("(");e=i[0].toLowerCase().trim();const r=i[1].substring(0,i[1].length-1);e==="currency"&&r.indexOf(":")<0?t.currency||(t.currency=r.trim()):e==="relativetime"&&r.indexOf(":")<0?t.range||(t.range=r.trim()):r.split(";").forEach(o=>{if(o){const[c,...l]=o.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),p=c.trim();t[p]||(t[p]=u),u==="false"&&(t[p]=!1),u==="true"&&(t[p]=!0),isNaN(u)||(t[p]=parseInt(u,10))}})}return{formatName:e,formatOptions:t}},bn=n=>{const e={};return(t,i,r)=>{let s=r;r&&r.interpolationkey&&r.formatParams&&r.formatParams[r.interpolationkey]&&r[r.interpolationkey]&&(s={...s,[r.interpolationkey]:void 0});const o=i+JSON.stringify(s);let c=e[o];return c||(c=n(ar(i),r),e[o]=c),c(t)}};class Lh{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=ht.create("formatter"),this.options=e,this.formats={number:bn((t,i)=>{const r=new Intl.NumberFormat(t,{...i});return s=>r.format(s)}),currency:bn((t,i)=>{const r=new Intl.NumberFormat(t,{...i,style:"currency"});return s=>r.format(s)}),datetime:bn((t,i)=>{const r=new Intl.DateTimeFormat(t,{...i});return s=>r.format(s)}),relativetime:bn((t,i)=>{const r=new Intl.RelativeTimeFormat(t,{...i});return s=>r.format(s,i.range||"day")}),list:bn((t,i)=>{const r=new Intl.ListFormat(t,{...i});return s=>r.format(s)})},this.init(e)}init(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=t.interpolation.formatSeparator||","}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=bn(t)}format(e,t,i){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=t.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(c=>c.indexOf(")")>-1)){const c=s.findIndex(l=>l.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,c)].join(this.formatSeparator)}return s.reduce((c,l)=>{var g;const{formatName:u,formatOptions:p}=Ph(l);if(this.formats[u]){let m=c;try{const x=((g=r==null?void 0:r.formatParams)==null?void 0:g[r.interpolationkey])||{},h=x.locale||x.lng||r.locale||r.lng||i;m=this.formats[u](c,h,{...p,...r,...x})}catch(x){this.logger.warn(x)}return m}else this.logger.warn(`there was no format function for ${u}`);return c},e)}}const Uh=(n,e)=>{n.pending[e]!==void 0&&(delete n.pending[e],n.pendingCount--)};class Vh extends ts{constructor(e,t,i){var s,o;let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=t,this.services=i,this.languageUtils=i.languageUtils,this.options=r,this.logger=ht.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],(o=(s=this.backend)==null?void 0:s.init)==null||o.call(s,i,r.backend,r)}queueLoad(e,t,i,r){const s={},o={},c={},l={};return e.forEach(u=>{let p=!0;t.forEach(g=>{const m=`${u}|${g}`;!i.reload&&this.store.hasResourceBundle(u,g)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?o[m]===void 0&&(o[m]=!0):(this.state[m]=1,p=!1,o[m]===void 0&&(o[m]=!0),s[m]===void 0&&(s[m]=!0),l[g]===void 0&&(l[g]=!0)))}),p||(c[u]=!0)}),(Object.keys(s).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(s),pending:Object.keys(o),toLoadLanguages:Object.keys(c),toLoadNamespaces:Object.keys(l)}}loaded(e,t,i){const r=e.split("|"),s=r[0],o=r[1];t&&this.emit("failedLoading",s,o,t),!t&&i&&this.store.addResourceBundle(s,o,i,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&i&&(this.state[e]=0);const c={};this.queue.forEach(l=>{Ih(l.loaded,[s],o),Uh(l,e),t&&l.errors.push(t),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{c[u]||(c[u]={});const p=l.loaded[u];p.length&&p.forEach(g=>{c[u][g]===void 0&&(c[u][g]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",c),this.queue=this.queue.filter(l=>!l.done)}read(e,t,i){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:i,tried:r,wait:s,callback:o});return}this.readingCalls++;const c=(u,p)=>{if(this.readingCalls--,this.waitingReads.length>0){const g=this.waitingReads.shift();this.read(g.lng,g.ns,g.fcName,g.tried,g.wait,g.callback)}if(u&&p&&r<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,i,r+1,s*2,o)},s);return}o(u,p)},l=this.backend[i].bind(this.backend);if(l.length===2){try{const u=l(e,t);u&&typeof u.then=="function"?u.then(p=>c(null,p)).catch(c):c(null,u)}catch(u){c(u)}return}return l(e,t,c)}prepareLoading(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();X(e)&&(e=this.languageUtils.toResolveHierarchy(e)),X(t)&&(t=[t]);const s=this.queueLoad(e,t,i,r);if(!s.toLoad.length)return s.pending.length||r(),null;s.toLoad.forEach(o=>{this.loadOne(o)})}load(e,t,i){this.prepareLoading(e,t,{},i)}reload(e,t,i){this.prepareLoading(e,t,{reload:!0},i)}loadOne(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const i=e.split("|"),r=i[0],s=i[1];this.read(r,s,"read",void 0,void 0,(o,c)=>{o&&this.logger.warn(`${t}loading namespace ${s} for language ${r} failed`,o),!o&&c&&this.logger.log(`${t}loaded namespace ${s} for language ${r}`,c),this.loaded(e,o,c)})}saveMissing(e,t,i,r,s){var l,u,p,g,m;let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if((u=(l=this.services)==null?void 0:l.utils)!=null&&u.hasLoadedNamespace&&!((g=(p=this.services)==null?void 0:p.utils)!=null&&g.hasLoadedNamespace(t))){this.logger.warn(`did not save key "${i}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(i==null||i==="")){if((m=this.backend)!=null&&m.create){const x={...o,isUpdate:s},h=this.backend.create.bind(this.backend);if(h.length<6)try{let _;h.length===5?_=h(e,t,i,r,x):_=h(e,t,i,r),_&&typeof _.then=="function"?_.then(b=>c(null,b)).catch(c):c(null,_)}catch(_){c(_)}else h(e,t,i,r,c,x)}!e||!e[0]||this.store.addResource(e[0],t,i,r)}}}const gl=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:n=>{let e={};if(typeof n[1]=="object"&&(e=n[1]),X(n[1])&&(e.defaultValue=n[1]),X(n[2])&&(e.tDescription=n[2]),typeof n[2]=="object"||typeof n[3]=="object"){const t=n[3]||n[2];Object.keys(t).forEach(i=>{e[i]=t[i]})}return e},interpolation:{escapeValue:!0,format:n=>n,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),_l=n=>{var e,t;return X(n.ns)&&(n.ns=[n.ns]),X(n.fallbackLng)&&(n.fallbackLng=[n.fallbackLng]),X(n.fallbackNS)&&(n.fallbackNS=[n.fallbackNS]),((t=(e=n.supportedLngs)==null?void 0:e.indexOf)==null?void 0:t.call(e,"cimode"))<0&&(n.supportedLngs=n.supportedLngs.concat(["cimode"])),typeof n.initImmediate=="boolean"&&(n.initAsync=n.initImmediate),n},Ki=()=>{},Mh=n=>{Object.getOwnPropertyNames(Object.getPrototypeOf(n)).forEach(t=>{typeof n[t]=="function"&&(n[t]=n[t].bind(n))})};class di extends ts{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;if(super(),this.options=_l(e),this.services={},this.logger=ht,this.modules={external:[]},Mh(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof t=="function"&&(i=t,t={}),!t.defaultNS&&t.defaultNS!==!1&&t.ns&&(X(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const r=gl();this.options={...r,...this.options,..._l(t)},this.options.interpolation={...r.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator);const s=p=>p?typeof p=="function"?new p:p:null;if(!this.options.isClone){this.modules.logger?ht.init(s(this.modules.logger),this.options):ht.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:p=Lh;const g=new dl(this.options);this.store=new ll(this.options.resources,this.options);const m=this.services;m.logger=ht,m.resourceStore=this.store,m.languageUtils=g,m.pluralResolver=new Th(g,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),p&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(m.formatter=s(p),m.formatter.init(m,this.options),this.options.interpolation.format=m.formatter.format.bind(m.formatter)),m.interpolator=new Rh(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new Vh(s(this.modules.backend),m.resourceStore,m,this.options),m.backendConnector.on("*",function(x){for(var h=arguments.length,_=new Array(h>1?h-1:0),b=1;b<h;b++)_[b-1]=arguments[b];e.emit(x,..._)}),this.modules.languageDetector&&(m.languageDetector=s(this.modules.languageDetector),m.languageDetector.init&&m.languageDetector.init(m,this.options.detection,this.options)),this.modules.i18nFormat&&(m.i18nFormat=s(this.modules.i18nFormat),m.i18nFormat.init&&m.i18nFormat.init(this)),this.translator=new lr(this.services,this.options),this.translator.on("*",function(x){for(var h=arguments.length,_=new Array(h>1?h-1:0),b=1;b<h;b++)_[b-1]=arguments[b];e.emit(x,..._)}),this.modules.external.forEach(x=>{x.init&&x.init(this)})}if(this.format=this.options.interpolation.format,i||(i=Ki),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const p=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);p.length>0&&p[0]!=="dev"&&(this.options.lng=p[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(p=>{this[p]=function(){return e.store[p](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(p=>{this[p]=function(){return e.store[p](...arguments),e}});const l=Qn(),u=()=>{const p=(g,m)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(m),i(g,m)};if(this.languages&&!this.isInitialized)return p(null,this.t.bind(this));this.changeLanguage(this.options.lng,p)};return this.options.resources||!this.options.initAsync?u():setTimeout(u,0),l}loadResources(e){var s,o;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ki;const r=X(e)?e:this.language;if(typeof e=="function"&&(i=e),!this.options.resources||this.options.partialBundledLanguages){if((r==null?void 0:r.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return i();const c=[],l=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(g=>{g!=="cimode"&&c.indexOf(g)<0&&c.push(g)})};r?l(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(p=>l(p)),(o=(s=this.options.preload)==null?void 0:s.forEach)==null||o.call(s,u=>l(u)),this.services.backendConnector.load(c,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),i(u)})}else i(null)}reloadResources(e,t,i){const r=Qn();return typeof e=="function"&&(i=e,e=void 0),typeof t=="function"&&(i=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),i||(i=Ki),this.services.backendConnector.reload(e,t,s=>{r.resolve(),i(s)}),r}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&wd.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1))for(let t=0;t<this.languages.length;t++){const i=this.languages[t];if(!(["cimode","dev"].indexOf(i)>-1)&&this.store.hasLanguageSomeTranslations(i)){this.resolvedLanguage=i;break}}}changeLanguage(e,t){var i=this;this.isLanguageChangingTo=e;const r=Qn();this.emit("languageChanging",e);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},o=(l,u)=>{u?(s(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,r.resolve(function(){return i.t(...arguments)}),t&&t(l,function(){return i.t(...arguments)})},c=l=>{var p,g;!e&&!l&&this.services.languageDetector&&(l=[]);const u=X(l)?l:this.services.languageUtils.getBestMatchFromCodes(l);u&&(this.language||s(u),this.translator.language||this.translator.changeLanguage(u),(g=(p=this.services.languageDetector)==null?void 0:p.cacheUserLanguage)==null||g.call(p,u)),this.loadResources(u,m=>{o(m,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?c(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(c):this.services.languageDetector.detect(c):c(e),r}getFixedT(e,t,i){var r=this;const s=function(o,c){let l;if(typeof c!="object"){for(var u=arguments.length,p=new Array(u>2?u-2:0),g=2;g<u;g++)p[g-2]=arguments[g];l=r.options.overloadTranslationOptionHandler([o,c].concat(p))}else l={...c};l.lng=l.lng||s.lng,l.lngs=l.lngs||s.lngs,l.ns=l.ns||s.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||i||s.keyPrefix);const m=r.options.keySeparator||".";let x;return l.keyPrefix&&Array.isArray(o)?x=o.map(h=>`${l.keyPrefix}${m}${h}`):x=l.keyPrefix?`${l.keyPrefix}${m}${o}`:o,r.t(x,l)};return X(e)?s.lng=e:s.lngs=e,s.ns=t,s.keyPrefix=i,s}t(){var r;for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return(r=this.translator)==null?void 0:r.translate(...t)}exists(){var r;for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return(r=this.translator)==null?void 0:r.exists(...t)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const i=t.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(i.toLowerCase()==="cimode")return!0;const o=(c,l)=>{const u=this.services.backendConnector.state[`${c}|${l}`];return u===-1||u===0||u===2};if(t.precheck){const c=t.precheck(this,o);if(c!==void 0)return c}return!!(this.hasResourceBundle(i,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(i,e)&&(!r||o(s,e)))}loadNamespaces(e,t){const i=Qn();return this.options.ns?(X(e)&&(e=[e]),e.forEach(r=>{this.options.ns.indexOf(r)<0&&this.options.ns.push(r)}),this.loadResources(r=>{i.resolve(),t&&t(r)}),i):(t&&t(),Promise.resolve())}loadLanguages(e,t){const i=Qn();X(e)&&(e=[e]);const r=this.options.preload||[],s=e.filter(o=>r.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return s.length?(this.options.preload=r.concat(s),this.loadResources(o=>{i.resolve(),t&&t(o)}),i):(t&&t(),Promise.resolve())}dir(e){var r,s;if(e||(e=this.resolvedLanguage||(((r=this.languages)==null?void 0:r.length)>0?this.languages[0]:this.language)),!e)return"rtl";const t=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],i=((s=this.services)==null?void 0:s.languageUtils)||new dl(gl());return t.indexOf(i.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return new di(e,t)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ki;const i=e.forkResourceStore;i&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},s=new di(r);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(c=>{s[c]=this[c]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},i){const c=Object.keys(this.store.data).reduce((l,u)=>(l[u]={...this.store.data[u]},Object.keys(l[u]).reduce((p,g)=>(p[g]={...l[u][g]},p),{})),{});s.store=new ll(c,r),s.services.resourceStore=s.store}return s.translator=new lr(s.services,r),s.translator.on("*",function(c){for(var l=arguments.length,u=new Array(l>1?l-1:0),p=1;p<l;p++)u[p-1]=arguments[p];s.emit(c,...u)}),s.init(r,t),s.translator.options=r,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Ne=di.createInstance();Ne.createInstance=di.createInstance;Ne.createInstance;Ne.dir;Ne.init;Ne.loadResources;Ne.reloadResources;Ne.use;Ne.changeLanguage;Ne.getFixedT;const ue=Ne.t;Ne.exists;Ne.setDefaultNamespace;Ne.hasLoadedNamespace;Ne.loadNamespaces;Ne.loadLanguages;const Mt=a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()}),Ha=a.z.object({created_at:a.z.string(),updated_at:a.z.string()}),bd=a.z.object({email:a.z.string().optional(),email_verified:a.z.boolean().optional(),name:a.z.string().optional(),username:a.z.string().optional(),given_name:a.z.string().optional(),phone_number:a.z.string().optional(),phone_verified:a.z.boolean().optional(),family_name:a.z.string().optional()}).catchall(a.z.any()),kd=a.z.object({connection:a.z.string(),user_id:a.z.string(),provider:a.z.string(),isSocial:a.z.boolean(),access_token:a.z.string().optional(),access_token_secret:a.z.string().optional(),refresh_token:a.z.string().optional(),profileData:bd.optional()}),ns=a.z.object({email:a.z.string().optional(),username:a.z.string().optional(),given_name:a.z.string().optional(),family_name:a.z.string().optional(),nickname:a.z.string().optional(),name:a.z.string().optional(),picture:a.z.string().optional(),locale:a.z.string().optional(),linked_to:a.z.string().optional(),profileData:a.z.string().optional(),user_id:a.z.string().optional(),app_metadata:a.z.any().default({}).optional(),user_metadata:a.z.any().default({}).optional()}),ur=ns.extend({email_verified:a.z.boolean().default(!1),verify_email:a.z.boolean().optional(),last_ip:a.z.string().optional(),last_login:a.z.string().optional(),user_id:a.z.string().optional(),provider:a.z.string().default("email"),connection:a.z.string().default("email"),is_social:a.z.boolean().optional()}),Da=a.z.object({...ur.shape,...Ha.shape,user_id:a.z.string(),is_social:a.z.boolean(),email:a.z.string(),login_count:a.z.number(),identities:a.z.array(kd).optional()}),ft=Da,Hh=ns.extend({email:a.z.string(),login_count:a.z.number(),multifactor:a.z.array(a.z.string()).optional(),last_ip:a.z.string().optional(),last_login:a.z.string().optional(),user_id:a.z.string()}).catchall(a.z.any()),Dh="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Fh=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n));for(;n--;)e+=Dh[t[n]&63];return e};const xd=a.z.object({audience:a.z.string().optional(),recipient:a.z.string().optional(),createUpnClaim:a.z.boolean().optional(),mapUnknownClaimsAsIs:a.z.boolean().optional(),passthroughClaimsWithNoMapping:a.z.boolean().optional(),mapIdentities:a.z.boolean().optional(),signatureAlgorithm:a.z.string().optional(),digestAlgorithm:a.z.string().optional(),issuer:a.z.string().optional(),destination:a.z.string().optional(),lifetimeInSeconds:a.z.number().optional(),signResponse:a.z.boolean().optional(),nameIdentifierFormat:a.z.string().optional(),nameIdentifierProbes:a.z.array(a.z.string()).optional(),authnContextClassRef:a.z.string().optional(),mappings:a.z.record(a.z.string()).optional()}),dr=a.z.object({id:a.z.string(),name:a.z.string(),callbacks:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level. Query strings and hash information are not taken into account when validating these URLs."}),web_origins:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode."}),allowed_logout_urls:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),allowed_clients:a.z.array(a.z.string()).default([]).optional().openapi({description:"Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients"}),addons:a.z.object({samlp:xd.optional()}).default({}).optional().openapi({description:"Addons associated with the client. The key is the addon's package name and the value is an object with the configuration for the addon."}),email_validation:a.z.enum(["enabled","disabled","enforced"]).default("enforced").optional().openapi({description:"Defines if it possible to sign in with an unverified email and if verification emails will be sent. This is not available in auth0"}),client_secret:a.z.string().default(()=>Fh()).optional(),disable_sign_ups:a.z.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),Jt=a.z.object({created_at:a.z.string().transform(n=>n===null?"":n),updated_at:a.z.string().transform(n=>n===null?"":n),...dr.shape});var Pt=(n=>(n.TOKEN="token",n.TOKEN_ID_TOKEN="token id_token",n.CODE="code",n))(Pt||{}),nn=(n=>(n.QUERY="query",n.FRAGMENT="fragment",n.FORM_POST="form_post",n.WEB_MESSAGE="web_message",n.SAML_POST="saml_post",n))(nn||{}),is=(n=>(n.S256="S256",n.Plain="plain",n))(is||{});const Fa=a.z.object({client_id:a.z.string(),vendor_id:a.z.string().optional(),act_as:a.z.string().optional(),response_type:a.z.nativeEnum(Pt).optional(),response_mode:a.z.nativeEnum(nn).optional(),redirect_uri:a.z.string().optional(),audience:a.z.string().optional(),state:a.z.string().optional(),nonce:a.z.string().optional(),scope:a.z.string().optional(),prompt:a.z.string().optional(),code_challenge_method:a.z.nativeEnum(is).optional(),code_challenge:a.z.string().optional(),username:a.z.string().optional(),ui_locales:a.z.string().optional()}),yo=a.z.object({colors:a.z.object({primary:a.z.string(),page_background:a.z.object({type:a.z.string().optional(),start:a.z.string().optional(),end:a.z.string().optional(),angle_deg:a.z.number().optional()}).optional()}).optional(),logo_url:a.z.string().optional(),favicon_url:a.z.string().optional(),font:a.z.object({url:a.z.string()}).optional()}),pr=a.z.object({id:a.z.string().optional(),name:a.z.string(),strategy:a.z.string(),options:a.z.object({kid:a.z.string().optional(),team_id:a.z.string().optional(),realms:a.z.string().optional(),client_id:a.z.string().optional(),client_secret:a.z.string().optional(),app_secret:a.z.string().optional(),scope:a.z.string().optional(),authorization_endpoint:a.z.string().default("").optional(),token_endpoint:a.z.string().default("").optional(),userinfo_endpoint:a.z.string().default("").optional(),jwks_uri:a.z.string().default("").optional(),discovery_url:a.z.string().default("").optional(),issuer:a.z.string().default("").optional()}).default({}).optional(),enabled_clients:a.z.array(a.z.string()).default([]).optional(),response_type:a.z.custom().optional(),response_mode:a.z.custom().optional()}),zt=a.z.object({id:a.z.string(),created_at:a.z.string().transform(n=>n===null?"":n),updated_at:a.z.string().transform(n=>n===null?"":n)}).extend(pr.shape),fr=a.z.object({name:a.z.string(),audience:a.z.string(),sender_email:a.z.string().email(),sender_name:a.z.string(),support_url:a.z.string().url().optional(),logo:a.z.string().url().optional(),primary_color:a.z.string().optional(),secondary_color:a.z.string().optional(),language:a.z.string().optional()}),An=a.z.object({created_at:a.z.string().transform(n=>n===null?"":n),updated_at:a.z.string().transform(n=>n===null?"":n),id:a.z.string(),...fr.shape}),qh=a.z.object({logoUrl:a.z.string(),loginBackgroundImage:a.z.string().nullish(),style:a.z.object({primaryColor:a.z.string(),buttonTextColor:a.z.string(),primaryHoverColor:a.z.string()}),supportEmail:a.z.string().nullable(),supportUrl:a.z.string().nullable(),name:a.z.string(),showGreyishBackground:a.z.boolean().optional(),termsAndConditionsUrl:a.z.string().nullable(),companyName:a.z.string().optional(),checkoutHideSocial:a.z.boolean().optional(),siteUrl:a.z.string().nullable(),manageSubscriptionsUrl:a.z.string().optional()}),Kh=a.z.object({domain:a.z.string(),dkim_private_key:a.z.string().optional(),dkim_public_key:a.z.string().optional(),email_api_key:a.z.string().optional(),email_service:a.z.string().optional()});a.z.object({...Jt.shape,domains:a.z.array(Kh),tenant:An,connections:a.z.array(zt)});const Sd=a.z.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),Ad=a.z.object({code_id:a.z.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:a.z.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:a.z.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:Sd,code_verifier:a.z.string().optional().openapi({description:"The code verifier used in PKCE in outbound flows"}),expires_at:a.z.string(),used_at:a.z.string().optional(),user_id:a.z.string().optional()}),Wh=a.z.object({...Ad.shape,created_at:a.z.string()}),Id=a.z.object({domain:a.z.string(),dkim_private_key:a.z.string().optional(),dkim_public_key:a.z.string().optional(),email_api_key:a.z.string().optional(),email_service:a.z.string().optional()}),Gh=Ha.extend({...Id.shape,id:a.z.string()}),hr=a.z.object({trigger_id:a.z.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:a.z.boolean().default(!1),url:a.z.string(),hook_id:a.z.string().optional(),synchronous:a.z.boolean().default(!1),priority:a.z.number().optional()}),xn=hr.extend({...Ha.shape,hook_id:a.z.string()}),qa=a.z.object({alg:a.z.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:a.z.string(),kid:a.z.string(),kty:a.z.enum(["RSA","EC","oct"]),n:a.z.string(),x5t:a.z.string().optional(),x5c:a.z.array(a.z.string()).optional(),use:a.z.enum(["sig","enc"]).optional()}),Ed=a.z.object({keys:a.z.array(qa)}),vo=a.z.object({issuer:a.z.string(),authorization_endpoint:a.z.string(),token_endpoint:a.z.string(),device_authorization_endpoint:a.z.string(),userinfo_endpoint:a.z.string(),mfa_challenge_endpoint:a.z.string(),jwks_uri:a.z.string(),registration_endpoint:a.z.string(),revocation_endpoint:a.z.string(),scopes_supported:a.z.array(a.z.string()),response_types_supported:a.z.array(a.z.string()),code_challenge_methods_supported:a.z.array(a.z.string()),response_modes_supported:a.z.array(a.z.string()),subject_types_supported:a.z.array(a.z.string()),id_token_signing_alg_values_supported:a.z.array(a.z.string()),token_endpoint_auth_methods_supported:a.z.array(a.z.string()),claims_supported:a.z.array(a.z.string()),request_uri_parameter_supported:a.z.boolean(),request_parameter_supported:a.z.boolean(),token_endpoint_auth_signing_alg_values_supported:a.z.array(a.z.string())}),$d=a.z.object({auth0Client:a.z.string().optional(),authParams:Fa,expires_at:a.z.string(),deleted_at:a.z.string().optional(),ip:a.z.string().optional(),useragent:a.z.string().optional()}).openapi({description:"This represents a login sesion"}),Jh=a.z.object({...$d.shape,login_id:a.z.string().openapi({description:"This is is used as the state in the universal login"}),created_at:a.z.string(),updated_at:a.z.string()});var _e=(n=>(n.FAILED_SILENT_AUTH="fsa",n.FAILED_SIGNUP="fs",n.FAILED_LOGIN="f",n.FAILED_LOGIN_INCORRECT_PASSWORD="fp",n.FAILED_CHANGE_PASSWORD="fcp",n.FAILED_BY_CONNECTOR="fc",n.FAILED_LOGIN_INVALID_EMAIL_USERNAME="fu",n.FAILED_HOOK="fh",n.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",n.SUCCESS_API_OPERATION="sapi",n.SUCCESS_CHANGE_PASSWORD="scp",n.SUCCESS_CHANGE_PASSWORD_REQUEST="scpr",n.SUCCESS_CHANGE_USERNAME="scu",n.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",n.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",n.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",n.SUCCESS_LOGIN="s",n.SUCCESS_LOGOUT="slo",n.SUCCESS_SIGNUP="ss",n.SUCCESS_SILENT_AUTH="ssa",n.SUCCESS_VERIFICATION_EMAIL="sv",n.SUCCESS_VERIFICATION_EMAIL_REQUEST="svr",n.CODE_LINK_SENT="cls",n.BLOCKED_ACCOUNT_EMAIL="limit_wc",n.BLOCKED_ACCOUNT_IP="limit_sul",n.BLOCKED_IP_ADDRESS="limit_mu",n))(_e||{});const Zh=a.z.enum(["cls","fsa","fs","f","fc","fcoa","fcp","fh","fp","fs","fu","s","sapi","scoa","scp","scpr","scu","seacft","serft","slo","ss","ssa","sv","svr"]),Cd=a.z.object({name:a.z.string(),version:a.z.string(),env:a.z.object({node:a.z.string().optional()}).optional()}),gr=a.z.object({type:Zh,date:a.z.string(),description:a.z.string().optional(),log_id:a.z.string().optional(),_id:a.z.string().optional(),ip:a.z.string(),user_agent:a.z.string(),details:a.z.any().optional(),isMobile:a.z.boolean(),user_id:a.z.string().optional(),user_name:a.z.string().optional(),connection:a.z.string().optional(),connection_id:a.z.string().optional(),client_id:a.z.string().optional(),client_name:a.z.string().optional(),audience:a.z.string().optional(),scope:a.z.array(a.z.string()).optional(),strategy:a.z.string().optional(),strategy_type:a.z.string().optional(),hostname:a.z.string().optional(),auth0_client:Cd.optional()}),jd=a.z.object({user_id:a.z.string(),password:a.z.string(),algorithm:a.z.enum(["bcrypt","argon2id"]).default("argon2id")}),Yh=a.z.object({...jd.shape,created_at:a.z.string(),updated_at:a.z.string()}),zd=a.z.object({session_id:a.z.string(),client_id:a.z.string(),expires_at:a.z.string(),used_at:a.z.string(),deleted_at:a.z.string().optional(),user_id:a.z.string()}),Ka=a.z.object({created_at:a.z.string(),...zd.shape}),wo=a.z.object({kid:a.z.string().openapi({description:"The key id of the signing key"}),cert:a.z.string().openapi({description:"The public certificate of the signing key"}),fingerprint:a.z.string().openapi({description:"The cert fingerprint"}),thumbprint:a.z.string().openapi({description:"The cert thumbprint"}),pkcs7:a.z.string().optional().openapi({description:"The private key in pkcs7 format"}),current:a.z.boolean().optional().openapi({description:"True if the key is the current key"}),next:a.z.boolean().optional().openapi({description:"True if the key is the next key"}),previous:a.z.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:a.z.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:a.z.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:a.z.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:a.z.string().optional().openapi({description:"The date and time when the key was revoked"})});var _r=(n=>(n.RefreshToken="refresh_token",n.AuthorizationCode="authorization_code",n.ClientCredential="client_credentials",n.Passwordless="passwordless",n.Password="password",n))(_r||{});a.z.object({access_token:a.z.string(),id_token:a.z.string().optional(),scope:a.z.string().optional(),state:a.z.string().optional(),refresh_token:a.z.string().optional(),token_type:a.z.string(),expires_in:a.z.number()});a.z.object({code:a.z.string(),state:a.z.string().optional()});const Nd=a.z.object({button_border_radius:a.z.number(),button_border_weight:a.z.number(),buttons_style:a.z.enum(["pill"]),input_border_radius:a.z.number(),input_border_weight:a.z.number(),inputs_style:a.z.enum(["pill"]),show_widget_shadow:a.z.boolean(),widget_border_weight:a.z.number(),widget_corner_radius:a.z.number()}),Od=a.z.object({base_focus_color:a.z.string(),base_hover_color:a.z.string(),body_text:a.z.string(),captcha_widget_theme:a.z.enum(["auto"]),error:a.z.string(),header:a.z.string(),icons:a.z.string(),input_background:a.z.string(),input_border:a.z.string(),input_filled_text:a.z.string(),input_labels_placeholders:a.z.string(),links_focused_components:a.z.string(),primary_button:a.z.string(),primary_button_label:a.z.string(),secondary_button_border:a.z.string(),secondary_button_label:a.z.string(),success:a.z.string(),widget_background:a.z.string(),widget_border:a.z.string()}),Wt=a.z.object({bold:a.z.boolean(),size:a.z.number()}),Bd=a.z.object({body_text:Wt,buttons_text:Wt,font_url:a.z.string(),input_labels:Wt,links:Wt,links_style:a.z.enum(["normal"]),reference_text_size:a.z.number(),subtitle:Wt,title:Wt}),Td=a.z.object({background_color:a.z.string(),background_image_url:a.z.string(),page_layout:a.z.enum(["center"])}),Rd=a.z.object({header_text_alignment:a.z.enum(["center"]),logo_height:a.z.number(),logo_position:a.z.enum(["center"]),logo_url:a.z.string(),social_buttons_layout:a.z.enum(["bottom"])}),Pd=a.z.object({borders:Nd,colors:Od,displayName:a.z.string(),fonts:Bd,page_background:Td,widget:Rd}),Xh=Pd.extend({themeId:a.z.string()}),Xi=a.z.object({universal_login_experience:a.z.enum(["new","classic"]).default("new"),identifier_first:a.z.boolean().default(!0),password_first:a.z.boolean().default(!1),webauthn_platform_first_factor:a.z.boolean()}),Qi=a.z.object({name:a.z.string(),enabled:a.z.boolean().optional().default(!0),default_from_address:a.z.string().optional(),credentials:a.z.union([a.z.object({accessKeyId:a.z.string(),secretAccessKey:a.z.string(),region:a.z.string()}),a.z.object({smtp_host:a.z.array(a.z.string()),smtp_port:a.z.number(),smtp_user:a.z.string(),smtp_pass:a.z.string()}),a.z.object({api_key:a.z.string(),domain:a.z.string().optional()}),a.z.object({connectionString:a.z.string()}),a.z.object({tenantId:a.z.string(),clientId:a.z.string(),clientSecret:a.z.string()})]),settings:a.z.object({}).optional()});function Qh(n){const[e,t]=n.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${n}`);return{connection:e,id:t}}const eg=new a.OpenAPIHono().openapi(a.createRoute({tags:["branding"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:yo}},description:"Branding settings"}}}),async n=>{const{"tenant-id":e}=n.req.valid("header"),t=await n.env.data.branding.get(e);return t?n.json(t):n.json({})}).openapi(a.createRoute({tags:["branding"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(yo.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async n=>{const{"tenant-id":e}=n.req.valid("header"),t=n.req.valid("json");return await n.env.data.branding.set(e,t),n.text("OK")});var O=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});te(this,"res");te(this,"status");this.res=t==null?void 0:t.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}},mr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function tg(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function ng(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}),t}function ig(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ld={exports:{}};const rg={},sg=Object.freeze(Object.defineProperty({__proto__:null,default:rg},Symbol.toStringTag,{value:"Module"})),og=ng(sg);(function(n){/**
1
+ "use strict";var kh=Object.defineProperty;var xh=(n,e,t)=>e in n?kh(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var te=(n,e,t)=>xh(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@hono/zod-openapi"),X=n=>typeof n=="string",Qn=()=>{let n,e;const t=new Promise((i,r)=>{n=i,e=r});return t.resolve=n,t.reject=e,t},sl=n=>n==null?"":""+n,Sh=(n,e,t)=>{n.forEach(i=>{e[i]&&(t[i]=e[i])})},Ah=/###/g,ol=n=>n&&n.indexOf("###")>-1?n.replace(Ah,"."):n,al=n=>!n||X(n),ri=(n,e,t)=>{const i=X(e)?e.split("."):e;let r=0;for(;r<i.length-1;){if(al(n))return{};const s=ol(i[r]);!n[s]&&t&&(n[s]=new t),Object.prototype.hasOwnProperty.call(n,s)?n=n[s]:n={},++r}return al(n)?{}:{obj:n,k:ol(i[r])}},cl=(n,e,t)=>{const{obj:i,k:r}=ri(n,e,Object);if(i!==void 0||e.length===1){i[r]=t;return}let s=e[e.length-1],o=e.slice(0,e.length-1),c=ri(n,o,Object);for(;c.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),c=ri(n,o,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${s}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${s}`]=t},Ih=(n,e,t,i)=>{const{obj:r,k:s}=ri(n,e,Object);r[s]=r[s]||[],r[s].push(t)},or=(n,e)=>{const{obj:t,k:i}=ri(n,e);if(t&&Object.prototype.hasOwnProperty.call(t,i))return t[i]},Eh=(n,e,t)=>{const i=or(n,t);return i!==void 0?i:or(e,t)},vd=(n,e,t)=>{for(const i in e)i!=="__proto__"&&i!=="constructor"&&(i in n?X(n[i])||n[i]instanceof String||X(e[i])||e[i]instanceof String?t&&(n[i]=e[i]):vd(n[i],e[i],t):n[i]=e[i]);return n},wn=n=>n.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var $h={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Ch=n=>X(n)?n.replace(/[&<>"'\/]/g,e=>$h[e]):n;class jh{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const t=this.regExpMap.get(e);if(t!==void 0)return t;const i=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,i),this.regExpQueue.push(e),i}}const zh=[" ",",","?","!",";"],Nh=new jh(20),Oh=(n,e,t)=>{e=e||"",t=t||"";const i=zh.filter(o=>e.indexOf(o)<0&&t.indexOf(o)<0);if(i.length===0)return!0;const r=Nh.getRegExp(`(${i.map(o=>o==="?"?"\\?":o).join("|")})`);let s=!r.test(n);if(!s){const o=n.indexOf(t);o>0&&!r.test(n.substring(0,o))&&(s=!0)}return s},mo=function(n,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!n)return;if(n[e])return Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0;const i=e.split(t);let r=n;for(let s=0;s<i.length;){if(!r||typeof r!="object")return;let o,c="";for(let l=s;l<i.length;++l)if(l!==s&&(c+=t),c+=i[l],o=r[c],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&l<i.length-1)continue;s+=l-s+1;break}r=o}return r},ar=n=>n==null?void 0:n.replace("_","-"),Bh={type:"logger",log(n){this.output("log",n)},warn(n){this.output("warn",n)},error(n){this.output("error",n)},output(n,e){var t,i;(i=(t=console==null?void 0:console[n])==null?void 0:t.apply)==null||i.call(t,console,e)}};class cr{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(e,t)}init(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||Bh,this.options=t,this.debug=t.debug}log(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.forward(t,"log","",!0)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.forward(t,"warn","",!0)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.forward(t,"error","")}deprecate(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,i,r){return r&&!this.debug?null:(X(e[0])&&(e[0]=`${i}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new cr(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new cr(this.logger,e)}}var ht=new cr;class ts{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(i=>{this.observers[i]||(this.observers[i]=new Map);const r=this.observers[i].get(t)||0;this.observers[i].set(t,r+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}emit(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];this.observers[e]&&Array.from(this.observers[e].entries()).forEach(o=>{let[c,l]=o;for(let u=0;u<l;u++)c(...i)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(o=>{let[c,l]=o;for(let u=0;u<l;u++)c.apply(c,[e,...i])})}}class ll extends ts{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,i){var u,p;let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator,o=r.ignoreJSONStructure!==void 0?r.ignoreJSONStructure:this.options.ignoreJSONStructure;let c;e.indexOf(".")>-1?c=e.split("."):(c=[e,t],i&&(Array.isArray(i)?c.push(...i):X(i)&&s?c.push(...i.split(s)):c.push(i)));const l=or(this.data,c);return!l&&!t&&!i&&e.indexOf(".")>-1&&(e=c[0],t=c[1],i=c.slice(2).join(".")),l||!o||!X(i)?l:mo((p=(u=this.data)==null?void 0:u[e])==null?void 0:p[t],i,s)}addResource(e,t,i,r){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let c=[e,t];i&&(c=c.concat(o?i.split(o):i)),e.indexOf(".")>-1&&(c=e.split("."),r=t,t=c[1]),this.addNamespaces(t),cl(this.data,c,r),s.silent||this.emit("added",e,t,i,r)}addResources(e,t,i){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const s in i)(X(i[s])||Array.isArray(i[s]))&&this.addResource(e,t,s,i[s],{silent:!0});r.silent||this.emit("added",e,t,i)}addResourceBundle(e,t,i,r,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},c=[e,t];e.indexOf(".")>-1&&(c=e.split("."),r=i,i=t,t=c[1]),this.addNamespaces(t);let l=or(this.data,c)||{};o.skipCopy||(i=JSON.parse(JSON.stringify(i))),r?vd(l,i,s):l={...l,...i},cl(this.data,c,l),o.silent||this.emit("added",e,t,i)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(r=>t[r]&&Object.keys(t[r]).length>0)}toJSON(){return this.data}}var wd={processors:{},addPostProcessor(n){this.processors[n.name]=n},handle(n,e,t,i,r){return n.forEach(s=>{var o;e=((o=this.processors[s])==null?void 0:o.process(e,t,i,r))??e}),e}};const ul={};class lr extends ts{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Sh(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=ht.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(e==null)return!1;const i=this.resolve(e,t);return(i==null?void 0:i.res)!==void 0}extractFromKey(e,t){let i=t.nsSeparator!==void 0?t.nsSeparator:this.options.nsSeparator;i===void 0&&(i=":");const r=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator;let s=t.ns||this.options.defaultNS||[];const o=i&&e.indexOf(i)>-1,c=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!Oh(e,i,r);if(o&&!c){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:X(s)?[s]:s};const u=e.split(i);(i!==r||i===r&&this.options.ns.indexOf(u[0])>-1)&&(s=u.shift()),e=u.join(r)}return{key:e,namespaces:X(s)?[s]:s}}translate(e,t,i){if(typeof t!="object"&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),typeof t=="object"&&(t={...t}),t||(t={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const r=t.returnDetails!==void 0?t.returnDetails:this.options.returnDetails,s=t.keySeparator!==void 0?t.keySeparator:this.options.keySeparator,{key:o,namespaces:c}=this.extractFromKey(e[e.length-1],t),l=c[c.length-1],u=t.lng||this.language,p=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((u==null?void 0:u.toLowerCase())==="cimode"){if(p){const q=t.nsSeparator||this.options.nsSeparator;return r?{res:`${l}${q}${o}`,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(t)}:`${l}${q}${o}`}return r?{res:o,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(t)}:o}const g=this.resolve(e,t);let m=g==null?void 0:g.res;const x=(g==null?void 0:g.usedKey)||o,h=(g==null?void 0:g.exactUsedKey)||o,_=Object.prototype.toString.apply(m),b=["[object Number]","[object Function]","[object RegExp]"],S=t.joinArrays!==void 0?t.joinArrays:this.options.joinArrays,N=!this.i18nFormat||this.i18nFormat.handleAsObject,T=!X(m)&&typeof m!="boolean"&&typeof m!="number";if(N&&m&&T&&b.indexOf(_)<0&&!(X(S)&&Array.isArray(m))){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const q=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,m,{...t,ns:c}):`key '${o} (${this.language})' returned an object instead of string.`;return r?(g.res=q,g.usedParams=this.getUsedParamsDetails(t),g):q}if(s){const q=Array.isArray(m),oe=q?[]:{},pe=q?h:x;for(const ce in m)if(Object.prototype.hasOwnProperty.call(m,ce)){const Re=`${pe}${s}${ce}`;oe[ce]=this.translate(Re,{...t,joinArrays:!1,ns:c}),oe[ce]===Re&&(oe[ce]=m[ce])}m=oe}}else if(N&&X(S)&&Array.isArray(m))m=m.join(S),m&&(m=this.extendTranslation(m,e,t,i));else{let q=!1,oe=!1;const pe=t.count!==void 0&&!X(t.count),ce=lr.hasDefaultValue(t),Re=pe?this.pluralResolver.getSuffix(u,t.count,t):"",nt=t.ordinal&&pe?this.pluralResolver.getSuffix(u,t.count,{ordinal:!1}):"",De=pe&&!t.ordinal&&t.count===0,$=De&&t[`defaultValue${this.options.pluralSeparator}zero`]||t[`defaultValue${Re}`]||t[`defaultValue${nt}`]||t.defaultValue;!this.isValidLookup(m)&&ce&&(q=!0,m=$),this.isValidLookup(m)||(oe=!0,m=o);const A=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&oe?void 0:m,w=ce&&$!==m&&this.options.updateMissing;if(oe||q||w){if(this.logger.log(w?"updateKey":"missingKey",u,l,o,w?$:m),s){const Z=this.resolve(o,{...t,keySeparator:!1});Z&&Z.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let v=[];const C=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if(this.options.saveMissingTo==="fallback"&&C&&C[0])for(let Z=0;Z<C.length;Z++)v.push(C[Z]);else this.options.saveMissingTo==="all"?v=this.languageUtils.toResolveHierarchy(t.lng||this.language):v.push(t.lng||this.language);const R=(Z,K,ee)=>{var M;const se=ce&&ee!==m?ee:A;this.options.missingKeyHandler?this.options.missingKeyHandler(Z,l,K,se,w,t):(M=this.backendConnector)!=null&&M.saveMissing&&this.backendConnector.saveMissing(Z,l,K,se,w,t),this.emit("missingKey",Z,l,K,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&pe?v.forEach(Z=>{const K=this.pluralResolver.getSuffixes(Z,t);De&&t[`defaultValue${this.options.pluralSeparator}zero`]&&K.indexOf(`${this.options.pluralSeparator}zero`)<0&&K.push(`${this.options.pluralSeparator}zero`),K.forEach(ee=>{R([Z],o+ee,t[`defaultValue${ee}`]||$)})}):R(v,o,$))}m=this.extendTranslation(m,e,t,g,i),oe&&m===o&&this.options.appendNamespaceToMissingKey&&(m=`${l}:${o}`),(oe||q)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${o}`:o,q?m:void 0))}return r?(g.res=m,g.usedParams=this.getUsedParamsDetails(t),g):m}extendTranslation(e,t,i,r,s){var u,p;var o=this;if((u=this.i18nFormat)!=null&&u.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...i},i.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init({...i,interpolation:{...this.options.interpolation,...i.interpolation}});const g=X(e)&&(((p=i==null?void 0:i.interpolation)==null?void 0:p.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let m;if(g){const h=e.match(this.interpolator.nestingRegexp);m=h&&h.length}let x=i.replace&&!X(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(x={...this.options.interpolation.defaultVariables,...x}),e=this.interpolator.interpolate(e,x,i.lng||this.language||r.usedLng,i),g){const h=e.match(this.interpolator.nestingRegexp),_=h&&h.length;m<_&&(i.nest=!1)}!i.lng&&r&&r.res&&(i.lng=this.language||r.usedLng),i.nest!==!1&&(e=this.interpolator.nest(e,function(){for(var h=arguments.length,_=new Array(h),b=0;b<h;b++)_[b]=arguments[b];return(s==null?void 0:s[0])===_[0]&&!i.context?(o.logger.warn(`It seems you are nesting recursively key: ${_[0]} in key: ${t[0]}`),null):o.translate(..._,t)},i)),i.interpolation&&this.interpolator.reset()}const c=i.postProcess||this.options.postProcess,l=X(c)?[c]:c;return e!=null&&(l!=null&&l.length)&&i.applyPostProcessor!==!1&&(e=wd.handle(l,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(i)},...i}:i,this)),e}resolve(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i,r,s,o,c;return X(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(i))return;const u=this.extractFromKey(l,t),p=u.key;r=p;let g=u.namespaces;this.options.fallbackNS&&(g=g.concat(this.options.fallbackNS));const m=t.count!==void 0&&!X(t.count),x=m&&!t.ordinal&&t.count===0,h=t.context!==void 0&&(X(t.context)||typeof t.context=="number")&&t.context!=="",_=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);g.forEach(b=>{var S,N;this.isValidLookup(i)||(c=b,!ul[`${_[0]}-${b}`]&&((S=this.utils)!=null&&S.hasLoadedNamespace)&&!((N=this.utils)!=null&&N.hasLoadedNamespace(c))&&(ul[`${_[0]}-${b}`]=!0,this.logger.warn(`key "${r}" for languages "${_.join(", ")}" won't get resolved as namespace "${c}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),_.forEach(T=>{var pe;if(this.isValidLookup(i))return;o=T;const q=[p];if((pe=this.i18nFormat)!=null&&pe.addLookupKeys)this.i18nFormat.addLookupKeys(q,p,T,b,t);else{let ce;m&&(ce=this.pluralResolver.getSuffix(T,t.count,t));const Re=`${this.options.pluralSeparator}zero`,nt=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(q.push(p+ce),t.ordinal&&ce.indexOf(nt)===0&&q.push(p+ce.replace(nt,this.options.pluralSeparator)),x&&q.push(p+Re)),h){const De=`${p}${this.options.contextSeparator}${t.context}`;q.push(De),m&&(q.push(De+ce),t.ordinal&&ce.indexOf(nt)===0&&q.push(De+ce.replace(nt,this.options.pluralSeparator)),x&&q.push(De+Re))}}let oe;for(;oe=q.pop();)this.isValidLookup(i)||(s=oe,i=this.getResource(T,b,oe,t))}))})}),{res:i,usedKey:r,exactUsedKey:s,usedLng:o,usedNS:c}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,t,i){var s;let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return(s=this.i18nFormat)!=null&&s.getResource?this.i18nFormat.getResource(e,t,i,r):this.resourceStore.getResource(e,t,i,r)}getUsedParamsDetails(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const t=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=e.replace&&!X(e.replace);let r=i?e.replace:e;if(i&&typeof e.count<"u"&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!i){r={...r};for(const s of t)delete r[s]}return r}static hasDefaultValue(e){const t="defaultValue";for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t===i.substring(0,t.length)&&e[i]!==void 0)return!0;return!1}}class dl{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ht.create("languageUtils")}getScriptPartFromCode(e){if(e=ar(e),!e||e.indexOf("-")<0)return null;const t=e.split("-");return t.length===2||(t.pop(),t[t.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(e=ar(e),!e||e.indexOf("-")<0)return e;const t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(X(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(i=>{if(t)return;const r=this.formatLanguageCode(i);(!this.options.supportedLngs||this.isSupportedCode(r))&&(t=r)}),!t&&this.options.supportedLngs&&e.forEach(i=>{if(t)return;const r=this.getLanguagePartFromCode(i);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(s=>{if(s===r)return s;if(!(s.indexOf("-")<0&&r.indexOf("-")<0)&&(s.indexOf("-")>0&&r.indexOf("-")<0&&s.substring(0,s.indexOf("-"))===r||s.indexOf(r)===0&&r.length>1))return s})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),X(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let i=e[t];return i||(i=e[this.getScriptPartFromCode(t)]),i||(i=e[this.formatLanguageCode(t)]),i||(i=e[this.getLanguagePartFromCode(t)]),i||(i=e.default),i||[]}toResolveHierarchy(e,t){const i=this.getFallbackCodes(t||this.options.fallbackLng||[],e),r=[],s=o=>{o&&(this.isSupportedCode(o)?r.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return X(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&s(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&s(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&s(this.getLanguagePartFromCode(e))):X(e)&&s(this.formatLanguageCode(e)),i.forEach(o=>{r.indexOf(o)<0&&s(this.formatLanguageCode(o))}),r}}const pl={zero:0,one:1,two:2,few:3,many:4,other:5},fl={select:n=>n===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Th{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=t,this.logger=ht.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=ar(e==="dev"?"en":e),r=t.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:i,type:r});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let o;try{o=new Intl.PluralRules(i,{type:r})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),fl;if(!e.match(/-|_/))return fl;const l=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(l,t)}return this.pluralRulesCache[s]=o,o}needsPlural(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),(i==null?void 0:i.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,i).map(r=>`${t}${r}`)}getSuffixes(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=this.getRule(e,t);return i||(i=this.getRule("dev",t)),i?i.resolvedOptions().pluralCategories.sort((r,s)=>pl[r]-pl[s]).map(r=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${r}`):[]}getSuffix(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=this.getRule(e,i);return r?`${this.options.prepend}${i.ordinal?`ordinal${this.options.prepend}`:""}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,i))}}const hl=function(n,e,t){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",r=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=Eh(n,e,t);return!s&&r&&X(t)&&(s=mo(n,t,i),s===void 0&&(s=mo(e,t,i))),s},to=n=>n.replace(/\$/g,"$$$$");class Rh{constructor(){var t;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=ht.create("interpolator"),this.options=e,this.format=((t=e==null?void 0:e.interpolation)==null?void 0:t.format)||(i=>i),this.init(e)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});const{escape:t,escapeValue:i,useRawValueToEscape:r,prefix:s,prefixEscaped:o,suffix:c,suffixEscaped:l,formatSeparator:u,unescapeSuffix:p,unescapePrefix:g,nestingPrefix:m,nestingPrefixEscaped:x,nestingSuffix:h,nestingSuffixEscaped:_,nestingOptionsSeparator:b,maxReplaces:S,alwaysFormat:N}=e.interpolation;this.escape=t!==void 0?t:Ch,this.escapeValue=i!==void 0?i:!0,this.useRawValueToEscape=r!==void 0?r:!1,this.prefix=s?wn(s):o||"{{",this.suffix=c?wn(c):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=p?"":g||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=m?wn(m):x||wn("$t("),this.nestingSuffix=h?wn(h):_||wn(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=S||1e3,this.alwaysFormat=N!==void 0?N:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(t,i)=>(t==null?void 0:t.source)===i?(t.lastIndex=0,t):new RegExp(i,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(e,t,i,r){var x;let s,o,c;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=h=>{if(h.indexOf(this.formatSeparator)<0){const N=hl(t,l,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(N,void 0,i,{...r,...t,interpolationkey:h}):N}const _=h.split(this.formatSeparator),b=_.shift().trim(),S=_.join(this.formatSeparator).trim();return this.format(hl(t,l,b,this.options.keySeparator,this.options.ignoreJSONStructure),S,i,{...r,...t,interpolationkey:b})};this.resetRegExp();const p=(r==null?void 0:r.missingInterpolationHandler)||this.options.missingInterpolationHandler,g=((x=r==null?void 0:r.interpolation)==null?void 0:x.skipOnVariables)!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>to(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?to(this.escape(h)):to(h)}].forEach(h=>{for(c=0;s=h.regex.exec(e);){const _=s[1].trim();if(o=u(_),o===void 0)if(typeof p=="function"){const S=p(e,s,r);o=X(S)?S:""}else if(r&&Object.prototype.hasOwnProperty.call(r,_))o="";else if(g){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${_} for interpolating ${e}`),o="";else!X(o)&&!this.useRawValueToEscape&&(o=sl(o));const b=h.safeValue(o);if(e=e.replace(s[0],b),g?(h.regex.lastIndex+=o.length,h.regex.lastIndex-=s[0].length):h.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),e}nest(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r,s,o;const c=(l,u)=>{const p=this.nestingOptionsSeparator;if(l.indexOf(p)<0)return l;const g=l.split(new RegExp(`${p}[ ]*{`));let m=`{${g[1]}`;l=g[0],m=this.interpolate(m,o);const x=m.match(/'/g),h=m.match(/"/g);(((x==null?void 0:x.length)??0)%2===0&&!h||h.length%2!==0)&&(m=m.replace(/'/g,'"'));try{o=JSON.parse(m),u&&(o={...u,...o})}catch(_){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,_),`${l}${p}${m}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,l};for(;r=this.nestingRegexp.exec(e);){let l=[];o={...i},o=o.replace&&!X(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;let u=!1;if(r[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(r[1])){const p=r[1].split(this.formatSeparator).map(g=>g.trim());r[1]=p.shift(),l=p,u=!0}if(s=t(c.call(this,r[1].trim(),o),o),s&&r[0]===e&&!X(s))return s;X(s)||(s=sl(s)),s||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),s=""),u&&(s=l.reduce((p,g)=>this.format(p,g,i.lng,{...i,interpolationkey:r[1].trim()}),s.trim())),e=e.replace(r[0],s),this.regexp.lastIndex=0}return e}}const Ph=n=>{let e=n.toLowerCase().trim();const t={};if(n.indexOf("(")>-1){const i=n.split("(");e=i[0].toLowerCase().trim();const r=i[1].substring(0,i[1].length-1);e==="currency"&&r.indexOf(":")<0?t.currency||(t.currency=r.trim()):e==="relativetime"&&r.indexOf(":")<0?t.range||(t.range=r.trim()):r.split(";").forEach(o=>{if(o){const[c,...l]=o.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),p=c.trim();t[p]||(t[p]=u),u==="false"&&(t[p]=!1),u==="true"&&(t[p]=!0),isNaN(u)||(t[p]=parseInt(u,10))}})}return{formatName:e,formatOptions:t}},bn=n=>{const e={};return(t,i,r)=>{let s=r;r&&r.interpolationkey&&r.formatParams&&r.formatParams[r.interpolationkey]&&r[r.interpolationkey]&&(s={...s,[r.interpolationkey]:void 0});const o=i+JSON.stringify(s);let c=e[o];return c||(c=n(ar(i),r),e[o]=c),c(t)}};class Lh{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=ht.create("formatter"),this.options=e,this.formats={number:bn((t,i)=>{const r=new Intl.NumberFormat(t,{...i});return s=>r.format(s)}),currency:bn((t,i)=>{const r=new Intl.NumberFormat(t,{...i,style:"currency"});return s=>r.format(s)}),datetime:bn((t,i)=>{const r=new Intl.DateTimeFormat(t,{...i});return s=>r.format(s)}),relativetime:bn((t,i)=>{const r=new Intl.RelativeTimeFormat(t,{...i});return s=>r.format(s,i.range||"day")}),list:bn((t,i)=>{const r=new Intl.ListFormat(t,{...i});return s=>r.format(s)})},this.init(e)}init(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=t.interpolation.formatSeparator||","}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=bn(t)}format(e,t,i){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=t.split(this.formatSeparator);if(s.length>1&&s[0].indexOf("(")>1&&s[0].indexOf(")")<0&&s.find(c=>c.indexOf(")")>-1)){const c=s.findIndex(l=>l.indexOf(")")>-1);s[0]=[s[0],...s.splice(1,c)].join(this.formatSeparator)}return s.reduce((c,l)=>{var g;const{formatName:u,formatOptions:p}=Ph(l);if(this.formats[u]){let m=c;try{const x=((g=r==null?void 0:r.formatParams)==null?void 0:g[r.interpolationkey])||{},h=x.locale||x.lng||r.locale||r.lng||i;m=this.formats[u](c,h,{...p,...r,...x})}catch(x){this.logger.warn(x)}return m}else this.logger.warn(`there was no format function for ${u}`);return c},e)}}const Uh=(n,e)=>{n.pending[e]!==void 0&&(delete n.pending[e],n.pendingCount--)};class Vh extends ts{constructor(e,t,i){var s,o;let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=t,this.services=i,this.languageUtils=i.languageUtils,this.options=r,this.logger=ht.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],(o=(s=this.backend)==null?void 0:s.init)==null||o.call(s,i,r.backend,r)}queueLoad(e,t,i,r){const s={},o={},c={},l={};return e.forEach(u=>{let p=!0;t.forEach(g=>{const m=`${u}|${g}`;!i.reload&&this.store.hasResourceBundle(u,g)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?o[m]===void 0&&(o[m]=!0):(this.state[m]=1,p=!1,o[m]===void 0&&(o[m]=!0),s[m]===void 0&&(s[m]=!0),l[g]===void 0&&(l[g]=!0)))}),p||(c[u]=!0)}),(Object.keys(s).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(s),pending:Object.keys(o),toLoadLanguages:Object.keys(c),toLoadNamespaces:Object.keys(l)}}loaded(e,t,i){const r=e.split("|"),s=r[0],o=r[1];t&&this.emit("failedLoading",s,o,t),!t&&i&&this.store.addResourceBundle(s,o,i,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&i&&(this.state[e]=0);const c={};this.queue.forEach(l=>{Ih(l.loaded,[s],o),Uh(l,e),t&&l.errors.push(t),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{c[u]||(c[u]={});const p=l.loaded[u];p.length&&p.forEach(g=>{c[u][g]===void 0&&(c[u][g]=!0)})}),l.done=!0,l.errors.length?l.callback(l.errors):l.callback())}),this.emit("loaded",c),this.queue=this.queue.filter(l=>!l.done)}read(e,t,i){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:i,tried:r,wait:s,callback:o});return}this.readingCalls++;const c=(u,p)=>{if(this.readingCalls--,this.waitingReads.length>0){const g=this.waitingReads.shift();this.read(g.lng,g.ns,g.fcName,g.tried,g.wait,g.callback)}if(u&&p&&r<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,i,r+1,s*2,o)},s);return}o(u,p)},l=this.backend[i].bind(this.backend);if(l.length===2){try{const u=l(e,t);u&&typeof u.then=="function"?u.then(p=>c(null,p)).catch(c):c(null,u)}catch(u){c(u)}return}return l(e,t,c)}prepareLoading(e,t){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();X(e)&&(e=this.languageUtils.toResolveHierarchy(e)),X(t)&&(t=[t]);const s=this.queueLoad(e,t,i,r);if(!s.toLoad.length)return s.pending.length||r(),null;s.toLoad.forEach(o=>{this.loadOne(o)})}load(e,t,i){this.prepareLoading(e,t,{},i)}reload(e,t,i){this.prepareLoading(e,t,{reload:!0},i)}loadOne(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const i=e.split("|"),r=i[0],s=i[1];this.read(r,s,"read",void 0,void 0,(o,c)=>{o&&this.logger.warn(`${t}loading namespace ${s} for language ${r} failed`,o),!o&&c&&this.logger.log(`${t}loaded namespace ${s} for language ${r}`,c),this.loaded(e,o,c)})}saveMissing(e,t,i,r,s){var l,u,p,g,m;let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if((u=(l=this.services)==null?void 0:l.utils)!=null&&u.hasLoadedNamespace&&!((g=(p=this.services)==null?void 0:p.utils)!=null&&g.hasLoadedNamespace(t))){this.logger.warn(`did not save key "${i}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(i==null||i==="")){if((m=this.backend)!=null&&m.create){const x={...o,isUpdate:s},h=this.backend.create.bind(this.backend);if(h.length<6)try{let _;h.length===5?_=h(e,t,i,r,x):_=h(e,t,i,r),_&&typeof _.then=="function"?_.then(b=>c(null,b)).catch(c):c(null,_)}catch(_){c(_)}else h(e,t,i,r,c,x)}!e||!e[0]||this.store.addResource(e[0],t,i,r)}}}const gl=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:n=>{let e={};if(typeof n[1]=="object"&&(e=n[1]),X(n[1])&&(e.defaultValue=n[1]),X(n[2])&&(e.tDescription=n[2]),typeof n[2]=="object"||typeof n[3]=="object"){const t=n[3]||n[2];Object.keys(t).forEach(i=>{e[i]=t[i]})}return e},interpolation:{escapeValue:!0,format:n=>n,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),_l=n=>{var e,t;return X(n.ns)&&(n.ns=[n.ns]),X(n.fallbackLng)&&(n.fallbackLng=[n.fallbackLng]),X(n.fallbackNS)&&(n.fallbackNS=[n.fallbackNS]),((t=(e=n.supportedLngs)==null?void 0:e.indexOf)==null?void 0:t.call(e,"cimode"))<0&&(n.supportedLngs=n.supportedLngs.concat(["cimode"])),typeof n.initImmediate=="boolean"&&(n.initAsync=n.initImmediate),n},Ki=()=>{},Mh=n=>{Object.getOwnPropertyNames(Object.getPrototypeOf(n)).forEach(t=>{typeof n[t]=="function"&&(n[t]=n[t].bind(n))})};class di extends ts{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;if(super(),this.options=_l(e),this.services={},this.logger=ht,this.modules={external:[]},Mh(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof t=="function"&&(i=t,t={}),!t.defaultNS&&t.defaultNS!==!1&&t.ns&&(X(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const r=gl();this.options={...r,...this.options,..._l(t)},this.options.interpolation={...r.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator);const s=p=>p?typeof p=="function"?new p:p:null;if(!this.options.isClone){this.modules.logger?ht.init(s(this.modules.logger),this.options):ht.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:p=Lh;const g=new dl(this.options);this.store=new ll(this.options.resources,this.options);const m=this.services;m.logger=ht,m.resourceStore=this.store,m.languageUtils=g,m.pluralResolver=new Th(g,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),p&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(m.formatter=s(p),m.formatter.init(m,this.options),this.options.interpolation.format=m.formatter.format.bind(m.formatter)),m.interpolator=new Rh(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new Vh(s(this.modules.backend),m.resourceStore,m,this.options),m.backendConnector.on("*",function(x){for(var h=arguments.length,_=new Array(h>1?h-1:0),b=1;b<h;b++)_[b-1]=arguments[b];e.emit(x,..._)}),this.modules.languageDetector&&(m.languageDetector=s(this.modules.languageDetector),m.languageDetector.init&&m.languageDetector.init(m,this.options.detection,this.options)),this.modules.i18nFormat&&(m.i18nFormat=s(this.modules.i18nFormat),m.i18nFormat.init&&m.i18nFormat.init(this)),this.translator=new lr(this.services,this.options),this.translator.on("*",function(x){for(var h=arguments.length,_=new Array(h>1?h-1:0),b=1;b<h;b++)_[b-1]=arguments[b];e.emit(x,..._)}),this.modules.external.forEach(x=>{x.init&&x.init(this)})}if(this.format=this.options.interpolation.format,i||(i=Ki),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const p=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);p.length>0&&p[0]!=="dev"&&(this.options.lng=p[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(p=>{this[p]=function(){return e.store[p](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(p=>{this[p]=function(){return e.store[p](...arguments),e}});const l=Qn(),u=()=>{const p=(g,m)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(m),i(g,m)};if(this.languages&&!this.isInitialized)return p(null,this.t.bind(this));this.changeLanguage(this.options.lng,p)};return this.options.resources||!this.options.initAsync?u():setTimeout(u,0),l}loadResources(e){var s,o;let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ki;const r=X(e)?e:this.language;if(typeof e=="function"&&(i=e),!this.options.resources||this.options.partialBundledLanguages){if((r==null?void 0:r.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return i();const c=[],l=u=>{if(!u||u==="cimode")return;this.services.languageUtils.toResolveHierarchy(u).forEach(g=>{g!=="cimode"&&c.indexOf(g)<0&&c.push(g)})};r?l(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(p=>l(p)),(o=(s=this.options.preload)==null?void 0:s.forEach)==null||o.call(s,u=>l(u)),this.services.backendConnector.load(c,this.options.ns,u=>{!u&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),i(u)})}else i(null)}reloadResources(e,t,i){const r=Qn();return typeof e=="function"&&(i=e,e=void 0),typeof t=="function"&&(i=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),i||(i=Ki),this.services.backendConnector.reload(e,t,s=>{r.resolve(),i(s)}),r}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&wd.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!(["cimode","dev"].indexOf(e)>-1))for(let t=0;t<this.languages.length;t++){const i=this.languages[t];if(!(["cimode","dev"].indexOf(i)>-1)&&this.store.hasLanguageSomeTranslations(i)){this.resolvedLanguage=i;break}}}changeLanguage(e,t){var i=this;this.isLanguageChangingTo=e;const r=Qn();this.emit("languageChanging",e);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},o=(l,u)=>{u?(s(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,r.resolve(function(){return i.t(...arguments)}),t&&t(l,function(){return i.t(...arguments)})},c=l=>{var p,g;!e&&!l&&this.services.languageDetector&&(l=[]);const u=X(l)?l:this.services.languageUtils.getBestMatchFromCodes(l);u&&(this.language||s(u),this.translator.language||this.translator.changeLanguage(u),(g=(p=this.services.languageDetector)==null?void 0:p.cacheUserLanguage)==null||g.call(p,u)),this.loadResources(u,m=>{o(m,u)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?c(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(c):this.services.languageDetector.detect(c):c(e),r}getFixedT(e,t,i){var r=this;const s=function(o,c){let l;if(typeof c!="object"){for(var u=arguments.length,p=new Array(u>2?u-2:0),g=2;g<u;g++)p[g-2]=arguments[g];l=r.options.overloadTranslationOptionHandler([o,c].concat(p))}else l={...c};l.lng=l.lng||s.lng,l.lngs=l.lngs||s.lngs,l.ns=l.ns||s.ns,l.keyPrefix!==""&&(l.keyPrefix=l.keyPrefix||i||s.keyPrefix);const m=r.options.keySeparator||".";let x;return l.keyPrefix&&Array.isArray(o)?x=o.map(h=>`${l.keyPrefix}${m}${h}`):x=l.keyPrefix?`${l.keyPrefix}${m}${o}`:o,r.t(x,l)};return X(e)?s.lng=e:s.lngs=e,s.ns=t,s.keyPrefix=i,s}t(){var r;for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return(r=this.translator)==null?void 0:r.translate(...t)}exists(){var r;for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return(r=this.translator)==null?void 0:r.exists(...t)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const i=t.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(i.toLowerCase()==="cimode")return!0;const o=(c,l)=>{const u=this.services.backendConnector.state[`${c}|${l}`];return u===-1||u===0||u===2};if(t.precheck){const c=t.precheck(this,o);if(c!==void 0)return c}return!!(this.hasResourceBundle(i,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(i,e)&&(!r||o(s,e)))}loadNamespaces(e,t){const i=Qn();return this.options.ns?(X(e)&&(e=[e]),e.forEach(r=>{this.options.ns.indexOf(r)<0&&this.options.ns.push(r)}),this.loadResources(r=>{i.resolve(),t&&t(r)}),i):(t&&t(),Promise.resolve())}loadLanguages(e,t){const i=Qn();X(e)&&(e=[e]);const r=this.options.preload||[],s=e.filter(o=>r.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return s.length?(this.options.preload=r.concat(s),this.loadResources(o=>{i.resolve(),t&&t(o)}),i):(t&&t(),Promise.resolve())}dir(e){var r,s;if(e||(e=this.resolvedLanguage||(((r=this.languages)==null?void 0:r.length)>0?this.languages[0]:this.language)),!e)return"rtl";const t=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],i=((s=this.services)==null?void 0:s.languageUtils)||new dl(gl());return t.indexOf(i.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return new di(e,t)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ki;const i=e.forkResourceStore;i&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},s=new di(r);if((e.debug!==void 0||e.prefix!==void 0)&&(s.logger=s.logger.clone(e)),["store","services","language"].forEach(c=>{s[c]=this[c]}),s.services={...this.services},s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},i){const c=Object.keys(this.store.data).reduce((l,u)=>(l[u]={...this.store.data[u]},Object.keys(l[u]).reduce((p,g)=>(p[g]={...l[u][g]},p),{})),{});s.store=new ll(c,r),s.services.resourceStore=s.store}return s.translator=new lr(s.services,r),s.translator.on("*",function(c){for(var l=arguments.length,u=new Array(l>1?l-1:0),p=1;p<l;p++)u[p-1]=arguments[p];s.emit(c,...u)}),s.init(r,t),s.translator.options=r,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Ne=di.createInstance();Ne.createInstance=di.createInstance;Ne.createInstance;Ne.dir;Ne.init;Ne.loadResources;Ne.reloadResources;Ne.use;Ne.changeLanguage;Ne.getFixedT;const ue=Ne.t;Ne.exists;Ne.setDefaultNamespace;Ne.hasLoadedNamespace;Ne.loadNamespaces;Ne.loadLanguages;const Mt=a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()}),Ha=a.z.object({created_at:a.z.string(),updated_at:a.z.string()}),bd=a.z.object({email:a.z.string().optional(),email_verified:a.z.boolean().optional(),name:a.z.string().optional(),username:a.z.string().optional(),given_name:a.z.string().optional(),phone_number:a.z.string().optional(),phone_verified:a.z.boolean().optional(),family_name:a.z.string().optional()}).catchall(a.z.any()),kd=a.z.object({connection:a.z.string(),user_id:a.z.string(),provider:a.z.string(),isSocial:a.z.boolean(),access_token:a.z.string().optional(),access_token_secret:a.z.string().optional(),refresh_token:a.z.string().optional(),profileData:bd.optional()}),ns=a.z.object({email:a.z.string().optional(),username:a.z.string().optional(),given_name:a.z.string().optional(),family_name:a.z.string().optional(),nickname:a.z.string().optional(),name:a.z.string().optional(),picture:a.z.string().optional(),locale:a.z.string().optional(),linked_to:a.z.string().optional(),profileData:a.z.string().optional(),user_id:a.z.string().optional(),app_metadata:a.z.any().default({}).optional(),user_metadata:a.z.any().default({}).optional()}),ur=ns.extend({email_verified:a.z.boolean().default(!1),verify_email:a.z.boolean().optional(),last_ip:a.z.string().optional(),last_login:a.z.string().optional(),user_id:a.z.string().optional(),provider:a.z.string().default("email"),connection:a.z.string().default("email"),is_social:a.z.boolean().optional()}),Da=a.z.object({...ur.shape,...Ha.shape,user_id:a.z.string(),is_social:a.z.boolean(),email:a.z.string(),login_count:a.z.number(),identities:a.z.array(kd).optional()}),ft=Da,Hh=ns.extend({email:a.z.string(),login_count:a.z.number(),multifactor:a.z.array(a.z.string()).optional(),last_ip:a.z.string().optional(),last_login:a.z.string().optional(),user_id:a.z.string()}).catchall(a.z.any()),Dh="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Fh=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n));for(;n--;)e+=Dh[t[n]&63];return e};const xd=a.z.object({audience:a.z.string().optional(),recipient:a.z.string().optional(),createUpnClaim:a.z.boolean().optional(),mapUnknownClaimsAsIs:a.z.boolean().optional(),passthroughClaimsWithNoMapping:a.z.boolean().optional(),mapIdentities:a.z.boolean().optional(),signatureAlgorithm:a.z.string().optional(),digestAlgorithm:a.z.string().optional(),issuer:a.z.string().optional(),destination:a.z.string().optional(),lifetimeInSeconds:a.z.number().optional(),signResponse:a.z.boolean().optional(),nameIdentifierFormat:a.z.string().optional(),nameIdentifierProbes:a.z.array(a.z.string()).optional(),authnContextClassRef:a.z.string().optional(),mappings:a.z.record(a.z.string()).optional()}),dr=a.z.object({id:a.z.string(),name:a.z.string(),callbacks:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level. Query strings and hash information are not taken into account when validating these URLs."}),web_origins:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode."}),allowed_logout_urls:a.z.array(a.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),allowed_clients:a.z.array(a.z.string()).default([]).optional().openapi({description:"Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients"}),addons:a.z.object({samlp:xd.optional()}).default({}).optional().openapi({description:"Addons associated with the client. The key is the addon's package name and the value is an object with the configuration for the addon."}),email_validation:a.z.enum(["enabled","disabled","enforced"]).default("enforced").optional().openapi({description:"Defines if it possible to sign in with an unverified email and if verification emails will be sent. This is not available in auth0"}),client_secret:a.z.string().default(()=>Fh()).optional(),disable_sign_ups:a.z.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),Jt=a.z.object({created_at:a.z.string().transform(n=>n===null?"":n),updated_at:a.z.string().transform(n=>n===null?"":n),...dr.shape});var Pt=(n=>(n.TOKEN="token",n.TOKEN_ID_TOKEN="token id_token",n.CODE="code",n))(Pt||{}),nn=(n=>(n.QUERY="query",n.FRAGMENT="fragment",n.FORM_POST="form_post",n.WEB_MESSAGE="web_message",n.SAML_POST="saml_post",n))(nn||{}),is=(n=>(n.S256="S256",n.Plain="plain",n))(is||{});const Fa=a.z.object({client_id:a.z.string(),vendor_id:a.z.string().optional(),act_as:a.z.string().optional(),response_type:a.z.nativeEnum(Pt).optional(),response_mode:a.z.nativeEnum(nn).optional(),redirect_uri:a.z.string().optional(),audience:a.z.string().optional(),state:a.z.string().optional(),nonce:a.z.string().optional(),scope:a.z.string().optional(),prompt:a.z.string().optional(),code_challenge_method:a.z.nativeEnum(is).optional(),code_challenge:a.z.string().optional(),username:a.z.string().optional(),ui_locales:a.z.string().optional()}),yo=a.z.object({colors:a.z.object({primary:a.z.string(),page_background:a.z.object({type:a.z.string().optional(),start:a.z.string().optional(),end:a.z.string().optional(),angle_deg:a.z.number().optional()}).optional()}).optional(),logo_url:a.z.string().optional(),favicon_url:a.z.string().optional(),font:a.z.object({url:a.z.string()}).optional()}),pr=a.z.object({id:a.z.string().optional(),name:a.z.string(),strategy:a.z.string(),options:a.z.object({kid:a.z.string().optional(),team_id:a.z.string().optional(),realms:a.z.string().optional(),client_id:a.z.string().optional(),client_secret:a.z.string().optional(),app_secret:a.z.string().optional(),scope:a.z.string().optional(),authorization_endpoint:a.z.string().default("").optional(),token_endpoint:a.z.string().default("").optional(),userinfo_endpoint:a.z.string().default("").optional(),jwks_uri:a.z.string().default("").optional(),discovery_url:a.z.string().default("").optional(),issuer:a.z.string().default("").optional()}).default({}).optional(),enabled_clients:a.z.array(a.z.string()).default([]).optional(),response_type:a.z.custom().optional(),response_mode:a.z.custom().optional()}),zt=a.z.object({id:a.z.string(),created_at:a.z.string().transform(n=>n===null?"":n),updated_at:a.z.string().transform(n=>n===null?"":n)}).extend(pr.shape),fr=a.z.object({name:a.z.string(),audience:a.z.string(),sender_email:a.z.string().email(),sender_name:a.z.string(),support_url:a.z.string().url().optional(),logo:a.z.string().url().optional(),primary_color:a.z.string().optional(),secondary_color:a.z.string().optional(),language:a.z.string().optional()}),An=a.z.object({created_at:a.z.string().transform(n=>n===null?"":n),updated_at:a.z.string().transform(n=>n===null?"":n),id:a.z.string(),...fr.shape}),qh=a.z.object({logoUrl:a.z.string(),loginBackgroundImage:a.z.string().nullish(),style:a.z.object({primaryColor:a.z.string(),buttonTextColor:a.z.string(),primaryHoverColor:a.z.string()}),supportEmail:a.z.string().nullable(),supportUrl:a.z.string().nullable(),name:a.z.string(),showGreyishBackground:a.z.boolean().optional(),termsAndConditionsUrl:a.z.string().nullable(),companyName:a.z.string().optional(),checkoutHideSocial:a.z.boolean().optional(),siteUrl:a.z.string().nullable(),manageSubscriptionsUrl:a.z.string().optional()}),Kh=a.z.object({domain:a.z.string(),dkim_private_key:a.z.string().optional(),dkim_public_key:a.z.string().optional(),email_api_key:a.z.string().optional(),email_service:a.z.string().optional()});a.z.object({...Jt.shape,domains:a.z.array(Kh),tenant:An,connections:a.z.array(zt)});const Sd=a.z.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),Ad=a.z.object({code_id:a.z.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:a.z.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:a.z.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:Sd,code_verifier:a.z.string().optional().openapi({description:"The code verifier used in PKCE in outbound flows"}),expires_at:a.z.string(),used_at:a.z.string().optional(),user_id:a.z.string().optional()}),Wh=a.z.object({...Ad.shape,created_at:a.z.string()}),Id=a.z.object({domain:a.z.string(),dkim_private_key:a.z.string().optional(),dkim_public_key:a.z.string().optional(),email_api_key:a.z.string().optional(),email_service:a.z.string().optional()}),Gh=Ha.extend({...Id.shape,id:a.z.string()}),hr=a.z.object({trigger_id:a.z.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:a.z.boolean().default(!1),url:a.z.string(),hook_id:a.z.string().optional(),synchronous:a.z.boolean().default(!1),priority:a.z.number().optional()}),xn=hr.extend({...Ha.shape,hook_id:a.z.string()}),qa=a.z.object({alg:a.z.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:a.z.string(),kid:a.z.string(),kty:a.z.enum(["RSA","EC","oct"]),n:a.z.string(),x5t:a.z.string().optional(),x5c:a.z.array(a.z.string()).optional(),use:a.z.enum(["sig","enc"]).optional()}),Ed=a.z.object({keys:a.z.array(qa)}),vo=a.z.object({issuer:a.z.string(),authorization_endpoint:a.z.string(),token_endpoint:a.z.string(),device_authorization_endpoint:a.z.string(),userinfo_endpoint:a.z.string(),mfa_challenge_endpoint:a.z.string(),jwks_uri:a.z.string(),registration_endpoint:a.z.string(),revocation_endpoint:a.z.string(),scopes_supported:a.z.array(a.z.string()),response_types_supported:a.z.array(a.z.string()),code_challenge_methods_supported:a.z.array(a.z.string()),response_modes_supported:a.z.array(a.z.string()),subject_types_supported:a.z.array(a.z.string()),id_token_signing_alg_values_supported:a.z.array(a.z.string()),token_endpoint_auth_methods_supported:a.z.array(a.z.string()),claims_supported:a.z.array(a.z.string()),request_uri_parameter_supported:a.z.boolean(),request_parameter_supported:a.z.boolean(),token_endpoint_auth_signing_alg_values_supported:a.z.array(a.z.string())}),$d=a.z.object({auth0Client:a.z.string().optional(),authParams:Fa,expires_at:a.z.string(),deleted_at:a.z.string().optional(),ip:a.z.string().optional(),useragent:a.z.string().optional()}).openapi({description:"This represents a login sesion"}),Jh=a.z.object({...$d.shape,login_id:a.z.string().openapi({description:"This is is used as the state in the universal login"}),created_at:a.z.string(),updated_at:a.z.string()});var _e=(n=>(n.FAILED_SILENT_AUTH="fsa",n.FAILED_SIGNUP="fs",n.FAILED_LOGIN="f",n.FAILED_LOGIN_INCORRECT_PASSWORD="fp",n.FAILED_CHANGE_PASSWORD="fcp",n.FAILED_BY_CONNECTOR="fc",n.FAILED_LOGIN_INVALID_EMAIL_USERNAME="fu",n.FAILED_HOOK="fh",n.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",n.SUCCESS_API_OPERATION="sapi",n.SUCCESS_CHANGE_PASSWORD="scp",n.SUCCESS_CHANGE_PASSWORD_REQUEST="scpr",n.SUCCESS_CHANGE_USERNAME="scu",n.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",n.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",n.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",n.SUCCESS_LOGIN="s",n.SUCCESS_LOGOUT="slo",n.SUCCESS_SIGNUP="ss",n.SUCCESS_SILENT_AUTH="ssa",n.SUCCESS_VERIFICATION_EMAIL="sv",n.SUCCESS_VERIFICATION_EMAIL_REQUEST="svr",n.CODE_LINK_SENT="cls",n.BLOCKED_ACCOUNT_EMAIL="limit_wc",n.BLOCKED_ACCOUNT_IP="limit_sul",n.BLOCKED_IP_ADDRESS="limit_mu",n))(_e||{});const Zh=a.z.enum(["cls","fsa","fs","f","fc","fcoa","fcp","fh","fp","fs","fu","s","sapi","scoa","scp","scpr","scu","seacft","serft","slo","ss","ssa","sv","svr"]),Cd=a.z.object({name:a.z.string(),version:a.z.string(),env:a.z.object({node:a.z.string().optional()}).optional()}),gr=a.z.object({type:Zh,date:a.z.string(),description:a.z.string().optional(),log_id:a.z.string().optional(),_id:a.z.string().optional(),ip:a.z.string(),user_agent:a.z.string(),details:a.z.any().optional(),isMobile:a.z.boolean(),user_id:a.z.string().optional(),user_name:a.z.string().optional(),connection:a.z.string().optional(),connection_id:a.z.string().optional(),client_id:a.z.string().optional(),client_name:a.z.string().optional(),audience:a.z.string().optional(),scope:a.z.array(a.z.string()).optional(),strategy:a.z.string().optional(),strategy_type:a.z.string().optional(),hostname:a.z.string().optional(),auth0_client:Cd.optional()}),jd=a.z.object({user_id:a.z.string(),password:a.z.string(),algorithm:a.z.enum(["bcrypt","argon2id"]).default("argon2id")}),Yh=a.z.object({...jd.shape,created_at:a.z.string(),updated_at:a.z.string()}),zd=a.z.object({session_id:a.z.string(),client_id:a.z.string(),expires_at:a.z.string(),used_at:a.z.string(),deleted_at:a.z.string().optional(),user_id:a.z.string()}),Ka=a.z.object({created_at:a.z.string(),...zd.shape}),wo=a.z.object({kid:a.z.string().openapi({description:"The key id of the signing key"}),cert:a.z.string().openapi({description:"The public certificate of the signing key"}),fingerprint:a.z.string().openapi({description:"The cert fingerprint"}),thumbprint:a.z.string().openapi({description:"The cert thumbprint"}),pkcs7:a.z.string().optional().openapi({description:"The private key in pkcs7 format"}),current:a.z.boolean().optional().openapi({description:"True if the key is the current key"}),next:a.z.boolean().optional().openapi({description:"True if the key is the next key"}),previous:a.z.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:a.z.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:a.z.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:a.z.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:a.z.string().optional().openapi({description:"The date and time when the key was revoked"})});var _r=(n=>(n.RefreshToken="refresh_token",n.AuthorizationCode="authorization_code",n.ClientCredential="client_credentials",n.Passwordless="passwordless",n.Password="password",n))(_r||{});a.z.object({access_token:a.z.string(),id_token:a.z.string().optional(),scope:a.z.string().optional(),state:a.z.string().optional(),refresh_token:a.z.string().optional(),token_type:a.z.string(),expires_in:a.z.number()});a.z.object({code:a.z.string(),state:a.z.string().optional()});const Nd=a.z.object({button_border_radius:a.z.number(),button_border_weight:a.z.number(),buttons_style:a.z.enum(["pill"]),input_border_radius:a.z.number(),input_border_weight:a.z.number(),inputs_style:a.z.enum(["pill"]),show_widget_shadow:a.z.boolean(),widget_border_weight:a.z.number(),widget_corner_radius:a.z.number()}),Od=a.z.object({base_focus_color:a.z.string(),base_hover_color:a.z.string(),body_text:a.z.string(),captcha_widget_theme:a.z.enum(["auto"]),error:a.z.string(),header:a.z.string(),icons:a.z.string(),input_background:a.z.string(),input_border:a.z.string(),input_filled_text:a.z.string(),input_labels_placeholders:a.z.string(),links_focused_components:a.z.string(),primary_button:a.z.string(),primary_button_label:a.z.string(),secondary_button_border:a.z.string(),secondary_button_label:a.z.string(),success:a.z.string(),widget_background:a.z.string(),widget_border:a.z.string()}),Wt=a.z.object({bold:a.z.boolean(),size:a.z.number()}),Bd=a.z.object({body_text:Wt,buttons_text:Wt,font_url:a.z.string(),input_labels:Wt,links:Wt,links_style:a.z.enum(["normal"]),reference_text_size:a.z.number(),subtitle:Wt,title:Wt}),Td=a.z.object({background_color:a.z.string(),background_image_url:a.z.string(),page_layout:a.z.enum(["center"])}),Rd=a.z.object({header_text_alignment:a.z.enum(["center"]),logo_height:a.z.number(),logo_position:a.z.enum(["center"]),logo_url:a.z.string(),social_buttons_layout:a.z.enum(["bottom"])}),Pd=a.z.object({borders:Nd,colors:Od,displayName:a.z.string(),fonts:Bd,page_background:Td,widget:Rd}),Xh=Pd.extend({themeId:a.z.string()}),Xi=a.z.object({universal_login_experience:a.z.enum(["new","classic"]).default("new"),identifier_first:a.z.boolean().default(!0),password_first:a.z.boolean().default(!1),webauthn_platform_first_factor:a.z.boolean()}),Qi=a.z.object({name:a.z.string(),enabled:a.z.boolean().optional().default(!0),default_from_address:a.z.string().optional(),credentials:a.z.union([a.z.object({accessKeyId:a.z.string(),secretAccessKey:a.z.string(),region:a.z.string()}),a.z.object({smtp_host:a.z.array(a.z.string()),smtp_port:a.z.number(),smtp_user:a.z.string(),smtp_pass:a.z.string()}),a.z.object({api_key:a.z.string(),domain:a.z.string().optional()}),a.z.object({connectionString:a.z.string()}),a.z.object({tenantId:a.z.string(),clientId:a.z.string(),clientSecret:a.z.string()})]),settings:a.z.object({}).optional()});function Qh(n){const[e,t]=n.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${n}`);return{connection:e,id:t}}const eg=new a.OpenAPIHono().openapi(a.createRoute({tags:["branding"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:yo}},description:"Branding settings"}}}),async n=>{const{"tenant-id":e}=n.req.valid("header"),t=await n.env.data.branding.get(e);return t?n.json(t):n.json({})}).openapi(a.createRoute({tags:["branding"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(yo.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async n=>{const{"tenant-id":e}=n.req.valid("header"),t=n.req.valid("json");return await n.env.data.branding.set(e,t),n.text("OK")});var O=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});te(this,"res");te(this,"status");this.res=t==null?void 0:t.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}},mr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function tg(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function ng(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return n[i]}})}),t}function ig(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ld={exports:{}};const rg={},sg=Object.freeze(Object.defineProperty({__proto__:null,default:rg},Symbol.toStringTag,{value:"Module"})),og=ng(sg);(function(n){/**
2
2
  * @license bcrypt.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
3
3
  * Released under the Apache License, Version 2.0
4
4
  * see: https://github.com/dcodeIO/bcrypt.js for details
5
- */(function(e,t){typeof ig=="function"&&n&&n.exports?n.exports=t():(e.dcodeIO=e.dcodeIO||{}).bcrypt=t()})(mr,function(){var e={},t=null;function i($){if(n&&n.exports)try{return og.randomBytes($)}catch{}try{var E;return(self.crypto||self.msCrypto).getRandomValues(E=new Uint32Array($)),Array.prototype.slice.call(E)}catch{}if(!t)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return t($)}var r=!1;try{i(1),r=!0}catch{}t=null,e.setRandomFallback=function($){t=$},e.genSaltSync=function($,E){if($=$||_,typeof $!="number")throw Error("Illegal arguments: "+typeof $+", "+typeof E);$<4?$=4:$>31&&($=31);var A=[];return A.push("$2a$"),$<10&&A.push("0"),A.push($.toString()),A.push("$"),A.push(g(i(h),h)),A.join("")},e.genSalt=function($,E,A){if(typeof E=="function"&&(A=E,E=void 0),typeof $=="function"&&(A=$,$=void 0),typeof $>"u")$=_;else if(typeof $!="number")throw Error("illegal arguments: "+typeof $);function w(v){o(function(){try{v(null,e.genSaltSync($))}catch(C){v(C)}})}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);w(A)}else return new Promise(function(v,C){w(function(R,Z){if(R){C(R);return}v(Z)})})},e.hashSync=function($,E){if(typeof E>"u"&&(E=_),typeof E=="number"&&(E=e.genSaltSync(E)),typeof $!="string"||typeof E!="string")throw Error("Illegal arguments: "+typeof $+", "+typeof E);return De($,E)},e.hash=function($,E,A,w){function v(C){typeof $=="string"&&typeof E=="number"?e.genSalt(E,function(R,Z){De($,Z,C,w)}):typeof $=="string"&&typeof E=="string"?De($,E,C,w):o(C.bind(this,Error("Illegal arguments: "+typeof $+", "+typeof E)))}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);v(A)}else return new Promise(function(C,R){v(function(Z,q){if(Z){R(Z);return}C(q)})})};function s($,E){for(var A=0,w=0,v=0,C=$.length;v<C;++v)$.charCodeAt(v)===E.charCodeAt(v)?++A:++w;return A<0?!1:w===0}e.compareSync=function($,E){if(typeof $!="string"||typeof E!="string")throw Error("Illegal arguments: "+typeof $+", "+typeof E);return E.length!==60?!1:s(e.hashSync($,E.substr(0,E.length-31)),E)},e.compare=function($,E,A,w){function v(C){if(typeof $!="string"||typeof E!="string"){o(C.bind(this,Error("Illegal arguments: "+typeof $+", "+typeof E)));return}if(E.length!==60){o(C.bind(this,null,!1));return}e.hash($,E.substr(0,29),function(R,Z){R?C(R):C(null,s(Z,E))},w)}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);v(A)}else return new Promise(function(C,R){v(function(Z,q){if(Z){R(Z);return}C(q)})})},e.getRounds=function($){if(typeof $!="string")throw Error("Illegal arguments: "+typeof $);return parseInt($.split("$")[2],10)},e.getSalt=function($){if(typeof $!="string")throw Error("Illegal arguments: "+typeof $);if($.length!==60)throw Error("Illegal hash length: "+$.length+" != 60");return $.substring(0,29)};var o=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function c($){var E=[],A=0;return x.encodeUTF16toUTF8(function(){return A>=$.length?null:$.charCodeAt(A++)},function(w){E.push(w)}),E}var l="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),u=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,54,55,56,57,58,59,60,61,62,63,-1,-1,-1,-1,-1,-1,-1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,-1,-1,-1,-1,-1,-1,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,-1,-1,-1,-1,-1],p=String.fromCharCode;function g($,E){var A=0,w=[],v,C;if(E<=0||E>$.length)throw Error("Illegal len: "+E);for(;A<E;){if(v=$[A++]&255,w.push(l[v>>2&63]),v=(v&3)<<4,A>=E){w.push(l[v&63]);break}if(C=$[A++]&255,v|=C>>4&15,w.push(l[v&63]),v=(C&15)<<2,A>=E){w.push(l[v&63]);break}C=$[A++]&255,v|=C>>6&3,w.push(l[v&63]),w.push(l[C&63])}return w.join("")}function m($,E){var A=0,w=$.length,v=0,C=[],R,Z,q,ee,se,M;if(E<=0)throw Error("Illegal len: "+E);for(;A<w-1&&v<E&&(M=$.charCodeAt(A++),R=M<u.length?u[M]:-1,M=$.charCodeAt(A++),Z=M<u.length?u[M]:-1,!(R==-1||Z==-1||(se=R<<2>>>0,se|=(Z&48)>>4,C.push(p(se)),++v>=E||A>=w)||(M=$.charCodeAt(A++),q=M<u.length?u[M]:-1,q==-1)||(se=(Z&15)<<4>>>0,se|=(q&60)>>2,C.push(p(se)),++v>=E||A>=w)));)M=$.charCodeAt(A++),ee=M<u.length?u[M]:-1,se=(q&3)<<6>>>0,se|=ee,C.push(p(se)),++v;var Se=[];for(A=0;A<v;A++)Se.push(C[A].charCodeAt(0));return Se}var x=function(){var $={};return $.MAX_CODEPOINT=1114111,$.encodeUTF8=function(E,A){var w=null;for(typeof E=="number"&&(w=E,E=function(){return null});w!==null||(w=E())!==null;)w<128?A(w&127):w<2048?(A(w>>6&31|192),A(w&63|128)):w<65536?(A(w>>12&15|224),A(w>>6&63|128),A(w&63|128)):(A(w>>18&7|240),A(w>>12&63|128),A(w>>6&63|128),A(w&63|128)),w=null},$.decodeUTF8=function(E,A){for(var w,v,C,R,Z=function(q){q=q.slice(0,q.indexOf(null));var ee=Error(q.toString());throw ee.name="TruncatedError",ee.bytes=q,ee};(w=E())!==null;)if(!(w&128))A(w);else if((w&224)===192)(v=E())===null&&Z([w,v]),A((w&31)<<6|v&63);else if((w&240)===224)((v=E())===null||(C=E())===null)&&Z([w,v,C]),A((w&15)<<12|(v&63)<<6|C&63);else if((w&248)===240)((v=E())===null||(C=E())===null||(R=E())===null)&&Z([w,v,C,R]),A((w&7)<<18|(v&63)<<12|(C&63)<<6|R&63);else throw RangeError("Illegal starting byte: "+w)},$.UTF16toUTF8=function(E,A){for(var w,v=null;(w=v!==null?v:E())!==null;){if(w>=55296&&w<=57343&&(v=E())!==null&&v>=56320&&v<=57343){A((w-55296)*1024+v-56320+65536),v=null;continue}A(w)}v!==null&&A(v)},$.UTF8toUTF16=function(E,A){var w=null;for(typeof E=="number"&&(w=E,E=function(){return null});w!==null||(w=E())!==null;)w<=65535?A(w):(w-=65536,A((w>>10)+55296),A(w%1024+56320)),w=null},$.encodeUTF16toUTF8=function(E,A){$.UTF16toUTF8(E,function(w){$.encodeUTF8(w,A)})},$.decodeUTF8toUTF16=function(E,A){$.decodeUTF8(E,function(w){$.UTF8toUTF16(w,A)})},$.calculateCodePoint=function(E){return E<128?1:E<2048?2:E<65536?3:4},$.calculateUTF8=function(E){for(var A,w=0;(A=E())!==null;)w+=$.calculateCodePoint(A);return w},$.calculateUTF16asUTF8=function(E){var A=0,w=0;return $.UTF16toUTF8(E,function(v){++A,w+=$.calculateCodePoint(v)}),[A,w]},$}();Date.now=Date.now||function(){return+new Date};var h=16,_=10,b=16,S=100,N=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],T=[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946,1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055,3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504,976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462],K=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function oe($,E,A,w){var v,C=$[E],R=$[E+1];return C^=A[0],v=w[C>>>24],v+=w[256|C>>16&255],v^=w[512|C>>8&255],v+=w[768|C&255],R^=v^A[1],v=w[R>>>24],v+=w[256|R>>16&255],v^=w[512|R>>8&255],v+=w[768|R&255],C^=v^A[2],v=w[C>>>24],v+=w[256|C>>16&255],v^=w[512|C>>8&255],v+=w[768|C&255],R^=v^A[3],v=w[R>>>24],v+=w[256|R>>16&255],v^=w[512|R>>8&255],v+=w[768|R&255],C^=v^A[4],v=w[C>>>24],v+=w[256|C>>16&255],v^=w[512|C>>8&255],v+=w[768|C&255],R^=v^A[5],v=w[R>>>24],v+=w[256|R>>16&255],v^=w[512|R>>8&255],v+=w[768|R&255],C^=v^A[6],v=w[C>>>24],v+=w[256|C>>16&255],v^=w[512|C>>8&255],v+=w[768|C&255],R^=v^A[7],v=w[R>>>24],v+=w[256|R>>16&255],v^=w[512|R>>8&255],v+=w[768|R&255],C^=v^A[8],v=w[C>>>24],v+=w[256|C>>16&255],v^=w[512|C>>8&255],v+=w[768|C&255],R^=v^A[9],v=w[R>>>24],v+=w[256|R>>16&255],v^=w[512|R>>8&255],v+=w[768|R&255],C^=v^A[10],v=w[C>>>24],v+=w[256|C>>16&255],v^=w[512|C>>8&255],v+=w[768|C&255],R^=v^A[11],v=w[R>>>24],v+=w[256|R>>16&255],v^=w[512|R>>8&255],v+=w[768|R&255],C^=v^A[12],v=w[C>>>24],v+=w[256|C>>16&255],v^=w[512|C>>8&255],v+=w[768|C&255],R^=v^A[13],v=w[R>>>24],v+=w[256|R>>16&255],v^=w[512|R>>8&255],v+=w[768|R&255],C^=v^A[14],v=w[C>>>24],v+=w[256|C>>16&255],v^=w[512|C>>8&255],v+=w[768|C&255],R^=v^A[15],v=w[R>>>24],v+=w[256|R>>16&255],v^=w[512|R>>8&255],v+=w[768|R&255],C^=v^A[16],$[E]=R^A[b+1],$[E+1]=C,$}function pe($,E){for(var A=0,w=0;A<4;++A)w=w<<8|$[E]&255,E=(E+1)%$.length;return{key:w,offp:E}}function ce($,E,A){for(var w=0,v=[0,0],C=E.length,R=A.length,Z,q=0;q<C;q++)Z=pe($,w),w=Z.offp,E[q]=E[q]^Z.key;for(q=0;q<C;q+=2)v=oe(v,0,E,A),E[q]=v[0],E[q+1]=v[1];for(q=0;q<R;q+=2)v=oe(v,0,E,A),A[q]=v[0],A[q+1]=v[1]}function Re($,E,A,w){for(var v=0,C=[0,0],R=A.length,Z=w.length,q,ee=0;ee<R;ee++)q=pe(E,v),v=q.offp,A[ee]=A[ee]^q.key;for(v=0,ee=0;ee<R;ee+=2)q=pe($,v),v=q.offp,C[0]^=q.key,q=pe($,v),v=q.offp,C[1]^=q.key,C=oe(C,0,A,w),A[ee]=C[0],A[ee+1]=C[1];for(ee=0;ee<Z;ee+=2)q=pe($,v),v=q.offp,C[0]^=q.key,q=pe($,v),v=q.offp,C[1]^=q.key,C=oe(C,0,A,w),w[ee]=C[0],w[ee+1]=C[1]}function nt($,E,A,w,v){var C=K.slice(),R=C.length,Z;if(A<4||A>31)if(Z=Error("Illegal number of rounds (4-31): "+A),w){o(w.bind(this,Z));return}else throw Z;if(E.length!==h)if(Z=Error("Illegal salt length: "+E.length+" != "+h),w){o(w.bind(this,Z));return}else throw Z;A=1<<A>>>0;var q,ee,se=0,M;Int32Array?(q=new Int32Array(N),ee=new Int32Array(T)):(q=N.slice(),ee=T.slice()),Re(E,$,q,ee);function Se(){if(v&&v(se/A),se<A)for(var de=Date.now();se<A&&(se=se+1,ce($,q,ee),ce(E,q,ee),!(Date.now()-de>S)););else{for(se=0;se<64;se++)for(M=0;M<R>>1;M++)oe(C,M<<1,q,ee);var we=[];for(se=0;se<R;se++)we.push((C[se]>>24&255)>>>0),we.push((C[se]>>16&255)>>>0),we.push((C[se]>>8&255)>>>0),we.push((C[se]&255)>>>0);if(w){w(null,we);return}else return we}w&&o(Se)}if(typeof w<"u")Se();else for(var Kt;;)if(typeof(Kt=Se())<"u")return Kt||[]}function De($,E,A,w){var v;if(typeof $!="string"||typeof E!="string")if(v=Error("Invalid string / salt: Not a string"),A){o(A.bind(this,v));return}else throw v;var C,R;if(E.charAt(0)!=="$"||E.charAt(1)!=="2")if(v=Error("Invalid salt version: "+E.substring(0,2)),A){o(A.bind(this,v));return}else throw v;if(E.charAt(2)==="$")C="\0",R=3;else{if(C=E.charAt(2),C!=="a"&&C!=="b"&&C!=="y"||E.charAt(3)!=="$")if(v=Error("Invalid salt revision: "+E.substring(2,4)),A){o(A.bind(this,v));return}else throw v;R=4}if(E.charAt(R+2)>"$")if(v=Error("Missing salt rounds"),A){o(A.bind(this,v));return}else throw v;var Z=parseInt(E.substring(R,R+1),10)*10,q=parseInt(E.substring(R+1,R+2),10),ee=Z+q,se=E.substring(R+3,R+25);$+=C>="a"?"\0":"";var M=c($),Se=m(se,h);function Kt(de){var we=[];return we.push("$2"),C>="a"&&we.push(C),we.push("$"),ee<10&&we.push("0"),we.push(ee.toString()),we.push("$"),we.push(g(Se,Se.length)),we.push(g(de,K.length*4-1)),we.join("")}if(typeof A>"u")return Kt(nt(M,Se,ee));nt(M,Se,ee,function(de,we){de?A(de,null):A(null,Kt(we))},w)}return e.encodeBase64=g,e.decodeBase64=m,e})})(Ld);var ag=Ld.exports;const Wa=tg(ag),cg="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let lg=n=>crypto.getRandomValues(new Uint8Array(n)),ug=(n,e,t)=>{let i=(2<<Math.log2(n.length-1))-1,r=-~(1.6*i*e/n.length);return(s=e)=>{let o="";for(;;){let c=t(r),l=r;for(;l--;)if(o+=n[c[l]&i]||"",o.length===s)return o}}},dg=(n,e=21)=>ug(n,e,lg),Ke=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n));for(;n--;)e+=cg[t[n]&63];return e};const pg=24;function Ga(){return dg("0123456789abcdef",pg)()}function ml(n){if(!n.includes("|"))return console.error("Invalid user_id format"),n;const[,e]=n.split("|");return e}async function Ud(n,e,t){return(await n.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`})).users}async function Ja({userAdapter:n,tenant_id:e,email:t,provider:i}){const{users:r}=await n.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t} provider:${i}`});return r.length>1&&console.error("More than one user found for same email and provider"),r[0]||null}async function Vd({userAdapter:n,tenant_id:e,email:t}){var c;const{users:i}=await n.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`}),r=i.filter(l=>!(l.provider==="auth2"&&!l.email_verified));if(r.length===0)return;const s=r.filter(l=>!l.linked_to);if(s.length>0)return s.length>1&&console.error("More than one primary user found for same email"),s[0];const o=await n.get(e,(c=r[0])==null?void 0:c.linked_to);if(!o)throw new Error("Primary account not found");return o}async function rs({userAdapter:n,tenant_id:e,email:t,provider:i}){const r=await Ja({userAdapter:n,tenant_id:e,email:t,provider:i});return r?r.linked_to?n.get(e,r.linked_to):r:null}const rn=a.z.object({page:a.z.string().min(0).optional().default("0").transform(n=>parseInt(n,10)).openapi({description:"The page number where 0 is the first page"}),per_page:a.z.string().min(1).optional().default("10").transform(n=>parseInt(n,10)).openapi({description:"The number of items per page"}),include_totals:a.z.string().optional().default("false").transform(n=>n==="true").openapi({description:"If the total number of items should be included in the response"}),sort:a.z.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:a.z.string().optional().openapi({description:"A lucene query string used to filter the results"})});function Mn(n){if(!n)return;const[e,t]=n.split(":"),i=t==="1"?"asc":"desc";if(!(!e||!i))return{sort_by:e,sort_order:i}}function ke(n,e){return{type:e.type,description:e.description||"",ip:n.req.header("x-real-ip")||"",user_agent:n.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:n.req.method,path:n.req.path,qs:n.req.queries(),body:e.body||n.var.body||""}},isMobile:!1,client_id:n.var.client_id,client_name:"",user_id:e.userId||n.var.user_id||"",hostname:n.req.header("host")||"",user_name:n.var.username||"",connection_id:"",connection:n.var.connection||"",strategy:e.strategy||"",strategy_type:e.strategy_type||"",audience:"",scope:[]}}var fg={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},hg=()=>{var t,i;const n=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[r,s]of Object.entries(fg))if(gg(s))return r}return typeof(n==null?void 0:n.EdgeRuntime)=="string"?"edge-light":(n==null?void 0:n.fastly)!==void 0?"fastly":((i=(t=n==null?void 0:n.process)==null?void 0:t.release)==null?void 0:i.name)==="node"?"node":"other"},gg=n=>navigator.userAgent.startsWith(n);function Nt(n,e){hg()==="workerd"&&n.executionCtx.waitUntil(e)}const yl=Mt.extend({users:a.z.array(ft)}),_g=Mt.extend({sessions:a.z.array(Ka)}),mg=new a.OpenAPIHono().openapi(a.createRoute({tags:["users"],method:"get",path:"/",request:{query:rn,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(ft),yl])}},description:"List of users"}}}),async n=>{const{page:e,per_page:t,include_totals:i,sort:r,q:s}=n.req.valid("query"),{"tenant-id":o}=n.req.valid("header");if(s!=null&&s.includes("identities.profileData.email")){const p=s.split("=")[1],m=(await n.env.data.users.list(o,{page:e,per_page:t,include_totals:i,q:`email:${p}`})).users.filter(_=>_.linked_to),[x]=m;if(!x)return n.json([]);const h=await n.env.data.users.get(o,x.linked_to);if(!h)throw new O(500,{message:"Primary account not found"});return n.json([ft.parse(h)])}const c=["-_exists_:linked_to"];s&&c.push(s);const l=await n.env.data.users.list(o,{page:e,per_page:t,include_totals:i,sort:Mn(r),q:c.join(" ")}),u=l.users.filter(p=>!p.linked_to);return i?n.json(yl.parse({users:u,length:l.length,start:l.start,limit:l.limit})):n.json(a.z.array(ft).parse(u))}).openapi(a.createRoute({tags:["users"],method:"get",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:ft}},description:"List of users"}}}),async n=>{const{user_id:e}=n.req.valid("param"),{"tenant-id":t}=n.req.valid("header"),i=await n.env.data.users.get(t,e);if(!i)throw new O(404);if(i.linked_to)throw new O(404,{message:"User is linked to another user"});return n.json(i)}).openapi(a.createRoute({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async n=>{const{user_id:e}=n.req.valid("param"),{"tenant-id":t}=n.req.valid("header");if(!await n.env.data.users.remove(t,e))throw new O(404);return n.text("OK")}).openapi(a.createRoute({tags:["users"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object({...ur.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:ft}},description:"Status"}}}),async n=>{const{"tenant-id":e}=n.req.valid("header"),t=n.req.valid("json");n.set("body",t);const{email:i}=t;if(!i)throw new O(400,{message:"Email is required"});const r=i.toLowerCase(),s=`${t.provider}|${t.user_id||Ga()}`;try{const o=await n.env.data.users.create(e,{email:r,user_id:s,name:t.name||r,provider:t.provider,connection:t.connection,email_verified:t.email_verified||!1,last_ip:"",is_social:!1,last_login:new Date().toISOString()});n.set("user_id",o.user_id);const c=ke(n,{type:_e.SUCCESS_API_OPERATION,description:"User created"});Nt(n,n.env.data.logs.create(e,c));const l={...o,identities:[{connection:o.connection,provider:o.provider,user_id:ml(o.user_id),isSocial:o.is_social}]};return n.json(ft.parse(l),{status:201})}catch(o){throw o.message==="User already exists"?new O(409,{message:"User already exists"}):o}}).openapi(a.createRoute({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object({...ur.shape,verify_email:a.z.boolean(),password:a.z.string()}).partial()}}},params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async n=>{var u;const{"tenant-id":e}=n.req.valid("header"),t=n.req.valid("json"),{user_id:i}=n.req.valid("param"),{verify_email:r,password:s,...o}=t,c=await n.env.data.users.get(e,i);if(!c)throw new O(404);if(o.email&&o.email!==c.email){const p=await Ud(n.env.data.users,e,o.email);if(p.length&&p.some(g=>g.user_id!==i))throw new O(409,{message:"Another user with the same email address already exists."})}if(c.linked_to)throw new O(404,{message:"User is linked to another user"});if(await n.env.data.users.update(e,i,o),s){const p=(u=c.identities)==null?void 0:u.find(g=>g.connection==="Username-Password-Authentication");if(!p)throw new O(400,{message:"User does not have a password identity"});await n.env.data.passwords.update(e,{user_id:`${p.provider}|${p.user_id}`,password:Wa.hashSync(s,10),algorithm:"bcrypt"})}const l=await n.env.data.users.get(e,i);if(!l)throw new O(500);return n.json(l)}).openapi(a.createRoute({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.union([a.z.object({link_with:a.z.string()}),a.z.object({user_id:a.z.string(),provider:a.z.string(),connection:a.z.string().optional()})])}}},params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:a.z.array(a.z.object({connection:a.z.string(),provider:a.z.string(),user_id:a.z.string(),isSocial:a.z.boolean()}))}},description:"Status"}}}),async n=>{const{"tenant-id":e}=n.req.valid("header"),t=n.req.valid("json"),{user_id:i}=n.req.valid("param"),r="link_with"in t?t.link_with:t.user_id,s=await n.env.data.users.get(e,i);if(!s)throw new O(400,{message:"Linking an inexistent identity is not allowed."});await n.env.data.users.update(e,r,{linked_to:i});const o=await n.env.data.users.list(e,{page:0,per_page:10,include_totals:!1,q:`linked_to:${i}`}),c=[s,...o.users].map(l=>({connection:l.connection,provider:l.provider,user_id:ml(l.user_id),isSocial:l.is_social}));return n.json(c,{status:201})}).openapi(a.createRoute({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string(),provider:a.z.string(),linked_user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:a.z.array(ft)}},description:"Status"}}}),async n=>{const{"tenant-id":e}=n.req.valid("header"),{user_id:t,provider:i,linked_user_id:r}=n.req.valid("param");await n.env.data.users.unlink(e,t,i,r);const s=await n.env.data.users.get(e,t);if(!s)throw new O(404);return n.json([ft.parse(s)])}).openapi(a.createRoute({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:rn,headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(Ka),_g])}},description:"List of sessions"}}}),async n=>{const{user_id:e}=n.req.valid("param"),{include_totals:t}=n.req.valid("query"),{"tenant-id":i}=n.req.valid("header"),r=await n.env.data.sessions.list(i,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return t?n.json(r):n.json(r.sessions)});/*! *****************************************************************************
5
+ */(function(e,t){typeof ig=="function"&&n&&n.exports?n.exports=t():(e.dcodeIO=e.dcodeIO||{}).bcrypt=t()})(mr,function(){var e={},t=null;function i($){if(n&&n.exports)try{return og.randomBytes($)}catch{}try{var E;return(self.crypto||self.msCrypto).getRandomValues(E=new Uint32Array($)),Array.prototype.slice.call(E)}catch{}if(!t)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return t($)}var r=!1;try{i(1),r=!0}catch{}t=null,e.setRandomFallback=function($){t=$},e.genSaltSync=function($,E){if($=$||_,typeof $!="number")throw Error("Illegal arguments: "+typeof $+", "+typeof E);$<4?$=4:$>31&&($=31);var A=[];return A.push("$2a$"),$<10&&A.push("0"),A.push($.toString()),A.push("$"),A.push(g(i(h),h)),A.join("")},e.genSalt=function($,E,A){if(typeof E=="function"&&(A=E,E=void 0),typeof $=="function"&&(A=$,$=void 0),typeof $>"u")$=_;else if(typeof $!="number")throw Error("illegal arguments: "+typeof $);function w(v){o(function(){try{v(null,e.genSaltSync($))}catch(C){v(C)}})}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);w(A)}else return new Promise(function(v,C){w(function(R,Z){if(R){C(R);return}v(Z)})})},e.hashSync=function($,E){if(typeof E>"u"&&(E=_),typeof E=="number"&&(E=e.genSaltSync(E)),typeof $!="string"||typeof E!="string")throw Error("Illegal arguments: "+typeof $+", "+typeof E);return De($,E)},e.hash=function($,E,A,w){function v(C){typeof $=="string"&&typeof E=="number"?e.genSalt(E,function(R,Z){De($,Z,C,w)}):typeof $=="string"&&typeof E=="string"?De($,E,C,w):o(C.bind(this,Error("Illegal arguments: "+typeof $+", "+typeof E)))}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);v(A)}else return new Promise(function(C,R){v(function(Z,K){if(Z){R(Z);return}C(K)})})};function s($,E){for(var A=0,w=0,v=0,C=$.length;v<C;++v)$.charCodeAt(v)===E.charCodeAt(v)?++A:++w;return A<0?!1:w===0}e.compareSync=function($,E){if(typeof $!="string"||typeof E!="string")throw Error("Illegal arguments: "+typeof $+", "+typeof E);return E.length!==60?!1:s(e.hashSync($,E.substr(0,E.length-31)),E)},e.compare=function($,E,A,w){function v(C){if(typeof $!="string"||typeof E!="string"){o(C.bind(this,Error("Illegal arguments: "+typeof $+", "+typeof E)));return}if(E.length!==60){o(C.bind(this,null,!1));return}e.hash($,E.substr(0,29),function(R,Z){R?C(R):C(null,s(Z,E))},w)}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);v(A)}else return new Promise(function(C,R){v(function(Z,K){if(Z){R(Z);return}C(K)})})},e.getRounds=function($){if(typeof $!="string")throw Error("Illegal arguments: "+typeof $);return parseInt($.split("$")[2],10)},e.getSalt=function($){if(typeof $!="string")throw Error("Illegal arguments: "+typeof $);if($.length!==60)throw Error("Illegal hash length: "+$.length+" != 60");return $.substring(0,29)};var o=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function c($){var E=[],A=0;return x.encodeUTF16toUTF8(function(){return A>=$.length?null:$.charCodeAt(A++)},function(w){E.push(w)}),E}var l="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),u=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,54,55,56,57,58,59,60,61,62,63,-1,-1,-1,-1,-1,-1,-1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,-1,-1,-1,-1,-1,-1,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,-1,-1,-1,-1,-1],p=String.fromCharCode;function g($,E){var A=0,w=[],v,C;if(E<=0||E>$.length)throw Error("Illegal len: "+E);for(;A<E;){if(v=$[A++]&255,w.push(l[v>>2&63]),v=(v&3)<<4,A>=E){w.push(l[v&63]);break}if(C=$[A++]&255,v|=C>>4&15,w.push(l[v&63]),v=(C&15)<<2,A>=E){w.push(l[v&63]);break}C=$[A++]&255,v|=C>>6&3,w.push(l[v&63]),w.push(l[C&63])}return w.join("")}function m($,E){var A=0,w=$.length,v=0,C=[],R,Z,K,ee,se,M;if(E<=0)throw Error("Illegal len: "+E);for(;A<w-1&&v<E&&(M=$.charCodeAt(A++),R=M<u.length?u[M]:-1,M=$.charCodeAt(A++),Z=M<u.length?u[M]:-1,!(R==-1||Z==-1||(se=R<<2>>>0,se|=(Z&48)>>4,C.push(p(se)),++v>=E||A>=w)||(M=$.charCodeAt(A++),K=M<u.length?u[M]:-1,K==-1)||(se=(Z&15)<<4>>>0,se|=(K&60)>>2,C.push(p(se)),++v>=E||A>=w)));)M=$.charCodeAt(A++),ee=M<u.length?u[M]:-1,se=(K&3)<<6>>>0,se|=ee,C.push(p(se)),++v;var Se=[];for(A=0;A<v;A++)Se.push(C[A].charCodeAt(0));return Se}var x=function(){var $={};return $.MAX_CODEPOINT=1114111,$.encodeUTF8=function(E,A){var w=null;for(typeof E=="number"&&(w=E,E=function(){return null});w!==null||(w=E())!==null;)w<128?A(w&127):w<2048?(A(w>>6&31|192),A(w&63|128)):w<65536?(A(w>>12&15|224),A(w>>6&63|128),A(w&63|128)):(A(w>>18&7|240),A(w>>12&63|128),A(w>>6&63|128),A(w&63|128)),w=null},$.decodeUTF8=function(E,A){for(var w,v,C,R,Z=function(K){K=K.slice(0,K.indexOf(null));var ee=Error(K.toString());throw ee.name="TruncatedError",ee.bytes=K,ee};(w=E())!==null;)if(!(w&128))A(w);else if((w&224)===192)(v=E())===null&&Z([w,v]),A((w&31)<<6|v&63);else if((w&240)===224)((v=E())===null||(C=E())===null)&&Z([w,v,C]),A((w&15)<<12|(v&63)<<6|C&63);else if((w&248)===240)((v=E())===null||(C=E())===null||(R=E())===null)&&Z([w,v,C,R]),A((w&7)<<18|(v&63)<<12|(C&63)<<6|R&63);else throw RangeError("Illegal starting byte: "+w)},$.UTF16toUTF8=function(E,A){for(var w,v=null;(w=v!==null?v:E())!==null;){if(w>=55296&&w<=57343&&(v=E())!==null&&v>=56320&&v<=57343){A((w-55296)*1024+v-56320+65536),v=null;continue}A(w)}v!==null&&A(v)},$.UTF8toUTF16=function(E,A){var w=null;for(typeof E=="number"&&(w=E,E=function(){return null});w!==null||(w=E())!==null;)w<=65535?A(w):(w-=65536,A((w>>10)+55296),A(w%1024+56320)),w=null},$.encodeUTF16toUTF8=function(E,A){$.UTF16toUTF8(E,function(w){$.encodeUTF8(w,A)})},$.decodeUTF8toUTF16=function(E,A){$.decodeUTF8(E,function(w){$.UTF8toUTF16(w,A)})},$.calculateCodePoint=function(E){return E<128?1:E<2048?2:E<65536?3:4},$.calculateUTF8=function(E){for(var A,w=0;(A=E())!==null;)w+=$.calculateCodePoint(A);return w},$.calculateUTF16asUTF8=function(E){var A=0,w=0;return $.UTF16toUTF8(E,function(v){++A,w+=$.calculateCodePoint(v)}),[A,w]},$}();Date.now=Date.now||function(){return+new Date};var h=16,_=10,b=16,S=100,N=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],T=[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946,1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055,3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504,976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462],q=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function oe($,E,A,w){var v,C=$[E],R=$[E+1];return C^=A[0],v=w[C>>>24],v+=w[256|C>>16&255],v^=w[512|C>>8&255],v+=w[768|C&255],R^=v^A[1],v=w[R>>>24],v+=w[256|R>>16&255],v^=w[512|R>>8&255],v+=w[768|R&255],C^=v^A[2],v=w[C>>>24],v+=w[256|C>>16&255],v^=w[512|C>>8&255],v+=w[768|C&255],R^=v^A[3],v=w[R>>>24],v+=w[256|R>>16&255],v^=w[512|R>>8&255],v+=w[768|R&255],C^=v^A[4],v=w[C>>>24],v+=w[256|C>>16&255],v^=w[512|C>>8&255],v+=w[768|C&255],R^=v^A[5],v=w[R>>>24],v+=w[256|R>>16&255],v^=w[512|R>>8&255],v+=w[768|R&255],C^=v^A[6],v=w[C>>>24],v+=w[256|C>>16&255],v^=w[512|C>>8&255],v+=w[768|C&255],R^=v^A[7],v=w[R>>>24],v+=w[256|R>>16&255],v^=w[512|R>>8&255],v+=w[768|R&255],C^=v^A[8],v=w[C>>>24],v+=w[256|C>>16&255],v^=w[512|C>>8&255],v+=w[768|C&255],R^=v^A[9],v=w[R>>>24],v+=w[256|R>>16&255],v^=w[512|R>>8&255],v+=w[768|R&255],C^=v^A[10],v=w[C>>>24],v+=w[256|C>>16&255],v^=w[512|C>>8&255],v+=w[768|C&255],R^=v^A[11],v=w[R>>>24],v+=w[256|R>>16&255],v^=w[512|R>>8&255],v+=w[768|R&255],C^=v^A[12],v=w[C>>>24],v+=w[256|C>>16&255],v^=w[512|C>>8&255],v+=w[768|C&255],R^=v^A[13],v=w[R>>>24],v+=w[256|R>>16&255],v^=w[512|R>>8&255],v+=w[768|R&255],C^=v^A[14],v=w[C>>>24],v+=w[256|C>>16&255],v^=w[512|C>>8&255],v+=w[768|C&255],R^=v^A[15],v=w[R>>>24],v+=w[256|R>>16&255],v^=w[512|R>>8&255],v+=w[768|R&255],C^=v^A[16],$[E]=R^A[b+1],$[E+1]=C,$}function pe($,E){for(var A=0,w=0;A<4;++A)w=w<<8|$[E]&255,E=(E+1)%$.length;return{key:w,offp:E}}function ce($,E,A){for(var w=0,v=[0,0],C=E.length,R=A.length,Z,K=0;K<C;K++)Z=pe($,w),w=Z.offp,E[K]=E[K]^Z.key;for(K=0;K<C;K+=2)v=oe(v,0,E,A),E[K]=v[0],E[K+1]=v[1];for(K=0;K<R;K+=2)v=oe(v,0,E,A),A[K]=v[0],A[K+1]=v[1]}function Re($,E,A,w){for(var v=0,C=[0,0],R=A.length,Z=w.length,K,ee=0;ee<R;ee++)K=pe(E,v),v=K.offp,A[ee]=A[ee]^K.key;for(v=0,ee=0;ee<R;ee+=2)K=pe($,v),v=K.offp,C[0]^=K.key,K=pe($,v),v=K.offp,C[1]^=K.key,C=oe(C,0,A,w),A[ee]=C[0],A[ee+1]=C[1];for(ee=0;ee<Z;ee+=2)K=pe($,v),v=K.offp,C[0]^=K.key,K=pe($,v),v=K.offp,C[1]^=K.key,C=oe(C,0,A,w),w[ee]=C[0],w[ee+1]=C[1]}function nt($,E,A,w,v){var C=q.slice(),R=C.length,Z;if(A<4||A>31)if(Z=Error("Illegal number of rounds (4-31): "+A),w){o(w.bind(this,Z));return}else throw Z;if(E.length!==h)if(Z=Error("Illegal salt length: "+E.length+" != "+h),w){o(w.bind(this,Z));return}else throw Z;A=1<<A>>>0;var K,ee,se=0,M;Int32Array?(K=new Int32Array(N),ee=new Int32Array(T)):(K=N.slice(),ee=T.slice()),Re(E,$,K,ee);function Se(){if(v&&v(se/A),se<A)for(var de=Date.now();se<A&&(se=se+1,ce($,K,ee),ce(E,K,ee),!(Date.now()-de>S)););else{for(se=0;se<64;se++)for(M=0;M<R>>1;M++)oe(C,M<<1,K,ee);var we=[];for(se=0;se<R;se++)we.push((C[se]>>24&255)>>>0),we.push((C[se]>>16&255)>>>0),we.push((C[se]>>8&255)>>>0),we.push((C[se]&255)>>>0);if(w){w(null,we);return}else return we}w&&o(Se)}if(typeof w<"u")Se();else for(var Kt;;)if(typeof(Kt=Se())<"u")return Kt||[]}function De($,E,A,w){var v;if(typeof $!="string"||typeof E!="string")if(v=Error("Invalid string / salt: Not a string"),A){o(A.bind(this,v));return}else throw v;var C,R;if(E.charAt(0)!=="$"||E.charAt(1)!=="2")if(v=Error("Invalid salt version: "+E.substring(0,2)),A){o(A.bind(this,v));return}else throw v;if(E.charAt(2)==="$")C="\0",R=3;else{if(C=E.charAt(2),C!=="a"&&C!=="b"&&C!=="y"||E.charAt(3)!=="$")if(v=Error("Invalid salt revision: "+E.substring(2,4)),A){o(A.bind(this,v));return}else throw v;R=4}if(E.charAt(R+2)>"$")if(v=Error("Missing salt rounds"),A){o(A.bind(this,v));return}else throw v;var Z=parseInt(E.substring(R,R+1),10)*10,K=parseInt(E.substring(R+1,R+2),10),ee=Z+K,se=E.substring(R+3,R+25);$+=C>="a"?"\0":"";var M=c($),Se=m(se,h);function Kt(de){var we=[];return we.push("$2"),C>="a"&&we.push(C),we.push("$"),ee<10&&we.push("0"),we.push(ee.toString()),we.push("$"),we.push(g(Se,Se.length)),we.push(g(de,q.length*4-1)),we.join("")}if(typeof A>"u")return Kt(nt(M,Se,ee));nt(M,Se,ee,function(de,we){de?A(de,null):A(null,Kt(we))},w)}return e.encodeBase64=g,e.decodeBase64=m,e})})(Ld);var ag=Ld.exports;const Wa=tg(ag),cg="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let lg=n=>crypto.getRandomValues(new Uint8Array(n)),ug=(n,e,t)=>{let i=(2<<Math.log2(n.length-1))-1,r=-~(1.6*i*e/n.length);return(s=e)=>{let o="";for(;;){let c=t(r),l=r;for(;l--;)if(o+=n[c[l]&i]||"",o.length===s)return o}}},dg=(n,e=21)=>ug(n,e,lg),Ke=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n));for(;n--;)e+=cg[t[n]&63];return e};const pg=24;function Ga(){return dg("0123456789abcdef",pg)()}function ml(n){if(!n.includes("|"))return console.error("Invalid user_id format"),n;const[,e]=n.split("|");return e}async function Ud(n,e,t){return(await n.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`})).users}async function Ja({userAdapter:n,tenant_id:e,email:t,provider:i}){const{users:r}=await n.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t} provider:${i}`});return r.length>1&&console.error("More than one user found for same email and provider"),r[0]||null}async function Vd({userAdapter:n,tenant_id:e,email:t}){var c;const{users:i}=await n.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${t}`}),r=i.filter(l=>!(l.provider==="auth2"&&!l.email_verified));if(r.length===0)return;const s=r.filter(l=>!l.linked_to);if(s.length>0)return s.length>1&&console.error("More than one primary user found for same email"),s[0];const o=await n.get(e,(c=r[0])==null?void 0:c.linked_to);if(!o)throw new Error("Primary account not found");return o}async function rs({userAdapter:n,tenant_id:e,email:t,provider:i}){const r=await Ja({userAdapter:n,tenant_id:e,email:t,provider:i});return r?r.linked_to?n.get(e,r.linked_to):r:null}const rn=a.z.object({page:a.z.string().min(0).optional().default("0").transform(n=>parseInt(n,10)).openapi({description:"The page number where 0 is the first page"}),per_page:a.z.string().min(1).optional().default("10").transform(n=>parseInt(n,10)).openapi({description:"The number of items per page"}),include_totals:a.z.string().optional().default("false").transform(n=>n==="true").openapi({description:"If the total number of items should be included in the response"}),sort:a.z.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:a.z.string().optional().openapi({description:"A lucene query string used to filter the results"})});function Mn(n){if(!n)return;const[e,t]=n.split(":"),i=t==="1"?"asc":"desc";if(!(!e||!i))return{sort_by:e,sort_order:i}}function ke(n,e){return{type:e.type,description:e.description||"",ip:n.req.header("x-real-ip")||"",user_agent:n.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:n.req.method,path:n.req.path,qs:n.req.queries(),body:e.body||n.var.body||""}},isMobile:!1,client_id:n.var.client_id,client_name:"",user_id:e.userId||n.var.user_id||"",hostname:n.req.header("host")||"",user_name:n.var.username||"",connection_id:"",connection:n.var.connection||"",strategy:e.strategy||"",strategy_type:e.strategy_type||"",audience:"",scope:[]}}var fg={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},hg=()=>{var t,i;const n=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[r,s]of Object.entries(fg))if(gg(s))return r}return typeof(n==null?void 0:n.EdgeRuntime)=="string"?"edge-light":(n==null?void 0:n.fastly)!==void 0?"fastly":((i=(t=n==null?void 0:n.process)==null?void 0:t.release)==null?void 0:i.name)==="node"?"node":"other"},gg=n=>navigator.userAgent.startsWith(n);function Nt(n,e){hg()==="workerd"&&n.executionCtx.waitUntil(e)}const yl=Mt.extend({users:a.z.array(ft)}),_g=Mt.extend({sessions:a.z.array(Ka)}),mg=new a.OpenAPIHono().openapi(a.createRoute({tags:["users"],method:"get",path:"/",request:{query:rn,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(ft),yl])}},description:"List of users"}}}),async n=>{const{page:e,per_page:t,include_totals:i,sort:r,q:s}=n.req.valid("query"),{"tenant-id":o}=n.req.valid("header");if(s!=null&&s.includes("identities.profileData.email")){const p=s.split("=")[1],m=(await n.env.data.users.list(o,{page:e,per_page:t,include_totals:i,q:`email:${p}`})).users.filter(_=>_.linked_to),[x]=m;if(!x)return n.json([]);const h=await n.env.data.users.get(o,x.linked_to);if(!h)throw new O(500,{message:"Primary account not found"});return n.json([ft.parse(h)])}const c=["-_exists_:linked_to"];s&&c.push(s);const l=await n.env.data.users.list(o,{page:e,per_page:t,include_totals:i,sort:Mn(r),q:c.join(" ")}),u=l.users.filter(p=>!p.linked_to);return i?n.json(yl.parse({users:u,length:l.length,start:l.start,limit:l.limit})):n.json(a.z.array(ft).parse(u))}).openapi(a.createRoute({tags:["users"],method:"get",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:ft}},description:"List of users"}}}),async n=>{const{user_id:e}=n.req.valid("param"),{"tenant-id":t}=n.req.valid("header"),i=await n.env.data.users.get(t,e);if(!i)throw new O(404);if(i.linked_to)throw new O(404,{message:"User is linked to another user"});return n.json(i)}).openapi(a.createRoute({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async n=>{const{user_id:e}=n.req.valid("param"),{"tenant-id":t}=n.req.valid("header");if(!await n.env.data.users.remove(t,e))throw new O(404);return n.text("OK")}).openapi(a.createRoute({tags:["users"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object({...ur.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:ft}},description:"Status"}}}),async n=>{const{"tenant-id":e}=n.req.valid("header"),t=n.req.valid("json");n.set("body",t);const{email:i}=t;if(!i)throw new O(400,{message:"Email is required"});const r=i.toLowerCase(),s=`${t.provider}|${t.user_id||Ga()}`;try{const o=await n.env.data.users.create(e,{email:r,user_id:s,name:t.name||r,provider:t.provider,connection:t.connection,email_verified:t.email_verified||!1,last_ip:"",is_social:!1,last_login:new Date().toISOString()});n.set("user_id",o.user_id);const c=ke(n,{type:_e.SUCCESS_API_OPERATION,description:"User created"});Nt(n,n.env.data.logs.create(e,c));const l={...o,identities:[{connection:o.connection,provider:o.provider,user_id:ml(o.user_id),isSocial:o.is_social}]};return n.json(ft.parse(l),{status:201})}catch(o){throw o.message==="User already exists"?new O(409,{message:"User already exists"}):o}}).openapi(a.createRoute({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object({...ur.shape,verify_email:a.z.boolean(),password:a.z.string()}).partial()}}},params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async n=>{var u;const{"tenant-id":e}=n.req.valid("header"),t=n.req.valid("json"),{user_id:i}=n.req.valid("param"),{verify_email:r,password:s,...o}=t,c=await n.env.data.users.get(e,i);if(!c)throw new O(404);if(o.email&&o.email!==c.email){const p=await Ud(n.env.data.users,e,o.email);if(p.length&&p.some(g=>g.user_id!==i))throw new O(409,{message:"Another user with the same email address already exists."})}if(c.linked_to)throw new O(404,{message:"User is linked to another user"});if(await n.env.data.users.update(e,i,o),s){const p=(u=c.identities)==null?void 0:u.find(g=>g.connection==="Username-Password-Authentication");if(!p)throw new O(400,{message:"User does not have a password identity"});await n.env.data.passwords.update(e,{user_id:`${p.provider}|${p.user_id}`,password:Wa.hashSync(s,10),algorithm:"bcrypt"})}const l=await n.env.data.users.get(e,i);if(!l)throw new O(500);return n.json(l)}).openapi(a.createRoute({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.union([a.z.object({link_with:a.z.string()}),a.z.object({user_id:a.z.string(),provider:a.z.string(),connection:a.z.string().optional()})])}}},params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:a.z.array(a.z.object({connection:a.z.string(),provider:a.z.string(),user_id:a.z.string(),isSocial:a.z.boolean()}))}},description:"Status"}}}),async n=>{const{"tenant-id":e}=n.req.valid("header"),t=n.req.valid("json"),{user_id:i}=n.req.valid("param"),r="link_with"in t?t.link_with:t.user_id,s=await n.env.data.users.get(e,i);if(!s)throw new O(400,{message:"Linking an inexistent identity is not allowed."});await n.env.data.users.update(e,r,{linked_to:i});const o=await n.env.data.users.list(e,{page:0,per_page:10,include_totals:!1,q:`linked_to:${i}`}),c=[s,...o.users].map(l=>({connection:l.connection,provider:l.provider,user_id:ml(l.user_id),isSocial:l.is_social}));return n.json(c,{status:201})}).openapi(a.createRoute({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string(),provider:a.z.string(),linked_user_id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:a.z.array(ft)}},description:"Status"}}}),async n=>{const{"tenant-id":e}=n.req.valid("header"),{user_id:t,provider:i,linked_user_id:r}=n.req.valid("param");await n.env.data.users.unlink(e,t,i,r);const s=await n.env.data.users.get(e,t);if(!s)throw new O(404);return n.json([ft.parse(s)])}).openapi(a.createRoute({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:rn,headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({user_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([a.z.array(Ka),_g])}},description:"List of sessions"}}}),async n=>{const{user_id:e}=n.req.valid("param"),{include_totals:t}=n.req.valid("query"),{"tenant-id":i}=n.req.valid("header"),r=await n.env.data.sessions.list(i,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return t?n.json(r):n.json(r.sessions)});/*! *****************************************************************************
6
6
  Copyright (C) Microsoft. All rights reserved.
7
7
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
8
8
  this file except in compliance with the License. You may obtain a copy of the
@@ -15,7 +15,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
15
15
 
16
16
  See the Apache Version 2.0 License for specific language governing permissions
17
17
  and limitations under the License.
18
- ***************************************************************************** */var vl;(function(n){(function(e){var t=typeof globalThis=="object"?globalThis:typeof mr=="object"?mr:typeof self=="object"?self:typeof this=="object"?this:c(),i=r(n);typeof t.Reflect<"u"&&(i=r(t.Reflect,i)),e(i,t),typeof t.Reflect>"u"&&(t.Reflect=n);function r(l,u){return function(p,g){Object.defineProperty(l,p,{configurable:!0,writable:!0,value:g}),u&&u(p,g)}}function s(){try{return Function("return this;")()}catch{}}function o(){try{return(0,eval)("(function() { return this; })()")}catch{}}function c(){return s()||o()}})(function(e,t){var i=Object.prototype.hasOwnProperty,r=typeof Symbol=="function",s=r&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=r&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",l={__proto__:[]}instanceof Array,u=!c&&!l,p={create:c?function(){return eo(Object.create(null))}:l?function(){return eo({__proto__:null})}:function(){return eo({})},has:u?function(k,I){return i.call(k,I)}:function(k,I){return I in k},get:u?function(k,I){return i.call(k,I)?k[I]:void 0}:function(k,I){return k[I]}},g=Object.getPrototypeOf(Function),m=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:mh(),x=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:yh(),h=typeof WeakMap=="function"?WeakMap:vh(),_=r?Symbol.for("@reflect-metadata:registry"):void 0,b=hh(),S=gh(b);function N(k,I,j,P){if(M(j)){if(!Yc(k))throw new TypeError;if(!Xc(I))throw new TypeError;return E(k,I)}else{if(!Yc(k))throw new TypeError;if(!de(I))throw new TypeError;if(!de(P)&&!M(P)&&!Se(P))throw new TypeError;return Se(P)&&(P=void 0),j=ut(j),A(k,I,j,P)}}e("decorate",N);function T(k,I){function j(P,Y){if(!de(P))throw new TypeError;if(!M(Y)&&!ph(Y))throw new TypeError;Z(k,I,P,Y)}return j}e("metadata",T);function K(k,I,j,P){if(!de(j))throw new TypeError;return M(P)||(P=ut(P)),Z(k,I,j,P)}e("defineMetadata",K);function oe(k,I,j){if(!de(I))throw new TypeError;return M(j)||(j=ut(j)),w(k,I,j)}e("hasMetadata",oe);function pe(k,I,j){if(!de(I))throw new TypeError;return M(j)||(j=ut(j)),v(k,I,j)}e("hasOwnMetadata",pe);function ce(k,I,j){if(!de(I))throw new TypeError;return M(j)||(j=ut(j)),C(k,I,j)}e("getMetadata",ce);function Re(k,I,j){if(!de(I))throw new TypeError;return M(j)||(j=ut(j)),R(k,I,j)}e("getOwnMetadata",Re);function nt(k,I){if(!de(k))throw new TypeError;return M(I)||(I=ut(I)),q(k,I)}e("getMetadataKeys",nt);function De(k,I){if(!de(k))throw new TypeError;return M(I)||(I=ut(I)),ee(k,I)}e("getOwnMetadataKeys",De);function $(k,I,j){if(!de(I))throw new TypeError;if(M(j)||(j=ut(j)),!de(I))throw new TypeError;M(j)||(j=ut(j));var P=Xn(I,j,!1);return M(P)?!1:P.OrdinaryDeleteMetadata(k,I,j)}e("deleteMetadata",$);function E(k,I){for(var j=k.length-1;j>=0;--j){var P=k[j],Y=P(I);if(!M(Y)&&!Se(Y)){if(!Xc(Y))throw new TypeError;I=Y}}return I}function A(k,I,j,P){for(var Y=k.length-1;Y>=0;--Y){var Ae=k[Y],be=Ae(I,j,P);if(!M(be)&&!Se(be)){if(!de(be))throw new TypeError;P=be}}return P}function w(k,I,j){var P=v(k,I,j);if(P)return!0;var Y=Qs(I);return Se(Y)?!1:w(k,Y,j)}function v(k,I,j){var P=Xn(I,j,!1);return M(P)?!1:Zc(P.OrdinaryHasOwnMetadata(k,I,j))}function C(k,I,j){var P=v(k,I,j);if(P)return R(k,I,j);var Y=Qs(I);if(!Se(Y))return C(k,Y,j)}function R(k,I,j){var P=Xn(I,j,!1);if(!M(P))return P.OrdinaryGetOwnMetadata(k,I,j)}function Z(k,I,j,P){var Y=Xn(j,P,!0);Y.OrdinaryDefineOwnMetadata(k,I,j,P)}function q(k,I){var j=ee(k,I),P=Qs(k);if(P===null)return j;var Y=q(P,I);if(Y.length<=0)return j;if(j.length<=0)return Y;for(var Ae=new x,be=[],ne=0,V=j;ne<V.length;ne++){var F=V[ne],G=Ae.has(F);G||(Ae.add(F),be.push(F))}for(var J=0,ie=Y;J<ie.length;J++){var F=ie[J],G=Ae.has(F);G||(Ae.add(F),be.push(F))}return be}function ee(k,I){var j=Xn(k,I,!1);return j?j.OrdinaryOwnMetadataKeys(k,I):[]}function se(k){if(k===null)return 1;switch(typeof k){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return k===null?1:6;default:return 6}}function M(k){return k===void 0}function Se(k){return k===null}function Kt(k){return typeof k=="symbol"}function de(k){return typeof k=="object"?k!==null:typeof k=="function"}function we(k,I){switch(se(k)){case 0:return k;case 1:return k;case 2:return k;case 3:return k;case 4:return k;case 5:return k}var j="string",P=Qc(k,s);if(P!==void 0){var Y=P.call(k,j);if(de(Y))throw new TypeError;return Y}return uh(k)}function uh(k,I){var j,P;{var Y=k.toString;if(qi(Y)){var P=Y.call(k);if(!de(P))return P}var j=k.valueOf;if(qi(j)){var P=j.call(k);if(!de(P))return P}}throw new TypeError}function Zc(k){return!!k}function dh(k){return""+k}function ut(k){var I=we(k);return Kt(I)?I:dh(I)}function Yc(k){return Array.isArray?Array.isArray(k):k instanceof Object?k instanceof Array:Object.prototype.toString.call(k)==="[object Array]"}function qi(k){return typeof k=="function"}function Xc(k){return typeof k=="function"}function ph(k){switch(se(k)){case 3:return!0;case 4:return!0;default:return!1}}function Xs(k,I){return k===I||k!==k&&I!==I}function Qc(k,I){var j=k[I];if(j!=null){if(!qi(j))throw new TypeError;return j}}function el(k){var I=Qc(k,o);if(!qi(I))throw new TypeError;var j=I.call(k);if(!de(j))throw new TypeError;return j}function tl(k){return k.value}function nl(k){var I=k.next();return I.done?!1:I}function il(k){var I=k.return;I&&I.call(k)}function Qs(k){var I=Object.getPrototypeOf(k);if(typeof k!="function"||k===g||I!==g)return I;var j=k.prototype,P=j&&Object.getPrototypeOf(j);if(P==null||P===Object.prototype)return I;var Y=P.constructor;return typeof Y!="function"||Y===k?I:Y}function fh(){var k;!M(_)&&typeof t.Reflect<"u"&&!(_ in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(k=_h(t.Reflect));var I,j,P,Y=new h,Ae={registerProvider:be,getProvider:V,setProvider:G};return Ae;function be(J){if(!Object.isExtensible(Ae))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case k===J:break;case M(I):I=J;break;case I===J:break;case M(j):j=J;break;case j===J:break;default:P===void 0&&(P=new x),P.add(J);break}}function ne(J,ie){if(!M(I)){if(I.isProviderFor(J,ie))return I;if(!M(j)){if(j.isProviderFor(J,ie))return I;if(!M(P))for(var fe=el(P);;){var me=nl(fe);if(!me)return;var it=tl(me);if(it.isProviderFor(J,ie))return il(fe),it}}}if(!M(k)&&k.isProviderFor(J,ie))return k}function V(J,ie){var fe=Y.get(J),me;return M(fe)||(me=fe.get(ie)),M(me)&&(me=ne(J,ie),M(me)||(M(fe)&&(fe=new m,Y.set(J,fe)),fe.set(ie,me))),me}function F(J){if(M(J))throw new TypeError;return I===J||j===J||!M(P)&&P.has(J)}function G(J,ie,fe){if(!F(fe))throw new Error("Metadata provider not registered.");var me=V(J,ie);if(me!==fe){if(!M(me))return!1;var it=Y.get(J);M(it)&&(it=new m,Y.set(J,it)),it.set(ie,fe)}return!0}}function hh(){var k;return!M(_)&&de(t.Reflect)&&Object.isExtensible(t.Reflect)&&(k=t.Reflect[_]),M(k)&&(k=fh()),!M(_)&&de(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,_,{enumerable:!1,configurable:!1,writable:!1,value:k}),k}function gh(k){var I=new h,j={isProviderFor:function(F,G){var J=I.get(F);return M(J)?!1:J.has(G)},OrdinaryDefineOwnMetadata:be,OrdinaryHasOwnMetadata:Y,OrdinaryGetOwnMetadata:Ae,OrdinaryOwnMetadataKeys:ne,OrdinaryDeleteMetadata:V};return b.registerProvider(j),j;function P(F,G,J){var ie=I.get(F),fe=!1;if(M(ie)){if(!J)return;ie=new m,I.set(F,ie),fe=!0}var me=ie.get(G);if(M(me)){if(!J)return;if(me=new m,ie.set(G,me),!k.setProvider(F,G,j))throw ie.delete(G),fe&&I.delete(F),new Error("Wrong provider for target.")}return me}function Y(F,G,J){var ie=P(G,J,!1);return M(ie)?!1:Zc(ie.has(F))}function Ae(F,G,J){var ie=P(G,J,!1);if(!M(ie))return ie.get(F)}function be(F,G,J,ie){var fe=P(J,ie,!0);fe.set(F,G)}function ne(F,G){var J=[],ie=P(F,G,!1);if(M(ie))return J;for(var fe=ie.keys(),me=el(fe),it=0;;){var rl=nl(me);if(!rl)return J.length=it,J;var wh=tl(rl);try{J[it]=wh}catch(bh){try{il(me)}finally{throw bh}}it++}}function V(F,G,J){var ie=P(G,J,!1);if(M(ie)||!ie.delete(F))return!1;if(ie.size===0){var fe=I.get(G);M(fe)||(fe.delete(J),fe.size===0&&I.delete(fe))}return!0}}function _h(k){var I=k.defineMetadata,j=k.hasOwnMetadata,P=k.getOwnMetadata,Y=k.getOwnMetadataKeys,Ae=k.deleteMetadata,be=new h,ne={isProviderFor:function(V,F){var G=be.get(V);return!M(G)&&G.has(F)?!0:Y(V,F).length?(M(G)&&(G=new x,be.set(V,G)),G.add(F),!0):!1},OrdinaryDefineOwnMetadata:I,OrdinaryHasOwnMetadata:j,OrdinaryGetOwnMetadata:P,OrdinaryOwnMetadataKeys:Y,OrdinaryDeleteMetadata:Ae};return ne}function Xn(k,I,j){var P=b.getProvider(k,I);if(!M(P))return P;if(j){if(b.setProvider(k,I,S))return S;throw new Error("Illegal state.")}}function mh(){var k={},I=[],j=function(){function ne(V,F,G){this._index=0,this._keys=V,this._values=F,this._selector=G}return ne.prototype["@@iterator"]=function(){return this},ne.prototype[o]=function(){return this},ne.prototype.next=function(){var V=this._index;if(V>=0&&V<this._keys.length){var F=this._selector(this._keys[V],this._values[V]);return V+1>=this._keys.length?(this._index=-1,this._keys=I,this._values=I):this._index++,{value:F,done:!1}}return{value:void 0,done:!0}},ne.prototype.throw=function(V){throw this._index>=0&&(this._index=-1,this._keys=I,this._values=I),V},ne.prototype.return=function(V){return this._index>=0&&(this._index=-1,this._keys=I,this._values=I),{value:V,done:!0}},ne}(),P=function(){function ne(){this._keys=[],this._values=[],this._cacheKey=k,this._cacheIndex=-2}return Object.defineProperty(ne.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),ne.prototype.has=function(V){return this._find(V,!1)>=0},ne.prototype.get=function(V){var F=this._find(V,!1);return F>=0?this._values[F]:void 0},ne.prototype.set=function(V,F){var G=this._find(V,!0);return this._values[G]=F,this},ne.prototype.delete=function(V){var F=this._find(V,!1);if(F>=0){for(var G=this._keys.length,J=F+1;J<G;J++)this._keys[J-1]=this._keys[J],this._values[J-1]=this._values[J];return this._keys.length--,this._values.length--,Xs(V,this._cacheKey)&&(this._cacheKey=k,this._cacheIndex=-2),!0}return!1},ne.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=k,this._cacheIndex=-2},ne.prototype.keys=function(){return new j(this._keys,this._values,Y)},ne.prototype.values=function(){return new j(this._keys,this._values,Ae)},ne.prototype.entries=function(){return new j(this._keys,this._values,be)},ne.prototype["@@iterator"]=function(){return this.entries()},ne.prototype[o]=function(){return this.entries()},ne.prototype._find=function(V,F){if(!Xs(this._cacheKey,V)){this._cacheIndex=-1;for(var G=0;G<this._keys.length;G++)if(Xs(this._keys[G],V)){this._cacheIndex=G;break}}return this._cacheIndex<0&&F&&(this._cacheIndex=this._keys.length,this._keys.push(V),this._values.push(void 0)),this._cacheIndex},ne}();return P;function Y(ne,V){return ne}function Ae(ne,V){return V}function be(ne,V){return[ne,V]}}function yh(){var k=function(){function I(){this._map=new m}return Object.defineProperty(I.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),I.prototype.has=function(j){return this._map.has(j)},I.prototype.add=function(j){return this._map.set(j,j),this},I.prototype.delete=function(j){return this._map.delete(j)},I.prototype.clear=function(){this._map.clear()},I.prototype.keys=function(){return this._map.keys()},I.prototype.values=function(){return this._map.keys()},I.prototype.entries=function(){return this._map.entries()},I.prototype["@@iterator"]=function(){return this.keys()},I.prototype[o]=function(){return this.keys()},I}();return k}function vh(){var k=16,I=p.create(),j=P();return function(){function V(){this._key=P()}return V.prototype.has=function(F){var G=Y(F,!1);return G!==void 0?p.has(G,this._key):!1},V.prototype.get=function(F){var G=Y(F,!1);return G!==void 0?p.get(G,this._key):void 0},V.prototype.set=function(F,G){var J=Y(F,!0);return J[this._key]=G,this},V.prototype.delete=function(F){var G=Y(F,!1);return G!==void 0?delete G[this._key]:!1},V.prototype.clear=function(){this._key=P()},V}();function P(){var V;do V="@@WeakMap@@"+ne();while(p.has(I,V));return I[V]=!0,V}function Y(V,F){if(!i.call(V,j)){if(!F)return;Object.defineProperty(V,j,{value:p.create()})}return V[j]}function Ae(V,F){for(var G=0;G<F;++G)V[G]=Math.random()*255|0;return V}function be(V){if(typeof Uint8Array=="function"){var F=new Uint8Array(V);return typeof crypto<"u"?crypto.getRandomValues(F):typeof msCrypto<"u"?msCrypto.getRandomValues(F):Ae(F,V),F}return Ae(new Array(V),V)}function ne(){var V=be(k);V[6]=V[6]&79|64,V[8]=V[8]&191|128;for(var F="",G=0;G<k;++G){var J=V[G];(G===4||G===6||G===8)&&(F+="-"),J<16&&(F+="0"),F+=J.toString(16).toLowerCase()}return F}}function eo(k){return k.__=void 0,delete k.__,k}})})(vl||(vl={}));/*!
18
+ ***************************************************************************** */var vl;(function(n){(function(e){var t=typeof globalThis=="object"?globalThis:typeof mr=="object"?mr:typeof self=="object"?self:typeof this=="object"?this:c(),i=r(n);typeof t.Reflect<"u"&&(i=r(t.Reflect,i)),e(i,t),typeof t.Reflect>"u"&&(t.Reflect=n);function r(l,u){return function(p,g){Object.defineProperty(l,p,{configurable:!0,writable:!0,value:g}),u&&u(p,g)}}function s(){try{return Function("return this;")()}catch{}}function o(){try{return(0,eval)("(function() { return this; })()")}catch{}}function c(){return s()||o()}})(function(e,t){var i=Object.prototype.hasOwnProperty,r=typeof Symbol=="function",s=r&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=r&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",l={__proto__:[]}instanceof Array,u=!c&&!l,p={create:c?function(){return eo(Object.create(null))}:l?function(){return eo({__proto__:null})}:function(){return eo({})},has:u?function(k,I){return i.call(k,I)}:function(k,I){return I in k},get:u?function(k,I){return i.call(k,I)?k[I]:void 0}:function(k,I){return k[I]}},g=Object.getPrototypeOf(Function),m=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:mh(),x=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:yh(),h=typeof WeakMap=="function"?WeakMap:vh(),_=r?Symbol.for("@reflect-metadata:registry"):void 0,b=hh(),S=gh(b);function N(k,I,j,P){if(M(j)){if(!Yc(k))throw new TypeError;if(!Xc(I))throw new TypeError;return E(k,I)}else{if(!Yc(k))throw new TypeError;if(!de(I))throw new TypeError;if(!de(P)&&!M(P)&&!Se(P))throw new TypeError;return Se(P)&&(P=void 0),j=ut(j),A(k,I,j,P)}}e("decorate",N);function T(k,I){function j(P,Y){if(!de(P))throw new TypeError;if(!M(Y)&&!ph(Y))throw new TypeError;Z(k,I,P,Y)}return j}e("metadata",T);function q(k,I,j,P){if(!de(j))throw new TypeError;return M(P)||(P=ut(P)),Z(k,I,j,P)}e("defineMetadata",q);function oe(k,I,j){if(!de(I))throw new TypeError;return M(j)||(j=ut(j)),w(k,I,j)}e("hasMetadata",oe);function pe(k,I,j){if(!de(I))throw new TypeError;return M(j)||(j=ut(j)),v(k,I,j)}e("hasOwnMetadata",pe);function ce(k,I,j){if(!de(I))throw new TypeError;return M(j)||(j=ut(j)),C(k,I,j)}e("getMetadata",ce);function Re(k,I,j){if(!de(I))throw new TypeError;return M(j)||(j=ut(j)),R(k,I,j)}e("getOwnMetadata",Re);function nt(k,I){if(!de(k))throw new TypeError;return M(I)||(I=ut(I)),K(k,I)}e("getMetadataKeys",nt);function De(k,I){if(!de(k))throw new TypeError;return M(I)||(I=ut(I)),ee(k,I)}e("getOwnMetadataKeys",De);function $(k,I,j){if(!de(I))throw new TypeError;if(M(j)||(j=ut(j)),!de(I))throw new TypeError;M(j)||(j=ut(j));var P=Xn(I,j,!1);return M(P)?!1:P.OrdinaryDeleteMetadata(k,I,j)}e("deleteMetadata",$);function E(k,I){for(var j=k.length-1;j>=0;--j){var P=k[j],Y=P(I);if(!M(Y)&&!Se(Y)){if(!Xc(Y))throw new TypeError;I=Y}}return I}function A(k,I,j,P){for(var Y=k.length-1;Y>=0;--Y){var Ae=k[Y],be=Ae(I,j,P);if(!M(be)&&!Se(be)){if(!de(be))throw new TypeError;P=be}}return P}function w(k,I,j){var P=v(k,I,j);if(P)return!0;var Y=Qs(I);return Se(Y)?!1:w(k,Y,j)}function v(k,I,j){var P=Xn(I,j,!1);return M(P)?!1:Zc(P.OrdinaryHasOwnMetadata(k,I,j))}function C(k,I,j){var P=v(k,I,j);if(P)return R(k,I,j);var Y=Qs(I);if(!Se(Y))return C(k,Y,j)}function R(k,I,j){var P=Xn(I,j,!1);if(!M(P))return P.OrdinaryGetOwnMetadata(k,I,j)}function Z(k,I,j,P){var Y=Xn(j,P,!0);Y.OrdinaryDefineOwnMetadata(k,I,j,P)}function K(k,I){var j=ee(k,I),P=Qs(k);if(P===null)return j;var Y=K(P,I);if(Y.length<=0)return j;if(j.length<=0)return Y;for(var Ae=new x,be=[],ne=0,V=j;ne<V.length;ne++){var F=V[ne],G=Ae.has(F);G||(Ae.add(F),be.push(F))}for(var J=0,ie=Y;J<ie.length;J++){var F=ie[J],G=Ae.has(F);G||(Ae.add(F),be.push(F))}return be}function ee(k,I){var j=Xn(k,I,!1);return j?j.OrdinaryOwnMetadataKeys(k,I):[]}function se(k){if(k===null)return 1;switch(typeof k){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return k===null?1:6;default:return 6}}function M(k){return k===void 0}function Se(k){return k===null}function Kt(k){return typeof k=="symbol"}function de(k){return typeof k=="object"?k!==null:typeof k=="function"}function we(k,I){switch(se(k)){case 0:return k;case 1:return k;case 2:return k;case 3:return k;case 4:return k;case 5:return k}var j="string",P=Qc(k,s);if(P!==void 0){var Y=P.call(k,j);if(de(Y))throw new TypeError;return Y}return uh(k)}function uh(k,I){var j,P;{var Y=k.toString;if(qi(Y)){var P=Y.call(k);if(!de(P))return P}var j=k.valueOf;if(qi(j)){var P=j.call(k);if(!de(P))return P}}throw new TypeError}function Zc(k){return!!k}function dh(k){return""+k}function ut(k){var I=we(k);return Kt(I)?I:dh(I)}function Yc(k){return Array.isArray?Array.isArray(k):k instanceof Object?k instanceof Array:Object.prototype.toString.call(k)==="[object Array]"}function qi(k){return typeof k=="function"}function Xc(k){return typeof k=="function"}function ph(k){switch(se(k)){case 3:return!0;case 4:return!0;default:return!1}}function Xs(k,I){return k===I||k!==k&&I!==I}function Qc(k,I){var j=k[I];if(j!=null){if(!qi(j))throw new TypeError;return j}}function el(k){var I=Qc(k,o);if(!qi(I))throw new TypeError;var j=I.call(k);if(!de(j))throw new TypeError;return j}function tl(k){return k.value}function nl(k){var I=k.next();return I.done?!1:I}function il(k){var I=k.return;I&&I.call(k)}function Qs(k){var I=Object.getPrototypeOf(k);if(typeof k!="function"||k===g||I!==g)return I;var j=k.prototype,P=j&&Object.getPrototypeOf(j);if(P==null||P===Object.prototype)return I;var Y=P.constructor;return typeof Y!="function"||Y===k?I:Y}function fh(){var k;!M(_)&&typeof t.Reflect<"u"&&!(_ in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(k=_h(t.Reflect));var I,j,P,Y=new h,Ae={registerProvider:be,getProvider:V,setProvider:G};return Ae;function be(J){if(!Object.isExtensible(Ae))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case k===J:break;case M(I):I=J;break;case I===J:break;case M(j):j=J;break;case j===J:break;default:P===void 0&&(P=new x),P.add(J);break}}function ne(J,ie){if(!M(I)){if(I.isProviderFor(J,ie))return I;if(!M(j)){if(j.isProviderFor(J,ie))return I;if(!M(P))for(var fe=el(P);;){var me=nl(fe);if(!me)return;var it=tl(me);if(it.isProviderFor(J,ie))return il(fe),it}}}if(!M(k)&&k.isProviderFor(J,ie))return k}function V(J,ie){var fe=Y.get(J),me;return M(fe)||(me=fe.get(ie)),M(me)&&(me=ne(J,ie),M(me)||(M(fe)&&(fe=new m,Y.set(J,fe)),fe.set(ie,me))),me}function F(J){if(M(J))throw new TypeError;return I===J||j===J||!M(P)&&P.has(J)}function G(J,ie,fe){if(!F(fe))throw new Error("Metadata provider not registered.");var me=V(J,ie);if(me!==fe){if(!M(me))return!1;var it=Y.get(J);M(it)&&(it=new m,Y.set(J,it)),it.set(ie,fe)}return!0}}function hh(){var k;return!M(_)&&de(t.Reflect)&&Object.isExtensible(t.Reflect)&&(k=t.Reflect[_]),M(k)&&(k=fh()),!M(_)&&de(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,_,{enumerable:!1,configurable:!1,writable:!1,value:k}),k}function gh(k){var I=new h,j={isProviderFor:function(F,G){var J=I.get(F);return M(J)?!1:J.has(G)},OrdinaryDefineOwnMetadata:be,OrdinaryHasOwnMetadata:Y,OrdinaryGetOwnMetadata:Ae,OrdinaryOwnMetadataKeys:ne,OrdinaryDeleteMetadata:V};return b.registerProvider(j),j;function P(F,G,J){var ie=I.get(F),fe=!1;if(M(ie)){if(!J)return;ie=new m,I.set(F,ie),fe=!0}var me=ie.get(G);if(M(me)){if(!J)return;if(me=new m,ie.set(G,me),!k.setProvider(F,G,j))throw ie.delete(G),fe&&I.delete(F),new Error("Wrong provider for target.")}return me}function Y(F,G,J){var ie=P(G,J,!1);return M(ie)?!1:Zc(ie.has(F))}function Ae(F,G,J){var ie=P(G,J,!1);if(!M(ie))return ie.get(F)}function be(F,G,J,ie){var fe=P(J,ie,!0);fe.set(F,G)}function ne(F,G){var J=[],ie=P(F,G,!1);if(M(ie))return J;for(var fe=ie.keys(),me=el(fe),it=0;;){var rl=nl(me);if(!rl)return J.length=it,J;var wh=tl(rl);try{J[it]=wh}catch(bh){try{il(me)}finally{throw bh}}it++}}function V(F,G,J){var ie=P(G,J,!1);if(M(ie)||!ie.delete(F))return!1;if(ie.size===0){var fe=I.get(G);M(fe)||(fe.delete(J),fe.size===0&&I.delete(fe))}return!0}}function _h(k){var I=k.defineMetadata,j=k.hasOwnMetadata,P=k.getOwnMetadata,Y=k.getOwnMetadataKeys,Ae=k.deleteMetadata,be=new h,ne={isProviderFor:function(V,F){var G=be.get(V);return!M(G)&&G.has(F)?!0:Y(V,F).length?(M(G)&&(G=new x,be.set(V,G)),G.add(F),!0):!1},OrdinaryDefineOwnMetadata:I,OrdinaryHasOwnMetadata:j,OrdinaryGetOwnMetadata:P,OrdinaryOwnMetadataKeys:Y,OrdinaryDeleteMetadata:Ae};return ne}function Xn(k,I,j){var P=b.getProvider(k,I);if(!M(P))return P;if(j){if(b.setProvider(k,I,S))return S;throw new Error("Illegal state.")}}function mh(){var k={},I=[],j=function(){function ne(V,F,G){this._index=0,this._keys=V,this._values=F,this._selector=G}return ne.prototype["@@iterator"]=function(){return this},ne.prototype[o]=function(){return this},ne.prototype.next=function(){var V=this._index;if(V>=0&&V<this._keys.length){var F=this._selector(this._keys[V],this._values[V]);return V+1>=this._keys.length?(this._index=-1,this._keys=I,this._values=I):this._index++,{value:F,done:!1}}return{value:void 0,done:!0}},ne.prototype.throw=function(V){throw this._index>=0&&(this._index=-1,this._keys=I,this._values=I),V},ne.prototype.return=function(V){return this._index>=0&&(this._index=-1,this._keys=I,this._values=I),{value:V,done:!0}},ne}(),P=function(){function ne(){this._keys=[],this._values=[],this._cacheKey=k,this._cacheIndex=-2}return Object.defineProperty(ne.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),ne.prototype.has=function(V){return this._find(V,!1)>=0},ne.prototype.get=function(V){var F=this._find(V,!1);return F>=0?this._values[F]:void 0},ne.prototype.set=function(V,F){var G=this._find(V,!0);return this._values[G]=F,this},ne.prototype.delete=function(V){var F=this._find(V,!1);if(F>=0){for(var G=this._keys.length,J=F+1;J<G;J++)this._keys[J-1]=this._keys[J],this._values[J-1]=this._values[J];return this._keys.length--,this._values.length--,Xs(V,this._cacheKey)&&(this._cacheKey=k,this._cacheIndex=-2),!0}return!1},ne.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=k,this._cacheIndex=-2},ne.prototype.keys=function(){return new j(this._keys,this._values,Y)},ne.prototype.values=function(){return new j(this._keys,this._values,Ae)},ne.prototype.entries=function(){return new j(this._keys,this._values,be)},ne.prototype["@@iterator"]=function(){return this.entries()},ne.prototype[o]=function(){return this.entries()},ne.prototype._find=function(V,F){if(!Xs(this._cacheKey,V)){this._cacheIndex=-1;for(var G=0;G<this._keys.length;G++)if(Xs(this._keys[G],V)){this._cacheIndex=G;break}}return this._cacheIndex<0&&F&&(this._cacheIndex=this._keys.length,this._keys.push(V),this._values.push(void 0)),this._cacheIndex},ne}();return P;function Y(ne,V){return ne}function Ae(ne,V){return V}function be(ne,V){return[ne,V]}}function yh(){var k=function(){function I(){this._map=new m}return Object.defineProperty(I.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),I.prototype.has=function(j){return this._map.has(j)},I.prototype.add=function(j){return this._map.set(j,j),this},I.prototype.delete=function(j){return this._map.delete(j)},I.prototype.clear=function(){this._map.clear()},I.prototype.keys=function(){return this._map.keys()},I.prototype.values=function(){return this._map.keys()},I.prototype.entries=function(){return this._map.entries()},I.prototype["@@iterator"]=function(){return this.keys()},I.prototype[o]=function(){return this.keys()},I}();return k}function vh(){var k=16,I=p.create(),j=P();return function(){function V(){this._key=P()}return V.prototype.has=function(F){var G=Y(F,!1);return G!==void 0?p.has(G,this._key):!1},V.prototype.get=function(F){var G=Y(F,!1);return G!==void 0?p.get(G,this._key):void 0},V.prototype.set=function(F,G){var J=Y(F,!0);return J[this._key]=G,this},V.prototype.delete=function(F){var G=Y(F,!1);return G!==void 0?delete G[this._key]:!1},V.prototype.clear=function(){this._key=P()},V}();function P(){var V;do V="@@WeakMap@@"+ne();while(p.has(I,V));return I[V]=!0,V}function Y(V,F){if(!i.call(V,j)){if(!F)return;Object.defineProperty(V,j,{value:p.create()})}return V[j]}function Ae(V,F){for(var G=0;G<F;++G)V[G]=Math.random()*255|0;return V}function be(V){if(typeof Uint8Array=="function"){var F=new Uint8Array(V);return typeof crypto<"u"?crypto.getRandomValues(F):typeof msCrypto<"u"?msCrypto.getRandomValues(F):Ae(F,V),F}return Ae(new Array(V),V)}function ne(){var V=be(k);V[6]=V[6]&79|64,V[8]=V[8]&191|128;for(var F="",G=0;G<k;++G){var J=V[G];(G===4||G===6||G===8)&&(F+="-"),J<16&&(F+="0"),F+=J.toString(16).toLowerCase()}return F}}function eo(k){return k.__=void 0,delete k.__,k}})})(vl||(vl={}));/*!
19
19
  * MIT License
20
20
  *
21
21
  * Copyright (c) 2017-2022 Peculiar Ventures, LLC
@@ -76,7 +76,7 @@ and limitations under the License.
76
76
  `).map(r=>` ${r}`).join(`
77
77
  `));const t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
78
78
  ${e.join(`
79
- `)}`:`${t} :`}}Zd=Ue;D.Constructed=Zd;Ue.NAME="CONSTRUCTED";class Yd extends Te{fromBER(e,t,i){return t}toBER(e){return ct}}Yd.override="EndOfContentValueBlock";var Xd;class Xa extends $e{constructor(e={}){super(e,Yd),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Xd=Xa;D.EndOfContent=Xd;Xa.NAME=pi;var Qd;class on extends $e{constructor(e={}){super(e,Te),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,i){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+=i,t+i>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+i}toBER(e,t){const i=new ArrayBuffer(2);if(!e){const r=new Uint8Array(i);r[0]=5,r[1]=0}return t&&t.write(i),i}onAsciiEncoding(){return`${this.constructor.NAME}`}}Qd=on;D.Null=Qd;on.NAME="NULL";class ep extends mt(Te){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=U.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,i){const r=U.toUint8Array(e);return $t(this,r,t,i)?(this.valueHexView=r.subarray(t,t+i),i>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Hd.call(this),this.blockLength=i,t+i):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}ep.NAME="BooleanValueBlock";var tp;class as extends $e{constructor(e={}){super(e,ep),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}}tp=as;D.Boolean=tp;as.NAME="BOOLEAN";class np extends mt(Tt){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,i){let r=0;if(this.isConstructed){if(this.isHexOnly=!1,r=Tt.prototype.fromBER.call(this,e,t,i),r===-1)return r;for(let s=0;s<this.value.length;s++){const o=this.value[s].constructor.NAME;if(o===pi){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(o!==Dd)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,r=super.fromBER(e,t,i),this.blockLength=i;return r}toBER(e,t){return this.isConstructed?Tt.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}np.NAME="OctetStringValueBlock";var ip;let Qt=class rp extends $e{constructor({idBlock:e={},lenBlock:t={},...i}={}){var r,s;(r=i.isConstructed)!==null&&r!==void 0||(i.isConstructed=!!(!((s=i.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:i.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!i.isIndefiniteForm},...i},np),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,i){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,i===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+i);try{if(s.byteLength){const o=Hn(s,0,s.byteLength);o.offset!==-1&&o.offset===i&&(this.valueBlock.value=[o.result])}}catch{}}return super.fromBER(e,t,i)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Ue.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${W.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const t of this.valueBlock.value)t instanceof rp&&e.push(t.valueBlock.valueHexView);return U.concat(e)}};ip=Qt;D.OctetString=ip;Qt.NAME=Dd;class sp extends mt(Tt){constructor({unusedBits:e=0,isConstructed:t=!1,...i}={}){super(i),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,i){if(!i)return t;let r=-1;if(this.isConstructed){if(r=Tt.prototype.fromBER.call(this,e,t,i),r===-1)return r;for(const c of this.value){const l=c.constructor.NAME;if(l===pi){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(l!==Fd)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const u=c.valueBlock;if(this.unusedBits>0&&u.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=u.unusedBits}return r}const s=U.toUint8Array(e);if(!$t(this,s,t,i))return-1;const o=s.subarray(t,t+i);if(this.unusedBits=o[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const c=o.subarray(1);try{if(c.byteLength){const l=Hn(c,0,c.byteLength);l.offset!==-1&&l.offset===i-1&&(this.value=[l.result])}}catch{}}return this.valueHexView=o.subarray(1),this.blockLength=o.length,t+i}toBER(e,t){if(this.isConstructed)return Tt.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return ct;const i=new Uint8Array(this.valueHexView.length+1);return i[0]=this.unusedBits,i.set(this.valueHexView,1),i.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}sp.NAME="BitStringValueBlock";var op;let en=class extends $e{constructor({idBlock:e={},lenBlock:t={},...i}={}){var r,s;(r=i.isConstructed)!==null&&r!==void 0||(i.isConstructed=!!(!((s=i.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:i.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!i.isIndefiniteForm},...i},sp),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,i){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,i)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Ue.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const r of t)e.push(r.toString(2).padStart(8,"0"));const i=e.join("");return`${this.constructor.NAME} : ${i.substring(0,i.length-this.valueBlock.unusedBits)}`}}};op=en;D.BitString=op;en.NAME=Fd;var ap;function Tg(n,e){const t=new Uint8Array([0]),i=new Uint8Array(n),r=new Uint8Array(e);let s=i.slice(0);const o=s.length-1,c=r.slice(0),l=c.length-1;let u=0;const p=l<o?o:l;let g=0;for(let m=p;m>=0;m--,g++){switch(!0){case g<c.length:u=s[o-g]+c[l-g]+t[0];break;default:u=s[o-g]+t[0]}switch(t[0]=u/10,!0){case g>=s.length:s=bo(new Uint8Array([u%10]),s);break;default:s[o-g]=u%10}}return t[0]>0&&(s=bo(t,s)),s}function xl(n){if(n>=ei.length)for(let e=ei.length;e<=n;e++){const t=new Uint8Array([0]);let i=ei[e-1].slice(0);for(let r=i.length-1;r>=0;r--){const s=new Uint8Array([(i[r]<<1)+t[0]]);t[0]=s[0]/10,i[r]=s[0]%10}t[0]>0&&(i=bo(t,i)),ei.push(i)}return ei[n]}function Rg(n,e){let t=0;const i=new Uint8Array(n),r=new Uint8Array(e),s=i.slice(0),o=s.length-1,c=r.slice(0),l=c.length-1;let u,p=0;for(let g=l;g>=0;g--,p++)switch(u=s[o-p]-c[l-p]-t,!0){case u<0:t=1,s[o-p]=u+10;break;default:t=0,s[o-p]=u}if(t>0)for(let g=o-l+1;g>=0;g--,p++)if(u=s[o-p]-t,u<0)t=1,s[o-p]=u+10;else{t=0,s[o-p]=u;break}return s.slice()}class Qa extends mt(Te){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){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=Hd.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(xg(e))}get valueDec(){return this._valueDec}fromDER(e,t,i,r=0){const s=this.fromBER(e,t,i);if(s===-1)return s;const o=this.valueHexView;return o[0]===0&&o[1]&128?this.valueHexView=o.subarray(1):r!==0&&o.length<r&&(r-o.length>1&&(r=o.length+1),this.valueHexView=o.subarray(r-o.length)),s}toDER(e=!1){const t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{const i=new Uint8Array(this.valueHexView.length+1);i[0]=0,i.set(t,1),this.valueHexView=i}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,i){const r=super.fromBER(e,t,i);return r===-1||this.setValueHex(),r}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=this.valueHexView.length*8-1;let t=new Uint8Array(this.valueHexView.length*8/3),i=0,r;const s=this.valueHexView;let o="",c=!1;for(let l=s.byteLength-1;l>=0;l--){r=s[l];for(let u=0;u<8;u++){if((r&1)===1)switch(i){case e:t=Rg(xl(i),t),o="-";break;default:t=Tg(t,xl(i))}i++,r>>=1}}for(let l=0;l<t.length;l++)t[l]&&(c=!0),c&&(o+=bl.charAt(t[l]));return c===!1&&(o+=bl.charAt(0)),o}}ap=Qa;Qa.NAME="IntegerValueBlock";Object.defineProperty(ap.prototype,"valueHex",{set:function(n){this.valueHexView=new Uint8Array(n),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var cp;class gt extends $e{constructor(e={}){super(e,Qa),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return yr(),BigInt(this.valueBlock.toString())}static fromBigInt(e){yr();const t=BigInt(e),i=new ss,r=t.toString(16).replace(/^-/,""),s=new Uint8Array(W.FromHex(r));if(t<0){const c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;const u=BigInt(`0x${W.ToHex(c)}`)+t,p=U.toUint8Array(W.FromHex(u.toString(16)));p[0]|=128,i.write(p)}else s[0]&128&&i.write(new Uint8Array([0])),i.write(s);return new gt({valueHex:i.final()})}convertToDER(){const e=new gt({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new gt({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}cp=gt;D.Integer=cp;gt.NAME="INTEGER";var lp;class cs extends gt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}lp=cs;D.Enumerated=lp;cs.NAME="ENUMERATED";class ko extends mt(Te){constructor({valueDec:e=-1,isFirstSid:t=!1,...i}={}){super(i),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,i){if(!i)return t;const r=U.toUint8Array(e);if(!$t(this,r,t,i))return-1;const s=r.subarray(t,t+i);this.valueHexView=new Uint8Array(i);for(let c=0;c<i&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,s[this.blockLength-1]&128?(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=Cn(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){yr();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const i=new Uint8Array(t.length/7);for(let r=0;r<i.length;r++)i[r]=parseInt(t.slice(r*7,r*7+7),2)+(r+1<i.length?128:0);this.fromBER(i.buffer,0,i.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const r=this.valueHexView,s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength-1;o++)s[o]=r[o]|128;return s[this.blockLength-1]=r[this.blockLength-1],s.buffer}const t=sn(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",ct;const i=new Uint8Array(t.byteLength);if(!e){const r=new Uint8Array(t),s=t.byteLength-1;for(let o=0;o<s;o++)i[o]=r[o]|128;i[s]=r[s]}return i}toString(){let e="";if(this.isHexOnly)e=W.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}ko.NAME="sidBlock";class up extends Te{constructor({value:e=Le,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,i){let r=t;for(;i>0;){const s=new ko;if(r=s.fromBER(e,r,i),r===-1)return this.blockLength=0,this.error=s.error,r;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,i-=s.blockLength,this.value.push(s)}return r}toBER(e){const t=[];for(let i=0;i<this.value.length;i++){const r=this.value[i].toBER(e);if(r.byteLength===0)return this.error=this.value[i].error,ct;t.push(r)}return Za(t)}fromString(e){this.value=[];let t=0,i=0,r="",s=!1;do if(i=e.indexOf(".",t),i===-1?r=e.substring(t):r=e.substring(t,i),t=i+1,s){const o=this.value[0];let c=0;switch(o.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}const l=parseInt(r,10);if(isNaN(l))return;o.valueDec=l+c,s=!1}else{const o=new ko;if(r>Number.MAX_SAFE_INTEGER){yr();const c=BigInt(r);o.valueBigInt=c}else if(o.valueDec=parseInt(r,10),isNaN(o.valueDec))return;this.value.length||(o.isFirstSid=!0,s=!0),this.value.push(o)}while(i!==-1)}toString(){let e="",t=!1;for(let i=0;i<this.value.length;i++){t=this.value[i].isHexOnly;let r=this.value[i].toString();i!==0&&(e=`${e}.`),t?(r=`{${r}}`,this.value[i].isFirstSid?e=`2.{${r} - 80}`:e+=r):e+=r}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}up.NAME="ObjectIdentifierValueBlock";var dp;class ls extends $e{constructor(e={}){super(e,up),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}dp=ls;D.ObjectIdentifier=dp;ls.NAME="OBJECT IDENTIFIER";class xo extends mt(mn){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,i){if(i===0)return t;const r=U.toUint8Array(e);if(!$t(this,r,t,i))return-1;const s=r.subarray(t,t+i);this.valueHexView=new Uint8Array(i);for(let c=0;c<i&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,s[this.blockLength-1]&128?(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=Cn(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const r=this.valueHexView,s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength-1;o++)s[o]=r[o]|128;return s[this.blockLength-1]=r[this.blockLength-1],s.buffer}const t=sn(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",ct;const i=new Uint8Array(t.byteLength);if(!e){const r=new Uint8Array(t),s=t.byteLength-1;for(let o=0;o<s;o++)i[o]=r[o]|128;i[s]=r[s]}return i.buffer}toString(){let e="";return this.isHexOnly?e=W.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}xo.NAME="relativeSidBlock";class pp extends Te{constructor({value:e=Le,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,i){let r=t;for(;i>0;){const s=new xo;if(r=s.fromBER(e,r,i),r===-1)return this.blockLength=0,this.error=s.error,r;this.blockLength+=s.blockLength,i-=s.blockLength,this.value.push(s)}return r}toBER(e,t){const i=[];for(let r=0;r<this.value.length;r++){const s=this.value[r].toBER(e);if(s.byteLength===0)return this.error=this.value[r].error,ct;i.push(s)}return Za(i)}fromString(e){this.value=[];let t=0,i=0,r="";do{i=e.indexOf(".",t),i===-1?r=e.substring(t):r=e.substring(t,i),t=i+1;const s=new xo;if(s.valueDec=parseInt(r,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(i!==-1);return!0}toString(){let e="",t=!1;for(let i=0;i<this.value.length;i++){t=this.value[i].isHexOnly;let r=this.value[i].toString();i!==0&&(e=`${e}.`),t&&(r=`{${r}}`),e+=r}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}pp.NAME="RelativeObjectIdentifierValueBlock";var fp;class ec extends $e{constructor(e={}){super(e,pp),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}fp=ec;D.RelativeObjectIdentifier=fp;ec.NAME="RelativeObjectIdentifier";var hp;class bt extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}hp=bt;D.Sequence=hp;bt.NAME="SEQUENCE";var gp;let kt=class extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};gp=kt;D.Set=gp;kt.NAME="SET";class _p extends mt(Te){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Le}toJSON(){return{...super.toJSON(),value:this.value}}}_p.NAME="StringValueBlock";class mp extends _p{}mp.NAME="SimpleStringValueBlock";class We extends Ya{constructor({...e}={}){super(e,mp)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,U.toUint8Array(e))}fromString(e){const t=e.length,i=this.valueBlock.valueHexView=new Uint8Array(t);for(let r=0;r<t;r++)i[r]=e.charCodeAt(r);this.valueBlock.value=e}}We.NAME="SIMPLE STRING";class yp extends We{fromBuffer(e){this.valueBlock.valueHexView=U.toUint8Array(e);try{this.valueBlock.value=W.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=W.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(W.FromUtf8String(e)),this.valueBlock.value=e}}yp.NAME="Utf8StringValueBlock";var vp;class Ct extends yp{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}vp=Ct;D.Utf8String=vp;Ct.NAME="UTF8String";class wp extends We{fromBuffer(e){this.valueBlock.value=W.ToUtf16String(e),this.valueBlock.valueHexView=U.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(W.FromUtf16String(e))}}wp.NAME="BmpStringValueBlock";var bp;class us extends wp{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}bp=us;D.BmpString=bp;us.NAME="BMPString";class kp extends We{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),i=new Uint8Array(t);for(let r=0;r<i.length;r+=4)i[r]=i[r+3],i[r+1]=i[r+2],i[r+2]=0,i[r+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,i=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let r=0;r<t;r++){const s=sn(e.charCodeAt(r),8),o=new Uint8Array(s);if(o.length>4)continue;const c=4-o.length;for(let l=o.length-1;l>=0;l--)i[r*4+l+c]=o[l]}this.valueBlock.value=e}}kp.NAME="UniversalStringValueBlock";var xp;class ds extends kp{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}xp=ds;D.UniversalString=xp;ds.NAME="UniversalString";var Sp;class ps extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Sp=ps;D.NumericString=Sp;ps.NAME="NumericString";var Ap;class fs extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Ap=fs;D.PrintableString=Ap;fs.NAME="PrintableString";var Ip;class hs extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Ip=hs;D.TeletexString=Ip;hs.NAME="TeletexString";var Ep;class gs extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Ep=gs;D.VideotexString=Ep;gs.NAME="VideotexString";var $p;class _s extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}$p=_s;D.IA5String=$p;_s.NAME="IA5String";var Cp;class ms extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Cp=ms;D.GraphicString=Cp;ms.NAME="GraphicString";var jp;class Ei extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}jp=Ei;D.VisibleString=jp;Ei.NAME="VisibleString";var zp;class ys extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}zp=ys;D.GeneralString=zp;ys.NAME="GeneralString";var Np;class vs extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Np=vs;D.CharacterString=Np;vs.NAME="CharacterString";var Op;class $i extends Ei{constructor({value:e,valueDate:t,...i}={}){if(super(i),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let r=0;r<e.length;r++)this.valueBlock.valueHexView[r]=e.charCodeAt(r)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,U.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let r=0;r<e.length;r++)i[r]=e.charCodeAt(r);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const i=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(i===null){this.error="Wrong input string for conversion";return}const r=parseInt(i[1],10);r>=50?this.year=1900+r:this.year=2e3+r,this.month=parseInt(i[2],10),this.day=parseInt(i[3],10),this.hour=parseInt(i[4],10),this.minute=parseInt(i[5],10),this.second=parseInt(i[6],10)}toString(e="iso"){if(e==="iso"){const t=new Array(7);return t[0]=Fe(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Fe(this.month,2),t[2]=Fe(this.day,2),t[3]=Fe(this.hour,2),t[4]=Fe(this.minute,2),t[5]=Fe(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}Op=$i;D.UTCTime=Op;$i.NAME="UTCTime";var Bp;class ws extends $i{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,i="",r="",s=0,o,c=0,l=0;if(e[e.length-1]==="Z")i=e.substring(0,e.length-1),t=!0;else{const g=new Number(e[e.length-1]);if(isNaN(g.valueOf()))throw new Error("Wrong input string for conversion");i=e}if(t){if(i.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(i.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let g=1,m=i.indexOf("+"),x="";if(m===-1&&(m=i.indexOf("-"),g=-1),m!==-1){if(x=i.substring(m+1),i=i.substring(0,m),x.length!==2&&x.length!==4)throw new Error("Wrong input string for conversion");let h=parseInt(x.substring(0,2),10);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");if(c=g*h,x.length===4){if(h=parseInt(x.substring(2,4),10),isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");l=g*h}}}let u=i.indexOf(".");if(u===-1&&(u=i.indexOf(",")),u!==-1){const g=new Number(`0${i.substring(u)}`);if(isNaN(g.valueOf()))throw new Error("Wrong input string for conversion");s=g.valueOf(),r=i.substring(0,u)}else r=i;switch(!0){case r.length===8:if(o=/(\d{4})(\d{2})(\d{2})/ig,u!==-1)throw new Error("Wrong input string for conversion");break;case r.length===10:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let g=60*s;this.minute=Math.floor(g),g=60*(g-this.minute),this.second=Math.floor(g),g=1e3*(g-this.second),this.millisecond=Math.floor(g)}break;case r.length===12:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let g=60*s;this.second=Math.floor(g),g=1e3*(g-this.second),this.millisecond=Math.floor(g)}break;case r.length===14:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){const g=1e3*s;this.millisecond=Math.floor(g)}break;default:throw new Error("Wrong input string for conversion")}const p=o.exec(r);if(p===null)throw new Error("Wrong input string for conversion");for(let g=1;g<p.length;g++)switch(g){case 1:this.year=parseInt(p[g],10);break;case 2:this.month=parseInt(p[g],10);break;case 3:this.day=parseInt(p[g],10);break;case 4:this.hour=parseInt(p[g],10)+c;break;case 5:this.minute=parseInt(p[g],10)+l;break;case 6:this.second=parseInt(p[g],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){const g=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=g.getUTCFullYear(),this.month=g.getUTCMonth(),this.day=g.getUTCDay(),this.hour=g.getUTCHours(),this.minute=g.getUTCMinutes(),this.second=g.getUTCSeconds(),this.millisecond=g.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const t=[];return t.push(Fe(this.year,4)),t.push(Fe(this.month,2)),t.push(Fe(this.day,2)),t.push(Fe(this.hour,2)),t.push(Fe(this.minute,2)),t.push(Fe(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Fe(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Bp=ws;D.GeneralizedTime=Bp;ws.NAME="GeneralizedTime";var Tp;class tc extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Tp=tc;D.DATE=Tp;tc.NAME="DATE";var Rp;class nc extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Rp=nc;D.TimeOfDay=Rp;nc.NAME="TimeOfDay";var Pp;class ic extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Pp=ic;D.DateTime=Pp;ic.NAME="DateTime";var Lp;class rc extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Lp=rc;D.Duration=Lp;rc.NAME="Duration";var Up;class sc extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Up=sc;D.TIME=Up;sc.NAME="TIME";class an{constructor({name:e=Le,optional:t=!1}={}){this.name=e,this.optional=t}}class oc extends an{constructor({value:e=[],...t}={}){super(t),this.value=e}}class vr extends an{constructor({value:e=new an,local:t=!1,...i}={}){super(i),this.value=e,this.local=t}}class Pg{constructor({data:e=os}={}){this.dataView=U.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=U.toUint8Array(e)}fromBER(e,t,i){const r=t+i;return this.dataView=U.toUint8Array(e).subarray(t,r),r}toBER(e){return this.dataView.slice().buffer}}function Zt(n,e,t){if(t instanceof oc){for(let s=0;s<t.value.length;s++)if(Zt(n,e,t.value[s]).verified)return{verified:!0,result:n};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(io)&&(s.name=t.name),s}}if(t instanceof an)return t.hasOwnProperty(io)&&(n[t.name]=e),{verified:!0,result:n};if(!(n instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Ig in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(jg in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(zg in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const i=t.idBlock.toBER(!1);if(i.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(t.idBlock.fromBER(i,0,i.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(t.idBlock.hasOwnProperty(Eg)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:n};if(t.idBlock.hasOwnProperty($g)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:n};if(t.idBlock.hasOwnProperty(Cg)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:n};if(!(Ag in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:n};if(t.idBlock.isHexOnly){if(!(kl in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=t.idBlock.valueHexView,o=e.idBlock.valueHexView;if(s.length!==o.length)return{verified:!1,result:n};for(let c=0;c<s.length;c++)if(s[c]!==o[1])return{verified:!1,result:n}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Le),t.name&&(n[t.name]=e)),t instanceof D.Constructed){let s=0,o={verified:!1,result:{error:"Unknown error"}},c=t.valueBlock.value.length;if(c>0&&t.valueBlock.value[0]instanceof vr&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:n};if(e.valueBlock.value.length===0&&t.valueBlock.value.length!==0){let l=!0;for(let u=0;u<t.valueBlock.value.length;u++)l=l&&(t.valueBlock.value[u].optional||!1);return l?{verified:!0,result:n}:(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Le),t.name&&delete n[t.name]),n.error="Inconsistent object length",{verified:!1,result:n})}for(let l=0;l<c;l++)if(l-s>=e.valueBlock.value.length){if(t.valueBlock.value[l].optional===!1){const u={verified:!1,result:n};return n.error="Inconsistent length between ASN.1 data and schema",t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Le),t.name&&(delete n[t.name],u.name=t.name)),u}}else if(t.valueBlock.value[0]instanceof vr){if(o=Zt(n,e.valueBlock.value[l],t.valueBlock.value[0].value),o.verified===!1)if(t.valueBlock.value[0].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Le),t.name&&delete n[t.name]),o;if(io in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let u={};Ng in t.valueBlock.value[0]&&t.valueBlock.value[0].local?u=e:u=n,typeof u[t.valueBlock.value[0].name]>"u"&&(u[t.valueBlock.value[0].name]=[]),u[t.valueBlock.value[0].name].push(e.valueBlock.value[l])}}else if(o=Zt(n,e.valueBlock.value[l-s],t.valueBlock.value[l]),o.verified===!1)if(t.valueBlock.value[l].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Le),t.name&&delete n[t.name]),o;if(o.verified===!1){const l={verified:!1,result:n};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Le),t.name&&(delete n[t.name],l.name=t.name)),l}return{verified:!0,result:n}}if(t.primitiveSchema&&kl in e.valueBlock){const s=Hn(e.valueBlock.valueHexView);if(s.offset===-1){const o={verified:!1,result:s.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Le),t.name&&(delete n[t.name],o.name=t.name)),o}return Zt(n,s.result,t.primitiveSchema)}return{verified:!0,result:n}}function Lg(n,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=Hn(U.toUint8Array(n));return t.offset===-1?{verified:!1,result:t.result}:Zt(t.result,t.result,e)}const Vp=Object.freeze(Object.defineProperty({__proto__:null,Any:an,BaseBlock:$e,BaseStringBlock:Ya,BitString:en,BmpString:us,Boolean:as,CharacterString:vs,Choice:oc,Constructed:Ue,DATE:tc,DateTime:ic,Duration:rc,EndOfContent:Xa,Enumerated:cs,GeneralString:ys,GeneralizedTime:ws,GraphicString:ms,HexBlock:mt,IA5String:_s,Integer:gt,Null:on,NumericString:ps,ObjectIdentifier:ls,OctetString:Qt,Primitive:Ii,PrintableString:fs,RawData:Pg,RelativeObjectIdentifier:ec,Repeated:vr,Sequence:bt,Set:kt,TIME:sc,TeletexString:hs,TimeOfDay:nc,UTCTime:$i,UniversalString:ds,Utf8String:Ct,ValueBlock:Te,VideotexString:gs,ViewWriter:ss,VisibleString:Ei,compareSchema:Zt,fromBER:In,verifySchema:Lg},Symbol.toStringTag,{value:"Module"}));var z;(function(n){n[n.Sequence=0]="Sequence",n[n.Set=1]="Set",n[n.Choice=2]="Choice"})(z||(z={}));var y;(function(n){n[n.Any=1]="Any",n[n.Boolean=2]="Boolean",n[n.OctetString=3]="OctetString",n[n.BitString=4]="BitString",n[n.Integer=5]="Integer",n[n.Enumerated=6]="Enumerated",n[n.ObjectIdentifier=7]="ObjectIdentifier",n[n.Utf8String=8]="Utf8String",n[n.BmpString=9]="BmpString",n[n.UniversalString=10]="UniversalString",n[n.NumericString=11]="NumericString",n[n.PrintableString=12]="PrintableString",n[n.TeletexString=13]="TeletexString",n[n.VideotexString=14]="VideotexString",n[n.IA5String=15]="IA5String",n[n.GraphicString=16]="GraphicString",n[n.VisibleString=17]="VisibleString",n[n.GeneralString=18]="GeneralString",n[n.CharacterString=19]="CharacterString",n[n.UTCTime=20]="UTCTime",n[n.GeneralizedTime=21]="GeneralizedTime",n[n.DATE=22]="DATE",n[n.TimeOfDay=23]="TimeOfDay",n[n.DateTime=24]="DateTime",n[n.Duration=25]="Duration",n[n.TIME=26]="TIME",n[n.Null=27]="Null"})(y||(y={}));class bs{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(U.isBufferSource(e))this.unusedBits=t,this.value=U.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof en))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new en({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new en({name:e})}toNumber(){let e="";const t=new Uint8Array(this.value);for(const i of t)e+=i.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let t=e.toString(2);const i=t.length+7>>3;this.unusedBits=(i<<3)-t.length;const r=new Uint8Array(i);t=t.padStart(i<<3,"0").split("").reverse().join("");let s=0;for(;s<i;)r[s]=parseInt(t.slice(s<<3,(s<<3)+8),2),s++;this.value=r.buffer}}class re{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):U.isBufferSource(e)?this.buffer=U.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof Qt))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new Qt({valueHex:this.buffer})}toSchema(e){return new Qt({name:e})}}const Ug={fromASN:n=>n instanceof on?null:n.valueBeforeDecodeView,toASN:n=>{if(n===null)return new on;const e=In(n);if(e.result.error)throw new Error(e.result.error);return e.result}},Vg={fromASN:n=>n.valueBlock.valueHexView.byteLength>=4?n.valueBlock.toString():n.valueBlock.valueDec,toASN:n=>new gt({value:+n})},Mg={fromASN:n=>n.valueBlock.valueDec,toASN:n=>new cs({value:n})},he={fromASN:n=>n.valueBlock.valueHexView,toASN:n=>new gt({valueHex:n})},Hg={fromASN:n=>n.valueBlock.valueHexView,toASN:n=>new en({valueHex:n})},Dg={fromASN:n=>n.valueBlock.toString(),toASN:n=>new ls({value:n})},Fg={fromASN:n=>n.valueBlock.value,toASN:n=>new as({value:n})},wr={fromASN:n=>n.valueBlock.valueHexView,toASN:n=>new Qt({valueHex:n})},qg={fromASN:n=>new re(n.getValue()),toASN:n=>n.toASN()};function Qe(n){return{fromASN:e=>e.valueBlock.value,toASN:e=>new n({value:e})}}const Mp=Qe(Ct),Kg=Qe(us),Wg=Qe(ds),Gg=Qe(ps),Jg=Qe(fs),Zg=Qe(hs),Yg=Qe(gs),Xg=Qe(_s),Qg=Qe(ms),e_=Qe(Ei),t_=Qe(ys),n_=Qe(vs),i_={fromASN:n=>n.toDate(),toASN:n=>new $i({valueDate:n})},r_={fromASN:n=>n.toDate(),toASN:n=>new ws({valueDate:n})},s_={fromASN:()=>null,toASN:()=>new on};function ac(n){switch(n){case y.Any:return Ug;case y.BitString:return Hg;case y.BmpString:return Kg;case y.Boolean:return Fg;case y.CharacterString:return n_;case y.Enumerated:return Mg;case y.GeneralString:return t_;case y.GeneralizedTime:return r_;case y.GraphicString:return Qg;case y.IA5String:return Xg;case y.Integer:return Vg;case y.Null:return s_;case y.NumericString:return Gg;case y.ObjectIdentifier:return Dg;case y.OctetString:return wr;case y.PrintableString:return Jg;case y.TeletexString:return Zg;case y.UTCTime:return i_;case y.UniversalString:return Wg;case y.Utf8String:return Mp;case y.VideotexString:return Yg;case y.VisibleString:return e_;default:return null}}function wt(n){return typeof n=="function"&&n.prototype?n.prototype.toASN&&n.prototype.fromASN?!0:wt(n.prototype):!!(n&&typeof n=="object"&&"toASN"in n&&"fromASN"in n)}function Hp(n){var e;if(n){const t=Object.getPrototypeOf(n);return((e=t==null?void 0:t.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:Hp(t)}return!1}function o_(n,e){if(!(n&&e)||n.byteLength!==e.byteLength)return!1;const t=new Uint8Array(n),i=new Uint8Array(e);for(let r=0;r<n.byteLength;r++)if(t[r]!==i[r])return!1;return!0}class a_{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){const i=this.items.get(e);if(!i)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!i.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return i}cache(e){const t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){const t={type:z.Sequence,items:{}},i=this.findParentSchema(e);return i&&(Object.assign(t,i),t.items=Object.assign({},t.items,i.items)),t}create(e,t){const i=this.items.get(e)||this.createDefault(e),r=[];for(const s in i.items){const o=i.items[s],c=t?s:"";let l;if(typeof o.type=="number"){const p=y[o.type],g=Vp[p];if(!g)throw new Error(`Cannot get ASN1 class by name '${p}'`);l=new g({name:c})}else wt(o.type)?l=new o.type().toSchema(c):o.optional?this.get(o.type).type===z.Choice?l=new an({name:c}):(l=this.create(o.type,!1),l.name=c):l=new an({name:c});const u=!!o.optional||o.defaultValue!==void 0;if(o.repeated){l.name="";const p=o.repeated==="set"?kt:bt;l=new p({name:"",value:[new vr({name:c,value:l})]})}if(o.context!==null&&o.context!==void 0)if(o.implicit)if(typeof o.type=="number"||wt(o.type)){const p=o.repeated?Ue:Ii;r.push(new p({name:c,optional:u,idBlock:{tagClass:3,tagNumber:o.context}}))}else{this.cache(o.type);const p=!!o.repeated;let g=p?l:this.get(o.type,!0).schema;g="valueBlock"in g?g.valueBlock.value:g.value,r.push(new Ue({name:p?"":c,optional:u,idBlock:{tagClass:3,tagNumber:o.context},value:g}))}else r.push(new Ue({optional:u,idBlock:{tagClass:3,tagNumber:o.context},value:[l]}));else l.optional=u,r.push(l)}switch(i.type){case z.Sequence:return new bt({value:r,name:""});case z.Set:return new kt({value:r,name:""});case z.Choice:return new oc({value:r,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}}const Je=new a_,B=n=>e=>{let t;Je.has(e)?t=Je.get(e):(t=Je.createDefault(e),Je.set(e,t)),Object.assign(t,n)},f=n=>(e,t)=>{let i;Je.has(e.constructor)?i=Je.get(e.constructor):(i=Je.createDefault(e.constructor),Je.set(e.constructor,i));const r=Object.assign({},n);if(typeof r.type=="number"&&!r.converter){const s=ac(n.type);if(!s)throw new Error(`Cannot get default converter for property '${t}' of ${e.constructor.name}`);r.converter=s}i.items[t]=r};class Sl extends Error{constructor(){super(...arguments),this.schemas=[]}}class c_{static parse(e,t){const i=In(e);if(i.result.error)throw new Error(i.result.error);return this.fromASN(i.result,t)}static fromASN(e,t){var i;try{if(wt(t))return new t().fromASN(e);const r=Je.get(t);Je.cache(t);let s=r.schema;if(e.constructor===Ue&&r.type!==z.Choice){s=new Ue({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:r.schema.valueBlock.value});for(const l in r.items)delete e[l]}const o=Zt({},e,s);if(!o.verified)throw new Sl(`Data does not match to ${t.name} ASN1 schema. ${o.result.error}`);const c=new t;if(Hp(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.");const l=r.itemType;if(typeof l=="number"){const u=ac(l);if(!u)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);return t.from(e.valueBlock.value,p=>u.fromASN(p))}else return t.from(e.valueBlock.value,u=>this.fromASN(u,l))}for(const l in r.items){const u=o.result[l];if(!u)continue;const p=r.items[l],g=p.type;if(typeof g=="number"||wt(g)){const m=(i=p.converter)!==null&&i!==void 0?i:wt(g)?new g:null;if(!m)throw new Error("Converter is empty");if(p.repeated)if(p.implicit){const x=p.repeated==="sequence"?bt:kt,h=new x;h.valueBlock=u.valueBlock;const _=In(h.toBER(!1));if(_.offset===-1)throw new Error(`Cannot parse the child item. ${_.result.error}`);if(!("value"in _.result.valueBlock&&Array.isArray(_.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const b=_.result.valueBlock.value;c[l]=Array.from(b,S=>m.fromASN(S))}else c[l]=Array.from(u,x=>m.fromASN(x));else{let x=u;if(p.implicit){let h;if(wt(g))h=new g().toSchema("");else{const _=y[g],b=Vp[_];if(!b)throw new Error(`Cannot get '${_}' class from asn1js module`);h=new b}h.valueBlock=x.valueBlock,x=In(h.toBER(!1)).result}c[l]=m.fromASN(x)}}else if(p.repeated){if(!Array.isArray(u))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");c[l]=Array.from(u,m=>this.fromASN(m,g))}else c[l]=this.fromASN(u,g)}return c}catch(r){throw r instanceof Sl&&r.schemas.push(t.name),r}}}class cc{static serialize(e){return e instanceof $e?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&wt(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,i=Je.get(t);Je.cache(t);let r=[];if(i.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof i.itemType=="number"){const o=ac(i.itemType);if(!o)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);r=e.map(c=>o.toASN(c))}else r=e.map(o=>this.toAsnItem({type:i.itemType},"[]",t,o))}else for(const o in i.items){const c=i.items[o],l=e[o];if(l===void 0||c.defaultValue===l||typeof c.defaultValue=="object"&&typeof l=="object"&&o_(this.serialize(c.defaultValue),this.serialize(l)))continue;const u=cc.toAsnItem(c,o,t,l);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||wt(c.type))){const p={};p.valueHex=u instanceof on?u.valueBeforeDecodeView:u.valueBlock.toBER(),r.push(new Ii({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...p}))}else r.push(new Ue({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:u.valueBlock.value}));else r.push(new Ue({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[u]}));else c.repeated?r=r.concat(u):r.push(u)}let s;switch(i.type){case z.Sequence:s=new bt({value:r});break;case z.Set:s=new kt({value:r});break;case z.Choice:if(!r[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);s=r[0];break}return s}static toAsnItem(e,t,i,r){let s;if(typeof e.type=="number"){const o=e.converter;if(!o)throw new Error(`Property '${t}' doesn't have converter for type ${y[e.type]} in schema '${i.name}'`);if(e.repeated){if(!Array.isArray(r))throw new TypeError("Parameter 'objProp' should be type of Array.");const c=Array.from(r,u=>o.toASN(u)),l=e.repeated==="sequence"?bt:kt;s=new l({value:c})}else s=o.toASN(r)}else if(e.repeated){if(!Array.isArray(r))throw new TypeError("Parameter 'objProp' should be type of Array.");const o=Array.from(r,l=>this.toASN(l)),c=e.repeated==="sequence"?bt:kt;s=new c({value:o})}else s=this.toASN(r);return s}}class le extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class L{static serialize(e){return cc.serialize(e)}static parse(e,t){return c_.parse(e,t)}static toString(e){const t=U.isBufferSource(e)?U.toArrayBuffer(e):L.serialize(e),i=In(t);if(i.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${i.result.error}`);return i.result.toString()}}function d(n,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,i);else for(var c=n.length-1;c>=0;c--)(o=n[c])&&(s=(r<3?o(s):r>3?o(e,t,s):o(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s}var Dp={exports:{}};(function(n){(function(e){const t="(0?\\d+|0x[a-f0-9]+)",i={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},r=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),o="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",l={zoneIndex:new RegExp(o,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${o})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${t}\\.${t}\\.${t}\\.${t}(${o})?$`,"i")};function u(h,_){if(h.indexOf("::")!==h.lastIndexOf("::"))return null;let b=0,S=-1,N=(h.match(l.zoneIndex)||[])[0],T,K;for(N&&(N=N.substring(1),h=h.replace(/%.+$/,""));(S=h.indexOf(":",S+1))>=0;)b++;if(h.substr(0,2)==="::"&&b--,h.substr(-2,2)==="::"&&b--,b>_)return null;for(K=_-b,T=":";K--;)T+="0:";return h=h.replace("::",T),h[0]===":"&&(h=h.slice(1)),h[h.length-1]===":"&&(h=h.slice(0,-1)),_=function(){const oe=h.split(":"),pe=[];for(let ce=0;ce<oe.length;ce++)pe.push(parseInt(oe[ce],16));return pe}(),{parts:_,zoneId:N}}function p(h,_,b,S){if(h.length!==_.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let N=0,T;for(;S>0;){if(T=b-S,T<0&&(T=0),h[N]>>T!==_[N]>>T)return!1;S-=b,N+=1}return!0}function g(h){if(s.test(h))return parseInt(h,16);if(h[0]==="0"&&!isNaN(parseInt(h[1],10))){if(r.test(h))return parseInt(h,8);throw new Error(`ipaddr: cannot parse ${h} as octal`)}return parseInt(h,10)}function m(h,_){for(;h.length<_;)h=`0${h}`;return h}const x={};x.IPv4=function(){function h(_){if(_.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let b,S;for(b=0;b<_.length;b++)if(S=_[b],!(0<=S&&S<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=_}return h.prototype.SpecialRanges={unspecified:[[new h([0,0,0,0]),8]],broadcast:[[new h([255,255,255,255]),32]],multicast:[[new h([224,0,0,0]),4]],linkLocal:[[new h([169,254,0,0]),16]],loopback:[[new h([127,0,0,0]),8]],carrierGradeNat:[[new h([100,64,0,0]),10]],private:[[new h([10,0,0,0]),8],[new h([172,16,0,0]),12],[new h([192,168,0,0]),16]],reserved:[[new h([192,0,0,0]),24],[new h([192,0,2,0]),24],[new h([192,88,99,0]),24],[new h([198,18,0,0]),15],[new h([198,51,100,0]),24],[new h([203,0,113,0]),24],[new h([240,0,0,0]),4]],as112:[[new h([192,175,48,0]),24],[new h([192,31,196,0]),24]],amt:[[new h([192,52,193,0]),24]]},h.prototype.kind=function(){return"ipv4"},h.prototype.match=function(_,b){let S;if(b===void 0&&(S=_,_=S[0],b=S[1]),_.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return p(this.octets,_.octets,8,b)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,b=!1;const S={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let N,T,K;for(N=3;N>=0;N-=1)if(T=this.octets[N],T in S){if(K=S[T],b&&K!==0)return null;K!==8&&(b=!0),_+=K}else return null;return 32-_},h.prototype.range=function(){return x.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){return this.octets.slice(0)},h.prototype.toIPv4MappedAddress=function(){return x.IPv6.parse(`::ffff:${this.toString()}`)},h.prototype.toNormalizedString=function(){return this.toString()},h.prototype.toString=function(){return this.octets.join(".")},h}(),x.IPv4.broadcastAddressFromCIDR=function(h){try{const _=this.parseCIDR(h),b=_[0].toByteArray(),S=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[];let T=0;for(;T<4;)N.push(parseInt(b[T],10)|parseInt(S[T],10)^255),T++;return new this(N)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},x.IPv4.isIPv4=function(h){return this.parser(h)!==null},x.IPv4.isValid=function(h){try{return new this(this.parser(h)),!0}catch{return!1}},x.IPv4.isValidCIDR=function(h){try{return this.parseCIDR(h),!0}catch{return!1}},x.IPv4.isValidFourPartDecimal=function(h){return!!(x.IPv4.isValid(h)&&h.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},x.IPv4.networkAddressFromCIDR=function(h){let _,b,S,N,T;try{for(_=this.parseCIDR(h),S=_[0].toByteArray(),T=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[],b=0;b<4;)N.push(parseInt(S[b],10)&parseInt(T[b],10)),b++;return new this(N)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},x.IPv4.parse=function(h){const _=this.parser(h);if(_===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(_)},x.IPv4.parseCIDR=function(h){let _;if(_=h.match(/^(.+)\/(\d+)$/)){const b=parseInt(_[2]);if(b>=0&&b<=32){const S=[this.parse(_[1]),b];return Object.defineProperty(S,"toString",{value:function(){return this.join("/")}}),S}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},x.IPv4.parser=function(h){let _,b,S;if(_=h.match(i.fourOctet))return function(){const N=_.slice(1,6),T=[];for(let K=0;K<N.length;K++)b=N[K],T.push(g(b));return T}();if(_=h.match(i.longValue)){if(S=g(_[1]),S>4294967295||S<0)throw new Error("ipaddr: address outside defined range");return function(){const N=[];let T;for(T=0;T<=24;T+=8)N.push(S>>T&255);return N}().reverse()}else return(_=h.match(i.twoOctet))?function(){const N=_.slice(1,4),T=[];if(S=g(N[1]),S>16777215||S<0)throw new Error("ipaddr: address outside defined range");return T.push(g(N[0])),T.push(S>>16&255),T.push(S>>8&255),T.push(S&255),T}():(_=h.match(i.threeOctet))?function(){const N=_.slice(1,5),T=[];if(S=g(N[2]),S>65535||S<0)throw new Error("ipaddr: address outside defined range");return T.push(g(N[0])),T.push(g(N[1])),T.push(S>>8&255),T.push(S&255),T}():null},x.IPv4.subnetMaskFromPrefixLength=function(h){if(h=parseInt(h),h<0||h>32)throw new Error("ipaddr: invalid IPv4 prefix length");const _=[0,0,0,0];let b=0;const S=Math.floor(h/8);for(;b<S;)_[b]=255,b++;return S<4&&(_[S]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},x.IPv6=function(){function h(_,b){let S,N;if(_.length===16)for(this.parts=[],S=0;S<=14;S+=2)this.parts.push(_[S]<<8|_[S+1]);else if(_.length===8)this.parts=_;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(S=0;S<this.parts.length;S++)if(N=this.parts[S],!(0<=N&&N<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");b&&(this.zoneId=b)}return h.prototype.SpecialRanges={unspecified:[new h([0,0,0,0,0,0,0,0]),128],linkLocal:[new h([65152,0,0,0,0,0,0,0]),10],multicast:[new h([65280,0,0,0,0,0,0,0]),8],loopback:[new h([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new h([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new h([0,0,0,0,0,65535,0,0]),96],discard:[new h([256,0,0,0,0,0,0,0]),64],rfc6145:[new h([0,0,0,0,65535,0,0,0]),96],rfc6052:[new h([100,65435,0,0,0,0,0,0]),96],"6to4":[new h([8194,0,0,0,0,0,0,0]),16],teredo:[new h([8193,0,0,0,0,0,0,0]),32],benchmarking:[new h([8193,2,0,0,0,0,0,0]),48],amt:[new h([8193,3,0,0,0,0,0,0]),32],as112v6:[[new h([8193,4,274,0,0,0,0,0]),48],[new h([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new h([8193,16,0,0,0,0,0,0]),28],orchid2:[new h([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new h([8193,48,0,0,0,0,0,0]),28],reserved:[[new h([8193,0,0,0,0,0,0,0]),23],[new h([8193,3512,0,0,0,0,0,0]),32]]},h.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},h.prototype.kind=function(){return"ipv6"},h.prototype.match=function(_,b){let S;if(b===void 0&&(S=_,_=S[0],b=S[1]),_.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return p(this.parts,_.parts,16,b)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,b=!1;const S={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let N,T;for(let K=7;K>=0;K-=1)if(N=this.parts[K],N in S){if(T=S[N],b&&T!==0)return null;T!==16&&(b=!0),_+=T}else return null;return 128-_},h.prototype.range=function(){return x.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){let _;const b=[],S=this.parts;for(let N=0;N<S.length;N++)_=S[N],b.push(_>>8),b.push(_&255);return b},h.prototype.toFixedLengthString=function(){const _=(function(){const S=[];for(let N=0;N<this.parts.length;N++)S.push(m(this.parts[N].toString(16),4));return S}).call(this).join(":");let b="";return this.zoneId&&(b=`%${this.zoneId}`),_+b},h.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const _=this.parts.slice(-2),b=_[0],S=_[1];return new x.IPv4([b>>8,b&255,S>>8,S&255])},h.prototype.toNormalizedString=function(){const _=(function(){const S=[];for(let N=0;N<this.parts.length;N++)S.push(this.parts[N].toString(16));return S}).call(this).join(":");let b="";return this.zoneId&&(b=`%${this.zoneId}`),_+b},h.prototype.toRFC5952String=function(){const _=/((^|:)(0(:|$)){2,})/g,b=this.toNormalizedString();let S=0,N=-1,T;for(;T=_.exec(b);)T[0].length>N&&(S=T.index,N=T[0].length);return N<0?b:`${b.substring(0,S)}::${b.substring(S+N)}`},h.prototype.toString=function(){return this.toRFC5952String()},h}(),x.IPv6.broadcastAddressFromCIDR=function(h){try{const _=this.parseCIDR(h),b=_[0].toByteArray(),S=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[];let T=0;for(;T<16;)N.push(parseInt(b[T],10)|parseInt(S[T],10)^255),T++;return new this(N)}catch(_){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${_})`)}},x.IPv6.isIPv6=function(h){return this.parser(h)!==null},x.IPv6.isValid=function(h){if(typeof h=="string"&&h.indexOf(":")===-1)return!1;try{const _=this.parser(h);return new this(_.parts,_.zoneId),!0}catch{return!1}},x.IPv6.isValidCIDR=function(h){if(typeof h=="string"&&h.indexOf(":")===-1)return!1;try{return this.parseCIDR(h),!0}catch{return!1}},x.IPv6.networkAddressFromCIDR=function(h){let _,b,S,N,T;try{for(_=this.parseCIDR(h),S=_[0].toByteArray(),T=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[],b=0;b<16;)N.push(parseInt(S[b],10)&parseInt(T[b],10)),b++;return new this(N)}catch(K){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${K})`)}},x.IPv6.parse=function(h){const _=this.parser(h);if(_.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(_.parts,_.zoneId)},x.IPv6.parseCIDR=function(h){let _,b,S;if((b=h.match(/^(.+)\/(\d+)$/))&&(_=parseInt(b[2]),_>=0&&_<=128))return S=[this.parse(b[1]),_],Object.defineProperty(S,"toString",{value:function(){return this.join("/")}}),S;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},x.IPv6.parser=function(h){let _,b,S,N,T,K;if(S=h.match(l.deprecatedTransitional))return this.parser(`::ffff:${S[1]}`);if(l.native.test(h))return u(h,8);if((S=h.match(l.transitional))&&(K=S[6]||"",_=S[1],S[1].endsWith("::")||(_=_.slice(0,-1)),_=u(_+K,6),_.parts)){for(T=[parseInt(S[2]),parseInt(S[3]),parseInt(S[4]),parseInt(S[5])],b=0;b<T.length;b++)if(N=T[b],!(0<=N&&N<=255))return null;return _.parts.push(T[0]<<8|T[1]),_.parts.push(T[2]<<8|T[3]),{parts:_.parts,zoneId:_.zoneId}}return null},x.IPv6.subnetMaskFromPrefixLength=function(h){if(h=parseInt(h),h<0||h>128)throw new Error("ipaddr: invalid IPv6 prefix length");const _=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let b=0;const S=Math.floor(h/8);for(;b<S;)_[b]=255,b++;return S<16&&(_[S]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},x.fromByteArray=function(h){const _=h.length;if(_===4)return new x.IPv4(h);if(_===16)return new x.IPv6(h);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},x.isValid=function(h){return x.IPv6.isValid(h)||x.IPv4.isValid(h)},x.isValidCIDR=function(h){return x.IPv6.isValidCIDR(h)||x.IPv4.isValidCIDR(h)},x.parse=function(h){if(x.IPv6.isValid(h))return x.IPv6.parse(h);if(x.IPv4.isValid(h))return x.IPv4.parse(h);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},x.parseCIDR=function(h){try{return x.IPv6.parseCIDR(h)}catch{try{return x.IPv4.parseCIDR(h)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},x.process=function(h){const _=this.parse(h);return _.kind()==="ipv6"&&_.isIPv4MappedAddress()?_.toIPv4Address():_},x.subnetMatch=function(h,_,b){let S,N,T,K;b==null&&(b="unicast");for(N in _)if(Object.prototype.hasOwnProperty.call(_,N)){for(T=_[N],T[0]&&!(T[0]instanceof Array)&&(T=[T]),S=0;S<T.length;S++)if(K=T[S],h.kind()===K[0].kind()&&h.match.apply(h,K))return N}return b},n.exports?n.exports=x:e.ipaddr=x})(mr)})(Dp);var Al=Dp.exports;class Il{static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const t=parseInt(e.slice(8),16).toString(2).split("").reduce((r,s)=>r+ +s,0);let i=e.slice(0,8).replace(/(.{2})/g,r=>`${parseInt(r,16)}.`);return i=i.slice(0,-1),`${i}/${t}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const t=new Uint8Array(e);return Al.fromByteArray(Array.from(t)).toString()}return this.decodeIP(W.ToHex(e))}static fromString(e){const t=Al.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var So,Ao,Io;let Ce=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};d([f({type:y.TeletexString})],Ce.prototype,"teletexString",void 0);d([f({type:y.PrintableString})],Ce.prototype,"printableString",void 0);d([f({type:y.UniversalString})],Ce.prototype,"universalString",void 0);d([f({type:y.Utf8String})],Ce.prototype,"utf8String",void 0);d([f({type:y.BmpString})],Ce.prototype,"bmpString",void 0);Ce=d([B({type:z.Choice})],Ce);let jn=class extends Ce{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?W.ToHex(this.anyValue):super.toString())}};d([f({type:y.IA5String})],jn.prototype,"ia5String",void 0);d([f({type:y.Any})],jn.prototype,"anyValue",void 0);jn=d([B({type:z.Choice})],jn);class ks{constructor(e={}){this.type="",this.value=new jn,Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],ks.prototype,"type",void 0);d([f({type:jn})],ks.prototype,"value",void 0);let zn=So=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,So.prototype)}};zn=So=d([B({type:z.Set,itemType:ks})],zn);let Eo=Ao=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Ao.prototype)}};Eo=Ao=d([B({type:z.Sequence,itemType:zn})],Eo);let ve=Io=class extends Eo{constructor(e){super(e),Object.setPrototypeOf(this,Io.prototype)}};ve=Io=d([B({type:z.Sequence})],ve);const l_={fromASN:n=>Il.toString(wr.fromASN(n)),toASN:n=>wr.toASN(Il.fromString(n))};class fi{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],fi.prototype,"typeId",void 0);d([f({type:y.Any,context:0})],fi.prototype,"value",void 0);class lc{constructor(e={}){this.partyName=new Ce,Object.assign(this,e)}}d([f({type:Ce,optional:!0,context:0,implicit:!0})],lc.prototype,"nameAssigner",void 0);d([f({type:Ce,context:1,implicit:!0})],lc.prototype,"partyName",void 0);let Q=class{constructor(e={}){Object.assign(this,e)}};d([f({type:fi,context:0,implicit:!0})],Q.prototype,"otherName",void 0);d([f({type:y.IA5String,context:1,implicit:!0})],Q.prototype,"rfc822Name",void 0);d([f({type:y.IA5String,context:2,implicit:!0})],Q.prototype,"dNSName",void 0);d([f({type:y.Any,context:3,implicit:!0})],Q.prototype,"x400Address",void 0);d([f({type:ve,context:4,implicit:!1})],Q.prototype,"directoryName",void 0);d([f({type:lc,context:5})],Q.prototype,"ediPartyName",void 0);d([f({type:y.IA5String,context:6,implicit:!0})],Q.prototype,"uniformResourceIdentifier",void 0);d([f({type:y.OctetString,context:7,implicit:!0,converter:l_})],Q.prototype,"iPAddress",void 0);d([f({type:y.ObjectIdentifier,context:8,implicit:!0})],Q.prototype,"registeredID",void 0);Q=d([B({type:z.Choice})],Q);const uc="1.3.6.1.5.5.7",u_=`${uc}.1`,Dn=`${uc}.3`,xs=`${uc}.48`,El=`${xs}.1`,$l=`${xs}.2`,Cl=`${xs}.3`,jl=`${xs}.5`,Ht="2.5.29";var $o;const Co=`${u_}.1`;class Ci{constructor(e={}){this.accessMethod="",this.accessLocation=new Q,Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Ci.prototype,"accessMethod",void 0);d([f({type:Q})],Ci.prototype,"accessLocation",void 0);let Sn=$o=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,$o.prototype)}};Sn=$o=d([B({type:z.Sequence,itemType:Ci})],Sn);const jo=`${Ht}.35`;class dc extends re{}class Yt{constructor(e={}){e&&Object.assign(this,e)}}d([f({type:dc,context:0,optional:!0,implicit:!0})],Yt.prototype,"keyIdentifier",void 0);d([f({type:Q,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Yt.prototype,"authorityCertIssuer",void 0);d([f({type:y.Integer,context:2,optional:!0,implicit:!0,converter:he})],Yt.prototype,"authorityCertSerialNumber",void 0);const Fp=`${Ht}.19`;class br{constructor(e={}){this.cA=!1,Object.assign(this,e)}}d([f({type:y.Boolean,defaultValue:!1})],br.prototype,"cA",void 0);d([f({type:y.Integer,optional:!0})],br.prototype,"pathLenConstraint",void 0);var zo;let Be=zo=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,zo.prototype)}};Be=zo=d([B({type:z.Sequence,itemType:Q})],Be);var No;let zl=No=class extends Be{constructor(e){super(e),Object.setPrototypeOf(this,No.prototype)}};zl=No=d([B({type:z.Sequence})],zl);var Oo;const qp=`${Ht}.32`;let xt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};d([f({type:y.IA5String})],xt.prototype,"ia5String",void 0);d([f({type:y.VisibleString})],xt.prototype,"visibleString",void 0);d([f({type:y.BmpString})],xt.prototype,"bmpString",void 0);d([f({type:y.Utf8String})],xt.prototype,"utf8String",void 0);xt=d([B({type:z.Choice})],xt);class pc{constructor(e={}){this.organization=new xt,this.noticeNumbers=[],Object.assign(this,e)}}d([f({type:xt})],pc.prototype,"organization",void 0);d([f({type:y.Integer,repeated:"sequence"})],pc.prototype,"noticeNumbers",void 0);class fc{constructor(e={}){Object.assign(this,e)}}d([f({type:pc,optional:!0})],fc.prototype,"noticeRef",void 0);d([f({type:xt,optional:!0})],fc.prototype,"explicitText",void 0);let kr=class{constructor(e={}){Object.assign(this,e)}};d([f({type:y.IA5String})],kr.prototype,"cPSuri",void 0);d([f({type:fc})],kr.prototype,"userNotice",void 0);kr=d([B({type:z.Choice})],kr);class hc{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],hc.prototype,"policyQualifierId",void 0);d([f({type:y.Any})],hc.prototype,"qualifier",void 0);class Ss{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Ss.prototype,"policyIdentifier",void 0);d([f({type:hc,repeated:"sequence",optional:!0})],Ss.prototype,"policyQualifiers",void 0);let xr=Oo=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Oo.prototype)}};xr=Oo=d([B({type:z.Sequence,itemType:Ss})],xr);let Sr=class{constructor(e=0){this.value=e}};d([f({type:y.Integer})],Sr.prototype,"value",void 0);Sr=d([B({type:z.Choice})],Sr);let Nl=class extends Sr{};Nl=d([B({type:z.Choice})],Nl);var Bo;const To=`${Ht}.31`;var rt;(function(n){n[n.unused=1]="unused",n[n.keyCompromise=2]="keyCompromise",n[n.cACompromise=4]="cACompromise",n[n.affiliationChanged=8]="affiliationChanged",n[n.superseded=16]="superseded",n[n.cessationOfOperation=32]="cessationOfOperation",n[n.certificateHold=64]="certificateHold",n[n.privilegeWithdrawn=128]="privilegeWithdrawn",n[n.aACompromise=256]="aACompromise"})(rt||(rt={}));class Kp extends bs{toJSON(){const e=[],t=this.toNumber();return t&rt.aACompromise&&e.push("aACompromise"),t&rt.affiliationChanged&&e.push("affiliationChanged"),t&rt.cACompromise&&e.push("cACompromise"),t&rt.certificateHold&&e.push("certificateHold"),t&rt.cessationOfOperation&&e.push("cessationOfOperation"),t&rt.keyCompromise&&e.push("keyCompromise"),t&rt.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&rt.superseded&&e.push("superseded"),t&rt.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let cn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Q,context:0,repeated:"sequence",implicit:!0})],cn.prototype,"fullName",void 0);d([f({type:zn,context:1,implicit:!0})],cn.prototype,"nameRelativeToCRLIssuer",void 0);cn=d([B({type:z.Choice})],cn);class Fn{constructor(e={}){Object.assign(this,e)}}d([f({type:cn,context:0,optional:!0})],Fn.prototype,"distributionPoint",void 0);d([f({type:Kp,context:1,optional:!0,implicit:!0})],Fn.prototype,"reasons",void 0);d([f({type:Q,context:2,optional:!0,repeated:"sequence",implicit:!0})],Fn.prototype,"cRLIssuer",void 0);let En=Bo=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Bo.prototype)}};En=Bo=d([B({type:z.Sequence,itemType:Fn})],En);var Ro;let Ol=Ro=class extends En{constructor(e){super(e),Object.setPrototypeOf(this,Ro.prototype)}};Ol=Ro=d([B({type:z.Sequence,itemType:Fn})],Ol);class ze{constructor(e={}){this.onlyContainsUserCerts=ze.ONLY,this.onlyContainsCACerts=ze.ONLY,this.indirectCRL=ze.ONLY,this.onlyContainsAttributeCerts=ze.ONLY,Object.assign(this,e)}}ze.ONLY=!1;d([f({type:cn,context:0,optional:!0})],ze.prototype,"distributionPoint",void 0);d([f({type:y.Boolean,context:1,defaultValue:ze.ONLY,implicit:!0})],ze.prototype,"onlyContainsUserCerts",void 0);d([f({type:y.Boolean,context:2,defaultValue:ze.ONLY,implicit:!0})],ze.prototype,"onlyContainsCACerts",void 0);d([f({type:Kp,context:3,optional:!0,implicit:!0})],ze.prototype,"onlySomeReasons",void 0);d([f({type:y.Boolean,context:4,defaultValue:ze.ONLY,implicit:!0})],ze.prototype,"indirectCRL",void 0);d([f({type:y.Boolean,context:5,defaultValue:ze.ONLY,implicit:!0})],ze.prototype,"onlyContainsAttributeCerts",void 0);var si;(function(n){n[n.unspecified=0]="unspecified",n[n.keyCompromise=1]="keyCompromise",n[n.cACompromise=2]="cACompromise",n[n.affiliationChanged=3]="affiliationChanged",n[n.superseded=4]="superseded",n[n.cessationOfOperation=5]="cessationOfOperation",n[n.certificateHold=6]="certificateHold",n[n.removeFromCRL=8]="removeFromCRL",n[n.privilegeWithdrawn=9]="privilegeWithdrawn",n[n.aACompromise=10]="aACompromise"})(si||(si={}));let Po=class{constructor(e=si.unspecified){this.reason=si.unspecified,this.reason=e}toJSON(){return si[this.reason]}toString(){return this.toJSON()}};d([f({type:y.Enumerated})],Po.prototype,"reason",void 0);Po=d([B({type:z.Choice})],Po);var Lo;const Wp=`${Ht}.37`;let Ar=Lo=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Lo.prototype)}};Ar=Lo=d([B({type:z.Sequence,itemType:y.ObjectIdentifier})],Ar);const d_=`${Dn}.1`,p_=`${Dn}.2`,f_=`${Dn}.3`,h_=`${Dn}.4`,g_=`${Dn}.8`,__=`${Dn}.9`;let Uo=class{constructor(e=new ArrayBuffer(0)){this.value=e}};d([f({type:y.Integer,converter:he})],Uo.prototype,"value",void 0);Uo=d([B({type:z.Choice})],Uo);let Vo=class{constructor(e){this.value=new Date,e&&(this.value=e)}};d([f({type:y.GeneralizedTime})],Vo.prototype,"value",void 0);Vo=d([B({type:z.Choice})],Vo);var Mo;let Bl=Mo=class extends Be{constructor(e){super(e),Object.setPrototypeOf(this,Mo.prototype)}};Bl=Mo=d([B({type:z.Sequence})],Bl);const Gp=`${Ht}.15`;var st;(function(n){n[n.digitalSignature=1]="digitalSignature",n[n.nonRepudiation=2]="nonRepudiation",n[n.keyEncipherment=4]="keyEncipherment",n[n.dataEncipherment=8]="dataEncipherment",n[n.keyAgreement=16]="keyAgreement",n[n.keyCertSign=32]="keyCertSign",n[n.cRLSign=64]="cRLSign",n[n.encipherOnly=128]="encipherOnly",n[n.decipherOnly=256]="decipherOnly"})(st||(st={}));class ro extends bs{toJSON(){const e=this.toNumber(),t=[];return e&st.cRLSign&&t.push("crlSign"),e&st.dataEncipherment&&t.push("dataEncipherment"),e&st.decipherOnly&&t.push("decipherOnly"),e&st.digitalSignature&&t.push("digitalSignature"),e&st.encipherOnly&&t.push("encipherOnly"),e&st.keyAgreement&&t.push("keyAgreement"),e&st.keyCertSign&&t.push("keyCertSign"),e&st.keyEncipherment&&t.push("keyEncipherment"),e&st.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var Ho;class As{constructor(e={}){this.base=new Q,this.minimum=0,Object.assign(this,e)}}d([f({type:Q})],As.prototype,"base",void 0);d([f({type:y.Integer,context:0,defaultValue:0,implicit:!0})],As.prototype,"minimum",void 0);d([f({type:y.Integer,context:1,optional:!0,implicit:!0})],As.prototype,"maximum",void 0);let Ir=Ho=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Ho.prototype)}};Ir=Ho=d([B({type:z.Sequence,itemType:As})],Ir);class Jp{constructor(e={}){Object.assign(this,e)}}d([f({type:Ir,context:0,optional:!0,implicit:!0})],Jp.prototype,"permittedSubtrees",void 0);d([f({type:Ir,context:1,optional:!0,implicit:!0})],Jp.prototype,"excludedSubtrees",void 0);class Zp{constructor(e={}){Object.assign(this,e)}}d([f({type:y.Integer,context:0,implicit:!0,optional:!0,converter:he})],Zp.prototype,"requireExplicitPolicy",void 0);d([f({type:y.Integer,context:1,implicit:!0,optional:!0,converter:he})],Zp.prototype,"inhibitPolicyMapping",void 0);var Do;class gc{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],gc.prototype,"issuerDomainPolicy",void 0);d([f({type:y.ObjectIdentifier})],gc.prototype,"subjectDomainPolicy",void 0);let Tl=Do=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Do.prototype)}};Tl=Do=d([B({type:z.Sequence,itemType:gc})],Tl);var Fo;const Yp=`${Ht}.17`;let qo=Fo=class extends Be{constructor(e){super(e),Object.setPrototypeOf(this,Fo.prototype)}};qo=Fo=d([B({type:z.Sequence})],qo);let St=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};d([f({type:y.ObjectIdentifier})],St.prototype,"type",void 0);d([f({type:y.Any,repeated:"set"})],St.prototype,"values",void 0);var Ko;let Rl=Ko=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Ko.prototype)}};Rl=Ko=d([B({type:z.Sequence,itemType:St})],Rl);const Xp=`${Ht}.14`;class Rt extends dc{}class Qp{constructor(e={}){Object.assign(this,e)}}d([f({type:y.GeneralizedTime,context:0,implicit:!0,optional:!0})],Qp.prototype,"notBefore",void 0);d([f({type:y.GeneralizedTime,context:1,implicit:!0,optional:!0})],Qp.prototype,"notAfter",void 0);var oi;(function(n){n[n.keyUpdateAllowed=1]="keyUpdateAllowed",n[n.newExtensions=2]="newExtensions",n[n.pKIXCertificate=4]="pKIXCertificate"})(oi||(oi={}));class ef extends bs{toJSON(){const e=[],t=this.toNumber();return t&oi.pKIXCertificate&&e.push("pKIXCertificate"),t&oi.newExtensions&&e.push("newExtensions"),t&oi.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class tf{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new ef,Object.assign(this,e)}}d([f({type:y.GeneralString})],tf.prototype,"entrustVers",void 0);d([f({type:ef})],tf.prototype,"entrustInfoFlags",void 0);var Wo;let Pl=Wo=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Wo.prototype)}};Pl=Wo=d([B({type:z.Sequence,itemType:Ci})],Pl);class H{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof H&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Md(e.parameters,this.parameters)||e.parameters===this.parameters)}}d([f({type:y.ObjectIdentifier})],H.prototype,"algorithm",void 0);d([f({type:y.Any,optional:!0})],H.prototype,"parameters",void 0);class ot{constructor(e={}){this.algorithm=new H,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:H})],ot.prototype,"algorithm",void 0);d([f({type:y.BitString})],ot.prototype,"subjectPublicKey",void 0);let Ee=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){const t=new Date(e);t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){const e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};d([f({type:y.UTCTime})],Ee.prototype,"utcTime",void 0);d([f({type:y.GeneralizedTime})],Ee.prototype,"generalTime",void 0);Ee=d([B({type:z.Choice})],Ee);class ji{constructor(e){this.notBefore=new Ee(new Date),this.notAfter=new Ee(new Date),e&&(this.notBefore=new Ee(e.notBefore),this.notAfter=new Ee(e.notAfter))}}d([f({type:Ee})],ji.prototype,"notBefore",void 0);d([f({type:Ee})],ji.prototype,"notAfter",void 0);var Go;let Xe=class nf{constructor(e={}){this.extnID="",this.critical=nf.CRITICAL,this.extnValue=new re,Object.assign(this,e)}};Xe.CRITICAL=!1;d([f({type:y.ObjectIdentifier})],Xe.prototype,"extnID",void 0);d([f({type:y.Boolean,defaultValue:Xe.CRITICAL})],Xe.prototype,"critical",void 0);d([f({type:re})],Xe.prototype,"extnValue",void 0);let Lt=Go=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Go.prototype)}};Lt=Go=d([B({type:z.Sequence,itemType:Xe})],Lt);var ln;(function(n){n[n.v1=0]="v1",n[n.v2=1]="v2",n[n.v3=2]="v3"})(ln||(ln={}));class Ge{constructor(e={}){this.version=ln.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new H,this.issuer=new ve,this.validity=new ji,this.subject=new ve,this.subjectPublicKeyInfo=new ot,Object.assign(this,e)}}d([f({type:y.Integer,context:0,defaultValue:ln.v1})],Ge.prototype,"version",void 0);d([f({type:y.Integer,converter:he})],Ge.prototype,"serialNumber",void 0);d([f({type:H})],Ge.prototype,"signature",void 0);d([f({type:ve})],Ge.prototype,"issuer",void 0);d([f({type:ji})],Ge.prototype,"validity",void 0);d([f({type:ve})],Ge.prototype,"subject",void 0);d([f({type:ot})],Ge.prototype,"subjectPublicKeyInfo",void 0);d([f({type:y.BitString,context:1,implicit:!0,optional:!0})],Ge.prototype,"issuerUniqueID",void 0);d([f({type:y.BitString,context:2,implicit:!0,optional:!0})],Ge.prototype,"subjectUniqueID",void 0);d([f({type:Lt,context:3,optional:!0})],Ge.prototype,"extensions",void 0);class un{constructor(e={}){this.tbsCertificate=new Ge,this.signatureAlgorithm=new H,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:Ge})],un.prototype,"tbsCertificate",void 0);d([f({type:H})],un.prototype,"signatureAlgorithm",void 0);d([f({type:y.BitString})],un.prototype,"signatureValue",void 0);class Is{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Ee,Object.assign(this,e)}}d([f({type:y.Integer,converter:he})],Is.prototype,"userCertificate",void 0);d([f({type:Ee})],Is.prototype,"revocationDate",void 0);d([f({type:Xe,optional:!0,repeated:"sequence"})],Is.prototype,"crlEntryExtensions",void 0);class jt{constructor(e={}){this.signature=new H,this.issuer=new ve,this.thisUpdate=new Ee,Object.assign(this,e)}}d([f({type:y.Integer,optional:!0})],jt.prototype,"version",void 0);d([f({type:H})],jt.prototype,"signature",void 0);d([f({type:ve})],jt.prototype,"issuer",void 0);d([f({type:Ee})],jt.prototype,"thisUpdate",void 0);d([f({type:Ee,optional:!0})],jt.prototype,"nextUpdate",void 0);d([f({type:Is,repeated:"sequence",optional:!0})],jt.prototype,"revokedCertificates",void 0);d([f({type:Xe,optional:!0,context:0,repeated:"sequence"})],jt.prototype,"crlExtensions",void 0);class _c{constructor(e={}){this.tbsCertList=new jt,this.signatureAlgorithm=new H,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:jt})],_c.prototype,"tbsCertList",void 0);d([f({type:H})],_c.prototype,"signatureAlgorithm",void 0);d([f({type:y.BitString})],_c.prototype,"signature",void 0);class qn{constructor(e={}){this.issuer=new ve,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:ve})],qn.prototype,"issuer",void 0);d([f({type:y.Integer,converter:he})],qn.prototype,"serialNumber",void 0);let Nn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Rt,context:0,implicit:!0})],Nn.prototype,"subjectKeyIdentifier",void 0);d([f({type:qn})],Nn.prototype,"issuerAndSerialNumber",void 0);Nn=d([B({type:z.Choice})],Nn);var At;(function(n){n[n.v0=0]="v0",n[n.v1=1]="v1",n[n.v2=2]="v2",n[n.v3=3]="v3",n[n.v4=4]="v4",n[n.v5=5]="v5"})(At||(At={}));let hi=class extends H{};hi=d([B({type:z.Sequence})],hi);let Er=class extends H{};Er=d([B({type:z.Sequence})],Er);let _t=class extends H{};_t=d([B({type:z.Sequence})],_t);let $r=class extends H{};$r=d([B({type:z.Sequence})],$r);let Ll=class extends H{};Ll=d([B({type:z.Sequence})],Ll);let Jo=class extends H{};Jo=d([B({type:z.Sequence})],Jo);let Kn=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};d([f({type:y.ObjectIdentifier})],Kn.prototype,"attrType",void 0);d([f({type:y.Any,repeated:"set"})],Kn.prototype,"attrValues",void 0);var Zo;class yt{constructor(e={}){this.version=At.v0,this.sid=new Nn,this.digestAlgorithm=new hi,this.signatureAlgorithm=new Er,this.signature=new re,Object.assign(this,e)}}d([f({type:y.Integer})],yt.prototype,"version",void 0);d([f({type:Nn})],yt.prototype,"sid",void 0);d([f({type:hi})],yt.prototype,"digestAlgorithm",void 0);d([f({type:Kn,repeated:"set",context:0,implicit:!0,optional:!0})],yt.prototype,"signedAttrs",void 0);d([f({type:Er})],yt.prototype,"signatureAlgorithm",void 0);d([f({type:re})],yt.prototype,"signature",void 0);d([f({type:Kn,repeated:"set",context:1,implicit:!0,optional:!0})],yt.prototype,"unsignedAttrs",void 0);let Cr=Zo=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Zo.prototype)}};Cr=Zo=d([B({type:z.Set,itemType:yt})],Cr);let Ul=class extends Ee{};Ul=d([B({type:z.Choice})],Ul);let Vl=class extends yt{};Vl=d([B({type:z.Sequence})],Vl);class mc{constructor(e={}){this.acIssuer=new Q,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}d([f({type:Q})],mc.prototype,"acIssuer",void 0);d([f({type:y.Integer})],mc.prototype,"acSerial",void 0);d([f({type:St,repeated:"sequence"})],mc.prototype,"attrs",void 0);var Yo;let jr=Yo=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Yo.prototype)}};jr=Yo=d([B({type:z.Sequence,itemType:y.ObjectIdentifier})],jr);class Es{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}d([f({type:y.Integer,optional:!0})],Es.prototype,"pathLenConstraint",void 0);d([f({type:jr,implicit:!0,context:0,optional:!0})],Es.prototype,"permittedAttrs",void 0);d([f({type:jr,implicit:!0,context:1,optional:!0})],Es.prototype,"excludedAttrs",void 0);d([f({type:y.Boolean,defaultValue:!0})],Es.prototype,"permitUnSpecified",void 0);class yn{constructor(e={}){this.issuer=new Be,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:Be})],yn.prototype,"issuer",void 0);d([f({type:y.Integer,converter:he})],yn.prototype,"serial",void 0);d([f({type:y.BitString,optional:!0})],yn.prototype,"issuerUID",void 0);var Xo;(function(n){n[n.publicKey=0]="publicKey",n[n.publicKeyCert=1]="publicKeyCert",n[n.otherObjectTypes=2]="otherObjectTypes"})(Xo||(Xo={}));class vn{constructor(e={}){this.digestedObjectType=Xo.publicKey,this.digestAlgorithm=new H,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.Enumerated})],vn.prototype,"digestedObjectType",void 0);d([f({type:y.ObjectIdentifier,optional:!0})],vn.prototype,"otherObjectTypeID",void 0);d([f({type:H})],vn.prototype,"digestAlgorithm",void 0);d([f({type:y.BitString})],vn.prototype,"objectDigest",void 0);class $s{constructor(e={}){Object.assign(this,e)}}d([f({type:Be,optional:!0})],$s.prototype,"issuerName",void 0);d([f({type:yn,context:0,implicit:!0,optional:!0})],$s.prototype,"baseCertificateID",void 0);d([f({type:vn,context:1,implicit:!0,optional:!0})],$s.prototype,"objectDigestInfo",void 0);let On=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Q,repeated:"sequence"})],On.prototype,"v1Form",void 0);d([f({type:$s,context:0,implicit:!0})],On.prototype,"v2Form",void 0);On=d([B({type:z.Choice})],On);class Cs{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}d([f({type:y.GeneralizedTime})],Cs.prototype,"notBeforeTime",void 0);d([f({type:y.GeneralizedTime})],Cs.prototype,"notAfterTime",void 0);class zi{constructor(e={}){Object.assign(this,e)}}d([f({type:yn,implicit:!0,context:0,optional:!0})],zi.prototype,"baseCertificateID",void 0);d([f({type:Be,implicit:!0,context:1,optional:!0})],zi.prototype,"entityName",void 0);d([f({type:vn,implicit:!0,context:2,optional:!0})],zi.prototype,"objectDigestInfo",void 0);var Qo;(function(n){n[n.v2=1]="v2"})(Qo||(Qo={}));class lt{constructor(e={}){this.version=Qo.v2,this.holder=new zi,this.issuer=new On,this.signature=new H,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Cs,this.attributes=[],Object.assign(this,e)}}d([f({type:y.Integer})],lt.prototype,"version",void 0);d([f({type:zi})],lt.prototype,"holder",void 0);d([f({type:On})],lt.prototype,"issuer",void 0);d([f({type:H})],lt.prototype,"signature",void 0);d([f({type:y.Integer,converter:he})],lt.prototype,"serialNumber",void 0);d([f({type:Cs})],lt.prototype,"attrCertValidityPeriod",void 0);d([f({type:St,repeated:"sequence"})],lt.prototype,"attributes",void 0);d([f({type:y.BitString,optional:!0})],lt.prototype,"issuerUniqueID",void 0);d([f({type:Lt,optional:!0})],lt.prototype,"extensions",void 0);class js{constructor(e={}){this.acinfo=new lt,this.signatureAlgorithm=new H,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:lt})],js.prototype,"acinfo",void 0);d([f({type:H})],js.prototype,"signatureAlgorithm",void 0);d([f({type:y.BitString})],js.prototype,"signatureValue",void 0);var zr;(function(n){n[n.unmarked=1]="unmarked",n[n.unclassified=2]="unclassified",n[n.restricted=4]="restricted",n[n.confidential=8]="confidential",n[n.secret=16]="secret",n[n.topSecret=32]="topSecret"})(zr||(zr={}));class ea extends bs{}class yc{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier,implicit:!0,context:0})],yc.prototype,"type",void 0);d([f({type:y.Any,implicit:!0,context:1})],yc.prototype,"value",void 0);class vc{constructor(e={}){this.policyId="",this.classList=new ea(zr.unclassified),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],vc.prototype,"policyId",void 0);d([f({type:ea,defaultValue:new ea(zr.unclassified)})],vc.prototype,"classList",void 0);d([f({type:yc,repeated:"set"})],vc.prototype,"securityCategories",void 0);class zs{constructor(e={}){Object.assign(this,e)}}d([f({type:re})],zs.prototype,"cotets",void 0);d([f({type:y.ObjectIdentifier})],zs.prototype,"oid",void 0);d([f({type:y.Utf8String})],zs.prototype,"string",void 0);class rf{constructor(e={}){this.values=[],Object.assign(this,e)}}d([f({type:Be,implicit:!0,context:0,optional:!0})],rf.prototype,"policyAuthority",void 0);d([f({type:zs,repeated:"sequence"})],rf.prototype,"values",void 0);var ta;class Ns{constructor(e={}){this.targetCertificate=new yn,Object.assign(this,e)}}d([f({type:yn})],Ns.prototype,"targetCertificate",void 0);d([f({type:Q,optional:!0})],Ns.prototype,"targetName",void 0);d([f({type:vn,optional:!0})],Ns.prototype,"certDigestInfo",void 0);let Bn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Q,context:0,implicit:!0})],Bn.prototype,"targetName",void 0);d([f({type:Q,context:1,implicit:!0})],Bn.prototype,"targetGroup",void 0);d([f({type:Ns,context:2,implicit:!0})],Bn.prototype,"targetCert",void 0);Bn=d([B({type:z.Choice})],Bn);let na=ta=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,ta.prototype)}};na=ta=d([B({type:z.Sequence,itemType:Bn})],na);var ia;let Ml=ia=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,ia.prototype)}};Ml=ia=d([B({type:z.Sequence,itemType:na})],Ml);class sf{constructor(e={}){Object.assign(this,e)}}d([f({type:Be,implicit:!0,context:0,optional:!0})],sf.prototype,"roleAuthority",void 0);d([f({type:Q,implicit:!0,context:1})],sf.prototype,"roleName",void 0);class wc{constructor(e={}){this.service=new Q,this.ident=new Q,Object.assign(this,e)}}d([f({type:Q})],wc.prototype,"service",void 0);d([f({type:Q})],wc.prototype,"ident",void 0);d([f({type:re,optional:!0})],wc.prototype,"authInfo",void 0);var ra;class bc{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],bc.prototype,"otherCertFormat",void 0);d([f({type:y.Any})],bc.prototype,"otherCert",void 0);let Tn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:un})],Tn.prototype,"certificate",void 0);d([f({type:js,context:2,implicit:!0})],Tn.prototype,"v2AttrCert",void 0);d([f({type:bc,context:3,implicit:!0})],Tn.prototype,"other",void 0);Tn=d([B({type:z.Choice})],Tn);let Nr=ra=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,ra.prototype)}};Nr=ra=d([B({type:z.Set,itemType:Tn})],Nr);class Wn{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Wn.prototype,"contentType",void 0);d([f({type:y.Any,context:0})],Wn.prototype,"content",void 0);let gi=class{constructor(e={}){Object.assign(this,e)}};d([f({type:re})],gi.prototype,"single",void 0);d([f({type:y.Any})],gi.prototype,"any",void 0);gi=d([B({type:z.Choice})],gi);class Os{constructor(e={}){this.eContentType="",Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Os.prototype,"eContentType",void 0);d([f({type:gi,context:0,optional:!0})],Os.prototype,"eContent",void 0);let _i=class{constructor(e={}){Object.assign(this,e)}};d([f({type:re,context:0,implicit:!0,optional:!0})],_i.prototype,"value",void 0);d([f({type:re,converter:qg,context:0,implicit:!0,optional:!0,repeated:"sequence"})],_i.prototype,"constructedValue",void 0);_i=d([B({type:z.Choice})],_i);class Ni{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new $r,Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Ni.prototype,"contentType",void 0);d([f({type:$r})],Ni.prototype,"contentEncryptionAlgorithm",void 0);d([f({type:_i,optional:!0})],Ni.prototype,"encryptedContent",void 0);class Bs{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Bs.prototype,"keyAttrId",void 0);d([f({type:y.Any,optional:!0})],Bs.prototype,"keyAttr",void 0);var sa;class Ts{constructor(e={}){this.subjectKeyIdentifier=new Rt,Object.assign(this,e)}}d([f({type:Rt})],Ts.prototype,"subjectKeyIdentifier",void 0);d([f({type:y.GeneralizedTime,optional:!0})],Ts.prototype,"date",void 0);d([f({type:Bs,optional:!0})],Ts.prototype,"other",void 0);let Rn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Ts,context:0,implicit:!0,optional:!0})],Rn.prototype,"rKeyId",void 0);d([f({type:qn,optional:!0})],Rn.prototype,"issuerAndSerialNumber",void 0);Rn=d([B({type:z.Choice})],Rn);class kc{constructor(e={}){this.rid=new Rn,this.encryptedKey=new re,Object.assign(this,e)}}d([f({type:Rn})],kc.prototype,"rid",void 0);d([f({type:re})],kc.prototype,"encryptedKey",void 0);let Or=sa=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,sa.prototype)}};Or=sa=d([B({type:z.Sequence,itemType:kc})],Or);class xc{constructor(e={}){this.algorithm=new H,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:H})],xc.prototype,"algorithm",void 0);d([f({type:y.BitString})],xc.prototype,"publicKey",void 0);let dn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Rt,context:0,implicit:!0,optional:!0})],dn.prototype,"subjectKeyIdentifier",void 0);d([f({type:xc,context:1,implicit:!0,optional:!0})],dn.prototype,"originatorKey",void 0);d([f({type:qn,optional:!0})],dn.prototype,"issuerAndSerialNumber",void 0);dn=d([B({type:z.Choice})],dn);class Gn{constructor(e={}){this.version=At.v3,this.originator=new dn,this.keyEncryptionAlgorithm=new _t,this.recipientEncryptedKeys=new Or,Object.assign(this,e)}}d([f({type:y.Integer})],Gn.prototype,"version",void 0);d([f({type:dn,context:0})],Gn.prototype,"originator",void 0);d([f({type:re,context:1,optional:!0})],Gn.prototype,"ukm",void 0);d([f({type:_t})],Gn.prototype,"keyEncryptionAlgorithm",void 0);d([f({type:Or})],Gn.prototype,"recipientEncryptedKeys",void 0);let Pn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Rt,context:0,implicit:!0})],Pn.prototype,"subjectKeyIdentifier",void 0);d([f({type:qn})],Pn.prototype,"issuerAndSerialNumber",void 0);Pn=d([B({type:z.Choice})],Pn);class Oi{constructor(e={}){this.version=At.v0,this.rid=new Pn,this.keyEncryptionAlgorithm=new _t,this.encryptedKey=new re,Object.assign(this,e)}}d([f({type:y.Integer})],Oi.prototype,"version",void 0);d([f({type:Pn})],Oi.prototype,"rid",void 0);d([f({type:_t})],Oi.prototype,"keyEncryptionAlgorithm",void 0);d([f({type:re})],Oi.prototype,"encryptedKey",void 0);class Bi{constructor(e={}){this.keyIdentifier=new re,Object.assign(this,e)}}d([f({type:re})],Bi.prototype,"keyIdentifier",void 0);d([f({type:y.GeneralizedTime,optional:!0})],Bi.prototype,"date",void 0);d([f({type:Bs,optional:!0})],Bi.prototype,"other",void 0);class Ti{constructor(e={}){this.version=At.v4,this.kekid=new Bi,this.keyEncryptionAlgorithm=new _t,this.encryptedKey=new re,Object.assign(this,e)}}d([f({type:y.Integer})],Ti.prototype,"version",void 0);d([f({type:Bi})],Ti.prototype,"kekid",void 0);d([f({type:_t})],Ti.prototype,"keyEncryptionAlgorithm",void 0);d([f({type:re})],Ti.prototype,"encryptedKey",void 0);class Ri{constructor(e={}){this.version=At.v0,this.keyEncryptionAlgorithm=new _t,this.encryptedKey=new re,Object.assign(this,e)}}d([f({type:y.Integer})],Ri.prototype,"version",void 0);d([f({type:Jo,context:0,optional:!0})],Ri.prototype,"keyDerivationAlgorithm",void 0);d([f({type:_t})],Ri.prototype,"keyEncryptionAlgorithm",void 0);d([f({type:re})],Ri.prototype,"encryptedKey",void 0);class Sc{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Sc.prototype,"oriType",void 0);d([f({type:y.Any})],Sc.prototype,"oriValue",void 0);let Ut=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Oi,optional:!0})],Ut.prototype,"ktri",void 0);d([f({type:Gn,context:1,implicit:!0,optional:!0})],Ut.prototype,"kari",void 0);d([f({type:Ti,context:2,implicit:!0,optional:!0})],Ut.prototype,"kekri",void 0);d([f({type:Ri,context:3,implicit:!0,optional:!0})],Ut.prototype,"pwri",void 0);d([f({type:Sc,context:4,implicit:!0,optional:!0})],Ut.prototype,"ori",void 0);Ut=d([B({type:z.Choice})],Ut);var oa;let Br=oa=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,oa.prototype)}};Br=oa=d([B({type:z.Set,itemType:Ut})],Br);var aa;class Rs{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Rs.prototype,"otherRevInfoFormat",void 0);d([f({type:y.Any})],Rs.prototype,"otherRevInfo",void 0);let Tr=class{constructor(e={}){this.other=new Rs,Object.assign(this,e)}};d([f({type:Rs,context:1,implicit:!0})],Tr.prototype,"other",void 0);Tr=d([B({type:z.Choice})],Tr);let Rr=aa=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,aa.prototype)}};Rr=aa=d([B({type:z.Set,itemType:Tr})],Rr);class Ac{constructor(e={}){Object.assign(this,e)}}d([f({type:Nr,context:0,implicit:!0,optional:!0})],Ac.prototype,"certs",void 0);d([f({type:Rr,context:1,implicit:!0,optional:!0})],Ac.prototype,"crls",void 0);var ca;let la=ca=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,ca.prototype)}};la=ca=d([B({type:z.Set,itemType:Kn})],la);class Pi{constructor(e={}){this.version=At.v0,this.recipientInfos=new Br,this.encryptedContentInfo=new Ni,Object.assign(this,e)}}d([f({type:y.Integer})],Pi.prototype,"version",void 0);d([f({type:Ac,context:0,implicit:!0,optional:!0})],Pi.prototype,"originatorInfo",void 0);d([f({type:Br})],Pi.prototype,"recipientInfos",void 0);d([f({type:Ni})],Pi.prototype,"encryptedContentInfo",void 0);d([f({type:la,context:1,implicit:!0,optional:!0})],Pi.prototype,"unprotectedAttrs",void 0);const m_="1.2.840.113549.1.7.2";var ua;let Pr=ua=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,ua.prototype)}};Pr=ua=d([B({type:z.Set,itemType:hi})],Pr);class Jn{constructor(e={}){this.version=At.v0,this.digestAlgorithms=new Pr,this.encapContentInfo=new Os,this.signerInfos=new Cr,Object.assign(this,e)}}d([f({type:y.Integer})],Jn.prototype,"version",void 0);d([f({type:Pr})],Jn.prototype,"digestAlgorithms",void 0);d([f({type:Os})],Jn.prototype,"encapContentInfo",void 0);d([f({type:Nr,context:0,implicit:!0,optional:!0})],Jn.prototype,"certificates",void 0);d([f({type:Rr,context:1,implicit:!0,optional:!0})],Jn.prototype,"crls",void 0);d([f({type:Cr})],Jn.prototype,"signerInfos",void 0);const mi="1.2.840.10045.2.1",Ic="1.2.840.10045.4.1",of="1.2.840.10045.4.3.1",Ec="1.2.840.10045.4.3.2",$c="1.2.840.10045.4.3.3",Cc="1.2.840.10045.4.3.4",Hl="1.2.840.10045.3.1.7",Dl="1.3.132.0.34",Fl="1.3.132.0.35";function Li(n){return new H({algorithm:n})}const y_=Li(Ic);Li(of);const v_=Li(Ec),w_=Li($c),b_=Li(Cc);let yi=class{constructor(e={}){Object.assign(this,e)}};d([f({type:y.ObjectIdentifier})],yi.prototype,"fieldType",void 0);d([f({type:y.Any})],yi.prototype,"parameters",void 0);yi=d([B({type:z.Sequence})],yi);class k_ extends re{}let Ln=class{constructor(e={}){Object.assign(this,e)}};d([f({type:y.OctetString})],Ln.prototype,"a",void 0);d([f({type:y.OctetString})],Ln.prototype,"b",void 0);d([f({type:y.BitString,optional:!0})],Ln.prototype,"seed",void 0);Ln=d([B({type:z.Sequence})],Ln);var da;(function(n){n[n.ecpVer1=1]="ecpVer1"})(da||(da={}));let It=class{constructor(e={}){this.version=da.ecpVer1,Object.assign(this,e)}};d([f({type:y.Integer})],It.prototype,"version",void 0);d([f({type:yi})],It.prototype,"fieldID",void 0);d([f({type:Ln})],It.prototype,"curve",void 0);d([f({type:k_})],It.prototype,"base",void 0);d([f({type:y.Integer,converter:he})],It.prototype,"order",void 0);d([f({type:y.Integer,optional:!0})],It.prototype,"cofactor",void 0);It=d([B({type:z.Sequence})],It);let Vt=class{constructor(e={}){Object.assign(this,e)}};d([f({type:y.ObjectIdentifier})],Vt.prototype,"namedCurve",void 0);d([f({type:y.Null})],Vt.prototype,"implicitCurve",void 0);d([f({type:It})],Vt.prototype,"specifiedCurve",void 0);Vt=d([B({type:z.Choice})],Vt);class Ps{constructor(e={}){this.version=1,this.privateKey=new re,Object.assign(this,e)}}d([f({type:y.Integer})],Ps.prototype,"version",void 0);d([f({type:re})],Ps.prototype,"privateKey",void 0);d([f({type:Vt,context:0,optional:!0})],Ps.prototype,"parameters",void 0);d([f({type:y.BitString,context:1,optional:!0})],Ps.prototype,"publicKey",void 0);class Lr{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.Integer,converter:he})],Lr.prototype,"r",void 0);d([f({type:y.Integer,converter:he})],Lr.prototype,"s",void 0);const Me="1.2.840.113549.1.1",pn=`${Me}.1`,x_=`${Me}.7`,S_=`${Me}.9`,ai=`${Me}.10`,A_=`${Me}.2`,I_=`${Me}.4`,Ur=`${Me}.5`,E_=`${Me}.14`,pa=`${Me}.11`,Vr=`${Me}.12`,Mr=`${Me}.13`,af=`${Me}.15`,cf=`${Me}.16`,Hr="1.3.14.3.2.26",lf="2.16.840.1.101.3.4.2.4",Dr="2.16.840.1.101.3.4.2.1",Fr="2.16.840.1.101.3.4.2.2",qr="2.16.840.1.101.3.4.2.3",$_="2.16.840.1.101.3.4.2.5",C_="2.16.840.1.101.3.4.2.6",j_="1.2.840.113549.2.2",z_="1.2.840.113549.2.5",Ls=`${Me}.8`;function xe(n){return new H({algorithm:n,parameters:null})}xe(j_);xe(z_);const fn=xe(Hr);xe(lf);xe(Dr);xe(Fr);xe(qr);xe($_);xe(C_);const uf=new H({algorithm:Ls,parameters:L.serialize(fn)}),df=new H({algorithm:S_,parameters:L.serialize(wr.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});xe(pn);xe(A_);xe(I_);xe(Ur);xe(af);xe(cf);xe(Vr);xe(Mr);xe(af);xe(cf);class Us{constructor(e={}){this.hashAlgorithm=new H(fn),this.maskGenAlgorithm=new H({algorithm:Ls,parameters:L.serialize(fn)}),this.pSourceAlgorithm=new H(df),Object.assign(this,e)}}d([f({type:H,context:0,defaultValue:fn})],Us.prototype,"hashAlgorithm",void 0);d([f({type:H,context:1,defaultValue:uf})],Us.prototype,"maskGenAlgorithm",void 0);d([f({type:H,context:2,defaultValue:df})],Us.prototype,"pSourceAlgorithm",void 0);new H({algorithm:x_,parameters:L.serialize(new Us)});class hn{constructor(e={}){this.hashAlgorithm=new H(fn),this.maskGenAlgorithm=new H({algorithm:Ls,parameters:L.serialize(fn)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}d([f({type:H,context:0,defaultValue:fn})],hn.prototype,"hashAlgorithm",void 0);d([f({type:H,context:1,defaultValue:uf})],hn.prototype,"maskGenAlgorithm",void 0);d([f({type:y.Integer,context:2,defaultValue:20})],hn.prototype,"saltLength",void 0);d([f({type:y.Integer,context:3,defaultValue:1})],hn.prototype,"trailerField",void 0);new H({algorithm:ai,parameters:L.serialize(new hn)});class Vs{constructor(e={}){this.digestAlgorithm=new H,this.digest=new re,Object.assign(this,e)}}d([f({type:H})],Vs.prototype,"digestAlgorithm",void 0);d([f({type:re})],Vs.prototype,"digest",void 0);var fa;class Ms{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.Integer,converter:he})],Ms.prototype,"prime",void 0);d([f({type:y.Integer,converter:he})],Ms.prototype,"exponent",void 0);d([f({type:y.Integer,converter:he})],Ms.prototype,"coefficient",void 0);let ha=fa=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,fa.prototype)}};ha=fa=d([B({type:z.Sequence,itemType:Ms})],ha);class vt{constructor(e={}){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),Object.assign(this,e)}}d([f({type:y.Integer})],vt.prototype,"version",void 0);d([f({type:y.Integer,converter:he})],vt.prototype,"modulus",void 0);d([f({type:y.Integer,converter:he})],vt.prototype,"publicExponent",void 0);d([f({type:y.Integer,converter:he})],vt.prototype,"privateExponent",void 0);d([f({type:y.Integer,converter:he})],vt.prototype,"prime1",void 0);d([f({type:y.Integer,converter:he})],vt.prototype,"prime2",void 0);d([f({type:y.Integer,converter:he})],vt.prototype,"exponent1",void 0);d([f({type:y.Integer,converter:he})],vt.prototype,"exponent2",void 0);d([f({type:y.Integer,converter:he})],vt.prototype,"coefficient",void 0);d([f({type:ha,optional:!0})],vt.prototype,"otherPrimeInfos",void 0);class jc{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.Integer,converter:he})],jc.prototype,"modulus",void 0);d([f({type:y.Integer,converter:he})],jc.prototype,"publicExponent",void 0);var ga;(function(n){n[n.Transient=0]="Transient",n[n.Singleton=1]="Singleton",n[n.ResolutionScoped=2]="ResolutionScoped",n[n.ContainerScoped=3]="ContainerScoped"})(ga||(ga={}));const Pe=ga;/*! *****************************************************************************
79
+ `)}`:`${t} :`}}Zd=Ue;D.Constructed=Zd;Ue.NAME="CONSTRUCTED";class Yd extends Te{fromBER(e,t,i){return t}toBER(e){return ct}}Yd.override="EndOfContentValueBlock";var Xd;class Xa extends $e{constructor(e={}){super(e,Yd),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Xd=Xa;D.EndOfContent=Xd;Xa.NAME=pi;var Qd;class on extends $e{constructor(e={}){super(e,Te),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,i){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+=i,t+i>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+i}toBER(e,t){const i=new ArrayBuffer(2);if(!e){const r=new Uint8Array(i);r[0]=5,r[1]=0}return t&&t.write(i),i}onAsciiEncoding(){return`${this.constructor.NAME}`}}Qd=on;D.Null=Qd;on.NAME="NULL";class ep extends mt(Te){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=U.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,i){const r=U.toUint8Array(e);return $t(this,r,t,i)?(this.valueHexView=r.subarray(t,t+i),i>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Hd.call(this),this.blockLength=i,t+i):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}ep.NAME="BooleanValueBlock";var tp;class as extends $e{constructor(e={}){super(e,ep),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}}tp=as;D.Boolean=tp;as.NAME="BOOLEAN";class np extends mt(Tt){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,i){let r=0;if(this.isConstructed){if(this.isHexOnly=!1,r=Tt.prototype.fromBER.call(this,e,t,i),r===-1)return r;for(let s=0;s<this.value.length;s++){const o=this.value[s].constructor.NAME;if(o===pi){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(o!==Dd)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,r=super.fromBER(e,t,i),this.blockLength=i;return r}toBER(e,t){return this.isConstructed?Tt.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}np.NAME="OctetStringValueBlock";var ip;let Qt=class rp extends $e{constructor({idBlock:e={},lenBlock:t={},...i}={}){var r,s;(r=i.isConstructed)!==null&&r!==void 0||(i.isConstructed=!!(!((s=i.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:i.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!i.isIndefiniteForm},...i},np),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,i){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,i===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+i);try{if(s.byteLength){const o=Hn(s,0,s.byteLength);o.offset!==-1&&o.offset===i&&(this.valueBlock.value=[o.result])}}catch{}}return super.fromBER(e,t,i)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Ue.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${W.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const t of this.valueBlock.value)t instanceof rp&&e.push(t.valueBlock.valueHexView);return U.concat(e)}};ip=Qt;D.OctetString=ip;Qt.NAME=Dd;class sp extends mt(Tt){constructor({unusedBits:e=0,isConstructed:t=!1,...i}={}){super(i),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,i){if(!i)return t;let r=-1;if(this.isConstructed){if(r=Tt.prototype.fromBER.call(this,e,t,i),r===-1)return r;for(const c of this.value){const l=c.constructor.NAME;if(l===pi){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(l!==Fd)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const u=c.valueBlock;if(this.unusedBits>0&&u.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=u.unusedBits}return r}const s=U.toUint8Array(e);if(!$t(this,s,t,i))return-1;const o=s.subarray(t,t+i);if(this.unusedBits=o[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const c=o.subarray(1);try{if(c.byteLength){const l=Hn(c,0,c.byteLength);l.offset!==-1&&l.offset===i-1&&(this.value=[l.result])}}catch{}}return this.valueHexView=o.subarray(1),this.blockLength=o.length,t+i}toBER(e,t){if(this.isConstructed)return Tt.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return ct;const i=new Uint8Array(this.valueHexView.length+1);return i[0]=this.unusedBits,i.set(this.valueHexView,1),i.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}sp.NAME="BitStringValueBlock";var op;let en=class extends $e{constructor({idBlock:e={},lenBlock:t={},...i}={}){var r,s;(r=i.isConstructed)!==null&&r!==void 0||(i.isConstructed=!!(!((s=i.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:i.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!i.isIndefiniteForm},...i},sp),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,i){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,i)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Ue.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const r of t)e.push(r.toString(2).padStart(8,"0"));const i=e.join("");return`${this.constructor.NAME} : ${i.substring(0,i.length-this.valueBlock.unusedBits)}`}}};op=en;D.BitString=op;en.NAME=Fd;var ap;function Tg(n,e){const t=new Uint8Array([0]),i=new Uint8Array(n),r=new Uint8Array(e);let s=i.slice(0);const o=s.length-1,c=r.slice(0),l=c.length-1;let u=0;const p=l<o?o:l;let g=0;for(let m=p;m>=0;m--,g++){switch(!0){case g<c.length:u=s[o-g]+c[l-g]+t[0];break;default:u=s[o-g]+t[0]}switch(t[0]=u/10,!0){case g>=s.length:s=bo(new Uint8Array([u%10]),s);break;default:s[o-g]=u%10}}return t[0]>0&&(s=bo(t,s)),s}function xl(n){if(n>=ei.length)for(let e=ei.length;e<=n;e++){const t=new Uint8Array([0]);let i=ei[e-1].slice(0);for(let r=i.length-1;r>=0;r--){const s=new Uint8Array([(i[r]<<1)+t[0]]);t[0]=s[0]/10,i[r]=s[0]%10}t[0]>0&&(i=bo(t,i)),ei.push(i)}return ei[n]}function Rg(n,e){let t=0;const i=new Uint8Array(n),r=new Uint8Array(e),s=i.slice(0),o=s.length-1,c=r.slice(0),l=c.length-1;let u,p=0;for(let g=l;g>=0;g--,p++)switch(u=s[o-p]-c[l-p]-t,!0){case u<0:t=1,s[o-p]=u+10;break;default:t=0,s[o-p]=u}if(t>0)for(let g=o-l+1;g>=0;g--,p++)if(u=s[o-p]-t,u<0)t=1,s[o-p]=u+10;else{t=0,s[o-p]=u;break}return s.slice()}class Qa extends mt(Te){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){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=Hd.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(xg(e))}get valueDec(){return this._valueDec}fromDER(e,t,i,r=0){const s=this.fromBER(e,t,i);if(s===-1)return s;const o=this.valueHexView;return o[0]===0&&o[1]&128?this.valueHexView=o.subarray(1):r!==0&&o.length<r&&(r-o.length>1&&(r=o.length+1),this.valueHexView=o.subarray(r-o.length)),s}toDER(e=!1){const t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{const i=new Uint8Array(this.valueHexView.length+1);i[0]=0,i.set(t,1),this.valueHexView=i}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,i){const r=super.fromBER(e,t,i);return r===-1||this.setValueHex(),r}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=this.valueHexView.length*8-1;let t=new Uint8Array(this.valueHexView.length*8/3),i=0,r;const s=this.valueHexView;let o="",c=!1;for(let l=s.byteLength-1;l>=0;l--){r=s[l];for(let u=0;u<8;u++){if((r&1)===1)switch(i){case e:t=Rg(xl(i),t),o="-";break;default:t=Tg(t,xl(i))}i++,r>>=1}}for(let l=0;l<t.length;l++)t[l]&&(c=!0),c&&(o+=bl.charAt(t[l]));return c===!1&&(o+=bl.charAt(0)),o}}ap=Qa;Qa.NAME="IntegerValueBlock";Object.defineProperty(ap.prototype,"valueHex",{set:function(n){this.valueHexView=new Uint8Array(n),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var cp;class gt extends $e{constructor(e={}){super(e,Qa),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return yr(),BigInt(this.valueBlock.toString())}static fromBigInt(e){yr();const t=BigInt(e),i=new ss,r=t.toString(16).replace(/^-/,""),s=new Uint8Array(W.FromHex(r));if(t<0){const c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;const u=BigInt(`0x${W.ToHex(c)}`)+t,p=U.toUint8Array(W.FromHex(u.toString(16)));p[0]|=128,i.write(p)}else s[0]&128&&i.write(new Uint8Array([0])),i.write(s);return new gt({valueHex:i.final()})}convertToDER(){const e=new gt({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new gt({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}cp=gt;D.Integer=cp;gt.NAME="INTEGER";var lp;class cs extends gt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}lp=cs;D.Enumerated=lp;cs.NAME="ENUMERATED";class ko extends mt(Te){constructor({valueDec:e=-1,isFirstSid:t=!1,...i}={}){super(i),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,i){if(!i)return t;const r=U.toUint8Array(e);if(!$t(this,r,t,i))return-1;const s=r.subarray(t,t+i);this.valueHexView=new Uint8Array(i);for(let c=0;c<i&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,s[this.blockLength-1]&128?(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=Cn(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){yr();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const i=new Uint8Array(t.length/7);for(let r=0;r<i.length;r++)i[r]=parseInt(t.slice(r*7,r*7+7),2)+(r+1<i.length?128:0);this.fromBER(i.buffer,0,i.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const r=this.valueHexView,s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength-1;o++)s[o]=r[o]|128;return s[this.blockLength-1]=r[this.blockLength-1],s.buffer}const t=sn(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",ct;const i=new Uint8Array(t.byteLength);if(!e){const r=new Uint8Array(t),s=t.byteLength-1;for(let o=0;o<s;o++)i[o]=r[o]|128;i[s]=r[s]}return i}toString(){let e="";if(this.isHexOnly)e=W.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}ko.NAME="sidBlock";class up extends Te{constructor({value:e=Le,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,i){let r=t;for(;i>0;){const s=new ko;if(r=s.fromBER(e,r,i),r===-1)return this.blockLength=0,this.error=s.error,r;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,i-=s.blockLength,this.value.push(s)}return r}toBER(e){const t=[];for(let i=0;i<this.value.length;i++){const r=this.value[i].toBER(e);if(r.byteLength===0)return this.error=this.value[i].error,ct;t.push(r)}return Za(t)}fromString(e){this.value=[];let t=0,i=0,r="",s=!1;do if(i=e.indexOf(".",t),i===-1?r=e.substring(t):r=e.substring(t,i),t=i+1,s){const o=this.value[0];let c=0;switch(o.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}const l=parseInt(r,10);if(isNaN(l))return;o.valueDec=l+c,s=!1}else{const o=new ko;if(r>Number.MAX_SAFE_INTEGER){yr();const c=BigInt(r);o.valueBigInt=c}else if(o.valueDec=parseInt(r,10),isNaN(o.valueDec))return;this.value.length||(o.isFirstSid=!0,s=!0),this.value.push(o)}while(i!==-1)}toString(){let e="",t=!1;for(let i=0;i<this.value.length;i++){t=this.value[i].isHexOnly;let r=this.value[i].toString();i!==0&&(e=`${e}.`),t?(r=`{${r}}`,this.value[i].isFirstSid?e=`2.{${r} - 80}`:e+=r):e+=r}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}up.NAME="ObjectIdentifierValueBlock";var dp;class ls extends $e{constructor(e={}){super(e,up),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}dp=ls;D.ObjectIdentifier=dp;ls.NAME="OBJECT IDENTIFIER";class xo extends mt(mn){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,i){if(i===0)return t;const r=U.toUint8Array(e);if(!$t(this,r,t,i))return-1;const s=r.subarray(t,t+i);this.valueHexView=new Uint8Array(i);for(let c=0;c<i&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,s[this.blockLength-1]&128?(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=Cn(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const r=this.valueHexView,s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength-1;o++)s[o]=r[o]|128;return s[this.blockLength-1]=r[this.blockLength-1],s.buffer}const t=sn(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",ct;const i=new Uint8Array(t.byteLength);if(!e){const r=new Uint8Array(t),s=t.byteLength-1;for(let o=0;o<s;o++)i[o]=r[o]|128;i[s]=r[s]}return i.buffer}toString(){let e="";return this.isHexOnly?e=W.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}xo.NAME="relativeSidBlock";class pp extends Te{constructor({value:e=Le,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,i){let r=t;for(;i>0;){const s=new xo;if(r=s.fromBER(e,r,i),r===-1)return this.blockLength=0,this.error=s.error,r;this.blockLength+=s.blockLength,i-=s.blockLength,this.value.push(s)}return r}toBER(e,t){const i=[];for(let r=0;r<this.value.length;r++){const s=this.value[r].toBER(e);if(s.byteLength===0)return this.error=this.value[r].error,ct;i.push(s)}return Za(i)}fromString(e){this.value=[];let t=0,i=0,r="";do{i=e.indexOf(".",t),i===-1?r=e.substring(t):r=e.substring(t,i),t=i+1;const s=new xo;if(s.valueDec=parseInt(r,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(i!==-1);return!0}toString(){let e="",t=!1;for(let i=0;i<this.value.length;i++){t=this.value[i].isHexOnly;let r=this.value[i].toString();i!==0&&(e=`${e}.`),t&&(r=`{${r}}`),e+=r}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}pp.NAME="RelativeObjectIdentifierValueBlock";var fp;class ec extends $e{constructor(e={}){super(e,pp),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}fp=ec;D.RelativeObjectIdentifier=fp;ec.NAME="RelativeObjectIdentifier";var hp;class bt extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}hp=bt;D.Sequence=hp;bt.NAME="SEQUENCE";var gp;let kt=class extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};gp=kt;D.Set=gp;kt.NAME="SET";class _p extends mt(Te){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Le}toJSON(){return{...super.toJSON(),value:this.value}}}_p.NAME="StringValueBlock";class mp extends _p{}mp.NAME="SimpleStringValueBlock";class We extends Ya{constructor({...e}={}){super(e,mp)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,U.toUint8Array(e))}fromString(e){const t=e.length,i=this.valueBlock.valueHexView=new Uint8Array(t);for(let r=0;r<t;r++)i[r]=e.charCodeAt(r);this.valueBlock.value=e}}We.NAME="SIMPLE STRING";class yp extends We{fromBuffer(e){this.valueBlock.valueHexView=U.toUint8Array(e);try{this.valueBlock.value=W.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=W.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(W.FromUtf8String(e)),this.valueBlock.value=e}}yp.NAME="Utf8StringValueBlock";var vp;class Ct extends yp{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}vp=Ct;D.Utf8String=vp;Ct.NAME="UTF8String";class wp extends We{fromBuffer(e){this.valueBlock.value=W.ToUtf16String(e),this.valueBlock.valueHexView=U.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(W.FromUtf16String(e))}}wp.NAME="BmpStringValueBlock";var bp;class us extends wp{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}bp=us;D.BmpString=bp;us.NAME="BMPString";class kp extends We{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),i=new Uint8Array(t);for(let r=0;r<i.length;r+=4)i[r]=i[r+3],i[r+1]=i[r+2],i[r+2]=0,i[r+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,i=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let r=0;r<t;r++){const s=sn(e.charCodeAt(r),8),o=new Uint8Array(s);if(o.length>4)continue;const c=4-o.length;for(let l=o.length-1;l>=0;l--)i[r*4+l+c]=o[l]}this.valueBlock.value=e}}kp.NAME="UniversalStringValueBlock";var xp;class ds extends kp{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}xp=ds;D.UniversalString=xp;ds.NAME="UniversalString";var Sp;class ps extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Sp=ps;D.NumericString=Sp;ps.NAME="NumericString";var Ap;class fs extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Ap=fs;D.PrintableString=Ap;fs.NAME="PrintableString";var Ip;class hs extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Ip=hs;D.TeletexString=Ip;hs.NAME="TeletexString";var Ep;class gs extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Ep=gs;D.VideotexString=Ep;gs.NAME="VideotexString";var $p;class _s extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}$p=_s;D.IA5String=$p;_s.NAME="IA5String";var Cp;class ms extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Cp=ms;D.GraphicString=Cp;ms.NAME="GraphicString";var jp;class Ei extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}jp=Ei;D.VisibleString=jp;Ei.NAME="VisibleString";var zp;class ys extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}zp=ys;D.GeneralString=zp;ys.NAME="GeneralString";var Np;class vs extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Np=vs;D.CharacterString=Np;vs.NAME="CharacterString";var Op;class $i extends Ei{constructor({value:e,valueDate:t,...i}={}){if(super(i),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let r=0;r<e.length;r++)this.valueBlock.valueHexView[r]=e.charCodeAt(r)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,U.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let r=0;r<e.length;r++)i[r]=e.charCodeAt(r);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const i=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(i===null){this.error="Wrong input string for conversion";return}const r=parseInt(i[1],10);r>=50?this.year=1900+r:this.year=2e3+r,this.month=parseInt(i[2],10),this.day=parseInt(i[3],10),this.hour=parseInt(i[4],10),this.minute=parseInt(i[5],10),this.second=parseInt(i[6],10)}toString(e="iso"){if(e==="iso"){const t=new Array(7);return t[0]=Fe(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Fe(this.month,2),t[2]=Fe(this.day,2),t[3]=Fe(this.hour,2),t[4]=Fe(this.minute,2),t[5]=Fe(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}Op=$i;D.UTCTime=Op;$i.NAME="UTCTime";var Bp;class ws extends $i{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,i="",r="",s=0,o,c=0,l=0;if(e[e.length-1]==="Z")i=e.substring(0,e.length-1),t=!0;else{const g=new Number(e[e.length-1]);if(isNaN(g.valueOf()))throw new Error("Wrong input string for conversion");i=e}if(t){if(i.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(i.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let g=1,m=i.indexOf("+"),x="";if(m===-1&&(m=i.indexOf("-"),g=-1),m!==-1){if(x=i.substring(m+1),i=i.substring(0,m),x.length!==2&&x.length!==4)throw new Error("Wrong input string for conversion");let h=parseInt(x.substring(0,2),10);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");if(c=g*h,x.length===4){if(h=parseInt(x.substring(2,4),10),isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");l=g*h}}}let u=i.indexOf(".");if(u===-1&&(u=i.indexOf(",")),u!==-1){const g=new Number(`0${i.substring(u)}`);if(isNaN(g.valueOf()))throw new Error("Wrong input string for conversion");s=g.valueOf(),r=i.substring(0,u)}else r=i;switch(!0){case r.length===8:if(o=/(\d{4})(\d{2})(\d{2})/ig,u!==-1)throw new Error("Wrong input string for conversion");break;case r.length===10:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let g=60*s;this.minute=Math.floor(g),g=60*(g-this.minute),this.second=Math.floor(g),g=1e3*(g-this.second),this.millisecond=Math.floor(g)}break;case r.length===12:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let g=60*s;this.second=Math.floor(g),g=1e3*(g-this.second),this.millisecond=Math.floor(g)}break;case r.length===14:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){const g=1e3*s;this.millisecond=Math.floor(g)}break;default:throw new Error("Wrong input string for conversion")}const p=o.exec(r);if(p===null)throw new Error("Wrong input string for conversion");for(let g=1;g<p.length;g++)switch(g){case 1:this.year=parseInt(p[g],10);break;case 2:this.month=parseInt(p[g],10);break;case 3:this.day=parseInt(p[g],10);break;case 4:this.hour=parseInt(p[g],10)+c;break;case 5:this.minute=parseInt(p[g],10)+l;break;case 6:this.second=parseInt(p[g],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){const g=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=g.getUTCFullYear(),this.month=g.getUTCMonth(),this.day=g.getUTCDay(),this.hour=g.getUTCHours(),this.minute=g.getUTCMinutes(),this.second=g.getUTCSeconds(),this.millisecond=g.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const t=[];return t.push(Fe(this.year,4)),t.push(Fe(this.month,2)),t.push(Fe(this.day,2)),t.push(Fe(this.hour,2)),t.push(Fe(this.minute,2)),t.push(Fe(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Fe(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Bp=ws;D.GeneralizedTime=Bp;ws.NAME="GeneralizedTime";var Tp;class tc extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Tp=tc;D.DATE=Tp;tc.NAME="DATE";var Rp;class nc extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Rp=nc;D.TimeOfDay=Rp;nc.NAME="TimeOfDay";var Pp;class ic extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Pp=ic;D.DateTime=Pp;ic.NAME="DateTime";var Lp;class rc extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Lp=rc;D.Duration=Lp;rc.NAME="Duration";var Up;class sc extends Ct{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Up=sc;D.TIME=Up;sc.NAME="TIME";class an{constructor({name:e=Le,optional:t=!1}={}){this.name=e,this.optional=t}}class oc extends an{constructor({value:e=[],...t}={}){super(t),this.value=e}}class vr extends an{constructor({value:e=new an,local:t=!1,...i}={}){super(i),this.value=e,this.local=t}}class Pg{constructor({data:e=os}={}){this.dataView=U.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=U.toUint8Array(e)}fromBER(e,t,i){const r=t+i;return this.dataView=U.toUint8Array(e).subarray(t,r),r}toBER(e){return this.dataView.slice().buffer}}function Zt(n,e,t){if(t instanceof oc){for(let s=0;s<t.value.length;s++)if(Zt(n,e,t.value[s]).verified)return{verified:!0,result:n};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(io)&&(s.name=t.name),s}}if(t instanceof an)return t.hasOwnProperty(io)&&(n[t.name]=e),{verified:!0,result:n};if(!(n instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Ig in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(jg in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(zg in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const i=t.idBlock.toBER(!1);if(i.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(t.idBlock.fromBER(i,0,i.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(t.idBlock.hasOwnProperty(Eg)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:n};if(t.idBlock.hasOwnProperty($g)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:n};if(t.idBlock.hasOwnProperty(Cg)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:n};if(!(Ag in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:n};if(t.idBlock.isHexOnly){if(!(kl in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=t.idBlock.valueHexView,o=e.idBlock.valueHexView;if(s.length!==o.length)return{verified:!1,result:n};for(let c=0;c<s.length;c++)if(s[c]!==o[1])return{verified:!1,result:n}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Le),t.name&&(n[t.name]=e)),t instanceof D.Constructed){let s=0,o={verified:!1,result:{error:"Unknown error"}},c=t.valueBlock.value.length;if(c>0&&t.valueBlock.value[0]instanceof vr&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:n};if(e.valueBlock.value.length===0&&t.valueBlock.value.length!==0){let l=!0;for(let u=0;u<t.valueBlock.value.length;u++)l=l&&(t.valueBlock.value[u].optional||!1);return l?{verified:!0,result:n}:(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Le),t.name&&delete n[t.name]),n.error="Inconsistent object length",{verified:!1,result:n})}for(let l=0;l<c;l++)if(l-s>=e.valueBlock.value.length){if(t.valueBlock.value[l].optional===!1){const u={verified:!1,result:n};return n.error="Inconsistent length between ASN.1 data and schema",t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Le),t.name&&(delete n[t.name],u.name=t.name)),u}}else if(t.valueBlock.value[0]instanceof vr){if(o=Zt(n,e.valueBlock.value[l],t.valueBlock.value[0].value),o.verified===!1)if(t.valueBlock.value[0].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Le),t.name&&delete n[t.name]),o;if(io in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let u={};Ng in t.valueBlock.value[0]&&t.valueBlock.value[0].local?u=e:u=n,typeof u[t.valueBlock.value[0].name]>"u"&&(u[t.valueBlock.value[0].name]=[]),u[t.valueBlock.value[0].name].push(e.valueBlock.value[l])}}else if(o=Zt(n,e.valueBlock.value[l-s],t.valueBlock.value[l]),o.verified===!1)if(t.valueBlock.value[l].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Le),t.name&&delete n[t.name]),o;if(o.verified===!1){const l={verified:!1,result:n};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Le),t.name&&(delete n[t.name],l.name=t.name)),l}return{verified:!0,result:n}}if(t.primitiveSchema&&kl in e.valueBlock){const s=Hn(e.valueBlock.valueHexView);if(s.offset===-1){const o={verified:!1,result:s.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Le),t.name&&(delete n[t.name],o.name=t.name)),o}return Zt(n,s.result,t.primitiveSchema)}return{verified:!0,result:n}}function Lg(n,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=Hn(U.toUint8Array(n));return t.offset===-1?{verified:!1,result:t.result}:Zt(t.result,t.result,e)}const Vp=Object.freeze(Object.defineProperty({__proto__:null,Any:an,BaseBlock:$e,BaseStringBlock:Ya,BitString:en,BmpString:us,Boolean:as,CharacterString:vs,Choice:oc,Constructed:Ue,DATE:tc,DateTime:ic,Duration:rc,EndOfContent:Xa,Enumerated:cs,GeneralString:ys,GeneralizedTime:ws,GraphicString:ms,HexBlock:mt,IA5String:_s,Integer:gt,Null:on,NumericString:ps,ObjectIdentifier:ls,OctetString:Qt,Primitive:Ii,PrintableString:fs,RawData:Pg,RelativeObjectIdentifier:ec,Repeated:vr,Sequence:bt,Set:kt,TIME:sc,TeletexString:hs,TimeOfDay:nc,UTCTime:$i,UniversalString:ds,Utf8String:Ct,ValueBlock:Te,VideotexString:gs,ViewWriter:ss,VisibleString:Ei,compareSchema:Zt,fromBER:In,verifySchema:Lg},Symbol.toStringTag,{value:"Module"}));var z;(function(n){n[n.Sequence=0]="Sequence",n[n.Set=1]="Set",n[n.Choice=2]="Choice"})(z||(z={}));var y;(function(n){n[n.Any=1]="Any",n[n.Boolean=2]="Boolean",n[n.OctetString=3]="OctetString",n[n.BitString=4]="BitString",n[n.Integer=5]="Integer",n[n.Enumerated=6]="Enumerated",n[n.ObjectIdentifier=7]="ObjectIdentifier",n[n.Utf8String=8]="Utf8String",n[n.BmpString=9]="BmpString",n[n.UniversalString=10]="UniversalString",n[n.NumericString=11]="NumericString",n[n.PrintableString=12]="PrintableString",n[n.TeletexString=13]="TeletexString",n[n.VideotexString=14]="VideotexString",n[n.IA5String=15]="IA5String",n[n.GraphicString=16]="GraphicString",n[n.VisibleString=17]="VisibleString",n[n.GeneralString=18]="GeneralString",n[n.CharacterString=19]="CharacterString",n[n.UTCTime=20]="UTCTime",n[n.GeneralizedTime=21]="GeneralizedTime",n[n.DATE=22]="DATE",n[n.TimeOfDay=23]="TimeOfDay",n[n.DateTime=24]="DateTime",n[n.Duration=25]="Duration",n[n.TIME=26]="TIME",n[n.Null=27]="Null"})(y||(y={}));class bs{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(U.isBufferSource(e))this.unusedBits=t,this.value=U.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof en))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new en({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new en({name:e})}toNumber(){let e="";const t=new Uint8Array(this.value);for(const i of t)e+=i.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let t=e.toString(2);const i=t.length+7>>3;this.unusedBits=(i<<3)-t.length;const r=new Uint8Array(i);t=t.padStart(i<<3,"0").split("").reverse().join("");let s=0;for(;s<i;)r[s]=parseInt(t.slice(s<<3,(s<<3)+8),2),s++;this.value=r.buffer}}class re{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):U.isBufferSource(e)?this.buffer=U.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof Qt))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new Qt({valueHex:this.buffer})}toSchema(e){return new Qt({name:e})}}const Ug={fromASN:n=>n instanceof on?null:n.valueBeforeDecodeView,toASN:n=>{if(n===null)return new on;const e=In(n);if(e.result.error)throw new Error(e.result.error);return e.result}},Vg={fromASN:n=>n.valueBlock.valueHexView.byteLength>=4?n.valueBlock.toString():n.valueBlock.valueDec,toASN:n=>new gt({value:+n})},Mg={fromASN:n=>n.valueBlock.valueDec,toASN:n=>new cs({value:n})},he={fromASN:n=>n.valueBlock.valueHexView,toASN:n=>new gt({valueHex:n})},Hg={fromASN:n=>n.valueBlock.valueHexView,toASN:n=>new en({valueHex:n})},Dg={fromASN:n=>n.valueBlock.toString(),toASN:n=>new ls({value:n})},Fg={fromASN:n=>n.valueBlock.value,toASN:n=>new as({value:n})},wr={fromASN:n=>n.valueBlock.valueHexView,toASN:n=>new Qt({valueHex:n})},qg={fromASN:n=>new re(n.getValue()),toASN:n=>n.toASN()};function Qe(n){return{fromASN:e=>e.valueBlock.value,toASN:e=>new n({value:e})}}const Mp=Qe(Ct),Kg=Qe(us),Wg=Qe(ds),Gg=Qe(ps),Jg=Qe(fs),Zg=Qe(hs),Yg=Qe(gs),Xg=Qe(_s),Qg=Qe(ms),e_=Qe(Ei),t_=Qe(ys),n_=Qe(vs),i_={fromASN:n=>n.toDate(),toASN:n=>new $i({valueDate:n})},r_={fromASN:n=>n.toDate(),toASN:n=>new ws({valueDate:n})},s_={fromASN:()=>null,toASN:()=>new on};function ac(n){switch(n){case y.Any:return Ug;case y.BitString:return Hg;case y.BmpString:return Kg;case y.Boolean:return Fg;case y.CharacterString:return n_;case y.Enumerated:return Mg;case y.GeneralString:return t_;case y.GeneralizedTime:return r_;case y.GraphicString:return Qg;case y.IA5String:return Xg;case y.Integer:return Vg;case y.Null:return s_;case y.NumericString:return Gg;case y.ObjectIdentifier:return Dg;case y.OctetString:return wr;case y.PrintableString:return Jg;case y.TeletexString:return Zg;case y.UTCTime:return i_;case y.UniversalString:return Wg;case y.Utf8String:return Mp;case y.VideotexString:return Yg;case y.VisibleString:return e_;default:return null}}function wt(n){return typeof n=="function"&&n.prototype?n.prototype.toASN&&n.prototype.fromASN?!0:wt(n.prototype):!!(n&&typeof n=="object"&&"toASN"in n&&"fromASN"in n)}function Hp(n){var e;if(n){const t=Object.getPrototypeOf(n);return((e=t==null?void 0:t.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:Hp(t)}return!1}function o_(n,e){if(!(n&&e)||n.byteLength!==e.byteLength)return!1;const t=new Uint8Array(n),i=new Uint8Array(e);for(let r=0;r<n.byteLength;r++)if(t[r]!==i[r])return!1;return!0}class a_{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){const i=this.items.get(e);if(!i)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!i.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return i}cache(e){const t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){const t={type:z.Sequence,items:{}},i=this.findParentSchema(e);return i&&(Object.assign(t,i),t.items=Object.assign({},t.items,i.items)),t}create(e,t){const i=this.items.get(e)||this.createDefault(e),r=[];for(const s in i.items){const o=i.items[s],c=t?s:"";let l;if(typeof o.type=="number"){const p=y[o.type],g=Vp[p];if(!g)throw new Error(`Cannot get ASN1 class by name '${p}'`);l=new g({name:c})}else wt(o.type)?l=new o.type().toSchema(c):o.optional?this.get(o.type).type===z.Choice?l=new an({name:c}):(l=this.create(o.type,!1),l.name=c):l=new an({name:c});const u=!!o.optional||o.defaultValue!==void 0;if(o.repeated){l.name="";const p=o.repeated==="set"?kt:bt;l=new p({name:"",value:[new vr({name:c,value:l})]})}if(o.context!==null&&o.context!==void 0)if(o.implicit)if(typeof o.type=="number"||wt(o.type)){const p=o.repeated?Ue:Ii;r.push(new p({name:c,optional:u,idBlock:{tagClass:3,tagNumber:o.context}}))}else{this.cache(o.type);const p=!!o.repeated;let g=p?l:this.get(o.type,!0).schema;g="valueBlock"in g?g.valueBlock.value:g.value,r.push(new Ue({name:p?"":c,optional:u,idBlock:{tagClass:3,tagNumber:o.context},value:g}))}else r.push(new Ue({optional:u,idBlock:{tagClass:3,tagNumber:o.context},value:[l]}));else l.optional=u,r.push(l)}switch(i.type){case z.Sequence:return new bt({value:r,name:""});case z.Set:return new kt({value:r,name:""});case z.Choice:return new oc({value:r,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}}const Je=new a_,B=n=>e=>{let t;Je.has(e)?t=Je.get(e):(t=Je.createDefault(e),Je.set(e,t)),Object.assign(t,n)},f=n=>(e,t)=>{let i;Je.has(e.constructor)?i=Je.get(e.constructor):(i=Je.createDefault(e.constructor),Je.set(e.constructor,i));const r=Object.assign({},n);if(typeof r.type=="number"&&!r.converter){const s=ac(n.type);if(!s)throw new Error(`Cannot get default converter for property '${t}' of ${e.constructor.name}`);r.converter=s}i.items[t]=r};class Sl extends Error{constructor(){super(...arguments),this.schemas=[]}}class c_{static parse(e,t){const i=In(e);if(i.result.error)throw new Error(i.result.error);return this.fromASN(i.result,t)}static fromASN(e,t){var i;try{if(wt(t))return new t().fromASN(e);const r=Je.get(t);Je.cache(t);let s=r.schema;if(e.constructor===Ue&&r.type!==z.Choice){s=new Ue({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:r.schema.valueBlock.value});for(const l in r.items)delete e[l]}const o=Zt({},e,s);if(!o.verified)throw new Sl(`Data does not match to ${t.name} ASN1 schema. ${o.result.error}`);const c=new t;if(Hp(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.");const l=r.itemType;if(typeof l=="number"){const u=ac(l);if(!u)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);return t.from(e.valueBlock.value,p=>u.fromASN(p))}else return t.from(e.valueBlock.value,u=>this.fromASN(u,l))}for(const l in r.items){const u=o.result[l];if(!u)continue;const p=r.items[l],g=p.type;if(typeof g=="number"||wt(g)){const m=(i=p.converter)!==null&&i!==void 0?i:wt(g)?new g:null;if(!m)throw new Error("Converter is empty");if(p.repeated)if(p.implicit){const x=p.repeated==="sequence"?bt:kt,h=new x;h.valueBlock=u.valueBlock;const _=In(h.toBER(!1));if(_.offset===-1)throw new Error(`Cannot parse the child item. ${_.result.error}`);if(!("value"in _.result.valueBlock&&Array.isArray(_.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const b=_.result.valueBlock.value;c[l]=Array.from(b,S=>m.fromASN(S))}else c[l]=Array.from(u,x=>m.fromASN(x));else{let x=u;if(p.implicit){let h;if(wt(g))h=new g().toSchema("");else{const _=y[g],b=Vp[_];if(!b)throw new Error(`Cannot get '${_}' class from asn1js module`);h=new b}h.valueBlock=x.valueBlock,x=In(h.toBER(!1)).result}c[l]=m.fromASN(x)}}else if(p.repeated){if(!Array.isArray(u))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");c[l]=Array.from(u,m=>this.fromASN(m,g))}else c[l]=this.fromASN(u,g)}return c}catch(r){throw r instanceof Sl&&r.schemas.push(t.name),r}}}class cc{static serialize(e){return e instanceof $e?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&wt(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,i=Je.get(t);Je.cache(t);let r=[];if(i.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof i.itemType=="number"){const o=ac(i.itemType);if(!o)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);r=e.map(c=>o.toASN(c))}else r=e.map(o=>this.toAsnItem({type:i.itemType},"[]",t,o))}else for(const o in i.items){const c=i.items[o],l=e[o];if(l===void 0||c.defaultValue===l||typeof c.defaultValue=="object"&&typeof l=="object"&&o_(this.serialize(c.defaultValue),this.serialize(l)))continue;const u=cc.toAsnItem(c,o,t,l);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||wt(c.type))){const p={};p.valueHex=u instanceof on?u.valueBeforeDecodeView:u.valueBlock.toBER(),r.push(new Ii({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...p}))}else r.push(new Ue({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:u.valueBlock.value}));else r.push(new Ue({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[u]}));else c.repeated?r=r.concat(u):r.push(u)}let s;switch(i.type){case z.Sequence:s=new bt({value:r});break;case z.Set:s=new kt({value:r});break;case z.Choice:if(!r[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);s=r[0];break}return s}static toAsnItem(e,t,i,r){let s;if(typeof e.type=="number"){const o=e.converter;if(!o)throw new Error(`Property '${t}' doesn't have converter for type ${y[e.type]} in schema '${i.name}'`);if(e.repeated){if(!Array.isArray(r))throw new TypeError("Parameter 'objProp' should be type of Array.");const c=Array.from(r,u=>o.toASN(u)),l=e.repeated==="sequence"?bt:kt;s=new l({value:c})}else s=o.toASN(r)}else if(e.repeated){if(!Array.isArray(r))throw new TypeError("Parameter 'objProp' should be type of Array.");const o=Array.from(r,l=>this.toASN(l)),c=e.repeated==="sequence"?bt:kt;s=new c({value:o})}else s=this.toASN(r);return s}}class le extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class L{static serialize(e){return cc.serialize(e)}static parse(e,t){return c_.parse(e,t)}static toString(e){const t=U.isBufferSource(e)?U.toArrayBuffer(e):L.serialize(e),i=In(t);if(i.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${i.result.error}`);return i.result.toString()}}function d(n,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,i);else for(var c=n.length-1;c>=0;c--)(o=n[c])&&(s=(r<3?o(s):r>3?o(e,t,s):o(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s}var Dp={exports:{}};(function(n){(function(e){const t="(0?\\d+|0x[a-f0-9]+)",i={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},r=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),o="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",l={zoneIndex:new RegExp(o,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${o})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${t}\\.${t}\\.${t}\\.${t}(${o})?$`,"i")};function u(h,_){if(h.indexOf("::")!==h.lastIndexOf("::"))return null;let b=0,S=-1,N=(h.match(l.zoneIndex)||[])[0],T,q;for(N&&(N=N.substring(1),h=h.replace(/%.+$/,""));(S=h.indexOf(":",S+1))>=0;)b++;if(h.substr(0,2)==="::"&&b--,h.substr(-2,2)==="::"&&b--,b>_)return null;for(q=_-b,T=":";q--;)T+="0:";return h=h.replace("::",T),h[0]===":"&&(h=h.slice(1)),h[h.length-1]===":"&&(h=h.slice(0,-1)),_=function(){const oe=h.split(":"),pe=[];for(let ce=0;ce<oe.length;ce++)pe.push(parseInt(oe[ce],16));return pe}(),{parts:_,zoneId:N}}function p(h,_,b,S){if(h.length!==_.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let N=0,T;for(;S>0;){if(T=b-S,T<0&&(T=0),h[N]>>T!==_[N]>>T)return!1;S-=b,N+=1}return!0}function g(h){if(s.test(h))return parseInt(h,16);if(h[0]==="0"&&!isNaN(parseInt(h[1],10))){if(r.test(h))return parseInt(h,8);throw new Error(`ipaddr: cannot parse ${h} as octal`)}return parseInt(h,10)}function m(h,_){for(;h.length<_;)h=`0${h}`;return h}const x={};x.IPv4=function(){function h(_){if(_.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let b,S;for(b=0;b<_.length;b++)if(S=_[b],!(0<=S&&S<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=_}return h.prototype.SpecialRanges={unspecified:[[new h([0,0,0,0]),8]],broadcast:[[new h([255,255,255,255]),32]],multicast:[[new h([224,0,0,0]),4]],linkLocal:[[new h([169,254,0,0]),16]],loopback:[[new h([127,0,0,0]),8]],carrierGradeNat:[[new h([100,64,0,0]),10]],private:[[new h([10,0,0,0]),8],[new h([172,16,0,0]),12],[new h([192,168,0,0]),16]],reserved:[[new h([192,0,0,0]),24],[new h([192,0,2,0]),24],[new h([192,88,99,0]),24],[new h([198,18,0,0]),15],[new h([198,51,100,0]),24],[new h([203,0,113,0]),24],[new h([240,0,0,0]),4]],as112:[[new h([192,175,48,0]),24],[new h([192,31,196,0]),24]],amt:[[new h([192,52,193,0]),24]]},h.prototype.kind=function(){return"ipv4"},h.prototype.match=function(_,b){let S;if(b===void 0&&(S=_,_=S[0],b=S[1]),_.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return p(this.octets,_.octets,8,b)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,b=!1;const S={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let N,T,q;for(N=3;N>=0;N-=1)if(T=this.octets[N],T in S){if(q=S[T],b&&q!==0)return null;q!==8&&(b=!0),_+=q}else return null;return 32-_},h.prototype.range=function(){return x.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){return this.octets.slice(0)},h.prototype.toIPv4MappedAddress=function(){return x.IPv6.parse(`::ffff:${this.toString()}`)},h.prototype.toNormalizedString=function(){return this.toString()},h.prototype.toString=function(){return this.octets.join(".")},h}(),x.IPv4.broadcastAddressFromCIDR=function(h){try{const _=this.parseCIDR(h),b=_[0].toByteArray(),S=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[];let T=0;for(;T<4;)N.push(parseInt(b[T],10)|parseInt(S[T],10)^255),T++;return new this(N)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},x.IPv4.isIPv4=function(h){return this.parser(h)!==null},x.IPv4.isValid=function(h){try{return new this(this.parser(h)),!0}catch{return!1}},x.IPv4.isValidCIDR=function(h){try{return this.parseCIDR(h),!0}catch{return!1}},x.IPv4.isValidFourPartDecimal=function(h){return!!(x.IPv4.isValid(h)&&h.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},x.IPv4.networkAddressFromCIDR=function(h){let _,b,S,N,T;try{for(_=this.parseCIDR(h),S=_[0].toByteArray(),T=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[],b=0;b<4;)N.push(parseInt(S[b],10)&parseInt(T[b],10)),b++;return new this(N)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},x.IPv4.parse=function(h){const _=this.parser(h);if(_===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(_)},x.IPv4.parseCIDR=function(h){let _;if(_=h.match(/^(.+)\/(\d+)$/)){const b=parseInt(_[2]);if(b>=0&&b<=32){const S=[this.parse(_[1]),b];return Object.defineProperty(S,"toString",{value:function(){return this.join("/")}}),S}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},x.IPv4.parser=function(h){let _,b,S;if(_=h.match(i.fourOctet))return function(){const N=_.slice(1,6),T=[];for(let q=0;q<N.length;q++)b=N[q],T.push(g(b));return T}();if(_=h.match(i.longValue)){if(S=g(_[1]),S>4294967295||S<0)throw new Error("ipaddr: address outside defined range");return function(){const N=[];let T;for(T=0;T<=24;T+=8)N.push(S>>T&255);return N}().reverse()}else return(_=h.match(i.twoOctet))?function(){const N=_.slice(1,4),T=[];if(S=g(N[1]),S>16777215||S<0)throw new Error("ipaddr: address outside defined range");return T.push(g(N[0])),T.push(S>>16&255),T.push(S>>8&255),T.push(S&255),T}():(_=h.match(i.threeOctet))?function(){const N=_.slice(1,5),T=[];if(S=g(N[2]),S>65535||S<0)throw new Error("ipaddr: address outside defined range");return T.push(g(N[0])),T.push(g(N[1])),T.push(S>>8&255),T.push(S&255),T}():null},x.IPv4.subnetMaskFromPrefixLength=function(h){if(h=parseInt(h),h<0||h>32)throw new Error("ipaddr: invalid IPv4 prefix length");const _=[0,0,0,0];let b=0;const S=Math.floor(h/8);for(;b<S;)_[b]=255,b++;return S<4&&(_[S]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},x.IPv6=function(){function h(_,b){let S,N;if(_.length===16)for(this.parts=[],S=0;S<=14;S+=2)this.parts.push(_[S]<<8|_[S+1]);else if(_.length===8)this.parts=_;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(S=0;S<this.parts.length;S++)if(N=this.parts[S],!(0<=N&&N<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");b&&(this.zoneId=b)}return h.prototype.SpecialRanges={unspecified:[new h([0,0,0,0,0,0,0,0]),128],linkLocal:[new h([65152,0,0,0,0,0,0,0]),10],multicast:[new h([65280,0,0,0,0,0,0,0]),8],loopback:[new h([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new h([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new h([0,0,0,0,0,65535,0,0]),96],discard:[new h([256,0,0,0,0,0,0,0]),64],rfc6145:[new h([0,0,0,0,65535,0,0,0]),96],rfc6052:[new h([100,65435,0,0,0,0,0,0]),96],"6to4":[new h([8194,0,0,0,0,0,0,0]),16],teredo:[new h([8193,0,0,0,0,0,0,0]),32],benchmarking:[new h([8193,2,0,0,0,0,0,0]),48],amt:[new h([8193,3,0,0,0,0,0,0]),32],as112v6:[[new h([8193,4,274,0,0,0,0,0]),48],[new h([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new h([8193,16,0,0,0,0,0,0]),28],orchid2:[new h([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new h([8193,48,0,0,0,0,0,0]),28],reserved:[[new h([8193,0,0,0,0,0,0,0]),23],[new h([8193,3512,0,0,0,0,0,0]),32]]},h.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},h.prototype.kind=function(){return"ipv6"},h.prototype.match=function(_,b){let S;if(b===void 0&&(S=_,_=S[0],b=S[1]),_.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return p(this.parts,_.parts,16,b)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,b=!1;const S={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let N,T;for(let q=7;q>=0;q-=1)if(N=this.parts[q],N in S){if(T=S[N],b&&T!==0)return null;T!==16&&(b=!0),_+=T}else return null;return 128-_},h.prototype.range=function(){return x.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){let _;const b=[],S=this.parts;for(let N=0;N<S.length;N++)_=S[N],b.push(_>>8),b.push(_&255);return b},h.prototype.toFixedLengthString=function(){const _=(function(){const S=[];for(let N=0;N<this.parts.length;N++)S.push(m(this.parts[N].toString(16),4));return S}).call(this).join(":");let b="";return this.zoneId&&(b=`%${this.zoneId}`),_+b},h.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const _=this.parts.slice(-2),b=_[0],S=_[1];return new x.IPv4([b>>8,b&255,S>>8,S&255])},h.prototype.toNormalizedString=function(){const _=(function(){const S=[];for(let N=0;N<this.parts.length;N++)S.push(this.parts[N].toString(16));return S}).call(this).join(":");let b="";return this.zoneId&&(b=`%${this.zoneId}`),_+b},h.prototype.toRFC5952String=function(){const _=/((^|:)(0(:|$)){2,})/g,b=this.toNormalizedString();let S=0,N=-1,T;for(;T=_.exec(b);)T[0].length>N&&(S=T.index,N=T[0].length);return N<0?b:`${b.substring(0,S)}::${b.substring(S+N)}`},h.prototype.toString=function(){return this.toRFC5952String()},h}(),x.IPv6.broadcastAddressFromCIDR=function(h){try{const _=this.parseCIDR(h),b=_[0].toByteArray(),S=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[];let T=0;for(;T<16;)N.push(parseInt(b[T],10)|parseInt(S[T],10)^255),T++;return new this(N)}catch(_){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${_})`)}},x.IPv6.isIPv6=function(h){return this.parser(h)!==null},x.IPv6.isValid=function(h){if(typeof h=="string"&&h.indexOf(":")===-1)return!1;try{const _=this.parser(h);return new this(_.parts,_.zoneId),!0}catch{return!1}},x.IPv6.isValidCIDR=function(h){if(typeof h=="string"&&h.indexOf(":")===-1)return!1;try{return this.parseCIDR(h),!0}catch{return!1}},x.IPv6.networkAddressFromCIDR=function(h){let _,b,S,N,T;try{for(_=this.parseCIDR(h),S=_[0].toByteArray(),T=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),N=[],b=0;b<16;)N.push(parseInt(S[b],10)&parseInt(T[b],10)),b++;return new this(N)}catch(q){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${q})`)}},x.IPv6.parse=function(h){const _=this.parser(h);if(_.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(_.parts,_.zoneId)},x.IPv6.parseCIDR=function(h){let _,b,S;if((b=h.match(/^(.+)\/(\d+)$/))&&(_=parseInt(b[2]),_>=0&&_<=128))return S=[this.parse(b[1]),_],Object.defineProperty(S,"toString",{value:function(){return this.join("/")}}),S;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},x.IPv6.parser=function(h){let _,b,S,N,T,q;if(S=h.match(l.deprecatedTransitional))return this.parser(`::ffff:${S[1]}`);if(l.native.test(h))return u(h,8);if((S=h.match(l.transitional))&&(q=S[6]||"",_=S[1],S[1].endsWith("::")||(_=_.slice(0,-1)),_=u(_+q,6),_.parts)){for(T=[parseInt(S[2]),parseInt(S[3]),parseInt(S[4]),parseInt(S[5])],b=0;b<T.length;b++)if(N=T[b],!(0<=N&&N<=255))return null;return _.parts.push(T[0]<<8|T[1]),_.parts.push(T[2]<<8|T[3]),{parts:_.parts,zoneId:_.zoneId}}return null},x.IPv6.subnetMaskFromPrefixLength=function(h){if(h=parseInt(h),h<0||h>128)throw new Error("ipaddr: invalid IPv6 prefix length");const _=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let b=0;const S=Math.floor(h/8);for(;b<S;)_[b]=255,b++;return S<16&&(_[S]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},x.fromByteArray=function(h){const _=h.length;if(_===4)return new x.IPv4(h);if(_===16)return new x.IPv6(h);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},x.isValid=function(h){return x.IPv6.isValid(h)||x.IPv4.isValid(h)},x.isValidCIDR=function(h){return x.IPv6.isValidCIDR(h)||x.IPv4.isValidCIDR(h)},x.parse=function(h){if(x.IPv6.isValid(h))return x.IPv6.parse(h);if(x.IPv4.isValid(h))return x.IPv4.parse(h);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},x.parseCIDR=function(h){try{return x.IPv6.parseCIDR(h)}catch{try{return x.IPv4.parseCIDR(h)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},x.process=function(h){const _=this.parse(h);return _.kind()==="ipv6"&&_.isIPv4MappedAddress()?_.toIPv4Address():_},x.subnetMatch=function(h,_,b){let S,N,T,q;b==null&&(b="unicast");for(N in _)if(Object.prototype.hasOwnProperty.call(_,N)){for(T=_[N],T[0]&&!(T[0]instanceof Array)&&(T=[T]),S=0;S<T.length;S++)if(q=T[S],h.kind()===q[0].kind()&&h.match.apply(h,q))return N}return b},n.exports?n.exports=x:e.ipaddr=x})(mr)})(Dp);var Al=Dp.exports;class Il{static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const t=parseInt(e.slice(8),16).toString(2).split("").reduce((r,s)=>r+ +s,0);let i=e.slice(0,8).replace(/(.{2})/g,r=>`${parseInt(r,16)}.`);return i=i.slice(0,-1),`${i}/${t}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const t=new Uint8Array(e);return Al.fromByteArray(Array.from(t)).toString()}return this.decodeIP(W.ToHex(e))}static fromString(e){const t=Al.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var So,Ao,Io;let Ce=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};d([f({type:y.TeletexString})],Ce.prototype,"teletexString",void 0);d([f({type:y.PrintableString})],Ce.prototype,"printableString",void 0);d([f({type:y.UniversalString})],Ce.prototype,"universalString",void 0);d([f({type:y.Utf8String})],Ce.prototype,"utf8String",void 0);d([f({type:y.BmpString})],Ce.prototype,"bmpString",void 0);Ce=d([B({type:z.Choice})],Ce);let jn=class extends Ce{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?W.ToHex(this.anyValue):super.toString())}};d([f({type:y.IA5String})],jn.prototype,"ia5String",void 0);d([f({type:y.Any})],jn.prototype,"anyValue",void 0);jn=d([B({type:z.Choice})],jn);class ks{constructor(e={}){this.type="",this.value=new jn,Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],ks.prototype,"type",void 0);d([f({type:jn})],ks.prototype,"value",void 0);let zn=So=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,So.prototype)}};zn=So=d([B({type:z.Set,itemType:ks})],zn);let Eo=Ao=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Ao.prototype)}};Eo=Ao=d([B({type:z.Sequence,itemType:zn})],Eo);let ve=Io=class extends Eo{constructor(e){super(e),Object.setPrototypeOf(this,Io.prototype)}};ve=Io=d([B({type:z.Sequence})],ve);const l_={fromASN:n=>Il.toString(wr.fromASN(n)),toASN:n=>wr.toASN(Il.fromString(n))};class fi{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],fi.prototype,"typeId",void 0);d([f({type:y.Any,context:0})],fi.prototype,"value",void 0);class lc{constructor(e={}){this.partyName=new Ce,Object.assign(this,e)}}d([f({type:Ce,optional:!0,context:0,implicit:!0})],lc.prototype,"nameAssigner",void 0);d([f({type:Ce,context:1,implicit:!0})],lc.prototype,"partyName",void 0);let Q=class{constructor(e={}){Object.assign(this,e)}};d([f({type:fi,context:0,implicit:!0})],Q.prototype,"otherName",void 0);d([f({type:y.IA5String,context:1,implicit:!0})],Q.prototype,"rfc822Name",void 0);d([f({type:y.IA5String,context:2,implicit:!0})],Q.prototype,"dNSName",void 0);d([f({type:y.Any,context:3,implicit:!0})],Q.prototype,"x400Address",void 0);d([f({type:ve,context:4,implicit:!1})],Q.prototype,"directoryName",void 0);d([f({type:lc,context:5})],Q.prototype,"ediPartyName",void 0);d([f({type:y.IA5String,context:6,implicit:!0})],Q.prototype,"uniformResourceIdentifier",void 0);d([f({type:y.OctetString,context:7,implicit:!0,converter:l_})],Q.prototype,"iPAddress",void 0);d([f({type:y.ObjectIdentifier,context:8,implicit:!0})],Q.prototype,"registeredID",void 0);Q=d([B({type:z.Choice})],Q);const uc="1.3.6.1.5.5.7",u_=`${uc}.1`,Dn=`${uc}.3`,xs=`${uc}.48`,El=`${xs}.1`,$l=`${xs}.2`,Cl=`${xs}.3`,jl=`${xs}.5`,Ht="2.5.29";var $o;const Co=`${u_}.1`;class Ci{constructor(e={}){this.accessMethod="",this.accessLocation=new Q,Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Ci.prototype,"accessMethod",void 0);d([f({type:Q})],Ci.prototype,"accessLocation",void 0);let Sn=$o=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,$o.prototype)}};Sn=$o=d([B({type:z.Sequence,itemType:Ci})],Sn);const jo=`${Ht}.35`;class dc extends re{}class Yt{constructor(e={}){e&&Object.assign(this,e)}}d([f({type:dc,context:0,optional:!0,implicit:!0})],Yt.prototype,"keyIdentifier",void 0);d([f({type:Q,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Yt.prototype,"authorityCertIssuer",void 0);d([f({type:y.Integer,context:2,optional:!0,implicit:!0,converter:he})],Yt.prototype,"authorityCertSerialNumber",void 0);const Fp=`${Ht}.19`;class br{constructor(e={}){this.cA=!1,Object.assign(this,e)}}d([f({type:y.Boolean,defaultValue:!1})],br.prototype,"cA",void 0);d([f({type:y.Integer,optional:!0})],br.prototype,"pathLenConstraint",void 0);var zo;let Be=zo=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,zo.prototype)}};Be=zo=d([B({type:z.Sequence,itemType:Q})],Be);var No;let zl=No=class extends Be{constructor(e){super(e),Object.setPrototypeOf(this,No.prototype)}};zl=No=d([B({type:z.Sequence})],zl);var Oo;const qp=`${Ht}.32`;let xt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};d([f({type:y.IA5String})],xt.prototype,"ia5String",void 0);d([f({type:y.VisibleString})],xt.prototype,"visibleString",void 0);d([f({type:y.BmpString})],xt.prototype,"bmpString",void 0);d([f({type:y.Utf8String})],xt.prototype,"utf8String",void 0);xt=d([B({type:z.Choice})],xt);class pc{constructor(e={}){this.organization=new xt,this.noticeNumbers=[],Object.assign(this,e)}}d([f({type:xt})],pc.prototype,"organization",void 0);d([f({type:y.Integer,repeated:"sequence"})],pc.prototype,"noticeNumbers",void 0);class fc{constructor(e={}){Object.assign(this,e)}}d([f({type:pc,optional:!0})],fc.prototype,"noticeRef",void 0);d([f({type:xt,optional:!0})],fc.prototype,"explicitText",void 0);let kr=class{constructor(e={}){Object.assign(this,e)}};d([f({type:y.IA5String})],kr.prototype,"cPSuri",void 0);d([f({type:fc})],kr.prototype,"userNotice",void 0);kr=d([B({type:z.Choice})],kr);class hc{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],hc.prototype,"policyQualifierId",void 0);d([f({type:y.Any})],hc.prototype,"qualifier",void 0);class Ss{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Ss.prototype,"policyIdentifier",void 0);d([f({type:hc,repeated:"sequence",optional:!0})],Ss.prototype,"policyQualifiers",void 0);let xr=Oo=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Oo.prototype)}};xr=Oo=d([B({type:z.Sequence,itemType:Ss})],xr);let Sr=class{constructor(e=0){this.value=e}};d([f({type:y.Integer})],Sr.prototype,"value",void 0);Sr=d([B({type:z.Choice})],Sr);let Nl=class extends Sr{};Nl=d([B({type:z.Choice})],Nl);var Bo;const To=`${Ht}.31`;var rt;(function(n){n[n.unused=1]="unused",n[n.keyCompromise=2]="keyCompromise",n[n.cACompromise=4]="cACompromise",n[n.affiliationChanged=8]="affiliationChanged",n[n.superseded=16]="superseded",n[n.cessationOfOperation=32]="cessationOfOperation",n[n.certificateHold=64]="certificateHold",n[n.privilegeWithdrawn=128]="privilegeWithdrawn",n[n.aACompromise=256]="aACompromise"})(rt||(rt={}));class Kp extends bs{toJSON(){const e=[],t=this.toNumber();return t&rt.aACompromise&&e.push("aACompromise"),t&rt.affiliationChanged&&e.push("affiliationChanged"),t&rt.cACompromise&&e.push("cACompromise"),t&rt.certificateHold&&e.push("certificateHold"),t&rt.cessationOfOperation&&e.push("cessationOfOperation"),t&rt.keyCompromise&&e.push("keyCompromise"),t&rt.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&rt.superseded&&e.push("superseded"),t&rt.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let cn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Q,context:0,repeated:"sequence",implicit:!0})],cn.prototype,"fullName",void 0);d([f({type:zn,context:1,implicit:!0})],cn.prototype,"nameRelativeToCRLIssuer",void 0);cn=d([B({type:z.Choice})],cn);class Fn{constructor(e={}){Object.assign(this,e)}}d([f({type:cn,context:0,optional:!0})],Fn.prototype,"distributionPoint",void 0);d([f({type:Kp,context:1,optional:!0,implicit:!0})],Fn.prototype,"reasons",void 0);d([f({type:Q,context:2,optional:!0,repeated:"sequence",implicit:!0})],Fn.prototype,"cRLIssuer",void 0);let En=Bo=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Bo.prototype)}};En=Bo=d([B({type:z.Sequence,itemType:Fn})],En);var Ro;let Ol=Ro=class extends En{constructor(e){super(e),Object.setPrototypeOf(this,Ro.prototype)}};Ol=Ro=d([B({type:z.Sequence,itemType:Fn})],Ol);class ze{constructor(e={}){this.onlyContainsUserCerts=ze.ONLY,this.onlyContainsCACerts=ze.ONLY,this.indirectCRL=ze.ONLY,this.onlyContainsAttributeCerts=ze.ONLY,Object.assign(this,e)}}ze.ONLY=!1;d([f({type:cn,context:0,optional:!0})],ze.prototype,"distributionPoint",void 0);d([f({type:y.Boolean,context:1,defaultValue:ze.ONLY,implicit:!0})],ze.prototype,"onlyContainsUserCerts",void 0);d([f({type:y.Boolean,context:2,defaultValue:ze.ONLY,implicit:!0})],ze.prototype,"onlyContainsCACerts",void 0);d([f({type:Kp,context:3,optional:!0,implicit:!0})],ze.prototype,"onlySomeReasons",void 0);d([f({type:y.Boolean,context:4,defaultValue:ze.ONLY,implicit:!0})],ze.prototype,"indirectCRL",void 0);d([f({type:y.Boolean,context:5,defaultValue:ze.ONLY,implicit:!0})],ze.prototype,"onlyContainsAttributeCerts",void 0);var si;(function(n){n[n.unspecified=0]="unspecified",n[n.keyCompromise=1]="keyCompromise",n[n.cACompromise=2]="cACompromise",n[n.affiliationChanged=3]="affiliationChanged",n[n.superseded=4]="superseded",n[n.cessationOfOperation=5]="cessationOfOperation",n[n.certificateHold=6]="certificateHold",n[n.removeFromCRL=8]="removeFromCRL",n[n.privilegeWithdrawn=9]="privilegeWithdrawn",n[n.aACompromise=10]="aACompromise"})(si||(si={}));let Po=class{constructor(e=si.unspecified){this.reason=si.unspecified,this.reason=e}toJSON(){return si[this.reason]}toString(){return this.toJSON()}};d([f({type:y.Enumerated})],Po.prototype,"reason",void 0);Po=d([B({type:z.Choice})],Po);var Lo;const Wp=`${Ht}.37`;let Ar=Lo=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Lo.prototype)}};Ar=Lo=d([B({type:z.Sequence,itemType:y.ObjectIdentifier})],Ar);const d_=`${Dn}.1`,p_=`${Dn}.2`,f_=`${Dn}.3`,h_=`${Dn}.4`,g_=`${Dn}.8`,__=`${Dn}.9`;let Uo=class{constructor(e=new ArrayBuffer(0)){this.value=e}};d([f({type:y.Integer,converter:he})],Uo.prototype,"value",void 0);Uo=d([B({type:z.Choice})],Uo);let Vo=class{constructor(e){this.value=new Date,e&&(this.value=e)}};d([f({type:y.GeneralizedTime})],Vo.prototype,"value",void 0);Vo=d([B({type:z.Choice})],Vo);var Mo;let Bl=Mo=class extends Be{constructor(e){super(e),Object.setPrototypeOf(this,Mo.prototype)}};Bl=Mo=d([B({type:z.Sequence})],Bl);const Gp=`${Ht}.15`;var st;(function(n){n[n.digitalSignature=1]="digitalSignature",n[n.nonRepudiation=2]="nonRepudiation",n[n.keyEncipherment=4]="keyEncipherment",n[n.dataEncipherment=8]="dataEncipherment",n[n.keyAgreement=16]="keyAgreement",n[n.keyCertSign=32]="keyCertSign",n[n.cRLSign=64]="cRLSign",n[n.encipherOnly=128]="encipherOnly",n[n.decipherOnly=256]="decipherOnly"})(st||(st={}));class ro extends bs{toJSON(){const e=this.toNumber(),t=[];return e&st.cRLSign&&t.push("crlSign"),e&st.dataEncipherment&&t.push("dataEncipherment"),e&st.decipherOnly&&t.push("decipherOnly"),e&st.digitalSignature&&t.push("digitalSignature"),e&st.encipherOnly&&t.push("encipherOnly"),e&st.keyAgreement&&t.push("keyAgreement"),e&st.keyCertSign&&t.push("keyCertSign"),e&st.keyEncipherment&&t.push("keyEncipherment"),e&st.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var Ho;class As{constructor(e={}){this.base=new Q,this.minimum=0,Object.assign(this,e)}}d([f({type:Q})],As.prototype,"base",void 0);d([f({type:y.Integer,context:0,defaultValue:0,implicit:!0})],As.prototype,"minimum",void 0);d([f({type:y.Integer,context:1,optional:!0,implicit:!0})],As.prototype,"maximum",void 0);let Ir=Ho=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Ho.prototype)}};Ir=Ho=d([B({type:z.Sequence,itemType:As})],Ir);class Jp{constructor(e={}){Object.assign(this,e)}}d([f({type:Ir,context:0,optional:!0,implicit:!0})],Jp.prototype,"permittedSubtrees",void 0);d([f({type:Ir,context:1,optional:!0,implicit:!0})],Jp.prototype,"excludedSubtrees",void 0);class Zp{constructor(e={}){Object.assign(this,e)}}d([f({type:y.Integer,context:0,implicit:!0,optional:!0,converter:he})],Zp.prototype,"requireExplicitPolicy",void 0);d([f({type:y.Integer,context:1,implicit:!0,optional:!0,converter:he})],Zp.prototype,"inhibitPolicyMapping",void 0);var Do;class gc{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],gc.prototype,"issuerDomainPolicy",void 0);d([f({type:y.ObjectIdentifier})],gc.prototype,"subjectDomainPolicy",void 0);let Tl=Do=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Do.prototype)}};Tl=Do=d([B({type:z.Sequence,itemType:gc})],Tl);var Fo;const Yp=`${Ht}.17`;let qo=Fo=class extends Be{constructor(e){super(e),Object.setPrototypeOf(this,Fo.prototype)}};qo=Fo=d([B({type:z.Sequence})],qo);let St=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};d([f({type:y.ObjectIdentifier})],St.prototype,"type",void 0);d([f({type:y.Any,repeated:"set"})],St.prototype,"values",void 0);var Ko;let Rl=Ko=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Ko.prototype)}};Rl=Ko=d([B({type:z.Sequence,itemType:St})],Rl);const Xp=`${Ht}.14`;class Rt extends dc{}class Qp{constructor(e={}){Object.assign(this,e)}}d([f({type:y.GeneralizedTime,context:0,implicit:!0,optional:!0})],Qp.prototype,"notBefore",void 0);d([f({type:y.GeneralizedTime,context:1,implicit:!0,optional:!0})],Qp.prototype,"notAfter",void 0);var oi;(function(n){n[n.keyUpdateAllowed=1]="keyUpdateAllowed",n[n.newExtensions=2]="newExtensions",n[n.pKIXCertificate=4]="pKIXCertificate"})(oi||(oi={}));class ef extends bs{toJSON(){const e=[],t=this.toNumber();return t&oi.pKIXCertificate&&e.push("pKIXCertificate"),t&oi.newExtensions&&e.push("newExtensions"),t&oi.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class tf{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new ef,Object.assign(this,e)}}d([f({type:y.GeneralString})],tf.prototype,"entrustVers",void 0);d([f({type:ef})],tf.prototype,"entrustInfoFlags",void 0);var Wo;let Pl=Wo=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Wo.prototype)}};Pl=Wo=d([B({type:z.Sequence,itemType:Ci})],Pl);class H{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof H&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Md(e.parameters,this.parameters)||e.parameters===this.parameters)}}d([f({type:y.ObjectIdentifier})],H.prototype,"algorithm",void 0);d([f({type:y.Any,optional:!0})],H.prototype,"parameters",void 0);class ot{constructor(e={}){this.algorithm=new H,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:H})],ot.prototype,"algorithm",void 0);d([f({type:y.BitString})],ot.prototype,"subjectPublicKey",void 0);let Ee=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){const t=new Date(e);t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){const e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};d([f({type:y.UTCTime})],Ee.prototype,"utcTime",void 0);d([f({type:y.GeneralizedTime})],Ee.prototype,"generalTime",void 0);Ee=d([B({type:z.Choice})],Ee);class ji{constructor(e){this.notBefore=new Ee(new Date),this.notAfter=new Ee(new Date),e&&(this.notBefore=new Ee(e.notBefore),this.notAfter=new Ee(e.notAfter))}}d([f({type:Ee})],ji.prototype,"notBefore",void 0);d([f({type:Ee})],ji.prototype,"notAfter",void 0);var Go;let Xe=class nf{constructor(e={}){this.extnID="",this.critical=nf.CRITICAL,this.extnValue=new re,Object.assign(this,e)}};Xe.CRITICAL=!1;d([f({type:y.ObjectIdentifier})],Xe.prototype,"extnID",void 0);d([f({type:y.Boolean,defaultValue:Xe.CRITICAL})],Xe.prototype,"critical",void 0);d([f({type:re})],Xe.prototype,"extnValue",void 0);let Lt=Go=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Go.prototype)}};Lt=Go=d([B({type:z.Sequence,itemType:Xe})],Lt);var ln;(function(n){n[n.v1=0]="v1",n[n.v2=1]="v2",n[n.v3=2]="v3"})(ln||(ln={}));class Ge{constructor(e={}){this.version=ln.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new H,this.issuer=new ve,this.validity=new ji,this.subject=new ve,this.subjectPublicKeyInfo=new ot,Object.assign(this,e)}}d([f({type:y.Integer,context:0,defaultValue:ln.v1})],Ge.prototype,"version",void 0);d([f({type:y.Integer,converter:he})],Ge.prototype,"serialNumber",void 0);d([f({type:H})],Ge.prototype,"signature",void 0);d([f({type:ve})],Ge.prototype,"issuer",void 0);d([f({type:ji})],Ge.prototype,"validity",void 0);d([f({type:ve})],Ge.prototype,"subject",void 0);d([f({type:ot})],Ge.prototype,"subjectPublicKeyInfo",void 0);d([f({type:y.BitString,context:1,implicit:!0,optional:!0})],Ge.prototype,"issuerUniqueID",void 0);d([f({type:y.BitString,context:2,implicit:!0,optional:!0})],Ge.prototype,"subjectUniqueID",void 0);d([f({type:Lt,context:3,optional:!0})],Ge.prototype,"extensions",void 0);class un{constructor(e={}){this.tbsCertificate=new Ge,this.signatureAlgorithm=new H,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:Ge})],un.prototype,"tbsCertificate",void 0);d([f({type:H})],un.prototype,"signatureAlgorithm",void 0);d([f({type:y.BitString})],un.prototype,"signatureValue",void 0);class Is{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Ee,Object.assign(this,e)}}d([f({type:y.Integer,converter:he})],Is.prototype,"userCertificate",void 0);d([f({type:Ee})],Is.prototype,"revocationDate",void 0);d([f({type:Xe,optional:!0,repeated:"sequence"})],Is.prototype,"crlEntryExtensions",void 0);class jt{constructor(e={}){this.signature=new H,this.issuer=new ve,this.thisUpdate=new Ee,Object.assign(this,e)}}d([f({type:y.Integer,optional:!0})],jt.prototype,"version",void 0);d([f({type:H})],jt.prototype,"signature",void 0);d([f({type:ve})],jt.prototype,"issuer",void 0);d([f({type:Ee})],jt.prototype,"thisUpdate",void 0);d([f({type:Ee,optional:!0})],jt.prototype,"nextUpdate",void 0);d([f({type:Is,repeated:"sequence",optional:!0})],jt.prototype,"revokedCertificates",void 0);d([f({type:Xe,optional:!0,context:0,repeated:"sequence"})],jt.prototype,"crlExtensions",void 0);class _c{constructor(e={}){this.tbsCertList=new jt,this.signatureAlgorithm=new H,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:jt})],_c.prototype,"tbsCertList",void 0);d([f({type:H})],_c.prototype,"signatureAlgorithm",void 0);d([f({type:y.BitString})],_c.prototype,"signature",void 0);class qn{constructor(e={}){this.issuer=new ve,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:ve})],qn.prototype,"issuer",void 0);d([f({type:y.Integer,converter:he})],qn.prototype,"serialNumber",void 0);let Nn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Rt,context:0,implicit:!0})],Nn.prototype,"subjectKeyIdentifier",void 0);d([f({type:qn})],Nn.prototype,"issuerAndSerialNumber",void 0);Nn=d([B({type:z.Choice})],Nn);var At;(function(n){n[n.v0=0]="v0",n[n.v1=1]="v1",n[n.v2=2]="v2",n[n.v3=3]="v3",n[n.v4=4]="v4",n[n.v5=5]="v5"})(At||(At={}));let hi=class extends H{};hi=d([B({type:z.Sequence})],hi);let Er=class extends H{};Er=d([B({type:z.Sequence})],Er);let _t=class extends H{};_t=d([B({type:z.Sequence})],_t);let $r=class extends H{};$r=d([B({type:z.Sequence})],$r);let Ll=class extends H{};Ll=d([B({type:z.Sequence})],Ll);let Jo=class extends H{};Jo=d([B({type:z.Sequence})],Jo);let Kn=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};d([f({type:y.ObjectIdentifier})],Kn.prototype,"attrType",void 0);d([f({type:y.Any,repeated:"set"})],Kn.prototype,"attrValues",void 0);var Zo;class yt{constructor(e={}){this.version=At.v0,this.sid=new Nn,this.digestAlgorithm=new hi,this.signatureAlgorithm=new Er,this.signature=new re,Object.assign(this,e)}}d([f({type:y.Integer})],yt.prototype,"version",void 0);d([f({type:Nn})],yt.prototype,"sid",void 0);d([f({type:hi})],yt.prototype,"digestAlgorithm",void 0);d([f({type:Kn,repeated:"set",context:0,implicit:!0,optional:!0})],yt.prototype,"signedAttrs",void 0);d([f({type:Er})],yt.prototype,"signatureAlgorithm",void 0);d([f({type:re})],yt.prototype,"signature",void 0);d([f({type:Kn,repeated:"set",context:1,implicit:!0,optional:!0})],yt.prototype,"unsignedAttrs",void 0);let Cr=Zo=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Zo.prototype)}};Cr=Zo=d([B({type:z.Set,itemType:yt})],Cr);let Ul=class extends Ee{};Ul=d([B({type:z.Choice})],Ul);let Vl=class extends yt{};Vl=d([B({type:z.Sequence})],Vl);class mc{constructor(e={}){this.acIssuer=new Q,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}d([f({type:Q})],mc.prototype,"acIssuer",void 0);d([f({type:y.Integer})],mc.prototype,"acSerial",void 0);d([f({type:St,repeated:"sequence"})],mc.prototype,"attrs",void 0);var Yo;let jr=Yo=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,Yo.prototype)}};jr=Yo=d([B({type:z.Sequence,itemType:y.ObjectIdentifier})],jr);class Es{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}d([f({type:y.Integer,optional:!0})],Es.prototype,"pathLenConstraint",void 0);d([f({type:jr,implicit:!0,context:0,optional:!0})],Es.prototype,"permittedAttrs",void 0);d([f({type:jr,implicit:!0,context:1,optional:!0})],Es.prototype,"excludedAttrs",void 0);d([f({type:y.Boolean,defaultValue:!0})],Es.prototype,"permitUnSpecified",void 0);class yn{constructor(e={}){this.issuer=new Be,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:Be})],yn.prototype,"issuer",void 0);d([f({type:y.Integer,converter:he})],yn.prototype,"serial",void 0);d([f({type:y.BitString,optional:!0})],yn.prototype,"issuerUID",void 0);var Xo;(function(n){n[n.publicKey=0]="publicKey",n[n.publicKeyCert=1]="publicKeyCert",n[n.otherObjectTypes=2]="otherObjectTypes"})(Xo||(Xo={}));class vn{constructor(e={}){this.digestedObjectType=Xo.publicKey,this.digestAlgorithm=new H,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.Enumerated})],vn.prototype,"digestedObjectType",void 0);d([f({type:y.ObjectIdentifier,optional:!0})],vn.prototype,"otherObjectTypeID",void 0);d([f({type:H})],vn.prototype,"digestAlgorithm",void 0);d([f({type:y.BitString})],vn.prototype,"objectDigest",void 0);class $s{constructor(e={}){Object.assign(this,e)}}d([f({type:Be,optional:!0})],$s.prototype,"issuerName",void 0);d([f({type:yn,context:0,implicit:!0,optional:!0})],$s.prototype,"baseCertificateID",void 0);d([f({type:vn,context:1,implicit:!0,optional:!0})],$s.prototype,"objectDigestInfo",void 0);let On=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Q,repeated:"sequence"})],On.prototype,"v1Form",void 0);d([f({type:$s,context:0,implicit:!0})],On.prototype,"v2Form",void 0);On=d([B({type:z.Choice})],On);class Cs{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}d([f({type:y.GeneralizedTime})],Cs.prototype,"notBeforeTime",void 0);d([f({type:y.GeneralizedTime})],Cs.prototype,"notAfterTime",void 0);class zi{constructor(e={}){Object.assign(this,e)}}d([f({type:yn,implicit:!0,context:0,optional:!0})],zi.prototype,"baseCertificateID",void 0);d([f({type:Be,implicit:!0,context:1,optional:!0})],zi.prototype,"entityName",void 0);d([f({type:vn,implicit:!0,context:2,optional:!0})],zi.prototype,"objectDigestInfo",void 0);var Qo;(function(n){n[n.v2=1]="v2"})(Qo||(Qo={}));class lt{constructor(e={}){this.version=Qo.v2,this.holder=new zi,this.issuer=new On,this.signature=new H,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Cs,this.attributes=[],Object.assign(this,e)}}d([f({type:y.Integer})],lt.prototype,"version",void 0);d([f({type:zi})],lt.prototype,"holder",void 0);d([f({type:On})],lt.prototype,"issuer",void 0);d([f({type:H})],lt.prototype,"signature",void 0);d([f({type:y.Integer,converter:he})],lt.prototype,"serialNumber",void 0);d([f({type:Cs})],lt.prototype,"attrCertValidityPeriod",void 0);d([f({type:St,repeated:"sequence"})],lt.prototype,"attributes",void 0);d([f({type:y.BitString,optional:!0})],lt.prototype,"issuerUniqueID",void 0);d([f({type:Lt,optional:!0})],lt.prototype,"extensions",void 0);class js{constructor(e={}){this.acinfo=new lt,this.signatureAlgorithm=new H,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:lt})],js.prototype,"acinfo",void 0);d([f({type:H})],js.prototype,"signatureAlgorithm",void 0);d([f({type:y.BitString})],js.prototype,"signatureValue",void 0);var zr;(function(n){n[n.unmarked=1]="unmarked",n[n.unclassified=2]="unclassified",n[n.restricted=4]="restricted",n[n.confidential=8]="confidential",n[n.secret=16]="secret",n[n.topSecret=32]="topSecret"})(zr||(zr={}));class ea extends bs{}class yc{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier,implicit:!0,context:0})],yc.prototype,"type",void 0);d([f({type:y.Any,implicit:!0,context:1})],yc.prototype,"value",void 0);class vc{constructor(e={}){this.policyId="",this.classList=new ea(zr.unclassified),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],vc.prototype,"policyId",void 0);d([f({type:ea,defaultValue:new ea(zr.unclassified)})],vc.prototype,"classList",void 0);d([f({type:yc,repeated:"set"})],vc.prototype,"securityCategories",void 0);class zs{constructor(e={}){Object.assign(this,e)}}d([f({type:re})],zs.prototype,"cotets",void 0);d([f({type:y.ObjectIdentifier})],zs.prototype,"oid",void 0);d([f({type:y.Utf8String})],zs.prototype,"string",void 0);class rf{constructor(e={}){this.values=[],Object.assign(this,e)}}d([f({type:Be,implicit:!0,context:0,optional:!0})],rf.prototype,"policyAuthority",void 0);d([f({type:zs,repeated:"sequence"})],rf.prototype,"values",void 0);var ta;class Ns{constructor(e={}){this.targetCertificate=new yn,Object.assign(this,e)}}d([f({type:yn})],Ns.prototype,"targetCertificate",void 0);d([f({type:Q,optional:!0})],Ns.prototype,"targetName",void 0);d([f({type:vn,optional:!0})],Ns.prototype,"certDigestInfo",void 0);let Bn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Q,context:0,implicit:!0})],Bn.prototype,"targetName",void 0);d([f({type:Q,context:1,implicit:!0})],Bn.prototype,"targetGroup",void 0);d([f({type:Ns,context:2,implicit:!0})],Bn.prototype,"targetCert",void 0);Bn=d([B({type:z.Choice})],Bn);let na=ta=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,ta.prototype)}};na=ta=d([B({type:z.Sequence,itemType:Bn})],na);var ia;let Ml=ia=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,ia.prototype)}};Ml=ia=d([B({type:z.Sequence,itemType:na})],Ml);class sf{constructor(e={}){Object.assign(this,e)}}d([f({type:Be,implicit:!0,context:0,optional:!0})],sf.prototype,"roleAuthority",void 0);d([f({type:Q,implicit:!0,context:1})],sf.prototype,"roleName",void 0);class wc{constructor(e={}){this.service=new Q,this.ident=new Q,Object.assign(this,e)}}d([f({type:Q})],wc.prototype,"service",void 0);d([f({type:Q})],wc.prototype,"ident",void 0);d([f({type:re,optional:!0})],wc.prototype,"authInfo",void 0);var ra;class bc{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],bc.prototype,"otherCertFormat",void 0);d([f({type:y.Any})],bc.prototype,"otherCert",void 0);let Tn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:un})],Tn.prototype,"certificate",void 0);d([f({type:js,context:2,implicit:!0})],Tn.prototype,"v2AttrCert",void 0);d([f({type:bc,context:3,implicit:!0})],Tn.prototype,"other",void 0);Tn=d([B({type:z.Choice})],Tn);let Nr=ra=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,ra.prototype)}};Nr=ra=d([B({type:z.Set,itemType:Tn})],Nr);class Wn{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Wn.prototype,"contentType",void 0);d([f({type:y.Any,context:0})],Wn.prototype,"content",void 0);let gi=class{constructor(e={}){Object.assign(this,e)}};d([f({type:re})],gi.prototype,"single",void 0);d([f({type:y.Any})],gi.prototype,"any",void 0);gi=d([B({type:z.Choice})],gi);class Os{constructor(e={}){this.eContentType="",Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Os.prototype,"eContentType",void 0);d([f({type:gi,context:0,optional:!0})],Os.prototype,"eContent",void 0);let _i=class{constructor(e={}){Object.assign(this,e)}};d([f({type:re,context:0,implicit:!0,optional:!0})],_i.prototype,"value",void 0);d([f({type:re,converter:qg,context:0,implicit:!0,optional:!0,repeated:"sequence"})],_i.prototype,"constructedValue",void 0);_i=d([B({type:z.Choice})],_i);class Ni{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new $r,Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Ni.prototype,"contentType",void 0);d([f({type:$r})],Ni.prototype,"contentEncryptionAlgorithm",void 0);d([f({type:_i,optional:!0})],Ni.prototype,"encryptedContent",void 0);class Bs{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Bs.prototype,"keyAttrId",void 0);d([f({type:y.Any,optional:!0})],Bs.prototype,"keyAttr",void 0);var sa;class Ts{constructor(e={}){this.subjectKeyIdentifier=new Rt,Object.assign(this,e)}}d([f({type:Rt})],Ts.prototype,"subjectKeyIdentifier",void 0);d([f({type:y.GeneralizedTime,optional:!0})],Ts.prototype,"date",void 0);d([f({type:Bs,optional:!0})],Ts.prototype,"other",void 0);let Rn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Ts,context:0,implicit:!0,optional:!0})],Rn.prototype,"rKeyId",void 0);d([f({type:qn,optional:!0})],Rn.prototype,"issuerAndSerialNumber",void 0);Rn=d([B({type:z.Choice})],Rn);class kc{constructor(e={}){this.rid=new Rn,this.encryptedKey=new re,Object.assign(this,e)}}d([f({type:Rn})],kc.prototype,"rid",void 0);d([f({type:re})],kc.prototype,"encryptedKey",void 0);let Or=sa=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,sa.prototype)}};Or=sa=d([B({type:z.Sequence,itemType:kc})],Or);class xc{constructor(e={}){this.algorithm=new H,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:H})],xc.prototype,"algorithm",void 0);d([f({type:y.BitString})],xc.prototype,"publicKey",void 0);let dn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Rt,context:0,implicit:!0,optional:!0})],dn.prototype,"subjectKeyIdentifier",void 0);d([f({type:xc,context:1,implicit:!0,optional:!0})],dn.prototype,"originatorKey",void 0);d([f({type:qn,optional:!0})],dn.prototype,"issuerAndSerialNumber",void 0);dn=d([B({type:z.Choice})],dn);class Gn{constructor(e={}){this.version=At.v3,this.originator=new dn,this.keyEncryptionAlgorithm=new _t,this.recipientEncryptedKeys=new Or,Object.assign(this,e)}}d([f({type:y.Integer})],Gn.prototype,"version",void 0);d([f({type:dn,context:0})],Gn.prototype,"originator",void 0);d([f({type:re,context:1,optional:!0})],Gn.prototype,"ukm",void 0);d([f({type:_t})],Gn.prototype,"keyEncryptionAlgorithm",void 0);d([f({type:Or})],Gn.prototype,"recipientEncryptedKeys",void 0);let Pn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Rt,context:0,implicit:!0})],Pn.prototype,"subjectKeyIdentifier",void 0);d([f({type:qn})],Pn.prototype,"issuerAndSerialNumber",void 0);Pn=d([B({type:z.Choice})],Pn);class Oi{constructor(e={}){this.version=At.v0,this.rid=new Pn,this.keyEncryptionAlgorithm=new _t,this.encryptedKey=new re,Object.assign(this,e)}}d([f({type:y.Integer})],Oi.prototype,"version",void 0);d([f({type:Pn})],Oi.prototype,"rid",void 0);d([f({type:_t})],Oi.prototype,"keyEncryptionAlgorithm",void 0);d([f({type:re})],Oi.prototype,"encryptedKey",void 0);class Bi{constructor(e={}){this.keyIdentifier=new re,Object.assign(this,e)}}d([f({type:re})],Bi.prototype,"keyIdentifier",void 0);d([f({type:y.GeneralizedTime,optional:!0})],Bi.prototype,"date",void 0);d([f({type:Bs,optional:!0})],Bi.prototype,"other",void 0);class Ti{constructor(e={}){this.version=At.v4,this.kekid=new Bi,this.keyEncryptionAlgorithm=new _t,this.encryptedKey=new re,Object.assign(this,e)}}d([f({type:y.Integer})],Ti.prototype,"version",void 0);d([f({type:Bi})],Ti.prototype,"kekid",void 0);d([f({type:_t})],Ti.prototype,"keyEncryptionAlgorithm",void 0);d([f({type:re})],Ti.prototype,"encryptedKey",void 0);class Ri{constructor(e={}){this.version=At.v0,this.keyEncryptionAlgorithm=new _t,this.encryptedKey=new re,Object.assign(this,e)}}d([f({type:y.Integer})],Ri.prototype,"version",void 0);d([f({type:Jo,context:0,optional:!0})],Ri.prototype,"keyDerivationAlgorithm",void 0);d([f({type:_t})],Ri.prototype,"keyEncryptionAlgorithm",void 0);d([f({type:re})],Ri.prototype,"encryptedKey",void 0);class Sc{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Sc.prototype,"oriType",void 0);d([f({type:y.Any})],Sc.prototype,"oriValue",void 0);let Ut=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Oi,optional:!0})],Ut.prototype,"ktri",void 0);d([f({type:Gn,context:1,implicit:!0,optional:!0})],Ut.prototype,"kari",void 0);d([f({type:Ti,context:2,implicit:!0,optional:!0})],Ut.prototype,"kekri",void 0);d([f({type:Ri,context:3,implicit:!0,optional:!0})],Ut.prototype,"pwri",void 0);d([f({type:Sc,context:4,implicit:!0,optional:!0})],Ut.prototype,"ori",void 0);Ut=d([B({type:z.Choice})],Ut);var oa;let Br=oa=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,oa.prototype)}};Br=oa=d([B({type:z.Set,itemType:Ut})],Br);var aa;class Rs{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Rs.prototype,"otherRevInfoFormat",void 0);d([f({type:y.Any})],Rs.prototype,"otherRevInfo",void 0);let Tr=class{constructor(e={}){this.other=new Rs,Object.assign(this,e)}};d([f({type:Rs,context:1,implicit:!0})],Tr.prototype,"other",void 0);Tr=d([B({type:z.Choice})],Tr);let Rr=aa=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,aa.prototype)}};Rr=aa=d([B({type:z.Set,itemType:Tr})],Rr);class Ac{constructor(e={}){Object.assign(this,e)}}d([f({type:Nr,context:0,implicit:!0,optional:!0})],Ac.prototype,"certs",void 0);d([f({type:Rr,context:1,implicit:!0,optional:!0})],Ac.prototype,"crls",void 0);var ca;let la=ca=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,ca.prototype)}};la=ca=d([B({type:z.Set,itemType:Kn})],la);class Pi{constructor(e={}){this.version=At.v0,this.recipientInfos=new Br,this.encryptedContentInfo=new Ni,Object.assign(this,e)}}d([f({type:y.Integer})],Pi.prototype,"version",void 0);d([f({type:Ac,context:0,implicit:!0,optional:!0})],Pi.prototype,"originatorInfo",void 0);d([f({type:Br})],Pi.prototype,"recipientInfos",void 0);d([f({type:Ni})],Pi.prototype,"encryptedContentInfo",void 0);d([f({type:la,context:1,implicit:!0,optional:!0})],Pi.prototype,"unprotectedAttrs",void 0);const m_="1.2.840.113549.1.7.2";var ua;let Pr=ua=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,ua.prototype)}};Pr=ua=d([B({type:z.Set,itemType:hi})],Pr);class Jn{constructor(e={}){this.version=At.v0,this.digestAlgorithms=new Pr,this.encapContentInfo=new Os,this.signerInfos=new Cr,Object.assign(this,e)}}d([f({type:y.Integer})],Jn.prototype,"version",void 0);d([f({type:Pr})],Jn.prototype,"digestAlgorithms",void 0);d([f({type:Os})],Jn.prototype,"encapContentInfo",void 0);d([f({type:Nr,context:0,implicit:!0,optional:!0})],Jn.prototype,"certificates",void 0);d([f({type:Rr,context:1,implicit:!0,optional:!0})],Jn.prototype,"crls",void 0);d([f({type:Cr})],Jn.prototype,"signerInfos",void 0);const mi="1.2.840.10045.2.1",Ic="1.2.840.10045.4.1",of="1.2.840.10045.4.3.1",Ec="1.2.840.10045.4.3.2",$c="1.2.840.10045.4.3.3",Cc="1.2.840.10045.4.3.4",Hl="1.2.840.10045.3.1.7",Dl="1.3.132.0.34",Fl="1.3.132.0.35";function Li(n){return new H({algorithm:n})}const y_=Li(Ic);Li(of);const v_=Li(Ec),w_=Li($c),b_=Li(Cc);let yi=class{constructor(e={}){Object.assign(this,e)}};d([f({type:y.ObjectIdentifier})],yi.prototype,"fieldType",void 0);d([f({type:y.Any})],yi.prototype,"parameters",void 0);yi=d([B({type:z.Sequence})],yi);class k_ extends re{}let Ln=class{constructor(e={}){Object.assign(this,e)}};d([f({type:y.OctetString})],Ln.prototype,"a",void 0);d([f({type:y.OctetString})],Ln.prototype,"b",void 0);d([f({type:y.BitString,optional:!0})],Ln.prototype,"seed",void 0);Ln=d([B({type:z.Sequence})],Ln);var da;(function(n){n[n.ecpVer1=1]="ecpVer1"})(da||(da={}));let It=class{constructor(e={}){this.version=da.ecpVer1,Object.assign(this,e)}};d([f({type:y.Integer})],It.prototype,"version",void 0);d([f({type:yi})],It.prototype,"fieldID",void 0);d([f({type:Ln})],It.prototype,"curve",void 0);d([f({type:k_})],It.prototype,"base",void 0);d([f({type:y.Integer,converter:he})],It.prototype,"order",void 0);d([f({type:y.Integer,optional:!0})],It.prototype,"cofactor",void 0);It=d([B({type:z.Sequence})],It);let Vt=class{constructor(e={}){Object.assign(this,e)}};d([f({type:y.ObjectIdentifier})],Vt.prototype,"namedCurve",void 0);d([f({type:y.Null})],Vt.prototype,"implicitCurve",void 0);d([f({type:It})],Vt.prototype,"specifiedCurve",void 0);Vt=d([B({type:z.Choice})],Vt);class Ps{constructor(e={}){this.version=1,this.privateKey=new re,Object.assign(this,e)}}d([f({type:y.Integer})],Ps.prototype,"version",void 0);d([f({type:re})],Ps.prototype,"privateKey",void 0);d([f({type:Vt,context:0,optional:!0})],Ps.prototype,"parameters",void 0);d([f({type:y.BitString,context:1,optional:!0})],Ps.prototype,"publicKey",void 0);class Lr{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.Integer,converter:he})],Lr.prototype,"r",void 0);d([f({type:y.Integer,converter:he})],Lr.prototype,"s",void 0);const Me="1.2.840.113549.1.1",pn=`${Me}.1`,x_=`${Me}.7`,S_=`${Me}.9`,ai=`${Me}.10`,A_=`${Me}.2`,I_=`${Me}.4`,Ur=`${Me}.5`,E_=`${Me}.14`,pa=`${Me}.11`,Vr=`${Me}.12`,Mr=`${Me}.13`,af=`${Me}.15`,cf=`${Me}.16`,Hr="1.3.14.3.2.26",lf="2.16.840.1.101.3.4.2.4",Dr="2.16.840.1.101.3.4.2.1",Fr="2.16.840.1.101.3.4.2.2",qr="2.16.840.1.101.3.4.2.3",$_="2.16.840.1.101.3.4.2.5",C_="2.16.840.1.101.3.4.2.6",j_="1.2.840.113549.2.2",z_="1.2.840.113549.2.5",Ls=`${Me}.8`;function xe(n){return new H({algorithm:n,parameters:null})}xe(j_);xe(z_);const fn=xe(Hr);xe(lf);xe(Dr);xe(Fr);xe(qr);xe($_);xe(C_);const uf=new H({algorithm:Ls,parameters:L.serialize(fn)}),df=new H({algorithm:S_,parameters:L.serialize(wr.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});xe(pn);xe(A_);xe(I_);xe(Ur);xe(af);xe(cf);xe(Vr);xe(Mr);xe(af);xe(cf);class Us{constructor(e={}){this.hashAlgorithm=new H(fn),this.maskGenAlgorithm=new H({algorithm:Ls,parameters:L.serialize(fn)}),this.pSourceAlgorithm=new H(df),Object.assign(this,e)}}d([f({type:H,context:0,defaultValue:fn})],Us.prototype,"hashAlgorithm",void 0);d([f({type:H,context:1,defaultValue:uf})],Us.prototype,"maskGenAlgorithm",void 0);d([f({type:H,context:2,defaultValue:df})],Us.prototype,"pSourceAlgorithm",void 0);new H({algorithm:x_,parameters:L.serialize(new Us)});class hn{constructor(e={}){this.hashAlgorithm=new H(fn),this.maskGenAlgorithm=new H({algorithm:Ls,parameters:L.serialize(fn)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}d([f({type:H,context:0,defaultValue:fn})],hn.prototype,"hashAlgorithm",void 0);d([f({type:H,context:1,defaultValue:uf})],hn.prototype,"maskGenAlgorithm",void 0);d([f({type:y.Integer,context:2,defaultValue:20})],hn.prototype,"saltLength",void 0);d([f({type:y.Integer,context:3,defaultValue:1})],hn.prototype,"trailerField",void 0);new H({algorithm:ai,parameters:L.serialize(new hn)});class Vs{constructor(e={}){this.digestAlgorithm=new H,this.digest=new re,Object.assign(this,e)}}d([f({type:H})],Vs.prototype,"digestAlgorithm",void 0);d([f({type:re})],Vs.prototype,"digest",void 0);var fa;class Ms{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.Integer,converter:he})],Ms.prototype,"prime",void 0);d([f({type:y.Integer,converter:he})],Ms.prototype,"exponent",void 0);d([f({type:y.Integer,converter:he})],Ms.prototype,"coefficient",void 0);let ha=fa=class extends le{constructor(e){super(e),Object.setPrototypeOf(this,fa.prototype)}};ha=fa=d([B({type:z.Sequence,itemType:Ms})],ha);class vt{constructor(e={}){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),Object.assign(this,e)}}d([f({type:y.Integer})],vt.prototype,"version",void 0);d([f({type:y.Integer,converter:he})],vt.prototype,"modulus",void 0);d([f({type:y.Integer,converter:he})],vt.prototype,"publicExponent",void 0);d([f({type:y.Integer,converter:he})],vt.prototype,"privateExponent",void 0);d([f({type:y.Integer,converter:he})],vt.prototype,"prime1",void 0);d([f({type:y.Integer,converter:he})],vt.prototype,"prime2",void 0);d([f({type:y.Integer,converter:he})],vt.prototype,"exponent1",void 0);d([f({type:y.Integer,converter:he})],vt.prototype,"exponent2",void 0);d([f({type:y.Integer,converter:he})],vt.prototype,"coefficient",void 0);d([f({type:ha,optional:!0})],vt.prototype,"otherPrimeInfos",void 0);class jc{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.Integer,converter:he})],jc.prototype,"modulus",void 0);d([f({type:y.Integer,converter:he})],jc.prototype,"publicExponent",void 0);var ga;(function(n){n[n.Transient=0]="Transient",n[n.Singleton=1]="Singleton",n[n.ResolutionScoped=2]="ResolutionScoped",n[n.ContainerScoped=3]="ContainerScoped"})(ga||(ga={}));const Pe=ga;/*! *****************************************************************************
80
80
  Copyright (c) Microsoft Corporation.
81
81
 
82
82
  Permission to use, copy, modify, and/or distribute this software for any
@@ -189,7 +189,7 @@ PERFORMANCE OF THIS SOFTWARE.
189
189
  <\/script>
190
190
  </body>
191
191
 
192
- </html>`}async function Av({ctx:n,client:e,session:t,redirect_uri:i,state:r,nonce:s,code_challenge_method:o,code_challenge:c,audience:l,scope:u}){const{env:p}=n,g=new URL(i);if(t){n.set("user_id",t.user_id);const x=new Headers,h=Jf(e.tenant.id,t.session_id);x.set("set-cookie",h);const _=await p.data.users.get(e.tenant.id,t.user_id);if(_){n.set("username",_.email),n.set("connection",_.connection);const b=await Wc(n,{client:e,authParams:{client_id:e.id,audience:l,code_challenge_method:o,code_challenge:c,scope:u,state:r,nonce:s,response_type:Pt.TOKEN_ID_TOKEN},user:_,sid:t.session_id});await p.data.sessions.update(e.tenant.id,t.session_id,{used_at:new Date().toISOString()});const S=ke(n,{type:_e.SUCCESS_SILENT_AUTH,description:"Successful silent authentication"});return await n.env.data.logs.create(e.tenant.id,S),n.html(yd(`${g.protocol}//${g.host}`,JSON.stringify(b)),{headers:x})}}const m=ke(n,{type:_e.FAILED_SILENT_AUTH,description:"Login required"});return await n.env.data.logs.create(e.tenant.id,m),n.html(yd(`${g.protocol}//${g.host}`,JSON.stringify({error:"login_required",error_description:"Login required",state:r})))}const Iv=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth"],method:"get",path:"/",request:{query:a.z.object({client_id:a.z.string(),vendor_id:a.z.string().optional(),redirect_uri:a.z.string(),scope:a.z.string().optional(),state:a.z.string(),prompt:a.z.string().optional(),response_mode:a.z.nativeEnum(nn).optional(),response_type:a.z.nativeEnum(Pt).optional(),audience:a.z.string().optional(),connection:a.z.string().optional(),nonce:a.z.string().optional(),max_age:a.z.string().optional(),login_ticket:a.z.string().optional(),code_challenge_method:a.z.nativeEnum(is).optional(),code_challenge:a.z.string().optional(),realm:a.z.string().optional(),auth0Client:a.z.string().optional(),login_hint:a.z.string().optional(),ui_locales:a.z.string().optional()})},responses:{200:{description:"Silent authentication page"},302:{description:"Redirect to the client's redirect uri"}}}),async n=>{const{env:e}=n,{client_id:t,vendor_id:i,redirect_uri:r,scope:s,state:o,audience:c,nonce:l,connection:u,response_type:p,response_mode:g,code_challenge:m,code_challenge_method:x,prompt:h,login_ticket:_,realm:b,auth0Client:S,login_hint:N,ui_locales:T}=n.req.valid("query");n.set("log","authorize");const K=await Hc(e,t);n.set("client_id",K.id);const oe={redirect_uri:r,scope:s,state:o,client_id:t,vendor_id:i,audience:c,nonce:l,prompt:h,response_type:p,response_mode:g,code_challenge:m,code_challenge_method:x,username:N,ui_locales:T},pe=n.req.header("origin");if(pe&&!bv(pe,K.web_origins||[]))throw new O(403,{message:`Origin ${pe} not allowed`});if(oe.redirect_uri&&!Js(oe.redirect_uri,K.callbacks||[]))throw new O(400,{message:`Invalid redirect URI - ${oe.redirect_uri}`});const ce=Gf(K.tenant.id,n.req.header("cookie")),Re=ce?await e.data.sessions.get(K.tenant.id,ce):void 0;if(h=="none"){if(!p)throw new O(400,{message:"Missing response_type"});return Av({ctx:n,session:Re||void 0,redirect_uri:r,state:o,response_type:p,client:K,nonce:l,code_challenge_method:x,code_challenge:m,audience:c,scope:s})}return u&&u!=="email"?tv(n,K,u,oe):_?Sv(n,K.tenant.id,_,oe,b):(console.log("5"),kv({ctx:n,client:K,auth0Client:S,authParams:oe,session:Re||void 0,connection:u,login_hint:N}))});function Ev(){const n=new a.OpenAPIHono;n.use(Rf(n));const e=n.route("/v2/logout",iv).route("/userinfo",rv).route("/.well-known",sv).route("/oauth/token",dv).route("/dbconnections",_v).route("/passwordless",mv).route("/co/authenticate",wv).route("/authorize",Iv).route("/callback",nv);return e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth API"}}),Tf(e),e}function $v(){const e=new a.OpenAPIHono;return e.doc("/u/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Universal login"}}),e}const Cv="Account detected",jv="We have detected that you have already created an account through",zv="By signing in, you agree to our",Nv="and",Ov="Callback URL mismatch",Bv="The provided redirect_uri is not in the list of allowed callback URLs.",Tv="continue with user",Rv="Please click the button to create a new password account.",Pv="Enter the code at {{vendorName}} to complete the login",Lv="Welcome to {{vendorName}}! {{code}} is the login code",Uv="Welcome to {{vendorName}}! {{code}} is the login code",Vv="The code is valid for 30 minutes",Mv="Confirm password",Hv="Need Help?",Dv="Contact us",Fv="or continue with social account",qv="Continue with {{provider}}",Kv="Would you like to continue with your existing account?",Wv="Copyright © 2023 SESAMY. All rights reserved.",Gv="©2023 Sesamy",Jv="Choose a password with a mix of uppercase and lowercase letters, numbers, and symbols.",Zv="Please enter a valid email address.",Yv="The passwords didn't match. Try again.",Xv="Choose password",Qv="Password must be at least 8 characters long and contain at least one lowercase letter, one uppercase letter, one number and one symbol.",ew="Create new account",tw="Sign up with password",nw="You are currently logged in as <0>{{email}}</0>",iw="Email",rw="Email address",sw="Your email address has been validated",ow="Now enter your password to login again",aw="An email has been sent to <0>{{email}}</0> with a verification link. Please click the link to verify your email address and set a password.",cw="Email verification sent",lw="Enter a code",uw="We'll send you a verification link to ensure you own this email address.",dw="Enter new password",pw="Enter password",fw="Enter your email address and password to login.",hw="Enter your password",gw="The magic link has expired. Please click on the button below to receive a new link in your inbox.",_w="Hey! We updated our login experience. <0>Click here to learn more about it.</0>",mw="Send password reset email",yw="Click the button below and we’ll send instructions on how to reset your password.",vw="Password reset email sent",ww="Forgot password?",bw="Forgot password?",kw="Go back",xw="Invalid password",Sw=`The link is no longer valid.
192
+ </html>`}async function Av({ctx:n,client:e,session:t,redirect_uri:i,state:r,nonce:s,code_challenge_method:o,code_challenge:c,audience:l,scope:u}){const{env:p}=n,g=new URL(i);if(t){n.set("user_id",t.user_id);const x=new Headers,h=Jf(e.tenant.id,t.session_id);x.set("set-cookie",h);const _=await p.data.users.get(e.tenant.id,t.user_id);if(_){n.set("username",_.email),n.set("connection",_.connection);const b=await Wc(n,{client:e,authParams:{client_id:e.id,audience:l,code_challenge_method:o,code_challenge:c,scope:u,state:r,nonce:s,response_type:Pt.TOKEN_ID_TOKEN},user:_,sid:t.session_id});await p.data.sessions.update(e.tenant.id,t.session_id,{used_at:new Date().toISOString()});const S=ke(n,{type:_e.SUCCESS_SILENT_AUTH,description:"Successful silent authentication"});return await n.env.data.logs.create(e.tenant.id,S),n.html(yd(`${g.protocol}//${g.host}`,JSON.stringify(b)),{headers:x})}}const m=ke(n,{type:_e.FAILED_SILENT_AUTH,description:"Login required"});return await n.env.data.logs.create(e.tenant.id,m),n.html(yd(`${g.protocol}//${g.host}`,JSON.stringify({error:"login_required",error_description:"Login required",state:r})))}const Iv=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth"],method:"get",path:"/",request:{query:a.z.object({client_id:a.z.string(),vendor_id:a.z.string().optional(),redirect_uri:a.z.string(),scope:a.z.string().optional(),state:a.z.string(),prompt:a.z.string().optional(),response_mode:a.z.nativeEnum(nn).optional(),response_type:a.z.nativeEnum(Pt).optional(),audience:a.z.string().optional(),connection:a.z.string().optional(),nonce:a.z.string().optional(),max_age:a.z.string().optional(),login_ticket:a.z.string().optional(),code_challenge_method:a.z.nativeEnum(is).optional(),code_challenge:a.z.string().optional(),realm:a.z.string().optional(),auth0Client:a.z.string().optional(),login_hint:a.z.string().optional(),ui_locales:a.z.string().optional()})},responses:{200:{description:"Silent authentication page"},302:{description:"Redirect to the client's redirect uri"}}}),async n=>{const{env:e}=n,{client_id:t,vendor_id:i,redirect_uri:r,scope:s,state:o,audience:c,nonce:l,connection:u,response_type:p,response_mode:g,code_challenge:m,code_challenge_method:x,prompt:h,login_ticket:_,realm:b,auth0Client:S,login_hint:N,ui_locales:T}=n.req.valid("query");n.set("log","authorize");const q=await Hc(e,t);n.set("client_id",q.id),n.set("tenant_id",q.tenant.id);const oe={redirect_uri:r,scope:s,state:o,client_id:t,vendor_id:i,audience:c,nonce:l,prompt:h,response_type:p,response_mode:g,code_challenge:m,code_challenge_method:x,username:N,ui_locales:T},pe=n.req.header("origin");if(pe&&!bv(pe,q.web_origins||[]))throw new O(403,{message:`Origin ${pe} not allowed`});if(oe.redirect_uri&&!Js(oe.redirect_uri,q.callbacks||[]))throw new O(400,{message:`Invalid redirect URI - ${oe.redirect_uri}`});const ce=Gf(q.tenant.id,n.req.header("cookie")),Re=ce?await e.data.sessions.get(q.tenant.id,ce):void 0;if(h=="none"){if(!p)throw new O(400,{message:"Missing response_type"});return Av({ctx:n,session:Re||void 0,redirect_uri:r,state:o,response_type:p,client:q,nonce:l,code_challenge_method:x,code_challenge:m,audience:c,scope:s})}return u&&u!=="email"?tv(n,q,u,oe):_?Sv(n,q.tenant.id,_,oe,b):kv({ctx:n,client:q,auth0Client:S,authParams:oe,session:Re||void 0,connection:u,login_hint:N})});function Ev(){const n=new a.OpenAPIHono;n.use(Rf(n));const e=n.route("/v2/logout",iv).route("/userinfo",rv).route("/.well-known",sv).route("/oauth/token",dv).route("/dbconnections",_v).route("/passwordless",mv).route("/co/authenticate",wv).route("/authorize",Iv).route("/callback",nv);return e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth API"}}),Tf(e),e}function $v(){const e=new a.OpenAPIHono;return e.doc("/u/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Universal login"}}),e}const Cv="Account detected",jv="We have detected that you have already created an account through",zv="By signing in, you agree to our",Nv="and",Ov="Callback URL mismatch",Bv="The provided redirect_uri is not in the list of allowed callback URLs.",Tv="continue with user",Rv="Please click the button to create a new password account.",Pv="Enter the code at {{vendorName}} to complete the login",Lv="Welcome to {{vendorName}}! {{code}} is the login code",Uv="Welcome to {{vendorName}}! {{code}} is the login code",Vv="The code is valid for 30 minutes",Mv="Confirm password",Hv="Need Help?",Dv="Contact us",Fv="or continue with social account",qv="Continue with {{provider}}",Kv="Would you like to continue with your existing account?",Wv="Copyright © 2023 SESAMY. All rights reserved.",Gv="©2023 Sesamy",Jv="Choose a password with a mix of uppercase and lowercase letters, numbers, and symbols.",Zv="Please enter a valid email address.",Yv="The passwords didn't match. Try again.",Xv="Choose password",Qv="Password must be at least 8 characters long and contain at least one lowercase letter, one uppercase letter, one number and one symbol.",ew="Create new account",tw="Sign up with password",nw="You are currently logged in as <0>{{email}}</0>",iw="Email",rw="Email address",sw="Your email address has been validated",ow="Now enter your password to login again",aw="An email has been sent to <0>{{email}}</0> with a verification link. Please click the link to verify your email address and set a password.",cw="Email verification sent",lw="Enter a code",uw="We'll send you a verification link to ensure you own this email address.",dw="Enter new password",pw="Enter password",fw="Enter your email address and password to login.",hw="Enter your password",gw="The magic link has expired. Please click on the button below to receive a new link in your inbox.",_w="Hey! We updated our login experience. <0>Click here to learn more about it.</0>",mw="Send password reset email",yw="Click the button below and we’ll send instructions on how to reset your password.",vw="Password reset email sent",ww="Forgot password?",bw="Forgot password?",kw="Go back",xw="Invalid password",Sw=`The link is no longer valid.
193
193
 
194
194
  Please make sure to open the login link in the same browser you started the login with.
195
195