authhero 0.62.0 → 0.63.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 +34 -34
- package/dist/authhero.d.ts +32 -2
- package/dist/authhero.mjs +8354 -7583
- package/package.json +1 -1
package/dist/authhero.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";var _g=Object.defineProperty;var mg=(t,e,n)=>e in t?_g(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Q=(t,e,n)=>mg(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@hono/zod-openapi"),ee=t=>typeof t=="string",ci=()=>{let t,e;const n=new Promise((i,r)=>{t=i,e=r});return n.resolve=t,n.reject=e,n},Ol=t=>t==null?"":""+t,yg=(t,e,n)=>{t.forEach(i=>{e[i]&&(n[i]=e[i])})},vg=/###/g,Bl=t=>t&&t.indexOf("###")>-1?t.replace(vg,"."):t,Tl=t=>!t||ee(t),fi=(t,e,n)=>{const i=ee(e)?e.split("."):e;let r=0;for(;r<i.length-1;){if(Tl(t))return{};const s=Bl(i[r]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++r}return Tl(t)?{}:{obj:t,k:Bl(i[r])}},Rl=(t,e,n)=>{const{obj:i,k:r}=fi(t,e,Object);if(i!==void 0||e.length===1){i[r]=n;return}let s=e[e.length-1],o=e.slice(0,e.length-1),c=fi(t,o,Object);for(;c.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),c=fi(t,o,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${s}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${s}`]=n},wg=(t,e,n,i)=>{const{obj:r,k:s}=fi(t,e,Object);r[s]=r[s]||[],r[s].push(n)},vr=(t,e)=>{const{obj:n,k:i}=fi(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,i))return n[i]},bg=(t,e,n)=>{const i=vr(t,n);return i!==void 0?i:vr(e,n)},ip=(t,e,n)=>{for(const i in e)i!=="__proto__"&&i!=="constructor"&&(i in t?ee(t[i])||t[i]instanceof String||ee(e[i])||e[i]instanceof String?n&&(t[i]=e[i]):ip(t[i],e[i],n):t[i]=e[i]);return t},En=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var kg={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const xg=t=>ee(t)?t.replace(/[&<>"'\/]/g,e=>kg[e]):t;class Sg{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const n=this.regExpMap.get(e);if(n!==void 0)return n;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 Ag=[" ",",","?","!",";"],Ig=new Sg(20),Eg=(t,e,n)=>{e=e||"",n=n||"";const i=Ag.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(i.length===0)return!0;const r=Ig.getRegExp(`(${i.map(o=>o==="?"?"\\?":o).join("|")})`);let s=!r.test(t);if(!s){const o=t.indexOf(n);o>0&&!r.test(t.substring(0,o))&&(s=!0)}return s},Vo=function(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const i=e.split(n);let r=t;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+=n),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},wr=t=>t==null?void 0:t.replace("_","-"),Cg={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){var n,i;(i=(n=console==null?void 0:console[t])==null?void 0:n.apply)==null||i.call(n,console,e)}};class br{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(e,n)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=e||Cg,this.options=n,this.debug=n.debug}log(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return this.forward(n,"log","",!0)}warn(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return this.forward(n,"warn","",!0)}error(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return this.forward(n,"error","")}deprecate(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,i,r){return r&&!this.debug?null:(ee(e[0])&&(e[0]=`${i}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new br(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new br(this.logger,e)}}var vt=new br;class gs{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(i=>{this.observers[i]||(this.observers[i]=new Map);const r=this.observers[i].get(n)||0;this.observers[i].set(n,r+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;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 Pl extends gs{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=e||{},this.options=n,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 n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,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,n],i&&(Array.isArray(i)?c.push(...i):ee(i)&&s?c.push(...i.split(s)):c.push(i)));const l=vr(this.data,c);return!l&&!n&&!i&&e.indexOf(".")>-1&&(e=c[0],n=c[1],i=c.slice(2).join(".")),l||!o||!ee(i)?l:Vo((p=(u=this.data)==null?void 0:u[e])==null?void 0:p[n],i,s)}addResource(e,n,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,n];i&&(c=c.concat(o?i.split(o):i)),e.indexOf(".")>-1&&(c=e.split("."),r=n,n=c[1]),this.addNamespaces(n),Rl(this.data,c,r),s.silent||this.emit("added",e,n,i,r)}addResources(e,n,i){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const s in i)(ee(i[s])||Array.isArray(i[s]))&&this.addResource(e,n,s,i[s],{silent:!0});r.silent||this.emit("added",e,n,i)}addResourceBundle(e,n,i,r,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},c=[e,n];e.indexOf(".")>-1&&(c=e.split("."),r=i,i=n,n=c[1]),this.addNamespaces(n);let l=vr(this.data,c)||{};o.skipCopy||(i=JSON.parse(JSON.stringify(i))),r?ip(l,i,s):l={...l,...i},Rl(this.data,c,l),o.silent||this.emit("added",e,n,i)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(r=>n[r]&&Object.keys(n[r]).length>0)}toJSON(){return this.data}}var rp={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,i,r){return t.forEach(s=>{var o;e=((o=this.processors[s])==null?void 0:o.process(e,n,i,r))??e}),e}};const Ll={};class kr extends gs{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),yg(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=vt.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(e==null)return!1;const i=this.resolve(e,n);return(i==null?void 0:i.res)!==void 0}extractFromKey(e,n){let i=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;i===void 0&&(i=":");const r=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const o=i&&e.indexOf(i)>-1,c=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Eg(e,i,r);if(o&&!c){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:ee(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:ee(s)?[s]:s}}translate(e,n,i){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const r=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:o,namespaces:c}=this.extractFromKey(e[e.length-1],n),l=c[c.length-1],u=n.lng||this.language,p=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((u==null?void 0:u.toLowerCase())==="cimode"){if(p){const K=n.nsSeparator||this.options.nsSeparator;return r?{res:`${l}${K}${o}`,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${K}${o}`}return r?{res:o,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:o}const g=this.resolve(e,n);let _=g==null?void 0:g.res;const k=(g==null?void 0:g.usedKey)||o,h=(g==null?void 0:g.exactUsedKey)||o,m=Object.prototype.toString.apply(_),b=["[object Number]","[object Function]","[object RegExp]"],S=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,O=!this.i18nFormat||this.i18nFormat.handleAsObject,T=!ee(_)&&typeof _!="boolean"&&typeof _!="number";if(O&&_&&T&&b.indexOf(m)<0&&!(ee(S)&&Array.isArray(_))){if(!n.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(k,_,{...n,ns:c}):`key '${o} (${this.language})' returned an object instead of string.`;return r?(g.res=K,g.usedParams=this.getUsedParamsDetails(n),g):K}if(s){const K=Array.isArray(_),ce=K?[]:{},he=K?h:k;for(const ue in _)if(Object.prototype.hasOwnProperty.call(_,ue)){const Le=`${he}${s}${ue}`;ce[ue]=this.translate(Le,{...n,joinArrays:!1,ns:c}),ce[ue]===Le&&(ce[ue]=_[ue])}_=ce}}else if(O&&ee(S)&&Array.isArray(_))_=_.join(S),_&&(_=this.extendTranslation(_,e,n,i));else{let K=!1,ce=!1;const he=n.count!==void 0&&!ee(n.count),ue=kr.hasDefaultValue(n),Le=he?this.pluralResolver.getSuffix(u,n.count,n):"",st=n.ordinal&&he?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",Ke=he&&!n.ordinal&&n.count===0,C=Ke&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${Le}`]||n[`defaultValue${st}`]||n.defaultValue;!this.isValidLookup(_)&&ue&&(K=!0,_=C),this.isValidLookup(_)||(ce=!0,_=o);const A=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&ce?void 0:_,w=ue&&C!==_&&this.options.updateMissing;if(ce||K||w){if(this.logger.log(w?"updateKey":"missingKey",u,l,o,w?C:_),s){const Y=this.resolve(o,{...n,keySeparator:!1});Y&&Y.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 z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&z&&z[0])for(let Y=0;Y<z.length;Y++)v.push(z[Y]);else this.options.saveMissingTo==="all"?v=this.languageUtils.toResolveHierarchy(n.lng||this.language):v.push(n.lng||this.language);const R=(Y,W,ne)=>{var D;const ae=ue&&ne!==_?ne:A;this.options.missingKeyHandler?this.options.missingKeyHandler(Y,l,W,ae,w,n):(D=this.backendConnector)!=null&&D.saveMissing&&this.backendConnector.saveMissing(Y,l,W,ae,w,n),this.emit("missingKey",Y,l,W,_)};this.options.saveMissing&&(this.options.saveMissingPlurals&&he?v.forEach(Y=>{const W=this.pluralResolver.getSuffixes(Y,n);Ke&&n[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(ne=>{R([Y],o+ne,n[`defaultValue${ne}`]||C)})}):R(v,o,C))}_=this.extendTranslation(_,e,n,g,i),ce&&_===o&&this.options.appendNamespaceToMissingKey&&(_=`${l}:${o}`),(ce||K)&&this.options.parseMissingKeyHandler&&(_=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${o}`:o,K?_:void 0))}return r?(g.res=_,g.usedParams=this.getUsedParamsDetails(n),g):_}extendTranslation(e,n,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=ee(e)&&(((p=i==null?void 0:i.interpolation)==null?void 0:p.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let _;if(g){const h=e.match(this.interpolator.nestingRegexp);_=h&&h.length}let k=i.replace&&!ee(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(k={...this.options.interpolation.defaultVariables,...k}),e=this.interpolator.interpolate(e,k,i.lng||this.language||r.usedLng,i),g){const h=e.match(this.interpolator.nestingRegexp),m=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,m=new Array(h),b=0;b<h;b++)m[b]=arguments[b];return(s==null?void 0:s[0])===m[0]&&!i.context?(o.logger.warn(`It seems you are nesting recursively key: ${m[0]} in key: ${n[0]}`),null):o.translate(...m,n)},i)),i.interpolation&&this.interpolator.reset()}const c=i.postProcess||this.options.postProcess,l=ee(c)?[c]:c;return e!=null&&(l!=null&&l.length)&&i.applyPostProcessor!==!1&&(e=rp.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(i)},...i}:i,this)),e}resolve(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i,r,s,o,c;return ee(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(i))return;const u=this.extractFromKey(l,n),p=u.key;r=p;let g=u.namespaces;this.options.fallbackNS&&(g=g.concat(this.options.fallbackNS));const _=n.count!==void 0&&!ee(n.count),k=_&&!n.ordinal&&n.count===0,h=n.context!==void 0&&(ee(n.context)||typeof n.context=="number")&&n.context!=="",m=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);g.forEach(b=>{var S,O;this.isValidLookup(i)||(c=b,!Ll[`${m[0]}-${b}`]&&((S=this.utils)!=null&&S.hasLoadedNamespace)&&!((O=this.utils)!=null&&O.hasLoadedNamespace(c))&&(Ll[`${m[0]}-${b}`]=!0,this.logger.warn(`key "${r}" for languages "${m.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!!!")),m.forEach(T=>{var he;if(this.isValidLookup(i))return;o=T;const K=[p];if((he=this.i18nFormat)!=null&&he.addLookupKeys)this.i18nFormat.addLookupKeys(K,p,T,b,n);else{let ue;_&&(ue=this.pluralResolver.getSuffix(T,n.count,n));const Le=`${this.options.pluralSeparator}zero`,st=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(_&&(K.push(p+ue),n.ordinal&&ue.indexOf(st)===0&&K.push(p+ue.replace(st,this.options.pluralSeparator)),k&&K.push(p+Le)),h){const Ke=`${p}${this.options.contextSeparator}${n.context}`;K.push(Ke),_&&(K.push(Ke+ue),n.ordinal&&ue.indexOf(st)===0&&K.push(Ke+ue.replace(st,this.options.pluralSeparator)),k&&K.push(Ke+Le))}}let ce;for(;ce=K.pop();)this.isValidLookup(i)||(s=ce,i=this.getResource(T,b,ce,n))}))})}),{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,n,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,n,i,r):this.resourceStore.getResource(e,n,i,r)}getUsedParamsDetails(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=e.replace&&!ee(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 n)delete r[s]}return r}static hasDefaultValue(e){const n="defaultValue";for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&n===i.substring(0,n.length)&&e[i]!==void 0)return!0;return!1}}class Ul{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=vt.create("languageUtils")}getScriptPartFromCode(e){if(e=wr(e),!e||e.indexOf("-")<0)return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=wr(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(ee(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(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 n;return e.forEach(i=>{if(n)return;const r=this.formatLanguageCode(i);(!this.options.supportedLngs||this.isSupportedCode(r))&&(n=r)}),!n&&this.options.supportedLngs&&e.forEach(i=>{if(n)return;const r=this.getLanguagePartFromCode(i);if(this.isSupportedCode(r))return n=r;n=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})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),ee(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let i=e[n];return i||(i=e[this.getScriptPartFromCode(n)]),i||(i=e[this.formatLanguageCode(n)]),i||(i=e[this.getLanguagePartFromCode(n)]),i||(i=e.default),i||[]}toResolveHierarchy(e,n){const i=this.getFallbackCodes(n||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 ee(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))):ee(e)&&s(this.formatLanguageCode(e)),i.forEach(o=>{r.indexOf(o)<0&&s(this.formatLanguageCode(o))}),r}}const Vl={zero:0,one:1,two:2,few:3,many:4,other:5},Ml={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class zg{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=vt.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=wr(e==="dev"?"en":e),r=n.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!"),Ml;if(!e.match(/-|_/))return Ml;const l=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(l,n)}return this.pluralRulesCache[s]=o,o}needsPlural(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=this.getRule(e,n);return i||(i=this.getRule("dev",n)),(i==null?void 0:i.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,n){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,i).map(r=>`${n}${r}`)}getSuffixes(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=this.getRule(e,n);return i||(i=this.getRule("dev",n)),i?i.resolvedOptions().pluralCategories.sort((r,s)=>Vl[r]-Vl[s]).map(r=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${r}`):[]}getSuffix(e,n){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(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,i))}}const Dl=function(t,e,n){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",r=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=bg(t,e,n);return!s&&r&&ee(n)&&(s=Vo(t,n,i),s===void 0&&(s=Vo(e,n,i))),s},ko=t=>t.replace(/\$/g,"$$$$");class $g{constructor(){var n;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=vt.create("interpolator"),this.options=e,this.format=((n=e==null?void 0:e.interpolation)==null?void 0:n.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:n,escapeValue:i,useRawValueToEscape:r,prefix:s,prefixEscaped:o,suffix:c,suffixEscaped:l,formatSeparator:u,unescapeSuffix:p,unescapePrefix:g,nestingPrefix:_,nestingPrefixEscaped:k,nestingSuffix:h,nestingSuffixEscaped:m,nestingOptionsSeparator:b,maxReplaces:S,alwaysFormat:O}=e.interpolation;this.escape=n!==void 0?n:xg,this.escapeValue=i!==void 0?i:!0,this.useRawValueToEscape=r!==void 0?r:!1,this.prefix=s?En(s):o||"{{",this.suffix=c?En(c):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=p?"":g||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=_?En(_):k||En("$t("),this.nestingSuffix=h?En(h):m||En(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=S||1e3,this.alwaysFormat=O!==void 0?O:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,i)=>(n==null?void 0:n.source)===i?(n.lastIndex=0,n):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,n,i,r){var k;let s,o,c;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=h=>{if(h.indexOf(this.formatSeparator)<0){const O=Dl(n,l,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(O,void 0,i,{...r,...n,interpolationkey:h}):O}const m=h.split(this.formatSeparator),b=m.shift().trim(),S=m.join(this.formatSeparator).trim();return this.format(Dl(n,l,b,this.options.keySeparator,this.options.ignoreJSONStructure),S,i,{...r,...n,interpolationkey:b})};this.resetRegExp();const p=(r==null?void 0:r.missingInterpolationHandler)||this.options.missingInterpolationHandler,g=((k=r==null?void 0:r.interpolation)==null?void 0:k.skipOnVariables)!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>ko(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?ko(this.escape(h)):ko(h)}].forEach(h=>{for(c=0;s=h.regex.exec(e);){const m=s[1].trim();if(o=u(m),o===void 0)if(typeof p=="function"){const S=p(e,s,r);o=ee(S)?S:""}else if(r&&Object.prototype.hasOwnProperty.call(r,m))o="";else if(g){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${m} for interpolating ${e}`),o="";else!ee(o)&&!this.useRawValueToEscape&&(o=Ol(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,n){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 _=`{${g[1]}`;l=g[0],_=this.interpolate(_,o);const k=_.match(/'/g),h=_.match(/"/g);(((k==null?void 0:k.length)??0)%2===0&&!h||h.length%2!==0)&&(_=_.replace(/'/g,'"'));try{o=JSON.parse(_),u&&(o={...u,...o})}catch(m){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,m),`${l}${p}${_}`}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&&!ee(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=n(c.call(this,r[1].trim(),o),o),s&&r[0]===e&&!ee(s))return s;ee(s)||(s=Ol(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 jg=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const i=t.split("(");e=i[0].toLowerCase().trim();const r=i[1].substring(0,i[1].length-1);e==="currency"&&r.indexOf(":")<0?n.currency||(n.currency=r.trim()):e==="relativetime"&&r.indexOf(":")<0?n.range||(n.range=r.trim()):r.split(";").forEach(o=>{if(o){const[c,...l]=o.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),p=c.trim();n[p]||(n[p]=u),u==="false"&&(n[p]=!1),u==="true"&&(n[p]=!0),isNaN(u)||(n[p]=parseInt(u,10))}})}return{formatName:e,formatOptions:n}},Cn=t=>{const e={};return(n,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=t(wr(i),r),e[o]=c),c(n)}};class Ng{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=vt.create("formatter"),this.options=e,this.formats={number:Cn((n,i)=>{const r=new Intl.NumberFormat(n,{...i});return s=>r.format(s)}),currency:Cn((n,i)=>{const r=new Intl.NumberFormat(n,{...i,style:"currency"});return s=>r.format(s)}),datetime:Cn((n,i)=>{const r=new Intl.DateTimeFormat(n,{...i});return s=>r.format(s)}),relativetime:Cn((n,i)=>{const r=new Intl.RelativeTimeFormat(n,{...i});return s=>r.format(s,i.range||"day")}),list:Cn((n,i)=>{const r=new Intl.ListFormat(n,{...i});return s=>r.format(s)})},this.init(e)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=n.interpolation.formatSeparator||","}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=Cn(n)}format(e,n,i){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=n.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}=jg(l);if(this.formats[u]){let _=c;try{const k=((g=r==null?void 0:r.formatParams)==null?void 0:g[r.interpolationkey])||{},h=k.locale||k.lng||r.locale||r.lng||i;_=this.formats[u](c,h,{...p,...r,...k})}catch(k){this.logger.warn(k)}return _}else this.logger.warn(`there was no format function for ${u}`);return c},e)}}const Og=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class Bg extends gs{constructor(e,n,i){var s,o;let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=n,this.services=i,this.languageUtils=i.languageUtils,this.options=r,this.logger=vt.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,n,i,r){const s={},o={},c={},l={};return e.forEach(u=>{let p=!0;n.forEach(g=>{const _=`${u}|${g}`;!i.reload&&this.store.hasResourceBundle(u,g)?this.state[_]=2:this.state[_]<0||(this.state[_]===1?o[_]===void 0&&(o[_]=!0):(this.state[_]=1,p=!1,o[_]===void 0&&(o[_]=!0),s[_]===void 0&&(s[_]=!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,n,i){const r=e.split("|"),s=r[0],o=r[1];n&&this.emit("failedLoading",s,o,n),!n&&i&&this.store.addResourceBundle(s,o,i,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&i&&(this.state[e]=0);const c={};this.queue.forEach(l=>{wg(l.loaded,[s],o),Og(l,e),n&&l.errors.push(n),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,n,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:n,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,n,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,n);u&&typeof u.then=="function"?u.then(p=>c(null,p)).catch(c):c(null,u)}catch(u){c(u)}return}return l(e,n,c)}prepareLoading(e,n){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();ee(e)&&(e=this.languageUtils.toResolveHierarchy(e)),ee(n)&&(n=[n]);const s=this.queueLoad(e,n,i,r);if(!s.toLoad.length)return s.pending.length||r(),null;s.toLoad.forEach(o=>{this.loadOne(o)})}load(e,n,i){this.prepareLoading(e,n,{},i)}reload(e,n,i){this.prepareLoading(e,n,{reload:!0},i)}loadOne(e){let n=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(`${n}loading namespace ${s} for language ${r} failed`,o),!o&&c&&this.logger.log(`${n}loaded namespace ${s} for language ${r}`,c),this.loaded(e,o,c)})}saveMissing(e,n,i,r,s){var l,u,p,g,_;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(n))){this.logger.warn(`did not save key "${i}" as the namespace "${n}" 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((_=this.backend)!=null&&_.create){const k={...o,isUpdate:s},h=this.backend.create.bind(this.backend);if(h.length<6)try{let m;h.length===5?m=h(e,n,i,r,k):m=h(e,n,i,r),m&&typeof m.then=="function"?m.then(b=>c(null,b)).catch(c):c(null,m)}catch(m){c(m)}else h(e,n,i,r,c,k)}!e||!e[0]||this.store.addResource(e[0],n,i,r)}}}const Fl=()=>({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:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),ee(t[1])&&(e.defaultValue=t[1]),ee(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(i=>{e[i]=n[i]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),Hl=t=>{var e,n;return ee(t.ns)&&(t.ns=[t.ns]),ee(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),ee(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),((n=(e=t.supportedLngs)==null?void 0:e.indexOf)==null?void 0:n.call(e,"cimode"))<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t},rr=()=>{},Tg=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class bi extends gs{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Hl(e),this.services={},this.logger=vt,this.modules={external:[]},Tg(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(i=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(ee(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const r=Fl();this.options={...r,...this.options,...Hl(n)},this.options.interpolation={...r.interpolation,...this.options.interpolation},n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);const s=p=>p?typeof p=="function"?new p:p:null;if(!this.options.isClone){this.modules.logger?vt.init(s(this.modules.logger),this.options):vt.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:p=Ng;const g=new Ul(this.options);this.store=new Pl(this.options.resources,this.options);const _=this.services;_.logger=vt,_.resourceStore=this.store,_.languageUtils=g,_.pluralResolver=new zg(g,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),p&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(_.formatter=s(p),_.formatter.init(_,this.options),this.options.interpolation.format=_.formatter.format.bind(_.formatter)),_.interpolator=new $g(this.options),_.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},_.backendConnector=new Bg(s(this.modules.backend),_.resourceStore,_,this.options),_.backendConnector.on("*",function(k){for(var h=arguments.length,m=new Array(h>1?h-1:0),b=1;b<h;b++)m[b-1]=arguments[b];e.emit(k,...m)}),this.modules.languageDetector&&(_.languageDetector=s(this.modules.languageDetector),_.languageDetector.init&&_.languageDetector.init(_,this.options.detection,this.options)),this.modules.i18nFormat&&(_.i18nFormat=s(this.modules.i18nFormat),_.i18nFormat.init&&_.i18nFormat.init(this)),this.translator=new kr(this.services,this.options),this.translator.on("*",function(k){for(var h=arguments.length,m=new Array(h>1?h-1:0),b=1;b<h;b++)m[b-1]=arguments[b];e.emit(k,...m)}),this.modules.external.forEach(k=>{k.init&&k.init(this)})}if(this.format=this.options.interpolation.format,i||(i=rr),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=ci(),u=()=>{const p=(g,_)=>{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(_),i(g,_)};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]:rr;const r=ee(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,n,i){const r=ci();return typeof e=="function"&&(i=e,e=void 0),typeof n=="function"&&(i=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),i||(i=rr),this.services.backendConnector.reload(e,n,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"&&rp.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 n=0;n<this.languages.length;n++){const i=this.languages[n];if(!(["cimode","dev"].indexOf(i)>-1)&&this.store.hasLanguageSomeTranslations(i)){this.resolvedLanguage=i;break}}}changeLanguage(e,n){var i=this;this.isLanguageChangingTo=e;const r=ci();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)}),n&&n(l,function(){return i.t(...arguments)})},c=l=>{var p,g;!e&&!l&&this.services.languageDetector&&(l=[]);const u=ee(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,_=>{o(_,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,n,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 _=r.options.keySeparator||".";let k;return l.keyPrefix&&Array.isArray(o)?k=o.map(h=>`${l.keyPrefix}${_}${h}`):k=l.keyPrefix?`${l.keyPrefix}${_}${o}`:o,r.t(k,l)};return ee(e)?s.lng=e:s.lngs=e,s.ns=n,s.keyPrefix=i,s}t(){var r;for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return(r=this.translator)==null?void 0:r.translate(...n)}exists(){var r;for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return(r=this.translator)==null?void 0:r.exists(...n)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let n=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=n.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(n.precheck){const c=n.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,n){const i=ci();return this.options.ns?(ee(e)&&(e=[e]),e.forEach(r=>{this.options.ns.indexOf(r)<0&&this.options.ns.push(r)}),this.loadResources(r=>{i.resolve(),n&&n(r)}),i):(n&&n(),Promise.resolve())}loadLanguages(e,n){const i=ci();ee(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(),n&&n(o)}),i):(n&&n(),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 n=["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 Ul(Fl());return n.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]:{},n=arguments.length>1?arguments[1]:void 0;return new bi(e,n)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:rr;const i=e.forkResourceStore;i&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},s=new bi(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 Pl(c,r),s.services.resourceStore=s.store}return s.translator=new kr(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,n),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 se=bi.createInstance();se.createInstance=bi.createInstance;se.createInstance;se.dir;se.init;se.loadResources;se.reloadResources;se.use;se.changeLanguage;se.getFixedT;const pe=se.t;se.exists;se.setDefaultNamespace;se.hasLoadedNamespace;se.loadNamespaces;se.loadLanguages;const Gt=a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()}),hc=a.z.object({created_at:a.z.string(),updated_at:a.z.string()}),sp=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()),op=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:sp.optional()}),_s=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()}),xr=_s.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()}),gc=a.z.object({...xr.shape,...hc.shape,user_id:a.z.string(),is_social:a.z.boolean(),email:a.z.string(),login_count:a.z.number(),identities:a.z.array(op).optional()}),yt=gc,Rg=_s.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()),Pg="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Lg=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Pg[n[t]&63];return e};const ap=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()}),Sr=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:ap.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(()=>Lg()).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"})}),nn=a.z.object({created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t),...Sr.shape});var un=(t=>(t.TOKEN="token",t.TOKEN_ID_TOKEN="token id_token",t.CODE="code",t))(un||{}),Ht=(t=>(t.QUERY="query",t.FRAGMENT="fragment",t.FORM_POST="form_post",t.WEB_MESSAGE="web_message",t.SAML_POST="saml_post",t))(Ht||{}),ms=(t=>(t.S256="S256",t.Plain="plain",t))(ms||{});const _c=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(un).optional(),response_mode:a.z.nativeEnum(Ht).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(ms).optional(),code_challenge:a.z.string().optional(),username:a.z.string().optional(),ui_locales:a.z.string().optional()}),Mo=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()}),Ar=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()}),Lt=a.z.object({id:a.z.string(),created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t)}).extend(Ar.shape),Ir=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(),id:a.z.string().optional()}),Nn=a.z.object({created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t),...Ir.shape,id:a.z.string()}),cp=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()}),Ug=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({...nn.shape,domains:a.z.array(Ug),tenant:Nn,connections:a.z.array(Lt)});const lp=a.z.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),up=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:lp,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()}),Vg=a.z.object({...up.shape,created_at:a.z.string()}),dp=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()}),Mg=hc.extend({...dp.shape,id:a.z.string()}),Er=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()}),$n=Er.extend({...hc.shape,hook_id:a.z.string()}),mc=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()}),pp=a.z.object({keys:a.z.array(mc)}),Do=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())}),fp=a.z.object({auth0Client:a.z.string().optional(),authParams:_c,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"}),Dg=a.z.object({...fp.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=(t=>(t.FAILED_SILENT_AUTH="fsa",t.FAILED_SIGNUP="fs",t.FAILED_LOGIN="f",t.FAILED_LOGIN_INCORRECT_PASSWORD="fp",t.FAILED_CHANGE_PASSWORD="fcp",t.FAILED_BY_CONNECTOR="fc",t.FAILED_LOGIN_INVALID_EMAIL_USERNAME="fu",t.FAILED_HOOK="fh",t.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",t.SUCCESS_API_OPERATION="sapi",t.SUCCESS_CHANGE_PASSWORD="scp",t.SUCCESS_CHANGE_PASSWORD_REQUEST="scpr",t.SUCCESS_CHANGE_USERNAME="scu",t.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",t.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",t.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",t.SUCCESS_LOGIN="s",t.SUCCESS_LOGOUT="slo",t.SUCCESS_SIGNUP="ss",t.SUCCESS_SILENT_AUTH="ssa",t.SUCCESS_VERIFICATION_EMAIL="sv",t.SUCCESS_VERIFICATION_EMAIL_REQUEST="svr",t.CODE_LINK_SENT="cls",t.BLOCKED_ACCOUNT_EMAIL="limit_wc",t.BLOCKED_ACCOUNT_IP="limit_sul",t.BLOCKED_IP_ADDRESS="limit_mu",t))(_e||{});const Fg=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"]),hp=a.z.object({name:a.z.string(),version:a.z.string(),env:a.z.object({node:a.z.string().optional()}).optional()}),Cr=a.z.object({type:Fg,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:hp.optional()}),gp=a.z.object({user_id:a.z.string(),password:a.z.string(),algorithm:a.z.enum(["bcrypt","argon2id"]).default("argon2id")}),Hg=a.z.object({...gp.shape,created_at:a.z.string(),updated_at:a.z.string()}),_p=a.z.object({initial_user_agent:a.z.string().describe("First user agent of the device from which this user logged in"),initial_ip:a.z.string().describe("First IP address associated with this session"),initial_asn:a.z.string().describe("First autonomous system number associated with this session"),last_user_agent:a.z.string().describe("Last user agent of the device from which this user logged in"),last_ip:a.z.string().describe("Last IP address from which this user logged in"),last_asn:a.z.string().describe("Last autonomous system number from which this user logged in")}),mp=a.z.object({id:a.z.string(),revoked_at:a.z.string().optional(),used_at:a.z.string().optional(),user_id:a.z.string().describe("The user ID associated with the session"),expires_at:a.z.string().optional(),idle_expires_at:a.z.string().optional(),device:_p.describe("Metadata related to the device used in the session"),clients:a.z.array(a.z.string()).describe("List of client details for the session")}),ys=a.z.object({created_at:a.z.string(),updated_at:a.z.string(),authenticated_at:a.z.string(),last_interaction_at:a.z.string(),...mp.shape}),Fo=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 hi=(t=>(t.RefreshToken="refresh_token",t.AuthorizationCode="authorization_code",t.ClientCredential="client_credentials",t.Passwordless="passwordless",t.Password="password",t))(hi||{});const yp=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 vp=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()}),wp=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()}),en=a.z.object({bold:a.z.boolean(),size:a.z.number()}),bp=a.z.object({body_text:en,buttons_text:en,font_url:a.z.string(),input_labels:en,links:en,links_style:a.z.enum(["normal"]),reference_text_size:a.z.number(),subtitle:en,title:en}),kp=a.z.object({background_color:a.z.string(),background_image_url:a.z.string(),page_layout:a.z.enum(["center"])}),xp=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"])}),Sp=a.z.object({borders:vp,colors:wp,displayName:a.z.string(),fonts:bp,page_background:kp,widget:xp}),qg=Sp.extend({themeId:a.z.string()}),dr=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()}),pr=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()}),yc=a.z.object({id:a.z.string(),session_id:a.z.string(),user_id:a.z.string(),client_id:a.z.string(),expires_at:a.z.string().optional(),idle_expires_at:a.z.string().optional(),last_exchanged_at:a.z.string().optional(),device:_p,resource_servers:a.z.array(a.z.object({audience:a.z.string(),scopes:a.z.string()})),rotating:a.z.boolean()}),Kg=a.z.object({created_at:a.z.string(),...yc.shape});function Wg(t){const[e,n]=t.split("|");if(!e||!n)throw new Error(`Invalid user_id: ${t}`);return{connection:e,id:n}}const Gg=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:Mo}},description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.branding.get(e);return n?t.json(n):t.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(Mo.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.branding.set(e,n),t.text("OK")});var j=class extends Error{constructor(e=500,n){super(n==null?void 0:n.message,{cause:n==null?void 0:n.cause});Q(this,"res");Q(this,"status");this.res=n==null?void 0:n.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})}},zr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ap(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Jg(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(n,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}),n}function Zg(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ip={exports:{}};const Yg={},Xg=Object.freeze(Object.defineProperty({__proto__:null,default:Yg},Symbol.toStringTag,{value:"Module"})),Qg=Jg(Xg);(function(t){/**
|
|
1
|
+
"use strict";var dm=Object.defineProperty;var pm=(t,e,n)=>e in t?dm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Q=(t,e,n)=>pm(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@hono/zod-openapi"),te=t=>typeof t=="string",hi=()=>{let t,e;const n=new Promise((i,r)=>{t=i,e=r});return n.resolve=t,n.reject=e,n},au=t=>t==null?"":""+t,fm=(t,e,n)=>{t.forEach(i=>{e[i]&&(n[i]=e[i])})},hm=/###/g,cu=t=>t&&t.indexOf("###")>-1?t.replace(hm,"."):t,lu=t=>!t||te(t),wi=(t,e,n)=>{const i=te(e)?e.split("."):e;let r=0;for(;r<i.length-1;){if(lu(t))return{};const s=cu(i[r]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++r}return lu(t)?{}:{obj:t,k:cu(i[r])}},uu=(t,e,n)=>{const{obj:i,k:r}=wi(t,e,Object);if(i!==void 0||e.length===1){i[r]=n;return}let s=e[e.length-1],o=e.slice(0,e.length-1),c=wi(t,o,Object);for(;c.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),c=wi(t,o,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${s}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${s}`]=n},gm=(t,e,n,i)=>{const{obj:r,k:s}=wi(t,e,Object);r[s]=r[s]||[],r[s].push(n)},Rr=(t,e)=>{const{obj:n,k:i}=wi(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,i))return n[i]},mm=(t,e,n)=>{const i=Rr(t,n);return i!==void 0?i:Rr(e,n)},Rp=(t,e,n)=>{for(const i in e)i!=="__proto__"&&i!=="constructor"&&(i in t?te(t[i])||t[i]instanceof String||te(e[i])||e[i]instanceof String?n&&(t[i]=e[i]):Rp(t[i],e[i],n):t[i]=e[i]);return t},zn=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var _m={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const ym=t=>te(t)?t.replace(/[&<>"'\/]/g,e=>_m[e]):t;class vm{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const n=this.regExpMap.get(e);if(n!==void 0)return n;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 wm=[" ",",","?","!",";"],bm=new vm(20),km=(t,e,n)=>{e=e||"",n=n||"";const i=wm.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(i.length===0)return!0;const r=bm.getRegExp(`(${i.map(o=>o==="?"?"\\?":o).join("|")})`);let s=!r.test(t);if(!s){const o=t.indexOf(n);o>0&&!r.test(t.substring(0,o))&&(s=!0)}return s},ca=function(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const i=e.split(n);let r=t;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+=n),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},Lr=t=>t==null?void 0:t.replace("_","-"),xm={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){var n,i;(i=(n=console==null?void 0:console[t])==null?void 0:n.apply)==null||i.call(n,console,e)}};class Ur{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(e,n)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=e||xm,this.options=n,this.debug=n.debug}log(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return this.forward(n,"log","",!0)}warn(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return this.forward(n,"warn","",!0)}error(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return this.forward(n,"error","")}deprecate(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,i,r){return r&&!this.debug?null:(te(e[0])&&(e[0]=`${i}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new Ur(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new Ur(this.logger,e)}}var wt=new Ur;class Ps{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(i=>{this.observers[i]||(this.observers[i]=new Map);const r=this.observers[i].get(n)||0;this.observers[i].set(n,r+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;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 du extends Ps{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=e||{},this.options=n,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 n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,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,n],i&&(Array.isArray(i)?c.push(...i):te(i)&&s?c.push(...i.split(s)):c.push(i)));const l=Rr(this.data,c);return!l&&!n&&!i&&e.indexOf(".")>-1&&(e=c[0],n=c[1],i=c.slice(2).join(".")),l||!o||!te(i)?l:ca((p=(u=this.data)==null?void 0:u[e])==null?void 0:p[n],i,s)}addResource(e,n,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,n];i&&(c=c.concat(o?i.split(o):i)),e.indexOf(".")>-1&&(c=e.split("."),r=n,n=c[1]),this.addNamespaces(n),uu(this.data,c,r),s.silent||this.emit("added",e,n,i,r)}addResources(e,n,i){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const s in i)(te(i[s])||Array.isArray(i[s]))&&this.addResource(e,n,s,i[s],{silent:!0});r.silent||this.emit("added",e,n,i)}addResourceBundle(e,n,i,r,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},c=[e,n];e.indexOf(".")>-1&&(c=e.split("."),r=i,i=n,n=c[1]),this.addNamespaces(n);let l=Rr(this.data,c)||{};o.skipCopy||(i=JSON.parse(JSON.stringify(i))),r?Rp(l,i,s):l={...l,...i},uu(this.data,c,l),o.silent||this.emit("added",e,n,i)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return this.getResource(e,n)!==void 0}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(r=>n[r]&&Object.keys(n[r]).length>0)}toJSON(){return this.data}}var Lp={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,i,r){return t.forEach(s=>{var o;e=((o=this.processors[s])==null?void 0:o.process(e,n,i,r))??e}),e}};const pu={};class Vr extends Ps{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),fm(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=wt.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(e==null)return!1;const i=this.resolve(e,n);return(i==null?void 0:i.res)!==void 0}extractFromKey(e,n){let i=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;i===void 0&&(i=":");const r=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const o=i&&e.indexOf(i)>-1,c=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!km(e,i,r);if(o&&!c){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:te(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:te(s)?[s]:s}}translate(e,n,i){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),e==null)return"";Array.isArray(e)||(e=[String(e)]);const r=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:o,namespaces:c}=this.extractFromKey(e[e.length-1],n),l=c[c.length-1],u=n.lng||this.language,p=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((u==null?void 0:u.toLowerCase())==="cimode"){if(p){const R=n.nsSeparator||this.options.nsSeparator;return r?{res:`${l}${R}${o}`,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${R}${o}`}return r?{res:o,usedKey:o,exactUsedKey:o,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:o}const f=this.resolve(e,n);let m=f==null?void 0:f.res;const v=(f==null?void 0:f.usedKey)||o,h=(f==null?void 0:f.exactUsedKey)||o,_=Object.prototype.toString.apply(m),y=["[object Number]","[object Function]","[object RegExp]"],x=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,C=!this.i18nFormat||this.i18nFormat.handleAsObject,j=!te(m)&&typeof m!="boolean"&&typeof m!="number";if(C&&m&&j&&y.indexOf(_)<0&&!(te(x)&&Array.isArray(m))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const R=this.options.returnedObjectHandler?this.options.returnedObjectHandler(v,m,{...n,ns:c}):`key '${o} (${this.language})' returned an object instead of string.`;return r?(f.res=R,f.usedParams=this.getUsedParamsDetails(n),f):R}if(s){const R=Array.isArray(m),ee=R?[]:{},pe=R?h:v;for(const le in m)if(Object.prototype.hasOwnProperty.call(m,le)){const Ue=`${pe}${s}${le}`;ee[le]=this.translate(Ue,{...n,joinArrays:!1,ns:c}),ee[le]===Ue&&(ee[le]=m[le])}m=ee}}else if(C&&te(x)&&Array.isArray(m))m=m.join(x),m&&(m=this.extendTranslation(m,e,n,i));else{let R=!1,ee=!1;const pe=n.count!==void 0&&!te(n.count),le=Vr.hasDefaultValue(n),Ue=pe?this.pluralResolver.getSuffix(u,n.count,n):"",ot=n.ordinal&&pe?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",We=pe&&!n.ordinal&&n.count===0,$=We&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${Ue}`]||n[`defaultValue${ot}`]||n.defaultValue;!this.isValidLookup(m)&&le&&(R=!0,m=$),this.isValidLookup(m)||(ee=!0,m=o);const A=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&ee?void 0:m,k=le&&$!==m&&this.options.updateMissing;if(ee||R||k){if(this.logger.log(k?"updateKey":"missingKey",u,l,o,k?$:m),s){const Y=this.resolve(o,{...n,keySeparator:!1});Y&&Y.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 b=[];const z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&z&&z[0])for(let Y=0;Y<z.length;Y++)b.push(z[Y]);else this.options.saveMissingTo==="all"?b=this.languageUtils.toResolveHierarchy(n.lng||this.language):b.push(n.lng||this.language);const L=(Y,W,ie)=>{var H;const ce=le&&ie!==m?ie:A;this.options.missingKeyHandler?this.options.missingKeyHandler(Y,l,W,ce,k,n):(H=this.backendConnector)!=null&&H.saveMissing&&this.backendConnector.saveMissing(Y,l,W,ce,k,n),this.emit("missingKey",Y,l,W,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&pe?b.forEach(Y=>{const W=this.pluralResolver.getSuffixes(Y,n);We&&n[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(ie=>{L([Y],o+ie,n[`defaultValue${ie}`]||$)})}):L(b,o,$))}m=this.extendTranslation(m,e,n,f,i),ee&&m===o&&this.options.appendNamespaceToMissingKey&&(m=`${l}:${o}`),(ee||R)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${o}`:o,R?m:void 0))}return r?(f.res=m,f.usedParams=this.getUsedParamsDetails(n),f):m}extendTranslation(e,n,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 f=te(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(f){const h=e.match(this.interpolator.nestingRegexp);m=h&&h.length}let v=i.replace&&!te(i.replace)?i.replace:i;if(this.options.interpolation.defaultVariables&&(v={...this.options.interpolation.defaultVariables,...v}),e=this.interpolator.interpolate(e,v,i.lng||this.language||r.usedLng,i),f){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),y=0;y<h;y++)_[y]=arguments[y];return(s==null?void 0:s[0])===_[0]&&!i.context?(o.logger.warn(`It seems you are nesting recursively key: ${_[0]} in key: ${n[0]}`),null):o.translate(..._,n)},i)),i.interpolation&&this.interpolator.reset()}const c=i.postProcess||this.options.postProcess,l=te(c)?[c]:c;return e!=null&&(l!=null&&l.length)&&i.applyPostProcessor!==!1&&(e=Lp.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(i)},...i}:i,this)),e}resolve(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i,r,s,o,c;return te(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(i))return;const u=this.extractFromKey(l,n),p=u.key;r=p;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const m=n.count!==void 0&&!te(n.count),v=m&&!n.ordinal&&n.count===0,h=n.context!==void 0&&(te(n.context)||typeof n.context=="number")&&n.context!=="",_=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(y=>{var x,C;this.isValidLookup(i)||(c=y,!pu[`${_[0]}-${y}`]&&((x=this.utils)!=null&&x.hasLoadedNamespace)&&!((C=this.utils)!=null&&C.hasLoadedNamespace(c))&&(pu[`${_[0]}-${y}`]=!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(j=>{var pe;if(this.isValidLookup(i))return;o=j;const R=[p];if((pe=this.i18nFormat)!=null&&pe.addLookupKeys)this.i18nFormat.addLookupKeys(R,p,j,y,n);else{let le;m&&(le=this.pluralResolver.getSuffix(j,n.count,n));const Ue=`${this.options.pluralSeparator}zero`,ot=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(R.push(p+le),n.ordinal&&le.indexOf(ot)===0&&R.push(p+le.replace(ot,this.options.pluralSeparator)),v&&R.push(p+Ue)),h){const We=`${p}${this.options.contextSeparator}${n.context}`;R.push(We),m&&(R.push(We+le),n.ordinal&&le.indexOf(ot)===0&&R.push(We+le.replace(ot,this.options.pluralSeparator)),v&&R.push(We+Ue))}}let ee;for(;ee=R.pop();)this.isValidLookup(i)||(s=ee,i=this.getResource(j,y,ee,n))}))})}),{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,n,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,n,i,r):this.resourceStore.getResource(e,n,i,r)}getUsedParamsDetails(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],i=e.replace&&!te(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 n)delete r[s]}return r}static hasDefaultValue(e){const n="defaultValue";for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&n===i.substring(0,n.length)&&e[i]!==void 0)return!0;return!1}}class fu{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=wt.create("languageUtils")}getScriptPartFromCode(e){if(e=Lr(e),!e||e.indexOf("-")<0)return null;const n=e.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(e=Lr(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(te(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch{}return n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n||(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 n;return e.forEach(i=>{if(n)return;const r=this.formatLanguageCode(i);(!this.options.supportedLngs||this.isSupportedCode(r))&&(n=r)}),!n&&this.options.supportedLngs&&e.forEach(i=>{if(n)return;const r=this.getLanguagePartFromCode(i);if(this.isSupportedCode(r))return n=r;n=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})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(e,n){if(!e)return[];if(typeof e=="function"&&(e=e(n)),te(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let i=e[n];return i||(i=e[this.getScriptPartFromCode(n)]),i||(i=e[this.formatLanguageCode(n)]),i||(i=e[this.getLanguagePartFromCode(n)]),i||(i=e.default),i||[]}toResolveHierarchy(e,n){const i=this.getFallbackCodes(n||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 te(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))):te(e)&&s(this.formatLanguageCode(e)),i.forEach(o=>{r.indexOf(o)<0&&s(this.formatLanguageCode(o))}),r}}const hu={zero:0,one:1,two:2,few:3,many:4,other:5},gu={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class Sm{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=wt.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=Lr(e==="dev"?"en":e),r=n.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!"),gu;if(!e.match(/-|_/))return gu;const l=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(l,n)}return this.pluralRulesCache[s]=o,o}needsPlural(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=this.getRule(e,n);return i||(i=this.getRule("dev",n)),(i==null?void 0:i.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,n){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,i).map(r=>`${n}${r}`)}getSuffixes(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=this.getRule(e,n);return i||(i=this.getRule("dev",n)),i?i.resolvedOptions().pluralCategories.sort((r,s)=>hu[r]-hu[s]).map(r=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${r}`):[]}getSuffix(e,n){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(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,i))}}const mu=function(t,e,n){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",r=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=mm(t,e,n);return!s&&r&&te(n)&&(s=ca(t,n,i),s===void 0&&(s=ca(e,n,i))),s},Vo=t=>t.replace(/\$/g,"$$$$");class Am{constructor(){var n;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=wt.create("interpolator"),this.options=e,this.format=((n=e==null?void 0:e.interpolation)==null?void 0:n.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:n,escapeValue:i,useRawValueToEscape:r,prefix:s,prefixEscaped:o,suffix:c,suffixEscaped:l,formatSeparator:u,unescapeSuffix:p,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:v,nestingSuffix:h,nestingSuffixEscaped:_,nestingOptionsSeparator:y,maxReplaces:x,alwaysFormat:C}=e.interpolation;this.escape=n!==void 0?n:ym,this.escapeValue=i!==void 0?i:!0,this.useRawValueToEscape=r!==void 0?r:!1,this.prefix=s?zn(s):o||"{{",this.suffix=c?zn(c):l||"}}",this.formatSeparator=u||",",this.unescapePrefix=p?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=m?zn(m):v||zn("$t("),this.nestingSuffix=h?zn(h):_||zn(")"),this.nestingOptionsSeparator=y||",",this.maxReplaces=x||1e3,this.alwaysFormat=C!==void 0?C:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,i)=>(n==null?void 0:n.source)===i?(n.lastIndex=0,n):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,n,i,r){var v;let s,o,c;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=h=>{if(h.indexOf(this.formatSeparator)<0){const C=mu(n,l,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(C,void 0,i,{...r,...n,interpolationkey:h}):C}const _=h.split(this.formatSeparator),y=_.shift().trim(),x=_.join(this.formatSeparator).trim();return this.format(mu(n,l,y,this.options.keySeparator,this.options.ignoreJSONStructure),x,i,{...r,...n,interpolationkey:y})};this.resetRegExp();const p=(r==null?void 0:r.missingInterpolationHandler)||this.options.missingInterpolationHandler,f=((v=r==null?void 0:r.interpolation)==null?void 0:v.skipOnVariables)!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>Vo(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?Vo(this.escape(h)):Vo(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 x=p(e,s,r);o=te(x)?x:""}else if(r&&Object.prototype.hasOwnProperty.call(r,_))o="";else if(f){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${_} for interpolating ${e}`),o="";else!te(o)&&!this.useRawValueToEscape&&(o=au(o));const y=h.safeValue(o);if(e=e.replace(s[0],y),f?(h.regex.lastIndex+=o.length,h.regex.lastIndex-=s[0].length):h.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),e}nest(e,n){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 f=l.split(new RegExp(`${p}[ ]*{`));let m=`{${f[1]}`;l=f[0],m=this.interpolate(m,o);const v=m.match(/'/g),h=m.match(/"/g);(((v==null?void 0:v.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&&!te(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(f=>f.trim());r[1]=p.shift(),l=p,u=!0}if(s=n(c.call(this,r[1].trim(),o),o),s&&r[0]===e&&!te(s))return s;te(s)||(s=au(s)),s||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),s=""),u&&(s=l.reduce((p,f)=>this.format(p,f,i.lng,{...i,interpolationkey:r[1].trim()}),s.trim())),e=e.replace(r[0],s),this.regexp.lastIndex=0}return e}}const Em=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const i=t.split("(");e=i[0].toLowerCase().trim();const r=i[1].substring(0,i[1].length-1);e==="currency"&&r.indexOf(":")<0?n.currency||(n.currency=r.trim()):e==="relativetime"&&r.indexOf(":")<0?n.range||(n.range=r.trim()):r.split(";").forEach(o=>{if(o){const[c,...l]=o.split(":"),u=l.join(":").trim().replace(/^'+|'+$/g,""),p=c.trim();n[p]||(n[p]=u),u==="false"&&(n[p]=!1),u==="true"&&(n[p]=!0),isNaN(u)||(n[p]=parseInt(u,10))}})}return{formatName:e,formatOptions:n}},Nn=t=>{const e={};return(n,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=t(Lr(i),r),e[o]=c),c(n)}};class Im{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=wt.create("formatter"),this.options=e,this.formats={number:Nn((n,i)=>{const r=new Intl.NumberFormat(n,{...i});return s=>r.format(s)}),currency:Nn((n,i)=>{const r=new Intl.NumberFormat(n,{...i,style:"currency"});return s=>r.format(s)}),datetime:Nn((n,i)=>{const r=new Intl.DateTimeFormat(n,{...i});return s=>r.format(s)}),relativetime:Nn((n,i)=>{const r=new Intl.RelativeTimeFormat(n,{...i});return s=>r.format(s,i.range||"day")}),list:Nn((n,i)=>{const r=new Intl.ListFormat(n,{...i});return s=>r.format(s)})},this.init(e)}init(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=n.interpolation.formatSeparator||","}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=Nn(n)}format(e,n,i){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=n.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 f;const{formatName:u,formatOptions:p}=Em(l);if(this.formats[u]){let m=c;try{const v=((f=r==null?void 0:r.formatParams)==null?void 0:f[r.interpolationkey])||{},h=v.locale||v.lng||r.locale||r.lng||i;m=this.formats[u](c,h,{...p,...r,...v})}catch(v){this.logger.warn(v)}return m}else this.logger.warn(`there was no format function for ${u}`);return c},e)}}const Cm=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class $m extends Ps{constructor(e,n,i){var s,o;let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=n,this.services=i,this.languageUtils=i.languageUtils,this.options=r,this.logger=wt.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,n,i,r){const s={},o={},c={},l={};return e.forEach(u=>{let p=!0;n.forEach(f=>{const m=`${u}|${f}`;!i.reload&&this.store.hasResourceBundle(u,f)?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[f]===void 0&&(l[f]=!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,n,i){const r=e.split("|"),s=r[0],o=r[1];n&&this.emit("failedLoading",s,o,n),!n&&i&&this.store.addResourceBundle(s,o,i,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&i&&(this.state[e]=0);const c={};this.queue.forEach(l=>{gm(l.loaded,[s],o),Cm(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(u=>{c[u]||(c[u]={});const p=l.loaded[u];p.length&&p.forEach(f=>{c[u][f]===void 0&&(c[u][f]=!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,n,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:n,fcName:i,tried:r,wait:s,callback:o});return}this.readingCalls++;const c=(u,p)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&p&&r<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,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,n);u&&typeof u.then=="function"?u.then(p=>c(null,p)).catch(c):c(null,u)}catch(u){c(u)}return}return l(e,n,c)}prepareLoading(e,n){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();te(e)&&(e=this.languageUtils.toResolveHierarchy(e)),te(n)&&(n=[n]);const s=this.queueLoad(e,n,i,r);if(!s.toLoad.length)return s.pending.length||r(),null;s.toLoad.forEach(o=>{this.loadOne(o)})}load(e,n,i){this.prepareLoading(e,n,{},i)}reload(e,n,i){this.prepareLoading(e,n,{reload:!0},i)}loadOne(e){let n=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(`${n}loading namespace ${s} for language ${r} failed`,o),!o&&c&&this.logger.log(`${n}loaded namespace ${s} for language ${r}`,c),this.loaded(e,o,c)})}saveMissing(e,n,i,r,s){var l,u,p,f,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&&!((f=(p=this.services)==null?void 0:p.utils)!=null&&f.hasLoadedNamespace(n))){this.logger.warn(`did not save key "${i}" as the namespace "${n}" 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 v={...o,isUpdate:s},h=this.backend.create.bind(this.backend);if(h.length<6)try{let _;h.length===5?_=h(e,n,i,r,v):_=h(e,n,i,r),_&&typeof _.then=="function"?_.then(y=>c(null,y)).catch(c):c(null,_)}catch(_){c(_)}else h(e,n,i,r,c,v)}!e||!e[0]||this.store.addResource(e[0],n,i,r)}}}const _u=()=>({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:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),te(t[1])&&(e.defaultValue=t[1]),te(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(i=>{e[i]=n[i]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),yu=t=>{var e,n;return te(t.ns)&&(t.ns=[t.ns]),te(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),te(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),((n=(e=t.supportedLngs)==null?void 0:e.indexOf)==null?void 0:n.call(e,"cimode"))<0&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),typeof t.initImmediate=="boolean"&&(t.initAsync=t.initImmediate),t},mr=()=>{},zm=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class Ci extends Ps{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=yu(e),this.services={},this.logger=wt,this.modules={external:[]},zm(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(i=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(te(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const r=_u();this.options={...r,...this.options,...yu(n)},this.options.interpolation={...r.interpolation,...this.options.interpolation},n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);const s=p=>p?typeof p=="function"?new p:p:null;if(!this.options.isClone){this.modules.logger?wt.init(s(this.modules.logger),this.options):wt.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:p=Im;const f=new fu(this.options);this.store=new du(this.options.resources,this.options);const m=this.services;m.logger=wt,m.resourceStore=this.store,m.languageUtils=f,m.pluralResolver=new Sm(f,{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 Am(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new $m(s(this.modules.backend),m.resourceStore,m,this.options),m.backendConnector.on("*",function(v){for(var h=arguments.length,_=new Array(h>1?h-1:0),y=1;y<h;y++)_[y-1]=arguments[y];e.emit(v,..._)}),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 Vr(this.services,this.options),this.translator.on("*",function(v){for(var h=arguments.length,_=new Array(h>1?h-1:0),y=1;y<h;y++)_[y-1]=arguments[y];e.emit(v,..._)}),this.modules.external.forEach(v=>{v.init&&v.init(this)})}if(this.format=this.options.interpolation.format,i||(i=mr),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=hi(),u=()=>{const p=(f,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(f,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]:mr;const r=te(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(f=>{f!=="cimode"&&c.indexOf(f)<0&&c.push(f)})};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,n,i){const r=hi();return typeof e=="function"&&(i=e,e=void 0),typeof n=="function"&&(i=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),i||(i=mr),this.services.backendConnector.reload(e,n,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"&&Lp.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 n=0;n<this.languages.length;n++){const i=this.languages[n];if(!(["cimode","dev"].indexOf(i)>-1)&&this.store.hasLanguageSomeTranslations(i)){this.resolvedLanguage=i;break}}}changeLanguage(e,n){var i=this;this.isLanguageChangingTo=e;const r=hi();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)}),n&&n(l,function(){return i.t(...arguments)})},c=l=>{var p,f;!e&&!l&&this.services.languageDetector&&(l=[]);const u=te(l)?l:this.services.languageUtils.getBestMatchFromCodes(l);u&&(this.language||s(u),this.translator.language||this.translator.changeLanguage(u),(f=(p=this.services.languageDetector)==null?void 0:p.cacheUserLanguage)==null||f.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,n,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),f=2;f<u;f++)p[f-2]=arguments[f];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 v;return l.keyPrefix&&Array.isArray(o)?v=o.map(h=>`${l.keyPrefix}${m}${h}`):v=l.keyPrefix?`${l.keyPrefix}${m}${o}`:o,r.t(v,l)};return te(e)?s.lng=e:s.lngs=e,s.ns=n,s.keyPrefix=i,s}t(){var r;for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return(r=this.translator)==null?void 0:r.translate(...n)}exists(){var r;for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return(r=this.translator)==null?void 0:r.exists(...n)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let n=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=n.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(n.precheck){const c=n.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,n){const i=hi();return this.options.ns?(te(e)&&(e=[e]),e.forEach(r=>{this.options.ns.indexOf(r)<0&&this.options.ns.push(r)}),this.loadResources(r=>{i.resolve(),n&&n(r)}),i):(n&&n(),Promise.resolve())}loadLanguages(e,n){const i=hi();te(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(),n&&n(o)}),i):(n&&n(),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 n=["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 fu(_u());return n.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]:{},n=arguments.length>1?arguments[1]:void 0;return new Ci(e,n)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:mr;const i=e.forkResourceStore;i&&delete e.forkResourceStore;const r={...this.options,...e,isClone:!0},s=new Ci(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,f)=>(p[f]={...l[u][f]},p),{})),{});s.store=new du(c,r),s.services.resourceStore=s.store}return s.translator=new Vr(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,n),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 re=Ci.createInstance();re.createInstance=Ci.createInstance;re.createInstance;re.dir;re.init;re.loadResources;re.reloadResources;re.use;re.changeLanguage;re.getFixedT;const fe=re.t;re.exists;re.setDefaultNamespace;re.hasLoadedNamespace;re.loadNamespaces;re.loadLanguages;const Yt=a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()}),Lc=a.z.object({created_at:a.z.string(),updated_at:a.z.string()}),Up=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()),Vp=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:Up.optional()}),Rs=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()}),Mr=Rs.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()}),Uc=a.z.object({...Mr.shape,...Lc.shape,user_id:a.z.string(),is_social:a.z.boolean(),email:a.z.string(),login_count:a.z.number(),identities:a.z.array(Vp).optional()}),vt=Uc,Nm=Rs.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()),jm="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Om=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=jm[n[t]&63];return e};const Mp=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:Mp.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(()=>Om()).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"})}),on=a.z.object({created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t),...Dr.shape});var fn=(t=>(t.TOKEN="token",t.TOKEN_ID_TOKEN="token id_token",t.CODE="code",t))(fn||{}),Wt=(t=>(t.QUERY="query",t.FRAGMENT="fragment",t.FORM_POST="form_post",t.WEB_MESSAGE="web_message",t.SAML_POST="saml_post",t))(Wt||{}),Ls=(t=>(t.S256="S256",t.Plain="plain",t))(Ls||{});const Vc=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(fn).optional(),response_mode:a.z.nativeEnum(Wt).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(Ls).optional(),code_challenge:a.z.string().optional(),username:a.z.string().optional(),ui_locales:a.z.string().optional()}),la=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()}),Hr=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()}),Vt=a.z.object({id:a.z.string(),created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t)}).extend(Hr.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(),id:a.z.string().optional()}),Pn=a.z.object({created_at:a.z.string().transform(t=>t===null?"":t),updated_at:a.z.string().transform(t=>t===null?"":t),...Fr.shape,id:a.z.string()}),Dp=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()}),Bm=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({...on.shape,domains:a.z.array(Bm),tenant:Pn,connections:a.z.array(Vt)});const Hp=a.z.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),Fp=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:Hp,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()}),Tm=a.z.object({...Fp.shape,created_at:a.z.string()}),qp=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()}),Pm=Lc.extend({...qp.shape,id:a.z.string()}),qr=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()}),Bn=qr.extend({...Lc.shape,hook_id:a.z.string()}),Mc=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()}),Kp=a.z.object({keys:a.z.array(Mc)}),ua=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())}),Wp=a.z.object({auth0Client:a.z.string().optional(),authParams:Vc,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"}),Rm=a.z.object({...Wp.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 me=(t=>(t.FAILED_SILENT_AUTH="fsa",t.FAILED_SIGNUP="fs",t.FAILED_LOGIN="f",t.FAILED_LOGIN_INCORRECT_PASSWORD="fp",t.FAILED_CHANGE_PASSWORD="fcp",t.FAILED_BY_CONNECTOR="fc",t.FAILED_LOGIN_INVALID_EMAIL_USERNAME="fu",t.FAILED_HOOK="fh",t.FAILED_CROSS_ORIGIN_AUTHENTICATION="fcoa",t.SUCCESS_API_OPERATION="sapi",t.SUCCESS_CHANGE_PASSWORD="scp",t.SUCCESS_CHANGE_PASSWORD_REQUEST="scpr",t.SUCCESS_CHANGE_USERNAME="scu",t.SUCCESS_CROSS_ORIGIN_AUTHENTICATION="scoa",t.SUCCESS_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN="seacft",t.SUCCESS_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN="serft",t.SUCCESS_LOGIN="s",t.SUCCESS_LOGOUT="slo",t.SUCCESS_SIGNUP="ss",t.SUCCESS_SILENT_AUTH="ssa",t.SUCCESS_VERIFICATION_EMAIL="sv",t.SUCCESS_VERIFICATION_EMAIL_REQUEST="svr",t.CODE_LINK_SENT="cls",t.BLOCKED_ACCOUNT_EMAIL="limit_wc",t.BLOCKED_ACCOUNT_IP="limit_sul",t.BLOCKED_IP_ADDRESS="limit_mu",t))(me||{});const Lm=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"]),Gp=a.z.object({name:a.z.string(),version:a.z.string(),env:a.z.object({node:a.z.string().optional()}).optional()}),Kr=a.z.object({type:Lm,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:Gp.optional()}),Jp=a.z.object({user_id:a.z.string(),password:a.z.string(),algorithm:a.z.enum(["bcrypt","argon2id"]).default("argon2id")}),Um=a.z.object({...Jp.shape,created_at:a.z.string(),updated_at:a.z.string()}),Zp=a.z.object({initial_user_agent:a.z.string().describe("First user agent of the device from which this user logged in"),initial_ip:a.z.string().describe("First IP address associated with this session"),initial_asn:a.z.string().describe("First autonomous system number associated with this session"),last_user_agent:a.z.string().describe("Last user agent of the device from which this user logged in"),last_ip:a.z.string().describe("Last IP address from which this user logged in"),last_asn:a.z.string().describe("Last autonomous system number from which this user logged in")}),Yp=a.z.object({id:a.z.string(),revoked_at:a.z.string().optional(),used_at:a.z.string().optional(),user_id:a.z.string().describe("The user ID associated with the session"),expires_at:a.z.string().optional(),idle_expires_at:a.z.string().optional(),device:Zp.describe("Metadata related to the device used in the session"),clients:a.z.array(a.z.string()).describe("List of client details for the session")}),Us=a.z.object({created_at:a.z.string(),updated_at:a.z.string(),authenticated_at:a.z.string(),last_interaction_at:a.z.string(),...Yp.shape}),da=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 bi=(t=>(t.RefreshToken="refresh_token",t.AuthorizationCode="authorization_code",t.ClientCredential="client_credentials",t.Passwordless="passwordless",t.Password="password",t))(bi||{});const Xp=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 Qp=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()}),ef=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()}),rn=a.z.object({bold:a.z.boolean(),size:a.z.number()}),tf=a.z.object({body_text:rn,buttons_text:rn,font_url:a.z.string(),input_labels:rn,links:rn,links_style:a.z.enum(["normal"]),reference_text_size:a.z.number(),subtitle:rn,title:rn}),nf=a.z.object({background_color:a.z.string(),background_image_url:a.z.string(),page_layout:a.z.enum(["center"])}),rf=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"])}),sf=a.z.object({borders:Qp,colors:ef,displayName:a.z.string(),fonts:tf,page_background:nf,widget:rf}),Vm=sf.extend({themeId:a.z.string()}),Sr=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()}),Ar=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()}),Dc=a.z.object({id:a.z.string(),session_id:a.z.string(),user_id:a.z.string(),client_id:a.z.string(),expires_at:a.z.string().optional(),idle_expires_at:a.z.string().optional(),last_exchanged_at:a.z.string().optional(),device:Zp,resource_servers:a.z.array(a.z.object({audience:a.z.string(),scopes:a.z.string()})),rotating:a.z.boolean()}),Mm=a.z.object({created_at:a.z.string(),...Dc.shape});function Dm(t){const[e,n]=t.split("|");if(!e||!n)throw new Error(`Invalid user_id: ${t}`);return{connection:e,id:n}}const Hm=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:la}},description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.branding.get(e);return n?t.json(n):t.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(la.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.branding.set(e,n),t.text("OK")});var O=class extends Error{constructor(e=500,n){super(n==null?void 0:n.message,{cause:n==null?void 0:n.cause});Q(this,"res");Q(this,"status");this.res=n==null?void 0:n.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})}},Wr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function of(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Fm(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(n,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}),n}function qm(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var af={exports:{}};const Km={},Wm=Object.freeze(Object.defineProperty({__proto__:null,default:Km},Symbol.toStringTag,{value:"Module"})),Gm=Fm(Wm);(function(t){/**
|
|
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,n){typeof Zg=="function"&&t&&t.exports?t.exports=n():(e.dcodeIO=e.dcodeIO||{}).bcrypt=n()})(zr,function(){var e={},n=null;function i(C){if(t&&t.exports)try{return Qg.randomBytes(C)}catch{}try{var E;return(self.crypto||self.msCrypto).getRandomValues(E=new Uint32Array(C)),Array.prototype.slice.call(E)}catch{}if(!n)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return n(C)}var r=!1;try{i(1),r=!0}catch{}n=null,e.setRandomFallback=function(C){n=C},e.genSaltSync=function(C,E){if(C=C||m,typeof C!="number")throw Error("Illegal arguments: "+typeof C+", "+typeof E);C<4?C=4:C>31&&(C=31);var A=[];return A.push("$2a$"),C<10&&A.push("0"),A.push(C.toString()),A.push("$"),A.push(g(i(h),h)),A.join("")},e.genSalt=function(C,E,A){if(typeof E=="function"&&(A=E,E=void 0),typeof C=="function"&&(A=C,C=void 0),typeof C>"u")C=m;else if(typeof C!="number")throw Error("illegal arguments: "+typeof C);function w(v){o(function(){try{v(null,e.genSaltSync(C))}catch(z){v(z)}})}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);w(A)}else return new Promise(function(v,z){w(function(R,Y){if(R){z(R);return}v(Y)})})},e.hashSync=function(C,E){if(typeof E>"u"&&(E=m),typeof E=="number"&&(E=e.genSaltSync(E)),typeof C!="string"||typeof E!="string")throw Error("Illegal arguments: "+typeof C+", "+typeof E);return Ke(C,E)},e.hash=function(C,E,A,w){function v(z){typeof C=="string"&&typeof E=="number"?e.genSalt(E,function(R,Y){Ke(C,Y,z,w)}):typeof C=="string"&&typeof E=="string"?Ke(C,E,z,w):o(z.bind(this,Error("Illegal arguments: "+typeof C+", "+typeof E)))}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);v(A)}else return new Promise(function(z,R){v(function(Y,W){if(Y){R(Y);return}z(W)})})};function s(C,E){for(var A=0,w=0,v=0,z=C.length;v<z;++v)C.charCodeAt(v)===E.charCodeAt(v)?++A:++w;return A<0?!1:w===0}e.compareSync=function(C,E){if(typeof C!="string"||typeof E!="string")throw Error("Illegal arguments: "+typeof C+", "+typeof E);return E.length!==60?!1:s(e.hashSync(C,E.substr(0,E.length-31)),E)},e.compare=function(C,E,A,w){function v(z){if(typeof C!="string"||typeof E!="string"){o(z.bind(this,Error("Illegal arguments: "+typeof C+", "+typeof E)));return}if(E.length!==60){o(z.bind(this,null,!1));return}e.hash(C,E.substr(0,29),function(R,Y){R?z(R):z(null,s(Y,E))},w)}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);v(A)}else return new Promise(function(z,R){v(function(Y,W){if(Y){R(Y);return}z(W)})})},e.getRounds=function(C){if(typeof C!="string")throw Error("Illegal arguments: "+typeof C);return parseInt(C.split("$")[2],10)},e.getSalt=function(C){if(typeof C!="string")throw Error("Illegal arguments: "+typeof C);if(C.length!==60)throw Error("Illegal hash length: "+C.length+" != 60");return C.substring(0,29)};var o=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function c(C){var E=[],A=0;return k.encodeUTF16toUTF8(function(){return A>=C.length?null:C.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(C,E){var A=0,w=[],v,z;if(E<=0||E>C.length)throw Error("Illegal len: "+E);for(;A<E;){if(v=C[A++]&255,w.push(l[v>>2&63]),v=(v&3)<<4,A>=E){w.push(l[v&63]);break}if(z=C[A++]&255,v|=z>>4&15,w.push(l[v&63]),v=(z&15)<<2,A>=E){w.push(l[v&63]);break}z=C[A++]&255,v|=z>>6&3,w.push(l[v&63]),w.push(l[z&63])}return w.join("")}function _(C,E){var A=0,w=C.length,v=0,z=[],R,Y,W,ne,ae,D;if(E<=0)throw Error("Illegal len: "+E);for(;A<w-1&&v<E&&(D=C.charCodeAt(A++),R=D<u.length?u[D]:-1,D=C.charCodeAt(A++),Y=D<u.length?u[D]:-1,!(R==-1||Y==-1||(ae=R<<2>>>0,ae|=(Y&48)>>4,z.push(p(ae)),++v>=E||A>=w)||(D=C.charCodeAt(A++),W=D<u.length?u[D]:-1,W==-1)||(ae=(Y&15)<<4>>>0,ae|=(W&60)>>2,z.push(p(ae)),++v>=E||A>=w)));)D=C.charCodeAt(A++),ne=D<u.length?u[D]:-1,ae=(W&3)<<6>>>0,ae|=ne,z.push(p(ae)),++v;var Ie=[];for(A=0;A<v;A++)Ie.push(z[A].charCodeAt(0));return Ie}var k=function(){var C={};return C.MAX_CODEPOINT=1114111,C.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},C.decodeUTF8=function(E,A){for(var w,v,z,R,Y=function(W){W=W.slice(0,W.indexOf(null));var ne=Error(W.toString());throw ne.name="TruncatedError",ne.bytes=W,ne};(w=E())!==null;)if(!(w&128))A(w);else if((w&224)===192)(v=E())===null&&Y([w,v]),A((w&31)<<6|v&63);else if((w&240)===224)((v=E())===null||(z=E())===null)&&Y([w,v,z]),A((w&15)<<12|(v&63)<<6|z&63);else if((w&248)===240)((v=E())===null||(z=E())===null||(R=E())===null)&&Y([w,v,z,R]),A((w&7)<<18|(v&63)<<12|(z&63)<<6|R&63);else throw RangeError("Illegal starting byte: "+w)},C.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)},C.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},C.encodeUTF16toUTF8=function(E,A){C.UTF16toUTF8(E,function(w){C.encodeUTF8(w,A)})},C.decodeUTF8toUTF16=function(E,A){C.decodeUTF8(E,function(w){C.UTF8toUTF16(w,A)})},C.calculateCodePoint=function(E){return E<128?1:E<2048?2:E<65536?3:4},C.calculateUTF8=function(E){for(var A,w=0;(A=E())!==null;)w+=C.calculateCodePoint(A);return w},C.calculateUTF16asUTF8=function(E){var A=0,w=0;return C.UTF16toUTF8(E,function(v){++A,w+=C.calculateCodePoint(v)}),[A,w]},C}();Date.now=Date.now||function(){return+new Date};var h=16,m=10,b=16,S=100,O=[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 ce(C,E,A,w){var v,z=C[E],R=C[E+1];return z^=A[0],v=w[z>>>24],v+=w[256|z>>16&255],v^=w[512|z>>8&255],v+=w[768|z&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],z^=v^A[2],v=w[z>>>24],v+=w[256|z>>16&255],v^=w[512|z>>8&255],v+=w[768|z&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],z^=v^A[4],v=w[z>>>24],v+=w[256|z>>16&255],v^=w[512|z>>8&255],v+=w[768|z&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],z^=v^A[6],v=w[z>>>24],v+=w[256|z>>16&255],v^=w[512|z>>8&255],v+=w[768|z&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],z^=v^A[8],v=w[z>>>24],v+=w[256|z>>16&255],v^=w[512|z>>8&255],v+=w[768|z&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],z^=v^A[10],v=w[z>>>24],v+=w[256|z>>16&255],v^=w[512|z>>8&255],v+=w[768|z&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],z^=v^A[12],v=w[z>>>24],v+=w[256|z>>16&255],v^=w[512|z>>8&255],v+=w[768|z&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],z^=v^A[14],v=w[z>>>24],v+=w[256|z>>16&255],v^=w[512|z>>8&255],v+=w[768|z&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],z^=v^A[16],C[E]=R^A[b+1],C[E+1]=z,C}function he(C,E){for(var A=0,w=0;A<4;++A)w=w<<8|C[E]&255,E=(E+1)%C.length;return{key:w,offp:E}}function ue(C,E,A){for(var w=0,v=[0,0],z=E.length,R=A.length,Y,W=0;W<z;W++)Y=he(C,w),w=Y.offp,E[W]=E[W]^Y.key;for(W=0;W<z;W+=2)v=ce(v,0,E,A),E[W]=v[0],E[W+1]=v[1];for(W=0;W<R;W+=2)v=ce(v,0,E,A),A[W]=v[0],A[W+1]=v[1]}function Le(C,E,A,w){for(var v=0,z=[0,0],R=A.length,Y=w.length,W,ne=0;ne<R;ne++)W=he(E,v),v=W.offp,A[ne]=A[ne]^W.key;for(v=0,ne=0;ne<R;ne+=2)W=he(C,v),v=W.offp,z[0]^=W.key,W=he(C,v),v=W.offp,z[1]^=W.key,z=ce(z,0,A,w),A[ne]=z[0],A[ne+1]=z[1];for(ne=0;ne<Y;ne+=2)W=he(C,v),v=W.offp,z[0]^=W.key,W=he(C,v),v=W.offp,z[1]^=W.key,z=ce(z,0,A,w),w[ne]=z[0],w[ne+1]=z[1]}function st(C,E,A,w,v){var z=K.slice(),R=z.length,Y;if(A<4||A>31)if(Y=Error("Illegal number of rounds (4-31): "+A),w){o(w.bind(this,Y));return}else throw Y;if(E.length!==h)if(Y=Error("Illegal salt length: "+E.length+" != "+h),w){o(w.bind(this,Y));return}else throw Y;A=1<<A>>>0;var W,ne,ae=0,D;Int32Array?(W=new Int32Array(O),ne=new Int32Array(T)):(W=O.slice(),ne=T.slice()),Le(E,C,W,ne);function Ie(){if(v&&v(ae/A),ae<A)for(var fe=Date.now();ae<A&&(ae=ae+1,ue(C,W,ne),ue(E,W,ne),!(Date.now()-fe>S)););else{for(ae=0;ae<64;ae++)for(D=0;D<R>>1;D++)ce(z,D<<1,W,ne);var xe=[];for(ae=0;ae<R;ae++)xe.push((z[ae]>>24&255)>>>0),xe.push((z[ae]>>16&255)>>>0),xe.push((z[ae]>>8&255)>>>0),xe.push((z[ae]&255)>>>0);if(w){w(null,xe);return}else return xe}w&&o(Ie)}if(typeof w<"u")Ie();else for(var Qt;;)if(typeof(Qt=Ie())<"u")return Qt||[]}function Ke(C,E,A,w){var v;if(typeof C!="string"||typeof E!="string")if(v=Error("Invalid string / salt: Not a string"),A){o(A.bind(this,v));return}else throw v;var z,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)==="$")z="\0",R=3;else{if(z=E.charAt(2),z!=="a"&&z!=="b"&&z!=="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 Y=parseInt(E.substring(R,R+1),10)*10,W=parseInt(E.substring(R+1,R+2),10),ne=Y+W,ae=E.substring(R+3,R+25);C+=z>="a"?"\0":"";var D=c(C),Ie=_(ae,h);function Qt(fe){var xe=[];return xe.push("$2"),z>="a"&&xe.push(z),xe.push("$"),ne<10&&xe.push("0"),xe.push(ne.toString()),xe.push("$"),xe.push(g(Ie,Ie.length)),xe.push(g(fe,K.length*4-1)),xe.join("")}if(typeof A>"u")return Qt(st(D,Ie,ne));st(D,Ie,ne,function(fe,xe){fe?A(fe,null):A(null,Qt(xe))},w)}return e.encodeBase64=g,e.decodeBase64=_,e})})(Ip);var e_=Ip.exports;const vc=Ap(e_),t_="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let n_=t=>crypto.getRandomValues(new Uint8Array(t)),i_=(t,e,n)=>{let i=(2<<Math.log2(t.length-1))-1,r=-~(1.6*i*e/t.length);return(s=e)=>{let o="";for(;;){let c=n(r),l=r;for(;l--;)if(o+=t[c[l]&i]||"",o.length===s)return o}}},r_=(t,e=21)=>i_(t,e,n_),De=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=t_[n[t]&63];return e};const s_=24;function wc(){return r_("0123456789abcdef",s_)()}function ql(t){if(!t.includes("|"))return console.error("Invalid user_id format"),t;const[,e]=t.split("|");return e}async function Ep(t,e,n){return(await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`})).users}async function bc({userAdapter:t,tenant_id:e,email:n,provider:i}){const{users:r}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n} provider:${i}`});return r.length>1&&console.error("More than one user found for same email and provider"),r[0]||null}async function vs({userAdapter:t,tenant_id:e,email:n}){var c;const{users:i}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`}),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 t.get(e,(c=r[0])==null?void 0:c.linked_to);if(!o)throw new Error("Primary account not found");return o}async function ws({userAdapter:t,tenant_id:e,email:n,provider:i}){const r=await bc({userAdapter:t,tenant_id:e,email:n,provider:i});return r?r.linked_to?t.get(e,r.linked_to):r:null}const dn=a.z.object({page:a.z.string().min(0).optional().default("0").transform(t=>parseInt(t,10)).openapi({description:"The page number where 0 is the first page"}),per_page:a.z.string().min(1).optional().default("10").transform(t=>parseInt(t,10)).openapi({description:"The number of items per page"}),include_totals:a.z.string().optional().default("false").transform(t=>t==="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 Jn(t){if(!t)return;const[e,n]=t.split(":"),i=n==="1"?"asc":"desc";if(!(!e||!i))return{sort_by:e,sort_order:i}}function be(t,e){return{type:e.type,description:e.description||"",ip:t.req.header("x-real-ip")||"",user_agent:t.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:t.req.method,path:t.req.path,qs:t.req.queries(),body:e.body||t.var.body||""}},isMobile:!1,client_id:t.var.client_id,client_name:"",user_id:e.userId||t.var.user_id||"",hostname:t.req.header("host")||"",user_name:t.var.username||"",connection_id:"",connection:t.var.connection||"",strategy:e.strategy||"",strategy_type:e.strategy_type||"",audience:"",scope:[]}}var o_={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},a_=()=>{var n,i;const t=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[r,s]of Object.entries(o_))if(c_(s))return r}return typeof(t==null?void 0:t.EdgeRuntime)=="string"?"edge-light":(t==null?void 0:t.fastly)!==void 0?"fastly":((i=(n=t==null?void 0:t.process)==null?void 0:n.release)==null?void 0:i.name)==="node"?"node":"other"},c_=t=>navigator.userAgent.startsWith(t);function Ye(t,e){a_()==="workerd"&&t.executionCtx.waitUntil(e)}const Kl=Gt.extend({users:a.z.array(yt)}),l_=Gt.extend({sessions:a.z.array(ys)}),u_=new a.OpenAPIHono().openapi(a.createRoute({tags:["users"],method:"get",path:"/",request:{query:dn,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(yt),Kl])}},description:"List of users"}}}),async t=>{const{page:e,per_page:n,include_totals:i,sort:r,q:s}=t.req.valid("query"),{"tenant-id":o}=t.req.valid("header");if(s!=null&&s.includes("identities.profileData.email")){const p=s.split("=")[1],_=(await t.env.data.users.list(o,{page:e,per_page:n,include_totals:i,q:`email:${p}`})).users.filter(m=>m.linked_to),[k]=_;if(!k)return t.json([]);const h=await t.env.data.users.get(o,k.linked_to);if(!h)throw new j(500,{message:"Primary account not found"});return t.json([yt.parse(h)])}const c=["-_exists_:linked_to"];s&&c.push(s);const l=await t.env.data.users.list(o,{page:e,per_page:n,include_totals:i,sort:Jn(r),q:c.join(" ")}),u=l.users.filter(p=>!p.linked_to);return i?t.json(Kl.parse({users:u,length:l.length,start:l.start,limit:l.limit})):t.json(a.z.array(yt).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:yt}},description:"List of users"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{"tenant-id":n}=t.req.valid("header"),i=await t.env.data.users.get(n,e);if(!i)throw new j(404);if(i.linked_to)throw new j(404,{message:"User is linked to another user"});return t.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 t=>{const{user_id:e}=t.req.valid("param"),{"tenant-id":n}=t.req.valid("header");if(!await t.env.data.users.remove(n,e))throw new j(404);return t.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({...xr.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:yt}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");t.set("body",n);const{email:i}=n;if(!i)throw new j(400,{message:"Email is required"});const r=i.toLowerCase(),s=`${n.provider}|${n.user_id||wc()}`;try{const o=await t.env.data.users.create(e,{email:r,user_id:s,name:n.name||r,provider:n.provider,connection:n.connection,email_verified:n.email_verified||!1,last_ip:"",is_social:!1,last_login:new Date().toISOString()});t.set("user_id",o.user_id);const c=be(t,{type:_e.SUCCESS_API_OPERATION,description:"User created"});Ye(t,t.env.data.logs.create(e,c));const l={...o,identities:[{connection:o.connection,provider:o.provider,user_id:ql(o.user_id),isSocial:o.is_social}]};return t.json(yt.parse(l),{status:201})}catch(o){throw o.message==="User already exists"?new j(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({...xr.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 t=>{var u;const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),{user_id:i}=t.req.valid("param"),{verify_email:r,password:s,...o}=n,c=await t.env.data.users.get(e,i);if(!c)throw new j(404);if(o.email&&o.email!==c.email){const p=await Ep(t.env.data.users,e,o.email);if(p.length&&p.some(g=>g.user_id!==i))throw new j(409,{message:"Another user with the same email address already exists."})}if(c.linked_to)throw new j(404,{message:"User is linked to another user"});if(await t.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 j(400,{message:"User does not have a password identity"});await t.env.data.passwords.update(e,{user_id:`${p.provider}|${p.user_id}`,password:vc.hashSync(s,10),algorithm:"bcrypt"})}const l=await t.env.data.users.get(e,i);if(!l)throw new j(500);return t.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 t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),{user_id:i}=t.req.valid("param"),r="link_with"in n?n.link_with:n.user_id,s=await t.env.data.users.get(e,i);if(!s)throw new j(400,{message:"Linking an inexistent identity is not allowed."});await t.env.data.users.update(e,r,{linked_to:i});const o=await t.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:ql(l.user_id),isSocial:l.is_social}));return t.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(yt)}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{user_id:n,provider:i,linked_user_id:r}=t.req.valid("param");await t.env.data.users.unlink(e,n,i,r);const s=await t.env.data.users.get(e,n);if(!s)throw new j(404);return t.json([yt.parse(s)])}).openapi(a.createRoute({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:dn,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(ys),l_])}},description:"List of sessions"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{include_totals:n}=t.req.valid("query"),{"tenant-id":i}=t.req.valid("header"),r=await t.env.data.sessions.list(i,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return n?t.json(r):t.json(r.sessions)});/*! *****************************************************************************
|
|
5
|
+
*/(function(e,n){typeof qm=="function"&&t&&t.exports?t.exports=n():(e.dcodeIO=e.dcodeIO||{}).bcrypt=n()})(Wr,function(){var e={},n=null;function i($){if(t&&t.exports)try{return Gm.randomBytes($)}catch{}try{var I;return(self.crypto||self.msCrypto).getRandomValues(I=new Uint32Array($)),Array.prototype.slice.call(I)}catch{}if(!n)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return n($)}var r=!1;try{i(1),r=!0}catch{}n=null,e.setRandomFallback=function($){n=$},e.genSaltSync=function($,I){if($=$||_,typeof $!="number")throw Error("Illegal arguments: "+typeof $+", "+typeof I);$<4?$=4:$>31&&($=31);var A=[];return A.push("$2a$"),$<10&&A.push("0"),A.push($.toString()),A.push("$"),A.push(f(i(h),h)),A.join("")},e.genSalt=function($,I,A){if(typeof I=="function"&&(A=I,I=void 0),typeof $=="function"&&(A=$,$=void 0),typeof $>"u")$=_;else if(typeof $!="number")throw Error("illegal arguments: "+typeof $);function k(b){o(function(){try{b(null,e.genSaltSync($))}catch(z){b(z)}})}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);k(A)}else return new Promise(function(b,z){k(function(L,Y){if(L){z(L);return}b(Y)})})},e.hashSync=function($,I){if(typeof I>"u"&&(I=_),typeof I=="number"&&(I=e.genSaltSync(I)),typeof $!="string"||typeof I!="string")throw Error("Illegal arguments: "+typeof $+", "+typeof I);return We($,I)},e.hash=function($,I,A,k){function b(z){typeof $=="string"&&typeof I=="number"?e.genSalt(I,function(L,Y){We($,Y,z,k)}):typeof $=="string"&&typeof I=="string"?We($,I,z,k):o(z.bind(this,Error("Illegal arguments: "+typeof $+", "+typeof I)))}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);b(A)}else return new Promise(function(z,L){b(function(Y,W){if(Y){L(Y);return}z(W)})})};function s($,I){for(var A=0,k=0,b=0,z=$.length;b<z;++b)$.charCodeAt(b)===I.charCodeAt(b)?++A:++k;return A<0?!1:k===0}e.compareSync=function($,I){if(typeof $!="string"||typeof I!="string")throw Error("Illegal arguments: "+typeof $+", "+typeof I);return I.length!==60?!1:s(e.hashSync($,I.substr(0,I.length-31)),I)},e.compare=function($,I,A,k){function b(z){if(typeof $!="string"||typeof I!="string"){o(z.bind(this,Error("Illegal arguments: "+typeof $+", "+typeof I)));return}if(I.length!==60){o(z.bind(this,null,!1));return}e.hash($,I.substr(0,29),function(L,Y){L?z(L):z(null,s(Y,I))},k)}if(A){if(typeof A!="function")throw Error("Illegal callback: "+typeof A);b(A)}else return new Promise(function(z,L){b(function(Y,W){if(Y){L(Y);return}z(W)})})},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 I=[],A=0;return v.encodeUTF16toUTF8(function(){return A>=$.length?null:$.charCodeAt(A++)},function(k){I.push(k)}),I}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 f($,I){var A=0,k=[],b,z;if(I<=0||I>$.length)throw Error("Illegal len: "+I);for(;A<I;){if(b=$[A++]&255,k.push(l[b>>2&63]),b=(b&3)<<4,A>=I){k.push(l[b&63]);break}if(z=$[A++]&255,b|=z>>4&15,k.push(l[b&63]),b=(z&15)<<2,A>=I){k.push(l[b&63]);break}z=$[A++]&255,b|=z>>6&3,k.push(l[b&63]),k.push(l[z&63])}return k.join("")}function m($,I){var A=0,k=$.length,b=0,z=[],L,Y,W,ie,ce,H;if(I<=0)throw Error("Illegal len: "+I);for(;A<k-1&&b<I&&(H=$.charCodeAt(A++),L=H<u.length?u[H]:-1,H=$.charCodeAt(A++),Y=H<u.length?u[H]:-1,!(L==-1||Y==-1||(ce=L<<2>>>0,ce|=(Y&48)>>4,z.push(p(ce)),++b>=I||A>=k)||(H=$.charCodeAt(A++),W=H<u.length?u[H]:-1,W==-1)||(ce=(Y&15)<<4>>>0,ce|=(W&60)>>2,z.push(p(ce)),++b>=I||A>=k)));)H=$.charCodeAt(A++),ie=H<u.length?u[H]:-1,ce=(W&3)<<6>>>0,ce|=ie,z.push(p(ce)),++b;var Ie=[];for(A=0;A<b;A++)Ie.push(z[A].charCodeAt(0));return Ie}var v=function(){var $={};return $.MAX_CODEPOINT=1114111,$.encodeUTF8=function(I,A){var k=null;for(typeof I=="number"&&(k=I,I=function(){return null});k!==null||(k=I())!==null;)k<128?A(k&127):k<2048?(A(k>>6&31|192),A(k&63|128)):k<65536?(A(k>>12&15|224),A(k>>6&63|128),A(k&63|128)):(A(k>>18&7|240),A(k>>12&63|128),A(k>>6&63|128),A(k&63|128)),k=null},$.decodeUTF8=function(I,A){for(var k,b,z,L,Y=function(W){W=W.slice(0,W.indexOf(null));var ie=Error(W.toString());throw ie.name="TruncatedError",ie.bytes=W,ie};(k=I())!==null;)if(!(k&128))A(k);else if((k&224)===192)(b=I())===null&&Y([k,b]),A((k&31)<<6|b&63);else if((k&240)===224)((b=I())===null||(z=I())===null)&&Y([k,b,z]),A((k&15)<<12|(b&63)<<6|z&63);else if((k&248)===240)((b=I())===null||(z=I())===null||(L=I())===null)&&Y([k,b,z,L]),A((k&7)<<18|(b&63)<<12|(z&63)<<6|L&63);else throw RangeError("Illegal starting byte: "+k)},$.UTF16toUTF8=function(I,A){for(var k,b=null;(k=b!==null?b:I())!==null;){if(k>=55296&&k<=57343&&(b=I())!==null&&b>=56320&&b<=57343){A((k-55296)*1024+b-56320+65536),b=null;continue}A(k)}b!==null&&A(b)},$.UTF8toUTF16=function(I,A){var k=null;for(typeof I=="number"&&(k=I,I=function(){return null});k!==null||(k=I())!==null;)k<=65535?A(k):(k-=65536,A((k>>10)+55296),A(k%1024+56320)),k=null},$.encodeUTF16toUTF8=function(I,A){$.UTF16toUTF8(I,function(k){$.encodeUTF8(k,A)})},$.decodeUTF8toUTF16=function(I,A){$.decodeUTF8(I,function(k){$.UTF8toUTF16(k,A)})},$.calculateCodePoint=function(I){return I<128?1:I<2048?2:I<65536?3:4},$.calculateUTF8=function(I){for(var A,k=0;(A=I())!==null;)k+=$.calculateCodePoint(A);return k},$.calculateUTF16asUTF8=function(I){var A=0,k=0;return $.UTF16toUTF8(I,function(b){++A,k+=$.calculateCodePoint(b)}),[A,k]},$}();Date.now=Date.now||function(){return+new Date};var h=16,_=10,y=16,x=100,C=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],j=[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],R=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function ee($,I,A,k){var b,z=$[I],L=$[I+1];return z^=A[0],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[1],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[2],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[3],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[4],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[5],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[6],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[7],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[8],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[9],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[10],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[11],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[12],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[13],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[14],b=k[z>>>24],b+=k[256|z>>16&255],b^=k[512|z>>8&255],b+=k[768|z&255],L^=b^A[15],b=k[L>>>24],b+=k[256|L>>16&255],b^=k[512|L>>8&255],b+=k[768|L&255],z^=b^A[16],$[I]=L^A[y+1],$[I+1]=z,$}function pe($,I){for(var A=0,k=0;A<4;++A)k=k<<8|$[I]&255,I=(I+1)%$.length;return{key:k,offp:I}}function le($,I,A){for(var k=0,b=[0,0],z=I.length,L=A.length,Y,W=0;W<z;W++)Y=pe($,k),k=Y.offp,I[W]=I[W]^Y.key;for(W=0;W<z;W+=2)b=ee(b,0,I,A),I[W]=b[0],I[W+1]=b[1];for(W=0;W<L;W+=2)b=ee(b,0,I,A),A[W]=b[0],A[W+1]=b[1]}function Ue($,I,A,k){for(var b=0,z=[0,0],L=A.length,Y=k.length,W,ie=0;ie<L;ie++)W=pe(I,b),b=W.offp,A[ie]=A[ie]^W.key;for(b=0,ie=0;ie<L;ie+=2)W=pe($,b),b=W.offp,z[0]^=W.key,W=pe($,b),b=W.offp,z[1]^=W.key,z=ee(z,0,A,k),A[ie]=z[0],A[ie+1]=z[1];for(ie=0;ie<Y;ie+=2)W=pe($,b),b=W.offp,z[0]^=W.key,W=pe($,b),b=W.offp,z[1]^=W.key,z=ee(z,0,A,k),k[ie]=z[0],k[ie+1]=z[1]}function ot($,I,A,k,b){var z=R.slice(),L=z.length,Y;if(A<4||A>31)if(Y=Error("Illegal number of rounds (4-31): "+A),k){o(k.bind(this,Y));return}else throw Y;if(I.length!==h)if(Y=Error("Illegal salt length: "+I.length+" != "+h),k){o(k.bind(this,Y));return}else throw Y;A=1<<A>>>0;var W,ie,ce=0,H;Int32Array?(W=new Int32Array(C),ie=new Int32Array(j)):(W=C.slice(),ie=j.slice()),Ue(I,$,W,ie);function Ie(){if(b&&b(ce/A),ce<A)for(var he=Date.now();ce<A&&(ce=ce+1,le($,W,ie),le(I,W,ie),!(Date.now()-he>x)););else{for(ce=0;ce<64;ce++)for(H=0;H<L>>1;H++)ee(z,H<<1,W,ie);var xe=[];for(ce=0;ce<L;ce++)xe.push((z[ce]>>24&255)>>>0),xe.push((z[ce]>>16&255)>>>0),xe.push((z[ce]>>8&255)>>>0),xe.push((z[ce]&255)>>>0);if(k){k(null,xe);return}else return xe}k&&o(Ie)}if(typeof k<"u")Ie();else for(var nn;;)if(typeof(nn=Ie())<"u")return nn||[]}function We($,I,A,k){var b;if(typeof $!="string"||typeof I!="string")if(b=Error("Invalid string / salt: Not a string"),A){o(A.bind(this,b));return}else throw b;var z,L;if(I.charAt(0)!=="$"||I.charAt(1)!=="2")if(b=Error("Invalid salt version: "+I.substring(0,2)),A){o(A.bind(this,b));return}else throw b;if(I.charAt(2)==="$")z="\0",L=3;else{if(z=I.charAt(2),z!=="a"&&z!=="b"&&z!=="y"||I.charAt(3)!=="$")if(b=Error("Invalid salt revision: "+I.substring(2,4)),A){o(A.bind(this,b));return}else throw b;L=4}if(I.charAt(L+2)>"$")if(b=Error("Missing salt rounds"),A){o(A.bind(this,b));return}else throw b;var Y=parseInt(I.substring(L,L+1),10)*10,W=parseInt(I.substring(L+1,L+2),10),ie=Y+W,ce=I.substring(L+3,L+25);$+=z>="a"?"\0":"";var H=c($),Ie=m(ce,h);function nn(he){var xe=[];return xe.push("$2"),z>="a"&&xe.push(z),xe.push("$"),ie<10&&xe.push("0"),xe.push(ie.toString()),xe.push("$"),xe.push(f(Ie,Ie.length)),xe.push(f(he,R.length*4-1)),xe.join("")}if(typeof A>"u")return nn(ot(H,Ie,ie));ot(H,Ie,ie,function(he,xe){he?A(he,null):A(null,nn(xe))},k)}return e.encodeBase64=f,e.decodeBase64=m,e})})(af);var Jm=af.exports;const Hc=of(Jm),Zm="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ym=t=>crypto.getRandomValues(new Uint8Array(t)),Xm=(t,e,n)=>{let i=(2<<Math.log2(t.length-1))-1,r=-~(1.6*i*e/t.length);return(s=e)=>{let o="";for(;;){let c=n(r),l=r;for(;l--;)if(o+=t[c[l]&i]||"",o.length===s)return o}}},Qm=(t,e=21)=>Xm(t,e,Ym),He=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Zm[n[t]&63];return e};const e_=24;function Fc(){return Qm("0123456789abcdef",e_)()}function vu(t){if(!t.includes("|"))return console.error("Invalid user_id format"),t;const[,e]=t.split("|");return e}async function cf(t,e,n){return(await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`})).users}async function qc({userAdapter:t,tenant_id:e,email:n,provider:i}){const{users:r}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n} provider:${i}`});return r.length>1&&console.error("More than one user found for same email and provider"),r[0]||null}async function Vs({userAdapter:t,tenant_id:e,email:n}){var c;const{users:i}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`}),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 t.get(e,(c=r[0])==null?void 0:c.linked_to);if(!o)throw new Error("Primary account not found");return o}async function Ki({userAdapter:t,tenant_id:e,email:n,provider:i}){const r=await qc({userAdapter:t,tenant_id:e,email:n,provider:i});return r?r.linked_to?t.get(e,r.linked_to):r:null}const hn=a.z.object({page:a.z.string().min(0).optional().default("0").transform(t=>parseInt(t,10)).openapi({description:"The page number where 0 is the first page"}),per_page:a.z.string().min(1).optional().default("10").transform(t=>parseInt(t,10)).openapi({description:"The number of items per page"}),include_totals:a.z.string().optional().default("false").transform(t=>t==="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 Qn(t){if(!t)return;const[e,n]=t.split(":"),i=n==="1"?"asc":"desc";if(!(!e||!i))return{sort_by:e,sort_order:i}}function be(t,e){return{type:e.type,description:e.description||"",ip:t.req.header("x-real-ip")||"",user_agent:t.req.header("user-agent")||"",date:new Date().toISOString(),details:{request:{method:t.req.method,path:t.req.path,qs:t.req.queries(),body:e.body||t.var.body||""}},isMobile:!1,client_id:t.var.client_id,client_name:"",user_id:e.userId||t.var.user_id||"",hostname:t.req.header("host")||"",user_name:t.var.username||"",connection_id:"",connection:t.var.connection||"",strategy:e.strategy||"",strategy_type:e.strategy_type||"",audience:"",scope:[]}}var t_={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},n_=()=>{var n,i;const t=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[r,s]of Object.entries(t_))if(i_(s))return r}return typeof(t==null?void 0:t.EdgeRuntime)=="string"?"edge-light":(t==null?void 0:t.fastly)!==void 0?"fastly":((i=(n=t==null?void 0:t.process)==null?void 0:n.release)==null?void 0:i.name)==="node"?"node":"other"},i_=t=>navigator.userAgent.startsWith(t);function Xe(t,e){n_()==="workerd"&&t.executionCtx.waitUntil(e)}const wu=Yt.extend({users:a.z.array(vt)}),r_=Yt.extend({sessions:a.z.array(Us)}),s_=new a.OpenAPIHono().openapi(a.createRoute({tags:["users"],method:"get",path:"/",request:{query:hn,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(vt),wu])}},description:"List of users"}}}),async t=>{const{page:e,per_page:n,include_totals:i,sort:r,q:s}=t.req.valid("query"),{"tenant-id":o}=t.req.valid("header");if(s!=null&&s.includes("identities.profileData.email")){const p=s.split("=")[1],m=(await t.env.data.users.list(o,{page:e,per_page:n,include_totals:i,q:`email:${p}`})).users.filter(_=>_.linked_to),[v]=m;if(!v)return t.json([]);const h=await t.env.data.users.get(o,v.linked_to);if(!h)throw new O(500,{message:"Primary account not found"});return t.json([vt.parse(h)])}const c=["-_exists_:linked_to"];s&&c.push(s);const l=await t.env.data.users.list(o,{page:e,per_page:n,include_totals:i,sort:Qn(r),q:c.join(" ")}),u=l.users.filter(p=>!p.linked_to);return i?t.json(wu.parse({users:u,length:l.length,start:l.start,limit:l.limit})):t.json(a.z.array(vt).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:vt}},description:"List of users"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{"tenant-id":n}=t.req.valid("header"),i=await t.env.data.users.get(n,e);if(!i)throw new O(404);if(i.linked_to)throw new O(404,{message:"User is linked to another user"});return t.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 t=>{const{user_id:e}=t.req.valid("param"),{"tenant-id":n}=t.req.valid("header");if(!await t.env.data.users.remove(n,e))throw new O(404);return t.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({...Mr.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:vt}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");t.set("body",n);const{email:i}=n;if(!i)throw new O(400,{message:"Email is required"});const r=i.toLowerCase(),s=`${n.provider}|${n.user_id||Fc()}`;try{const o=await t.env.data.users.create(e,{email:r,user_id:s,name:n.name||r,provider:n.provider,connection:n.connection,email_verified:n.email_verified||!1,last_ip:"",is_social:!1,last_login:new Date().toISOString()});t.set("user_id",o.user_id);const c=be(t,{type:me.SUCCESS_API_OPERATION,description:"User created"});Xe(t,t.env.data.logs.create(e,c));const l={...o,identities:[{connection:o.connection,provider:o.provider,user_id:vu(o.user_id),isSocial:o.is_social}]};return t.json(vt.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({...Mr.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 t=>{var u;const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),{user_id:i}=t.req.valid("param"),{verify_email:r,password:s,...o}=n,c=await t.env.data.users.get(e,i);if(!c)throw new O(404);if(o.email&&o.email!==c.email){const p=await cf(t.env.data.users,e,o.email);if(p.length&&p.some(f=>f.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 t.env.data.users.update(e,i,o),s){const p=(u=c.identities)==null?void 0:u.find(f=>f.connection==="Username-Password-Authentication");if(!p)throw new O(400,{message:"User does not have a password identity"});await t.env.data.passwords.update(e,{user_id:`${p.provider}|${p.user_id}`,password:Hc.hashSync(s,10),algorithm:"bcrypt"})}const l=await t.env.data.users.get(e,i);if(!l)throw new O(500);return t.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 t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),{user_id:i}=t.req.valid("param"),r="link_with"in n?n.link_with:n.user_id,s=await t.env.data.users.get(e,i);if(!s)throw new O(400,{message:"Linking an inexistent identity is not allowed."});await t.env.data.users.update(e,r,{linked_to:i});const o=await t.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:vu(l.user_id),isSocial:l.is_social}));return t.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(vt)}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{user_id:n,provider:i,linked_user_id:r}=t.req.valid("param");await t.env.data.users.unlink(e,n,i,r);const s=await t.env.data.users.get(e,n);if(!s)throw new O(404);return t.json([vt.parse(s)])}).openapi(a.createRoute({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:hn,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(Us),r_])}},description:"List of sessions"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{include_totals:n}=t.req.valid("query"),{"tenant-id":i}=t.req.valid("header"),r=await t.env.data.sessions.list(i,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return n?t.json(r):t.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 Wl;(function(t){(function(e){var n=typeof globalThis=="object"?globalThis:typeof zr=="object"?zr:typeof self=="object"?self:typeof this=="object"?this:c(),i=r(t);typeof n.Reflect<"u"&&(i=r(n.Reflect,i)),e(i,n),typeof n.Reflect>"u"&&(n.Reflect=t);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,n){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 bo(Object.create(null))}:l?function(){return bo({__proto__:null})}:function(){return bo({})},has:u?function(x,I){return i.call(x,I)}:function(x,I){return I in x},get:u?function(x,I){return i.call(x,I)?x[I]:void 0}:function(x,I){return x[I]}},g=Object.getPrototypeOf(Function),_=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:dg(),k=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:pg(),h=typeof WeakMap=="function"?WeakMap:fg(),m=r?Symbol.for("@reflect-metadata:registry"):void 0,b=cg(),S=lg(b);function O(x,I,$,L){if(D($)){if(!Al(x))throw new TypeError;if(!Il(I))throw new TypeError;return E(x,I)}else{if(!Al(x))throw new TypeError;if(!fe(I))throw new TypeError;if(!fe(L)&&!D(L)&&!Ie(L))throw new TypeError;return Ie(L)&&(L=void 0),$=gt($),A(x,I,$,L)}}e("decorate",O);function T(x,I){function $(L,X){if(!fe(L))throw new TypeError;if(!D(X)&&!og(X))throw new TypeError;Y(x,I,L,X)}return $}e("metadata",T);function K(x,I,$,L){if(!fe($))throw new TypeError;return D(L)||(L=gt(L)),Y(x,I,$,L)}e("defineMetadata",K);function ce(x,I,$){if(!fe(I))throw new TypeError;return D($)||($=gt($)),w(x,I,$)}e("hasMetadata",ce);function he(x,I,$){if(!fe(I))throw new TypeError;return D($)||($=gt($)),v(x,I,$)}e("hasOwnMetadata",he);function ue(x,I,$){if(!fe(I))throw new TypeError;return D($)||($=gt($)),z(x,I,$)}e("getMetadata",ue);function Le(x,I,$){if(!fe(I))throw new TypeError;return D($)||($=gt($)),R(x,I,$)}e("getOwnMetadata",Le);function st(x,I){if(!fe(x))throw new TypeError;return D(I)||(I=gt(I)),W(x,I)}e("getMetadataKeys",st);function Ke(x,I){if(!fe(x))throw new TypeError;return D(I)||(I=gt(I)),ne(x,I)}e("getOwnMetadataKeys",Ke);function C(x,I,$){if(!fe(I))throw new TypeError;if(D($)||($=gt($)),!fe(I))throw new TypeError;D($)||($=gt($));var L=ai(I,$,!1);return D(L)?!1:L.OrdinaryDeleteMetadata(x,I,$)}e("deleteMetadata",C);function E(x,I){for(var $=x.length-1;$>=0;--$){var L=x[$],X=L(I);if(!D(X)&&!Ie(X)){if(!Il(X))throw new TypeError;I=X}}return I}function A(x,I,$,L){for(var X=x.length-1;X>=0;--X){var Ee=x[X],Se=Ee(I,$,L);if(!D(Se)&&!Ie(Se)){if(!fe(Se))throw new TypeError;L=Se}}return L}function w(x,I,$){var L=v(x,I,$);if(L)return!0;var X=wo(I);return Ie(X)?!1:w(x,X,$)}function v(x,I,$){var L=ai(I,$,!1);return D(L)?!1:Sl(L.OrdinaryHasOwnMetadata(x,I,$))}function z(x,I,$){var L=v(x,I,$);if(L)return R(x,I,$);var X=wo(I);if(!Ie(X))return z(x,X,$)}function R(x,I,$){var L=ai(I,$,!1);if(!D(L))return L.OrdinaryGetOwnMetadata(x,I,$)}function Y(x,I,$,L){var X=ai($,L,!0);X.OrdinaryDefineOwnMetadata(x,I,$,L)}function W(x,I){var $=ne(x,I),L=wo(x);if(L===null)return $;var X=W(L,I);if(X.length<=0)return $;if($.length<=0)return X;for(var Ee=new k,Se=[],ie=0,M=$;ie<M.length;ie++){var q=M[ie],J=Ee.has(q);J||(Ee.add(q),Se.push(q))}for(var Z=0,re=X;Z<re.length;Z++){var q=re[Z],J=Ee.has(q);J||(Ee.add(q),Se.push(q))}return Se}function ne(x,I){var $=ai(x,I,!1);return $?$.OrdinaryOwnMetadataKeys(x,I):[]}function ae(x){if(x===null)return 1;switch(typeof x){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return x===null?1:6;default:return 6}}function D(x){return x===void 0}function Ie(x){return x===null}function Qt(x){return typeof x=="symbol"}function fe(x){return typeof x=="object"?x!==null:typeof x=="function"}function xe(x,I){switch(ae(x)){case 0:return x;case 1:return x;case 2:return x;case 3:return x;case 4:return x;case 5:return x}var $="string",L=El(x,s);if(L!==void 0){var X=L.call(x,$);if(fe(X))throw new TypeError;return X}return rg(x)}function rg(x,I){var $,L;{var X=x.toString;if(ir(X)){var L=X.call(x);if(!fe(L))return L}var $=x.valueOf;if(ir($)){var L=$.call(x);if(!fe(L))return L}}throw new TypeError}function Sl(x){return!!x}function sg(x){return""+x}function gt(x){var I=xe(x);return Qt(I)?I:sg(I)}function Al(x){return Array.isArray?Array.isArray(x):x instanceof Object?x instanceof Array:Object.prototype.toString.call(x)==="[object Array]"}function ir(x){return typeof x=="function"}function Il(x){return typeof x=="function"}function og(x){switch(ae(x)){case 3:return!0;case 4:return!0;default:return!1}}function vo(x,I){return x===I||x!==x&&I!==I}function El(x,I){var $=x[I];if($!=null){if(!ir($))throw new TypeError;return $}}function Cl(x){var I=El(x,o);if(!ir(I))throw new TypeError;var $=I.call(x);if(!fe($))throw new TypeError;return $}function zl(x){return x.value}function $l(x){var I=x.next();return I.done?!1:I}function jl(x){var I=x.return;I&&I.call(x)}function wo(x){var I=Object.getPrototypeOf(x);if(typeof x!="function"||x===g||I!==g)return I;var $=x.prototype,L=$&&Object.getPrototypeOf($);if(L==null||L===Object.prototype)return I;var X=L.constructor;return typeof X!="function"||X===x?I:X}function ag(){var x;!D(m)&&typeof n.Reflect<"u"&&!(m in n.Reflect)&&typeof n.Reflect.defineMetadata=="function"&&(x=ug(n.Reflect));var I,$,L,X=new h,Ee={registerProvider:Se,getProvider:M,setProvider:J};return Ee;function Se(Z){if(!Object.isExtensible(Ee))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case x===Z:break;case D(I):I=Z;break;case I===Z:break;case D($):$=Z;break;case $===Z:break;default:L===void 0&&(L=new k),L.add(Z);break}}function ie(Z,re){if(!D(I)){if(I.isProviderFor(Z,re))return I;if(!D($)){if($.isProviderFor(Z,re))return I;if(!D(L))for(var ge=Cl(L);;){var ve=$l(ge);if(!ve)return;var ot=zl(ve);if(ot.isProviderFor(Z,re))return jl(ge),ot}}}if(!D(x)&&x.isProviderFor(Z,re))return x}function M(Z,re){var ge=X.get(Z),ve;return D(ge)||(ve=ge.get(re)),D(ve)&&(ve=ie(Z,re),D(ve)||(D(ge)&&(ge=new _,X.set(Z,ge)),ge.set(re,ve))),ve}function q(Z){if(D(Z))throw new TypeError;return I===Z||$===Z||!D(L)&&L.has(Z)}function J(Z,re,ge){if(!q(ge))throw new Error("Metadata provider not registered.");var ve=M(Z,re);if(ve!==ge){if(!D(ve))return!1;var ot=X.get(Z);D(ot)&&(ot=new _,X.set(Z,ot)),ot.set(re,ge)}return!0}}function cg(){var x;return!D(m)&&fe(n.Reflect)&&Object.isExtensible(n.Reflect)&&(x=n.Reflect[m]),D(x)&&(x=ag()),!D(m)&&fe(n.Reflect)&&Object.isExtensible(n.Reflect)&&Object.defineProperty(n.Reflect,m,{enumerable:!1,configurable:!1,writable:!1,value:x}),x}function lg(x){var I=new h,$={isProviderFor:function(q,J){var Z=I.get(q);return D(Z)?!1:Z.has(J)},OrdinaryDefineOwnMetadata:Se,OrdinaryHasOwnMetadata:X,OrdinaryGetOwnMetadata:Ee,OrdinaryOwnMetadataKeys:ie,OrdinaryDeleteMetadata:M};return b.registerProvider($),$;function L(q,J,Z){var re=I.get(q),ge=!1;if(D(re)){if(!Z)return;re=new _,I.set(q,re),ge=!0}var ve=re.get(J);if(D(ve)){if(!Z)return;if(ve=new _,re.set(J,ve),!x.setProvider(q,J,$))throw re.delete(J),ge&&I.delete(q),new Error("Wrong provider for target.")}return ve}function X(q,J,Z){var re=L(J,Z,!1);return D(re)?!1:Sl(re.has(q))}function Ee(q,J,Z){var re=L(J,Z,!1);if(!D(re))return re.get(q)}function Se(q,J,Z,re){var ge=L(Z,re,!0);ge.set(q,J)}function ie(q,J){var Z=[],re=L(q,J,!1);if(D(re))return Z;for(var ge=re.keys(),ve=Cl(ge),ot=0;;){var Nl=$l(ve);if(!Nl)return Z.length=ot,Z;var hg=zl(Nl);try{Z[ot]=hg}catch(gg){try{jl(ve)}finally{throw gg}}ot++}}function M(q,J,Z){var re=L(J,Z,!1);if(D(re)||!re.delete(q))return!1;if(re.size===0){var ge=I.get(J);D(ge)||(ge.delete(Z),ge.size===0&&I.delete(ge))}return!0}}function ug(x){var I=x.defineMetadata,$=x.hasOwnMetadata,L=x.getOwnMetadata,X=x.getOwnMetadataKeys,Ee=x.deleteMetadata,Se=new h,ie={isProviderFor:function(M,q){var J=Se.get(M);return!D(J)&&J.has(q)?!0:X(M,q).length?(D(J)&&(J=new k,Se.set(M,J)),J.add(q),!0):!1},OrdinaryDefineOwnMetadata:I,OrdinaryHasOwnMetadata:$,OrdinaryGetOwnMetadata:L,OrdinaryOwnMetadataKeys:X,OrdinaryDeleteMetadata:Ee};return ie}function ai(x,I,$){var L=b.getProvider(x,I);if(!D(L))return L;if($){if(b.setProvider(x,I,S))return S;throw new Error("Illegal state.")}}function dg(){var x={},I=[],$=function(){function ie(M,q,J){this._index=0,this._keys=M,this._values=q,this._selector=J}return ie.prototype["@@iterator"]=function(){return this},ie.prototype[o]=function(){return this},ie.prototype.next=function(){var M=this._index;if(M>=0&&M<this._keys.length){var q=this._selector(this._keys[M],this._values[M]);return M+1>=this._keys.length?(this._index=-1,this._keys=I,this._values=I):this._index++,{value:q,done:!1}}return{value:void 0,done:!0}},ie.prototype.throw=function(M){throw this._index>=0&&(this._index=-1,this._keys=I,this._values=I),M},ie.prototype.return=function(M){return this._index>=0&&(this._index=-1,this._keys=I,this._values=I),{value:M,done:!0}},ie}(),L=function(){function ie(){this._keys=[],this._values=[],this._cacheKey=x,this._cacheIndex=-2}return Object.defineProperty(ie.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),ie.prototype.has=function(M){return this._find(M,!1)>=0},ie.prototype.get=function(M){var q=this._find(M,!1);return q>=0?this._values[q]:void 0},ie.prototype.set=function(M,q){var J=this._find(M,!0);return this._values[J]=q,this},ie.prototype.delete=function(M){var q=this._find(M,!1);if(q>=0){for(var J=this._keys.length,Z=q+1;Z<J;Z++)this._keys[Z-1]=this._keys[Z],this._values[Z-1]=this._values[Z];return this._keys.length--,this._values.length--,vo(M,this._cacheKey)&&(this._cacheKey=x,this._cacheIndex=-2),!0}return!1},ie.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=x,this._cacheIndex=-2},ie.prototype.keys=function(){return new $(this._keys,this._values,X)},ie.prototype.values=function(){return new $(this._keys,this._values,Ee)},ie.prototype.entries=function(){return new $(this._keys,this._values,Se)},ie.prototype["@@iterator"]=function(){return this.entries()},ie.prototype[o]=function(){return this.entries()},ie.prototype._find=function(M,q){if(!vo(this._cacheKey,M)){this._cacheIndex=-1;for(var J=0;J<this._keys.length;J++)if(vo(this._keys[J],M)){this._cacheIndex=J;break}}return this._cacheIndex<0&&q&&(this._cacheIndex=this._keys.length,this._keys.push(M),this._values.push(void 0)),this._cacheIndex},ie}();return L;function X(ie,M){return ie}function Ee(ie,M){return M}function Se(ie,M){return[ie,M]}}function pg(){var x=function(){function I(){this._map=new _}return Object.defineProperty(I.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),I.prototype.has=function($){return this._map.has($)},I.prototype.add=function($){return this._map.set($,$),this},I.prototype.delete=function($){return this._map.delete($)},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 x}function fg(){var x=16,I=p.create(),$=L();return function(){function M(){this._key=L()}return M.prototype.has=function(q){var J=X(q,!1);return J!==void 0?p.has(J,this._key):!1},M.prototype.get=function(q){var J=X(q,!1);return J!==void 0?p.get(J,this._key):void 0},M.prototype.set=function(q,J){var Z=X(q,!0);return Z[this._key]=J,this},M.prototype.delete=function(q){var J=X(q,!1);return J!==void 0?delete J[this._key]:!1},M.prototype.clear=function(){this._key=L()},M}();function L(){var M;do M="@@WeakMap@@"+ie();while(p.has(I,M));return I[M]=!0,M}function X(M,q){if(!i.call(M,$)){if(!q)return;Object.defineProperty(M,$,{value:p.create()})}return M[$]}function Ee(M,q){for(var J=0;J<q;++J)M[J]=Math.random()*255|0;return M}function Se(M){if(typeof Uint8Array=="function"){var q=new Uint8Array(M);return typeof crypto<"u"?crypto.getRandomValues(q):typeof msCrypto<"u"?msCrypto.getRandomValues(q):Ee(q,M),q}return Ee(new Array(M),M)}function ie(){var M=Se(x);M[6]=M[6]&79|64,M[8]=M[8]&191|128;for(var q="",J=0;J<x;++J){var Z=M[J];(J===4||J===6||J===8)&&(q+="-"),Z<16&&(q+="0"),q+=Z.toString(16).toLowerCase()}return q}}function bo(x){return x.__=void 0,delete x.__,x}})})(Wl||(Wl={}));/*!
|
|
18
|
+
***************************************************************************** */var bu;(function(t){(function(e){var n=typeof globalThis=="object"?globalThis:typeof Wr=="object"?Wr:typeof self=="object"?self:typeof this=="object"?this:c(),i=r(t);typeof n.Reflect<"u"&&(i=r(n.Reflect,i)),e(i,n),typeof n.Reflect>"u"&&(n.Reflect=t);function r(l,u){return function(p,f){Object.defineProperty(l,p,{configurable:!0,writable:!0,value:f}),u&&u(p,f)}}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,n){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 Uo(Object.create(null))}:l?function(){return Uo({__proto__:null})}:function(){return Uo({})},has:u?function(S,E){return i.call(S,E)}:function(S,E){return E in S},get:u?function(S,E){return i.call(S,E)?S[E]:void 0}:function(S,E){return S[E]}},f=Object.getPrototypeOf(Function),m=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:om(),v=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:am(),h=typeof WeakMap=="function"?WeakMap:cm(),_=r?Symbol.for("@reflect-metadata:registry"):void 0,y=im(),x=rm(y);function C(S,E,N,U){if(H(N)){if(!Ql(S))throw new TypeError;if(!eu(E))throw new TypeError;return I(S,E)}else{if(!Ql(S))throw new TypeError;if(!he(E))throw new TypeError;if(!he(U)&&!H(U)&&!Ie(U))throw new TypeError;return Ie(U)&&(U=void 0),N=mt(N),A(S,E,N,U)}}e("decorate",C);function j(S,E){function N(U,X){if(!he(U))throw new TypeError;if(!H(X)&&!tm(X))throw new TypeError;Y(S,E,U,X)}return N}e("metadata",j);function R(S,E,N,U){if(!he(N))throw new TypeError;return H(U)||(U=mt(U)),Y(S,E,N,U)}e("defineMetadata",R);function ee(S,E,N){if(!he(E))throw new TypeError;return H(N)||(N=mt(N)),k(S,E,N)}e("hasMetadata",ee);function pe(S,E,N){if(!he(E))throw new TypeError;return H(N)||(N=mt(N)),b(S,E,N)}e("hasOwnMetadata",pe);function le(S,E,N){if(!he(E))throw new TypeError;return H(N)||(N=mt(N)),z(S,E,N)}e("getMetadata",le);function Ue(S,E,N){if(!he(E))throw new TypeError;return H(N)||(N=mt(N)),L(S,E,N)}e("getOwnMetadata",Ue);function ot(S,E){if(!he(S))throw new TypeError;return H(E)||(E=mt(E)),W(S,E)}e("getMetadataKeys",ot);function We(S,E){if(!he(S))throw new TypeError;return H(E)||(E=mt(E)),ie(S,E)}e("getOwnMetadataKeys",We);function $(S,E,N){if(!he(E))throw new TypeError;if(H(N)||(N=mt(N)),!he(E))throw new TypeError;H(N)||(N=mt(N));var U=fi(E,N,!1);return H(U)?!1:U.OrdinaryDeleteMetadata(S,E,N)}e("deleteMetadata",$);function I(S,E){for(var N=S.length-1;N>=0;--N){var U=S[N],X=U(E);if(!H(X)&&!Ie(X)){if(!eu(X))throw new TypeError;E=X}}return E}function A(S,E,N,U){for(var X=S.length-1;X>=0;--X){var Ce=S[X],Ae=Ce(E,N,U);if(!H(Ae)&&!Ie(Ae)){if(!he(Ae))throw new TypeError;U=Ae}}return U}function k(S,E,N){var U=b(S,E,N);if(U)return!0;var X=Lo(E);return Ie(X)?!1:k(S,X,N)}function b(S,E,N){var U=fi(E,N,!1);return H(U)?!1:Xl(U.OrdinaryHasOwnMetadata(S,E,N))}function z(S,E,N){var U=b(S,E,N);if(U)return L(S,E,N);var X=Lo(E);if(!Ie(X))return z(S,X,N)}function L(S,E,N){var U=fi(E,N,!1);if(!H(U))return U.OrdinaryGetOwnMetadata(S,E,N)}function Y(S,E,N,U){var X=fi(N,U,!0);X.OrdinaryDefineOwnMetadata(S,E,N,U)}function W(S,E){var N=ie(S,E),U=Lo(S);if(U===null)return N;var X=W(U,E);if(X.length<=0)return N;if(N.length<=0)return X;for(var Ce=new v,Ae=[],se=0,D=N;se<D.length;se++){var K=D[se],J=Ce.has(K);J||(Ce.add(K),Ae.push(K))}for(var Z=0,oe=X;Z<oe.length;Z++){var K=oe[Z],J=Ce.has(K);J||(Ce.add(K),Ae.push(K))}return Ae}function ie(S,E){var N=fi(S,E,!1);return N?N.OrdinaryOwnMetadataKeys(S,E):[]}function ce(S){if(S===null)return 1;switch(typeof S){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return S===null?1:6;default:return 6}}function H(S){return S===void 0}function Ie(S){return S===null}function nn(S){return typeof S=="symbol"}function he(S){return typeof S=="object"?S!==null:typeof S=="function"}function xe(S,E){switch(ce(S)){case 0:return S;case 1:return S;case 2:return S;case 3:return S;case 4:return S;case 5:return S}var N="string",U=tu(S,s);if(U!==void 0){var X=U.call(S,N);if(he(X))throw new TypeError;return X}return Qg(S)}function Qg(S,E){var N,U;{var X=S.toString;if(gr(X)){var U=X.call(S);if(!he(U))return U}var N=S.valueOf;if(gr(N)){var U=N.call(S);if(!he(U))return U}}throw new TypeError}function Xl(S){return!!S}function em(S){return""+S}function mt(S){var E=xe(S);return nn(E)?E:em(E)}function Ql(S){return Array.isArray?Array.isArray(S):S instanceof Object?S instanceof Array:Object.prototype.toString.call(S)==="[object Array]"}function gr(S){return typeof S=="function"}function eu(S){return typeof S=="function"}function tm(S){switch(ce(S)){case 3:return!0;case 4:return!0;default:return!1}}function Ro(S,E){return S===E||S!==S&&E!==E}function tu(S,E){var N=S[E];if(N!=null){if(!gr(N))throw new TypeError;return N}}function nu(S){var E=tu(S,o);if(!gr(E))throw new TypeError;var N=E.call(S);if(!he(N))throw new TypeError;return N}function iu(S){return S.value}function ru(S){var E=S.next();return E.done?!1:E}function su(S){var E=S.return;E&&E.call(S)}function Lo(S){var E=Object.getPrototypeOf(S);if(typeof S!="function"||S===f||E!==f)return E;var N=S.prototype,U=N&&Object.getPrototypeOf(N);if(U==null||U===Object.prototype)return E;var X=U.constructor;return typeof X!="function"||X===S?E:X}function nm(){var S;!H(_)&&typeof n.Reflect<"u"&&!(_ in n.Reflect)&&typeof n.Reflect.defineMetadata=="function"&&(S=sm(n.Reflect));var E,N,U,X=new h,Ce={registerProvider:Ae,getProvider:D,setProvider:J};return Ce;function Ae(Z){if(!Object.isExtensible(Ce))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case S===Z:break;case H(E):E=Z;break;case E===Z:break;case H(N):N=Z;break;case N===Z:break;default:U===void 0&&(U=new v),U.add(Z);break}}function se(Z,oe){if(!H(E)){if(E.isProviderFor(Z,oe))return E;if(!H(N)){if(N.isProviderFor(Z,oe))return E;if(!H(U))for(var ge=nu(U);;){var ve=ru(ge);if(!ve)return;var at=iu(ve);if(at.isProviderFor(Z,oe))return su(ge),at}}}if(!H(S)&&S.isProviderFor(Z,oe))return S}function D(Z,oe){var ge=X.get(Z),ve;return H(ge)||(ve=ge.get(oe)),H(ve)&&(ve=se(Z,oe),H(ve)||(H(ge)&&(ge=new m,X.set(Z,ge)),ge.set(oe,ve))),ve}function K(Z){if(H(Z))throw new TypeError;return E===Z||N===Z||!H(U)&&U.has(Z)}function J(Z,oe,ge){if(!K(ge))throw new Error("Metadata provider not registered.");var ve=D(Z,oe);if(ve!==ge){if(!H(ve))return!1;var at=X.get(Z);H(at)&&(at=new m,X.set(Z,at)),at.set(oe,ge)}return!0}}function im(){var S;return!H(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&(S=n.Reflect[_]),H(S)&&(S=nm()),!H(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&Object.defineProperty(n.Reflect,_,{enumerable:!1,configurable:!1,writable:!1,value:S}),S}function rm(S){var E=new h,N={isProviderFor:function(K,J){var Z=E.get(K);return H(Z)?!1:Z.has(J)},OrdinaryDefineOwnMetadata:Ae,OrdinaryHasOwnMetadata:X,OrdinaryGetOwnMetadata:Ce,OrdinaryOwnMetadataKeys:se,OrdinaryDeleteMetadata:D};return y.registerProvider(N),N;function U(K,J,Z){var oe=E.get(K),ge=!1;if(H(oe)){if(!Z)return;oe=new m,E.set(K,oe),ge=!0}var ve=oe.get(J);if(H(ve)){if(!Z)return;if(ve=new m,oe.set(J,ve),!S.setProvider(K,J,N))throw oe.delete(J),ge&&E.delete(K),new Error("Wrong provider for target.")}return ve}function X(K,J,Z){var oe=U(J,Z,!1);return H(oe)?!1:Xl(oe.has(K))}function Ce(K,J,Z){var oe=U(J,Z,!1);if(!H(oe))return oe.get(K)}function Ae(K,J,Z,oe){var ge=U(Z,oe,!0);ge.set(K,J)}function se(K,J){var Z=[],oe=U(K,J,!1);if(H(oe))return Z;for(var ge=oe.keys(),ve=nu(ge),at=0;;){var ou=ru(ve);if(!ou)return Z.length=at,Z;var lm=iu(ou);try{Z[at]=lm}catch(um){try{su(ve)}finally{throw um}}at++}}function D(K,J,Z){var oe=U(J,Z,!1);if(H(oe)||!oe.delete(K))return!1;if(oe.size===0){var ge=E.get(J);H(ge)||(ge.delete(Z),ge.size===0&&E.delete(ge))}return!0}}function sm(S){var E=S.defineMetadata,N=S.hasOwnMetadata,U=S.getOwnMetadata,X=S.getOwnMetadataKeys,Ce=S.deleteMetadata,Ae=new h,se={isProviderFor:function(D,K){var J=Ae.get(D);return!H(J)&&J.has(K)?!0:X(D,K).length?(H(J)&&(J=new v,Ae.set(D,J)),J.add(K),!0):!1},OrdinaryDefineOwnMetadata:E,OrdinaryHasOwnMetadata:N,OrdinaryGetOwnMetadata:U,OrdinaryOwnMetadataKeys:X,OrdinaryDeleteMetadata:Ce};return se}function fi(S,E,N){var U=y.getProvider(S,E);if(!H(U))return U;if(N){if(y.setProvider(S,E,x))return x;throw new Error("Illegal state.")}}function om(){var S={},E=[],N=function(){function se(D,K,J){this._index=0,this._keys=D,this._values=K,this._selector=J}return se.prototype["@@iterator"]=function(){return this},se.prototype[o]=function(){return this},se.prototype.next=function(){var D=this._index;if(D>=0&&D<this._keys.length){var K=this._selector(this._keys[D],this._values[D]);return D+1>=this._keys.length?(this._index=-1,this._keys=E,this._values=E):this._index++,{value:K,done:!1}}return{value:void 0,done:!0}},se.prototype.throw=function(D){throw this._index>=0&&(this._index=-1,this._keys=E,this._values=E),D},se.prototype.return=function(D){return this._index>=0&&(this._index=-1,this._keys=E,this._values=E),{value:D,done:!0}},se}(),U=function(){function se(){this._keys=[],this._values=[],this._cacheKey=S,this._cacheIndex=-2}return Object.defineProperty(se.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),se.prototype.has=function(D){return this._find(D,!1)>=0},se.prototype.get=function(D){var K=this._find(D,!1);return K>=0?this._values[K]:void 0},se.prototype.set=function(D,K){var J=this._find(D,!0);return this._values[J]=K,this},se.prototype.delete=function(D){var K=this._find(D,!1);if(K>=0){for(var J=this._keys.length,Z=K+1;Z<J;Z++)this._keys[Z-1]=this._keys[Z],this._values[Z-1]=this._values[Z];return this._keys.length--,this._values.length--,Ro(D,this._cacheKey)&&(this._cacheKey=S,this._cacheIndex=-2),!0}return!1},se.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=S,this._cacheIndex=-2},se.prototype.keys=function(){return new N(this._keys,this._values,X)},se.prototype.values=function(){return new N(this._keys,this._values,Ce)},se.prototype.entries=function(){return new N(this._keys,this._values,Ae)},se.prototype["@@iterator"]=function(){return this.entries()},se.prototype[o]=function(){return this.entries()},se.prototype._find=function(D,K){if(!Ro(this._cacheKey,D)){this._cacheIndex=-1;for(var J=0;J<this._keys.length;J++)if(Ro(this._keys[J],D)){this._cacheIndex=J;break}}return this._cacheIndex<0&&K&&(this._cacheIndex=this._keys.length,this._keys.push(D),this._values.push(void 0)),this._cacheIndex},se}();return U;function X(se,D){return se}function Ce(se,D){return D}function Ae(se,D){return[se,D]}}function am(){var S=function(){function E(){this._map=new m}return Object.defineProperty(E.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),E.prototype.has=function(N){return this._map.has(N)},E.prototype.add=function(N){return this._map.set(N,N),this},E.prototype.delete=function(N){return this._map.delete(N)},E.prototype.clear=function(){this._map.clear()},E.prototype.keys=function(){return this._map.keys()},E.prototype.values=function(){return this._map.keys()},E.prototype.entries=function(){return this._map.entries()},E.prototype["@@iterator"]=function(){return this.keys()},E.prototype[o]=function(){return this.keys()},E}();return S}function cm(){var S=16,E=p.create(),N=U();return function(){function D(){this._key=U()}return D.prototype.has=function(K){var J=X(K,!1);return J!==void 0?p.has(J,this._key):!1},D.prototype.get=function(K){var J=X(K,!1);return J!==void 0?p.get(J,this._key):void 0},D.prototype.set=function(K,J){var Z=X(K,!0);return Z[this._key]=J,this},D.prototype.delete=function(K){var J=X(K,!1);return J!==void 0?delete J[this._key]:!1},D.prototype.clear=function(){this._key=U()},D}();function U(){var D;do D="@@WeakMap@@"+se();while(p.has(E,D));return E[D]=!0,D}function X(D,K){if(!i.call(D,N)){if(!K)return;Object.defineProperty(D,N,{value:p.create()})}return D[N]}function Ce(D,K){for(var J=0;J<K;++J)D[J]=Math.random()*255|0;return D}function Ae(D){if(typeof Uint8Array=="function"){var K=new Uint8Array(D);return typeof crypto<"u"?crypto.getRandomValues(K):typeof msCrypto<"u"?msCrypto.getRandomValues(K):Ce(K,D),K}return Ce(new Array(D),D)}function se(){var D=Ae(S);D[6]=D[6]&79|64,D[8]=D[8]&191|128;for(var K="",J=0;J<S;++J){var Z=D[J];(J===4||J===6||J===8)&&(K+="-"),Z<16&&(K+="0"),K+=Z.toString(16).toLowerCase()}return K}}function Uo(S){return S.__=void 0,delete S.__,S}})})(bu||(bu={}));/*!
|
|
19
19
|
* MIT License
|
|
20
20
|
*
|
|
21
21
|
* Copyright (c) 2017-2022 Peculiar Ventures, LLC
|
|
@@ -38,9 +38,9 @@ and limitations under the License.
|
|
|
38
38
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
39
39
|
* SOFTWARE.
|
|
40
40
|
*
|
|
41
|
-
*/const
|
|
41
|
+
*/const o_="[object ArrayBuffer]";class M{static isArrayBuffer(e){return Object.prototype.toString.call(e)===o_}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,n){if(e.constructor===n)return e;if(this.isArrayBuffer(e))return new n(e);if(this.isArrayBufferView(e))return new n(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,n){const i=M.toUint8Array(e),r=M.toUint8Array(n);if(i.length!==r.byteLength)return!1;for(let s=0;s<i.length;s++)if(i[s]!==r[s])return!1;return!0}static concat(...e){let n;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?n=e[0]:e[e.length-1]instanceof Function?n=e.slice(0,e.length-1):n=e;let i=0;for(const o of n)i+=o.byteLength;const r=new Uint8Array(i);let s=0;for(const o of n){const c=this.toUint8Array(o);r.set(c,s),s+=c.length}return e[e.length-1]instanceof Function?this.toView(r,e[e.length-1]):r.buffer}}const Mo="string",a_=/^[0-9a-f]+$/i,c_=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,l_=/^[a-zA-Z0-9-_]+$/;class ku{static fromString(e){const n=unescape(encodeURIComponent(e)),i=new Uint8Array(n.length);for(let r=0;r<n.length;r++)i[r]=n.charCodeAt(r);return i.buffer}static toString(e){const n=M.toUint8Array(e);let i="";for(let s=0;s<n.length;s++)i+=String.fromCharCode(n[s]);return decodeURIComponent(escape(i))}}class _t{static toString(e,n=!1){const i=M.toArrayBuffer(e),r=new DataView(i);let s="";for(let o=0;o<i.byteLength;o+=2){const c=r.getUint16(o,n);s+=String.fromCharCode(c)}return s}static fromString(e,n=!1){const i=new ArrayBuffer(e.length*2),r=new DataView(i);for(let s=0;s<e.length;s++)r.setUint16(s*2,e.charCodeAt(s),n);return i}}class G{static isHex(e){return typeof e===Mo&&a_.test(e)}static isBase64(e){return typeof e===Mo&&c_.test(e)}static isBase64Url(e){return typeof e===Mo&&l_.test(e)}static ToString(e,n="utf8"){const i=M.toUint8Array(e);switch(n.toLowerCase()){case"utf8":return this.ToUtf8String(i);case"binary":return this.ToBinary(i);case"hex":return this.ToHex(i);case"base64":return this.ToBase64(i);case"base64url":return this.ToBase64Url(i);case"utf16le":return _t.toString(i,!0);case"utf16":case"utf16be":return _t.toString(i);default:throw new Error(`Unknown type of encoding '${n}'`)}}static FromString(e,n="utf8"){if(!e)return new ArrayBuffer(0);switch(n.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return _t.fromString(e,!0);case"utf16":case"utf16be":return _t.fromString(e);default:throw new Error(`Unknown type of encoding '${n}'`)}}static ToBase64(e){const n=M.toUint8Array(e);if(typeof btoa<"u"){const i=this.ToString(n,"binary");return btoa(i)}else return Buffer.from(n).toString("base64")}static FromBase64(e){const n=this.formatString(e);if(!n)return new ArrayBuffer(0);if(!G.isBase64(n))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(n)):new Uint8Array(Buffer.from(n,"base64")).buffer}static FromBase64Url(e){const n=this.formatString(e);if(!n)return new ArrayBuffer(0);if(!G.isBase64Url(n))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(n.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,n=G.DEFAULT_UTF8_ENCODING){switch(n){case"ascii":return this.FromBinary(e);case"utf8":return ku.fromString(e);case"utf16":case"utf16be":return _t.fromString(e);case"utf16le":case"usc2":return _t.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${n}'`)}}static ToUtf8String(e,n=G.DEFAULT_UTF8_ENCODING){switch(n){case"ascii":return this.ToBinary(e);case"utf8":return ku.toString(e);case"utf16":case"utf16be":return _t.toString(e);case"utf16le":case"usc2":return _t.toString(e,!0);default:throw new Error(`Unknown type of encoding '${n}'`)}}static FromBinary(e){const n=e.length,i=new Uint8Array(n);for(let r=0;r<n;r++)i[r]=e.charCodeAt(r);return i.buffer}static ToBinary(e){const n=M.toUint8Array(e);let i="";for(let r=0;r<n.length;r++)i+=String.fromCharCode(n[r]);return i}static ToHex(e){const n=M.toUint8Array(e);let i="";const r=n.length;for(let s=0;s<r;s++){const o=n[s];o<16&&(i+="0"),i+=o.toString(16)}return i}static FromHex(e){let n=this.formatString(e);if(!n)return new ArrayBuffer(0);if(!G.isHex(n))throw new TypeError("Argument 'hexString' is not HEX encoded");n.length%2&&(n=`0${n}`);const i=new Uint8Array(n.length/2);for(let r=0;r<n.length;r=r+2){const s=n.slice(r,r+2);i[r/2]=parseInt(s,16)}return i.buffer}static ToUtf16String(e,n=!1){return _t.toString(e,n)}static FromUtf16String(e,n=!1){return _t.fromString(e,n)}static Base64Padding(e){const n=4-e.length%4;if(n<4)for(let i=0;i<n;i++)e+="=";return e}static formatString(e){return(e==null?void 0:e.replace(/[\n\r\t ]/g,""))||""}}G.DEFAULT_UTF8_ENCODING="utf8";function u_(...t){const e=t.map(r=>r.byteLength).reduce((r,s)=>r+s),n=new Uint8Array(e);let i=0;return t.map(r=>new Uint8Array(r)).forEach(r=>{for(const s of r)n[i++]=s}),n.buffer}function lf(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),i=new Uint8Array(e);for(let r=0;r<t.byteLength;r++)if(n[r]!==i[r])return!1;return!0}/*!
|
|
42
42
|
Copyright (c) Peculiar Ventures, LLC
|
|
43
|
-
*/function
|
|
43
|
+
*/function Vn(t,e){let n=0;if(t.length===1)return t[0];for(let i=t.length-1;i>=0;i--)n+=t[t.length-1-i]*Math.pow(2,e*i);return n}function gn(t,e,n=-1){const i=n;let r=t,s=0,o=Math.pow(2,e);for(let c=1;c<8;c++){if(t<o){let l;if(i<0)l=new ArrayBuffer(c),s=c;else{if(i<c)return new ArrayBuffer(0);l=new ArrayBuffer(i),s=i}const u=new Uint8Array(l);for(let p=c-1;p>=0;p--){const f=Math.pow(2,p*e);u[s-p-1]=Math.floor(r/f),r-=u[s-p-1]*f}return l}o*=Math.pow(2,e)}return new ArrayBuffer(0)}function pa(...t){let e=0,n=0;for(const s of t)e+=s.length;const i=new ArrayBuffer(e),r=new Uint8Array(i);for(const s of t)r.set(s,n),n+=s.length;return r}function uf(){const t=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const c=t[0]===255&&t[1]&128,l=t[0]===0&&(t[1]&128)===0;(c||l)&&this.warnings.push("Needlessly long format")}const e=new ArrayBuffer(this.valueHex.byteLength),n=new Uint8Array(e);for(let c=0;c<this.valueHex.byteLength;c++)n[c]=0;n[0]=t[0]&128;const i=Vn(n,8),r=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(r);for(let c=0;c<this.valueHex.byteLength;c++)s[c]=t[c];return s[0]&=127,Vn(s,8)-i}function d_(t){const e=t<0?t*-1:t;let n=128;for(let i=1;i<8;i++){if(e<=n){if(t<0){const o=n-e,c=gn(o,8,i),l=new Uint8Array(c);return l[0]|=128,c}let r=gn(e,8,i),s=new Uint8Array(r);if(s[0]&128){const o=r.slice(0),c=new Uint8Array(o);r=new ArrayBuffer(r.byteLength+1),s=new Uint8Array(r);for(let l=0;l<o.byteLength;l++)s[l+1]=c[l];s[0]=0}return r}n*=Math.pow(2,8)}return new ArrayBuffer(0)}function p_(t,e){if(t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),i=new Uint8Array(e);for(let r=0;r<n.length;r++)if(n[r]!==i[r])return!1;return!0}function Ge(t,e){const n=t.toString(10);if(e<n.length)return"";const i=e-n.length,r=new Array(i);for(let o=0;o<i;o++)r[o]="0";return r.join("").concat(n)}/*!
|
|
44
44
|
* Copyright (c) 2014, GMO GlobalSign
|
|
45
45
|
* Copyright (c) 2015-2022, Peculiar Ventures
|
|
46
46
|
* All rights reserved.
|
|
@@ -72,11 +72,11 @@ and limitations under the License.
|
|
|
72
72
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
73
73
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
74
74
|
*
|
|
75
|
-
*/function $r(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function kc(t){let e=0,n=0;for(let r=0;r<t.length;r++){const s=t[r];e+=s.byteLength}const i=new Uint8Array(e);for(let r=0;r<t.length;r++){const s=t[r];i.set(new Uint8Array(s),n),n+=s.byteLength}return i.buffer}function Tt(t,e,n,i){return e instanceof Uint8Array?e.byteLength?n<0?(t.error="Wrong parameter: inputOffset less than zero",!1):i<0?(t.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-n-i<0?(t.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(t.error="Wrong parameter: inputBuffer has zero length",!1):(t.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class bs{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return kc(this.items)}}const li=[new Uint8Array([1])],Jl="0123456789",So="name",Zl="valueHexView",y_="isHexOnly",v_="idBlock",w_="tagClass",b_="tagNumber",k_="isConstructed",x_="fromBER",S_="toBER",A_="local",Ve="",ft=new ArrayBuffer(0),ks=new Uint8Array(0),ki="EndOfContent",$p="OCTET STRING",jp="BIT STRING";function xt(t){var e;return e=class extends t{constructor(...i){var r;super(...i);const s=i[0]||{};this.isHexOnly=(r=s.isHexOnly)!==null&&r!==void 0?r:!1,this.valueHexView=s.valueHex?V.toUint8Array(s.valueHex):ks}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(i){this.valueHexView=new Uint8Array(i)}fromBER(i,r,s){const o=i instanceof ArrayBuffer?new Uint8Array(i):i;if(!Tt(this,o,r,s))return-1;const c=r+s;return this.valueHexView=o.subarray(r,c),this.valueHexView.length?(this.blockLength=s,c):(this.warnings.push("Zero buffer length"),r)}toBER(i=!1){return this.isHexOnly?i?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",ft)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:G.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class Sn{constructor({blockLength:e=0,error:n=Ve,warnings:i=[],valueBeforeDecode:r=ks}={}){this.blockLength=e,this.error=n,this.warnings=i,this.valueBeforeDecodeView=V.toUint8Array(r)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:G.ToHex(this.valueBeforeDecodeView)}}}Sn.NAME="baseBlock";class Pe extends Sn{fromBER(e,n,i){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}Pe.NAME="valueBlock";class Np extends xt(Sn){constructor({idBlock:e={}}={}){var n,i,r,s;super(),e?(this.isHexOnly=(n=e.isHexOnly)!==null&&n!==void 0?n:!1,this.valueHexView=e.valueHex?V.toUint8Array(e.valueHex):ks,this.tagClass=(i=e.tagClass)!==null&&i!==void 0?i:-1,this.tagNumber=(r=e.tagNumber)!==null&&r!==void 0?r:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let n=0;switch(this.tagClass){case 1:n|=0;break;case 2:n|=64;break;case 3:n|=128;break;case 4:n|=192;break;default:return this.error="Unknown tag class",ft}if(this.isConstructed&&(n|=32),this.tagNumber<31&&!this.isHexOnly){const r=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,n|=s,r[0]=n}return r.buffer}if(!this.isHexOnly){const r=pn(this.tagNumber,7),s=new Uint8Array(r),o=r.byteLength,c=new Uint8Array(o+1);if(c[0]=n|31,!e){for(let l=0;l<o-1;l++)c[l+1]=s[l]|128;c[o]=s[o-1]}return c.buffer}const i=new Uint8Array(this.valueHexView.byteLength+1);if(i[0]=n|31,!e){const r=this.valueHexView;for(let s=0;s<r.length-1;s++)i[s+1]=r[s]|128;i[this.valueHexView.byteLength]=r[r.length-1]}return i.buffer}fromBER(e,n,i){const r=V.toUint8Array(e);if(!Tt(this,r,n,i))return-1;const s=r.subarray(n,n+i);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;const c=s[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let l=1,u=this.valueHexView=new Uint8Array(255),p=255;for(;s[l]&128;){if(u[l-1]=s[l]&127,l++,l>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(l===p){p+=255;const _=new Uint8Array(p);for(let k=0;k<u.length;k++)_[k]=u[k];u=this.valueHexView=new Uint8Array(p)}}this.blockLength=l+1,u[l-1]=s[l]&127;const g=new Uint8Array(l);for(let _=0;_<l;_++)g[_]=u[_];u=this.valueHexView=new Uint8Array(l),u.set(g),this.blockLength<=9?this.tagNumber=Pn(u,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return n+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}}Np.NAME="identificationBlock";class Op extends Sn{constructor({lenBlock:e={}}={}){var n,i,r;super(),this.isIndefiniteForm=(n=e.isIndefiniteForm)!==null&&n!==void 0?n:!1,this.longFormUsed=(i=e.longFormUsed)!==null&&i!==void 0?i:!1,this.length=(r=e.length)!==null&&r!==void 0?r:0}fromBER(e,n,i){const r=V.toUint8Array(e);if(!Tt(this,r,n,i))return-1;const s=r.subarray(n,n+i);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,n+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,n+this.blockLength;const o=s[0]&127;if(o>8)return this.error="Too big integer",-1;if(o+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const c=n+1,l=r.subarray(c,c+o);return l[o-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Pn(l,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=o+1,n+this.blockLength}toBER(e=!1){let n,i;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return n=new ArrayBuffer(1),e===!1&&(i=new Uint8Array(n),i[0]=128),n;if(this.longFormUsed){const r=pn(this.length,8);if(r.byteLength>127)return this.error="Too big length",ft;if(n=new ArrayBuffer(r.byteLength+1),e)return n;const s=new Uint8Array(r);i=new Uint8Array(n),i[0]=r.byteLength|128;for(let o=0;o<r.byteLength;o++)i[o+1]=s[o];return n}return n=new ArrayBuffer(1),e===!1&&(i=new Uint8Array(n),i[0]=this.length),n}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}Op.NAME="lengthBlock";const H={};class je extends Sn{constructor({name:e=Ve,optional:n=!1,primitiveSchema:i,...r}={},s){super(r),this.name=e,this.optional=n,i&&(this.primitiveSchema=i),this.idBlock=new Np(r),this.lenBlock=new Op(r),this.valueBlock=s?new s(r):new Pe(r)}fromBER(e,n,i){const r=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?i:this.lenBlock.length);return r===-1?(this.error=this.valueBlock.error,r):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),r)}toBER(e,n){const i=n||new bs;n||Bp(this);const r=this.idBlock.toBER(e);if(i.write(r),this.lenBlock.isIndefiniteForm)i.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,i),i.write(new ArrayBuffer(2));else{const s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;const o=this.lenBlock.toBER(e);i.write(o),i.write(s)}return n?ft:i.final()}toJSON(){const e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():G.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${G.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const n=this.toBER(),i=e.toBER();return m_(n,i)}}je.NAME="BaseBlock";function Bp(t){if(t instanceof H.Constructed)for(const e of t.valueBlock.value)Bp(e)&&(t.lenBlock.isIndefiniteForm=!0);return!!t.lenBlock.isIndefiniteForm}class xc extends je{constructor({value:e=Ve,...n}={},i){super(n,i),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,n,i){const r=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?i:this.lenBlock.length);return r===-1?(this.error=this.valueBlock.error,r):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),r)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}xc.NAME="BaseStringBlock";class Tp extends xt(Pe){constructor({isHexOnly:e=!0,...n}={}){super(n),this.isHexOnly=e}}Tp.NAME="PrimitiveValueBlock";var Rp;class Pi extends je{constructor(e={}){super(e,Tp),this.idBlock.isConstructed=!1}}Rp=Pi;H.Primitive=Rp;Pi.NAME="PRIMITIVE";function I_(t,e){if(t instanceof e)return t;const n=new e;return n.idBlock=t.idBlock,n.lenBlock=t.lenBlock,n.warnings=t.warnings,n.valueBeforeDecodeView=t.valueBeforeDecodeView,n}function Zn(t,e=0,n=t.length){const i=e;let r=new je({},Pe);const s=new Sn;if(!Tt(s,t,e,n))return r.error=s.error,{offset:-1,result:r};if(!t.subarray(e,e+n).length)return r.error="Zero buffer length",{offset:-1,result:r};let c=r.idBlock.fromBER(t,e,n);if(r.idBlock.warnings.length&&r.warnings.concat(r.idBlock.warnings),c===-1)return r.error=r.idBlock.error,{offset:-1,result:r};if(e=c,n-=r.idBlock.blockLength,c=r.lenBlock.fromBER(t,e,n),r.lenBlock.warnings.length&&r.warnings.concat(r.lenBlock.warnings),c===-1)return r.error=r.lenBlock.error,{offset:-1,result:r};if(e=c,n-=r.lenBlock.blockLength,!r.idBlock.isConstructed&&r.lenBlock.isIndefiniteForm)return r.error="Indefinite length form used for primitive encoding form",{offset:-1,result:r};let l=je;switch(r.idBlock.tagClass){case 1:if(r.idBlock.tagNumber>=37&&r.idBlock.isHexOnly===!1)return r.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:r};switch(r.idBlock.tagNumber){case 0:if(r.idBlock.isConstructed&&r.lenBlock.length>0)return r.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:r};l=H.EndOfContent;break;case 1:l=H.Boolean;break;case 2:l=H.Integer;break;case 3:l=H.BitString;break;case 4:l=H.OctetString;break;case 5:l=H.Null;break;case 6:l=H.ObjectIdentifier;break;case 10:l=H.Enumerated;break;case 12:l=H.Utf8String;break;case 13:l=H.RelativeObjectIdentifier;break;case 14:l=H.TIME;break;case 15:return r.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:r};case 16:l=H.Sequence;break;case 17:l=H.Set;break;case 18:l=H.NumericString;break;case 19:l=H.PrintableString;break;case 20:l=H.TeletexString;break;case 21:l=H.VideotexString;break;case 22:l=H.IA5String;break;case 23:l=H.UTCTime;break;case 24:l=H.GeneralizedTime;break;case 25:l=H.GraphicString;break;case 26:l=H.VisibleString;break;case 27:l=H.GeneralString;break;case 28:l=H.UniversalString;break;case 29:l=H.CharacterString;break;case 30:l=H.BmpString;break;case 31:l=H.DATE;break;case 32:l=H.TimeOfDay;break;case 33:l=H.DateTime;break;case 34:l=H.Duration;break;default:{const u=r.idBlock.isConstructed?new H.Constructed:new H.Primitive;u.idBlock=r.idBlock,u.lenBlock=r.lenBlock,u.warnings=r.warnings,r=u}}break;case 2:case 3:case 4:default:l=r.idBlock.isConstructed?H.Constructed:H.Primitive}return r=I_(r,l),c=r.fromBER(t,e,r.lenBlock.isIndefiniteForm?n:r.lenBlock.length),r.valueBeforeDecodeView=t.subarray(i,i+r.blockLength),{offset:c,result:r}}function On(t){if(!t.byteLength){const e=new je({},Pe);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Zn(V.toUint8Array(t).slice(),0,t.byteLength)}function E_(t,e){return t?1:e}class Mt extends Pe{constructor({value:e=[],isIndefiniteForm:n=!1,...i}={}){super(i),this.value=e,this.isIndefiniteForm=n}fromBER(e,n,i){const r=V.toUint8Array(e);if(!Tt(this,r,n,i))return-1;if(this.valueBeforeDecodeView=r.subarray(n,n+i),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),n;let s=n;for(;E_(this.isIndefiniteForm,i)>0;){const o=Zn(r,s,i);if(o.offset===-1)return this.error=o.result.error,this.warnings.concat(o.result.warnings),-1;if(s=o.offset,this.blockLength+=o.result.blockLength,i-=o.result.blockLength,this.value.push(o.result),this.isIndefiniteForm&&o.result.constructor.NAME===ki)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===ki?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,n){const i=n||new bs;for(let r=0;r<this.value.length;r++)this.value[r].toBER(e,i);return n?ft:i.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const n of this.value)e.value.push(n.toJSON());return e}}Mt.NAME="ConstructedValueBlock";var Pp;class Me extends je{constructor(e={}){super(e,Mt),this.idBlock.isConstructed=!0}fromBER(e,n,i){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const r=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?i:this.lenBlock.length);return r===-1?(this.error=this.valueBlock.error,r):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),r)}onAsciiEncoding(){const e=[];for(const i of this.valueBlock.value)e.push(i.toString("ascii").split(`
|
|
75
|
+
*/function Gr(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Kc(t){let e=0,n=0;for(let r=0;r<t.length;r++){const s=t[r];e+=s.byteLength}const i=new Uint8Array(e);for(let r=0;r<t.length;r++){const s=t[r];i.set(new Uint8Array(s),n),n+=s.byteLength}return i.buffer}function Rt(t,e,n,i){return e instanceof Uint8Array?e.byteLength?n<0?(t.error="Wrong parameter: inputOffset less than zero",!1):i<0?(t.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-n-i<0?(t.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(t.error="Wrong parameter: inputBuffer has zero length",!1):(t.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class Ms{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Kc(this.items)}}const gi=[new Uint8Array([1])],xu="0123456789",Do="name",Su="valueHexView",f_="isHexOnly",h_="idBlock",g_="tagClass",m_="tagNumber",__="isConstructed",y_="fromBER",v_="toBER",w_="local",Me="",ht=new ArrayBuffer(0),Ds=new Uint8Array(0),$i="EndOfContent",df="OCTET STRING",pf="BIT STRING";function At(t){var e;return e=class extends t{constructor(...i){var r;super(...i);const s=i[0]||{};this.isHexOnly=(r=s.isHexOnly)!==null&&r!==void 0?r:!1,this.valueHexView=s.valueHex?M.toUint8Array(s.valueHex):Ds}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(i){this.valueHexView=new Uint8Array(i)}fromBER(i,r,s){const o=i instanceof ArrayBuffer?new Uint8Array(i):i;if(!Rt(this,o,r,s))return-1;const c=r+s;return this.valueHexView=o.subarray(r,c),this.valueHexView.length?(this.blockLength=s,c):(this.warnings.push("Zero buffer length"),r)}toBER(i=!1){return this.isHexOnly?i?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",ht)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:G.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class In{constructor({blockLength:e=0,error:n=Me,warnings:i=[],valueBeforeDecode:r=Ds}={}){this.blockLength=e,this.error=n,this.warnings=i,this.valueBeforeDecodeView=M.toUint8Array(r)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:G.ToHex(this.valueBeforeDecodeView)}}}In.NAME="baseBlock";class Le extends In{fromBER(e,n,i){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}Le.NAME="valueBlock";class ff extends At(In){constructor({idBlock:e={}}={}){var n,i,r,s;super(),e?(this.isHexOnly=(n=e.isHexOnly)!==null&&n!==void 0?n:!1,this.valueHexView=e.valueHex?M.toUint8Array(e.valueHex):Ds,this.tagClass=(i=e.tagClass)!==null&&i!==void 0?i:-1,this.tagNumber=(r=e.tagNumber)!==null&&r!==void 0?r:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let n=0;switch(this.tagClass){case 1:n|=0;break;case 2:n|=64;break;case 3:n|=128;break;case 4:n|=192;break;default:return this.error="Unknown tag class",ht}if(this.isConstructed&&(n|=32),this.tagNumber<31&&!this.isHexOnly){const r=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,n|=s,r[0]=n}return r.buffer}if(!this.isHexOnly){const r=gn(this.tagNumber,7),s=new Uint8Array(r),o=r.byteLength,c=new Uint8Array(o+1);if(c[0]=n|31,!e){for(let l=0;l<o-1;l++)c[l+1]=s[l]|128;c[o]=s[o-1]}return c.buffer}const i=new Uint8Array(this.valueHexView.byteLength+1);if(i[0]=n|31,!e){const r=this.valueHexView;for(let s=0;s<r.length-1;s++)i[s+1]=r[s]|128;i[this.valueHexView.byteLength]=r[r.length-1]}return i.buffer}fromBER(e,n,i){const r=M.toUint8Array(e);if(!Rt(this,r,n,i))return-1;const s=r.subarray(n,n+i);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(s[0]&32)===32,this.isHexOnly=!1;const c=s[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let l=1,u=this.valueHexView=new Uint8Array(255),p=255;for(;s[l]&128;){if(u[l-1]=s[l]&127,l++,l>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(l===p){p+=255;const m=new Uint8Array(p);for(let v=0;v<u.length;v++)m[v]=u[v];u=this.valueHexView=new Uint8Array(p)}}this.blockLength=l+1,u[l-1]=s[l]&127;const f=new Uint8Array(l);for(let m=0;m<l;m++)f[m]=u[m];u=this.valueHexView=new Uint8Array(l),u.set(f),this.blockLength<=9?this.tagNumber=Vn(u,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return n+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}}ff.NAME="identificationBlock";class hf extends In{constructor({lenBlock:e={}}={}){var n,i,r;super(),this.isIndefiniteForm=(n=e.isIndefiniteForm)!==null&&n!==void 0?n:!1,this.longFormUsed=(i=e.longFormUsed)!==null&&i!==void 0?i:!1,this.length=(r=e.length)!==null&&r!==void 0?r:0}fromBER(e,n,i){const r=M.toUint8Array(e);if(!Rt(this,r,n,i))return-1;const s=r.subarray(n,n+i);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,n+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,n+this.blockLength;const o=s[0]&127;if(o>8)return this.error="Too big integer",-1;if(o+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const c=n+1,l=r.subarray(c,c+o);return l[o-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Vn(l,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=o+1,n+this.blockLength}toBER(e=!1){let n,i;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return n=new ArrayBuffer(1),e===!1&&(i=new Uint8Array(n),i[0]=128),n;if(this.longFormUsed){const r=gn(this.length,8);if(r.byteLength>127)return this.error="Too big length",ht;if(n=new ArrayBuffer(r.byteLength+1),e)return n;const s=new Uint8Array(r);i=new Uint8Array(n),i[0]=r.byteLength|128;for(let o=0;o<r.byteLength;o++)i[o+1]=s[o];return n}return n=new ArrayBuffer(1),e===!1&&(i=new Uint8Array(n),i[0]=this.length),n}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}hf.NAME="lengthBlock";const q={};class je extends In{constructor({name:e=Me,optional:n=!1,primitiveSchema:i,...r}={},s){super(r),this.name=e,this.optional=n,i&&(this.primitiveSchema=i),this.idBlock=new ff(r),this.lenBlock=new hf(r),this.valueBlock=s?new s(r):new Le(r)}fromBER(e,n,i){const r=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?i:this.lenBlock.length);return r===-1?(this.error=this.valueBlock.error,r):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),r)}toBER(e,n){const i=n||new Ms;n||gf(this);const r=this.idBlock.toBER(e);if(i.write(r),this.lenBlock.isIndefiniteForm)i.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,i),i.write(new ArrayBuffer(2));else{const s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;const o=this.lenBlock.toBER(e);i.write(o),i.write(s)}return n?ht:i.final()}toJSON(){const e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():G.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${G.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const n=this.toBER(),i=e.toBER();return p_(n,i)}}je.NAME="BaseBlock";function gf(t){if(t instanceof q.Constructed)for(const e of t.valueBlock.value)gf(e)&&(t.lenBlock.isIndefiniteForm=!0);return!!t.lenBlock.isIndefiniteForm}class Wc extends je{constructor({value:e=Me,...n}={},i){super(n,i),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,n,i){const r=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?i:this.lenBlock.length);return r===-1?(this.error=this.valueBlock.error,r):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),r)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}Wc.NAME="BaseStringBlock";class mf extends At(Le){constructor({isHexOnly:e=!0,...n}={}){super(n),this.isHexOnly=e}}mf.NAME="PrimitiveValueBlock";var _f;class Wi extends je{constructor(e={}){super(e,mf),this.idBlock.isConstructed=!1}}_f=Wi;q.Primitive=_f;Wi.NAME="PRIMITIVE";function b_(t,e){if(t instanceof e)return t;const n=new e;return n.idBlock=t.idBlock,n.lenBlock=t.lenBlock,n.warnings=t.warnings,n.valueBeforeDecodeView=t.valueBeforeDecodeView,n}function ei(t,e=0,n=t.length){const i=e;let r=new je({},Le);const s=new In;if(!Rt(s,t,e,n))return r.error=s.error,{offset:-1,result:r};if(!t.subarray(e,e+n).length)return r.error="Zero buffer length",{offset:-1,result:r};let c=r.idBlock.fromBER(t,e,n);if(r.idBlock.warnings.length&&r.warnings.concat(r.idBlock.warnings),c===-1)return r.error=r.idBlock.error,{offset:-1,result:r};if(e=c,n-=r.idBlock.blockLength,c=r.lenBlock.fromBER(t,e,n),r.lenBlock.warnings.length&&r.warnings.concat(r.lenBlock.warnings),c===-1)return r.error=r.lenBlock.error,{offset:-1,result:r};if(e=c,n-=r.lenBlock.blockLength,!r.idBlock.isConstructed&&r.lenBlock.isIndefiniteForm)return r.error="Indefinite length form used for primitive encoding form",{offset:-1,result:r};let l=je;switch(r.idBlock.tagClass){case 1:if(r.idBlock.tagNumber>=37&&r.idBlock.isHexOnly===!1)return r.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:r};switch(r.idBlock.tagNumber){case 0:if(r.idBlock.isConstructed&&r.lenBlock.length>0)return r.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:r};l=q.EndOfContent;break;case 1:l=q.Boolean;break;case 2:l=q.Integer;break;case 3:l=q.BitString;break;case 4:l=q.OctetString;break;case 5:l=q.Null;break;case 6:l=q.ObjectIdentifier;break;case 10:l=q.Enumerated;break;case 12:l=q.Utf8String;break;case 13:l=q.RelativeObjectIdentifier;break;case 14:l=q.TIME;break;case 15:return r.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:r};case 16:l=q.Sequence;break;case 17:l=q.Set;break;case 18:l=q.NumericString;break;case 19:l=q.PrintableString;break;case 20:l=q.TeletexString;break;case 21:l=q.VideotexString;break;case 22:l=q.IA5String;break;case 23:l=q.UTCTime;break;case 24:l=q.GeneralizedTime;break;case 25:l=q.GraphicString;break;case 26:l=q.VisibleString;break;case 27:l=q.GeneralString;break;case 28:l=q.UniversalString;break;case 29:l=q.CharacterString;break;case 30:l=q.BmpString;break;case 31:l=q.DATE;break;case 32:l=q.TimeOfDay;break;case 33:l=q.DateTime;break;case 34:l=q.Duration;break;default:{const u=r.idBlock.isConstructed?new q.Constructed:new q.Primitive;u.idBlock=r.idBlock,u.lenBlock=r.lenBlock,u.warnings=r.warnings,r=u}}break;case 2:case 3:case 4:default:l=r.idBlock.isConstructed?q.Constructed:q.Primitive}return r=b_(r,l),c=r.fromBER(t,e,r.lenBlock.isIndefiniteForm?n:r.lenBlock.length),r.valueBeforeDecodeView=t.subarray(i,i+r.blockLength),{offset:c,result:r}}function Rn(t){if(!t.byteLength){const e=new je({},Le);return e.error="Input buffer has zero length",{offset:-1,result:e}}return ei(M.toUint8Array(t).slice(),0,t.byteLength)}function k_(t,e){return t?1:e}class Ht extends Le{constructor({value:e=[],isIndefiniteForm:n=!1,...i}={}){super(i),this.value=e,this.isIndefiniteForm=n}fromBER(e,n,i){const r=M.toUint8Array(e);if(!Rt(this,r,n,i))return-1;if(this.valueBeforeDecodeView=r.subarray(n,n+i),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),n;let s=n;for(;k_(this.isIndefiniteForm,i)>0;){const o=ei(r,s,i);if(o.offset===-1)return this.error=o.result.error,this.warnings.concat(o.result.warnings),-1;if(s=o.offset,this.blockLength+=o.result.blockLength,i-=o.result.blockLength,this.value.push(o.result),this.isIndefiniteForm&&o.result.constructor.NAME===$i)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===$i?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,n){const i=n||new Ms;for(let r=0;r<this.value.length;r++)this.value[r].toBER(e,i);return n?ht:i.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const n of this.value)e.value.push(n.toJSON());return e}}Ht.NAME="ConstructedValueBlock";var yf;class De extends je{constructor(e={}){super(e,Ht),this.idBlock.isConstructed=!0}fromBER(e,n,i){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const r=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?i:this.lenBlock.length);return r===-1?(this.error=this.valueBlock.error,r):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),r)}onAsciiEncoding(){const e=[];for(const i of this.valueBlock.value)e.push(i.toString("ascii").split(`
|
|
76
76
|
`).map(r=>` ${r}`).join(`
|
|
77
77
|
`));const n=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${n} :
|
|
78
78
|
${e.join(`
|
|
79
|
-
`)}`:`${n} :`}}Pp=Me;H.Constructed=Pp;Me.NAME="CONSTRUCTED";class Lp extends Pe{fromBER(e,n,i){return n}toBER(e){return ft}}Lp.override="EndOfContentValueBlock";var Up;class Sc extends je{constructor(e={}){super(e,Lp),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Up=Sc;H.EndOfContent=Up;Sc.NAME=ki;var Vp;class fn extends je{constructor(e={}){super(e,Pe),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,n,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,n+i>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):n+i}toBER(e,n){const i=new ArrayBuffer(2);if(!e){const r=new Uint8Array(i);r[0]=5,r[1]=0}return n&&n.write(i),i}onAsciiEncoding(){return`${this.constructor.NAME}`}}Vp=fn;H.Null=Vp;fn.NAME="NULL";class Mp extends xt(Pe){constructor({value:e,...n}={}){super(n),n.valueHex?this.valueHexView=V.toUint8Array(n.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,n,i){const r=V.toUint8Array(e);return Tt(this,r,n,i)?(this.valueHexView=r.subarray(n,n+i),i>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,zp.call(this),this.blockLength=i,n+i):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}Mp.NAME="BooleanValueBlock";var Dp;class xs extends je{constructor(e={}){super(e,Mp),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}`}}Dp=xs;H.Boolean=Dp;xs.NAME="BOOLEAN";class Fp extends xt(Mt){constructor({isConstructed:e=!1,...n}={}){super(n),this.isConstructed=e}fromBER(e,n,i){let r=0;if(this.isConstructed){if(this.isHexOnly=!1,r=Mt.prototype.fromBER.call(this,e,n,i),r===-1)return r;for(let s=0;s<this.value.length;s++){const o=this.value[s].constructor.NAME;if(o===ki){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(o!==$p)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,r=super.fromBER(e,n,i),this.blockLength=i;return r}toBER(e,n){return this.isConstructed?Mt.prototype.toBER.call(this,e,n):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}Fp.NAME="OctetStringValueBlock";var Hp;let an=class qp extends je{constructor({idBlock:e={},lenBlock:n={},...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:{...n,isIndefiniteForm:!!i.isIndefiniteForm},...i},Fp),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,n,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),n;if(!this.valueBlock.isConstructed){const s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(n,n+i);try{if(s.byteLength){const o=Zn(s,0,s.byteLength);o.offset!==-1&&o.offset===i&&(this.valueBlock.value=[o.result])}}catch{}}return super.fromBER(e,n,i)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Me.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${G.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const n of this.valueBlock.value)n instanceof qp&&e.push(n.valueBlock.valueHexView);return V.concat(e)}};Hp=an;H.OctetString=Hp;an.NAME=$p;class Kp extends xt(Mt){constructor({unusedBits:e=0,isConstructed:n=!1,...i}={}){super(i),this.unusedBits=e,this.isConstructed=n,this.blockLength=this.valueHexView.byteLength}fromBER(e,n,i){if(!i)return n;let r=-1;if(this.isConstructed){if(r=Mt.prototype.fromBER.call(this,e,n,i),r===-1)return r;for(const c of this.value){const l=c.constructor.NAME;if(l===ki){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(l!==jp)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=V.toUint8Array(e);if(!Tt(this,s,n,i))return-1;const o=s.subarray(n,n+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=Zn(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,n+i}toBER(e,n){if(this.isConstructed)return Mt.prototype.toBER.call(this,e,n);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return ft;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}}}Kp.NAME="BitStringValueBlock";var Wp;let cn=class extends je{constructor({idBlock:e={},lenBlock:n={},...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:{...n,isIndefiniteForm:!!i.isIndefiniteForm},...i},Kp),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,n,i){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,n,i)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Me.prototype.onAsciiEncoding.call(this);{const e=[],n=this.valueBlock.valueHexView;for(const r of n)e.push(r.toString(2).padStart(8,"0"));const i=e.join("");return`${this.constructor.NAME} : ${i.substring(0,i.length-this.valueBlock.unusedBits)}`}}};Wp=cn;H.BitString=Wp;cn.NAME=jp;var Gp;function C_(t,e){const n=new Uint8Array([0]),i=new Uint8Array(t),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 _=p;_>=0;_--,g++){switch(!0){case g<c.length:u=s[o-g]+c[l-g]+n[0];break;default:u=s[o-g]+n[0]}switch(n[0]=u/10,!0){case g>=s.length:s=Ho(new Uint8Array([u%10]),s);break;default:s[o-g]=u%10}}return n[0]>0&&(s=Ho(n,s)),s}function Yl(t){if(t>=li.length)for(let e=li.length;e<=t;e++){const n=new Uint8Array([0]);let i=li[e-1].slice(0);for(let r=i.length-1;r>=0;r--){const s=new Uint8Array([(i[r]<<1)+n[0]]);n[0]=s[0]/10,i[r]=s[0]%10}n[0]>0&&(i=Ho(n,i)),li.push(i)}return li[t]}function z_(t,e){let n=0;const i=new Uint8Array(t),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]-n,!0){case u<0:n=1,s[o-p]=u+10;break;default:n=0,s[o-p]=u}if(n>0)for(let g=o-l+1;g>=0;g--,p++)if(u=s[o-p]-n,u<0)n=1,s[o-p]=u+10;else{n=0,s[o-p]=u;break}return s.slice()}class Ac extends xt(Pe){constructor({value:e,...n}={}){super(n),this._valueDec=0,n.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=zp.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(__(e))}get valueDec(){return this._valueDec}fromDER(e,n,i,r=0){const s=this.fromBER(e,n,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 n=this.valueHexView;switch(!0){case(n[0]&128)!==0:{const i=new Uint8Array(this.valueHexView.length+1);i[0]=0,i.set(n,1),this.valueHexView=i}break;case(n[0]===0&&(n[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,n,i){const r=super.fromBER(e,n,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 n=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:n=z_(Yl(i),n),o="-";break;default:n=C_(n,Yl(i))}i++,r>>=1}}for(let l=0;l<n.length;l++)n[l]&&(c=!0),c&&(o+=Jl.charAt(n[l]));return c===!1&&(o+=Jl.charAt(0)),o}}Gp=Ac;Ac.NAME="IntegerValueBlock";Object.defineProperty(Gp.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Jp;class wt extends je{constructor(e={}){super(e,Ac),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return $r(),BigInt(this.valueBlock.toString())}static fromBigInt(e){$r();const n=BigInt(e),i=new bs,r=n.toString(16).replace(/^-/,""),s=new Uint8Array(G.FromHex(r));if(n<0){const c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;const u=BigInt(`0x${G.ToHex(c)}`)+n,p=V.toUint8Array(G.FromHex(u.toString(16)));p[0]|=128,i.write(p)}else s[0]&128&&i.write(new Uint8Array([0])),i.write(s);return new wt({valueHex:i.final()})}convertToDER(){const e=new wt({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new wt({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}Jp=wt;H.Integer=Jp;wt.NAME="INTEGER";var Zp;class Ss extends wt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}Zp=Ss;H.Enumerated=Zp;Ss.NAME="ENUMERATED";class qo extends xt(Pe){constructor({valueDec:e=-1,isFirstSid:n=!1,...i}={}){super(i),this.valueDec=e,this.isFirstSid=n}fromBER(e,n,i){if(!i)return n;const r=V.toUint8Array(e);if(!Tt(this,r,n,i))return-1;const s=r.subarray(n,n+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=Pn(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}set valueBigInt(e){$r();let n=BigInt(e).toString(2);for(;n.length%7;)n="0"+n;const i=new Uint8Array(n.length/7);for(let r=0;r<i.length;r++)i[r]=parseInt(n.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 n=pn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",ft;const i=new Uint8Array(n.byteLength);if(!e){const r=new Uint8Array(n),s=n.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=G.ToHex(this.valueHexView);else if(this.isFirstSid){let n=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",n-=40):(e="2.",n-=80),e+=n.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}qo.NAME="sidBlock";class Yp extends Pe{constructor({value:e=Ve,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,i){let r=n;for(;i>0;){const s=new qo;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 n=[];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,ft;n.push(r)}return kc(n)}fromString(e){this.value=[];let n=0,i=0,r="",s=!1;do if(i=e.indexOf(".",n),i===-1?r=e.substring(n):r=e.substring(n,i),n=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 qo;if(r>Number.MAX_SAFE_INTEGER){$r();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="",n=!1;for(let i=0;i<this.value.length;i++){n=this.value[i].isHexOnly;let r=this.value[i].toString();i!==0&&(e=`${e}.`),n?(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 n=0;n<this.value.length;n++)e.sidArray.push(this.value[n].toJSON());return e}}Yp.NAME="ObjectIdentifierValueBlock";var Xp;class As extends je{constructor(e={}){super(e,Yp),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()}}}Xp=As;H.ObjectIdentifier=Xp;As.NAME="OBJECT IDENTIFIER";class Ko extends xt(Sn){constructor({valueDec:e=0,...n}={}){super(n),this.valueDec=e}fromBER(e,n,i){if(i===0)return n;const r=V.toUint8Array(e);if(!Tt(this,r,n,i))return-1;const s=r.subarray(n,n+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=Pn(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+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 n=pn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",ft;const i=new Uint8Array(n.byteLength);if(!e){const r=new Uint8Array(n),s=n.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=G.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Ko.NAME="relativeSidBlock";class Qp extends Pe{constructor({value:e=Ve,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,i){let r=n;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.blockLength+=s.blockLength,i-=s.blockLength,this.value.push(s)}return r}toBER(e,n){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,ft;i.push(s)}return kc(i)}fromString(e){this.value=[];let n=0,i=0,r="";do{i=e.indexOf(".",n),i===-1?r=e.substring(n):r=e.substring(n,i),n=i+1;const s=new Ko;if(s.valueDec=parseInt(r,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(i!==-1);return!0}toString(){let e="",n=!1;for(let i=0;i<this.value.length;i++){n=this.value[i].isHexOnly;let r=this.value[i].toString();i!==0&&(e=`${e}.`),n&&(r=`{${r}}`),e+=r}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let n=0;n<this.value.length;n++)e.sidArray.push(this.value[n].toJSON());return e}}Qp.NAME="RelativeObjectIdentifierValueBlock";var ef;class Ic extends je{constructor(e={}){super(e,Qp),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()}}}ef=Ic;H.RelativeObjectIdentifier=ef;Ic.NAME="RelativeObjectIdentifier";var tf;class Et extends Me{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}tf=Et;H.Sequence=tf;Et.NAME="SEQUENCE";var nf;let Ct=class extends Me{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};nf=Ct;H.Set=nf;Ct.NAME="SET";class rf extends xt(Pe){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Ve}toJSON(){return{...super.toJSON(),value:this.value}}}rf.NAME="StringValueBlock";class sf extends rf{}sf.NAME="SimpleStringValueBlock";class Je extends xc{constructor({...e}={}){super(e,sf)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,V.toUint8Array(e))}fromString(e){const n=e.length,i=this.valueBlock.valueHexView=new Uint8Array(n);for(let r=0;r<n;r++)i[r]=e.charCodeAt(r);this.valueBlock.value=e}}Je.NAME="SIMPLE STRING";class of extends Je{fromBuffer(e){this.valueBlock.valueHexView=V.toUint8Array(e);try{this.valueBlock.value=G.ToUtf8String(e)}catch(n){this.warnings.push(`Error during "decodeURIComponent": ${n}, using raw string`),this.valueBlock.value=G.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(G.FromUtf8String(e)),this.valueBlock.value=e}}of.NAME="Utf8StringValueBlock";var af;class Rt extends of{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}af=Rt;H.Utf8String=af;Rt.NAME="UTF8String";class cf extends Je{fromBuffer(e){this.valueBlock.value=G.ToUtf16String(e),this.valueBlock.valueHexView=V.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(G.FromUtf16String(e))}}cf.NAME="BmpStringValueBlock";var lf;class Is extends cf{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}lf=Is;H.BmpString=lf;Is.NAME="BMPString";class uf extends Je{fromBuffer(e){const n=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),i=new Uint8Array(n);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(n))}fromString(e){const n=e.length,i=this.valueBlock.valueHexView=new Uint8Array(n*4);for(let r=0;r<n;r++){const s=pn(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}}uf.NAME="UniversalStringValueBlock";var df;class Es extends uf{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}df=Es;H.UniversalString=df;Es.NAME="UniversalString";var pf;class Cs extends Je{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}pf=Cs;H.NumericString=pf;Cs.NAME="NumericString";var ff;class zs extends Je{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}ff=zs;H.PrintableString=ff;zs.NAME="PrintableString";var hf;class $s extends Je{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}hf=$s;H.TeletexString=hf;$s.NAME="TeletexString";var gf;class js extends Je{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}gf=js;H.VideotexString=gf;js.NAME="VideotexString";var _f;class Ns extends Je{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}_f=Ns;H.IA5String=_f;Ns.NAME="IA5String";var mf;class Os extends Je{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}mf=Os;H.GraphicString=mf;Os.NAME="GraphicString";var yf;class Li extends Je{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}yf=Li;H.VisibleString=yf;Li.NAME="VisibleString";var vf;class Bs extends Je{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}vf=Bs;H.GeneralString=vf;Bs.NAME="GeneralString";var wf;class Ts extends Je{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}wf=Ts;H.CharacterString=wf;Ts.NAME="CharacterString";var bf;class Ui extends Li{constructor({value:e,valueDate:n,...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)}n&&(this.fromDate(n),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,V.toUint8Array(e)))}toBuffer(){const e=this.toString(),n=new ArrayBuffer(e.length),i=new Uint8Array(n);for(let r=0;r<e.length;r++)i[r]=e.charCodeAt(r);return n}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 n=new Array(7);return n[0]=We(this.year<2e3?this.year-1900:this.year-2e3,2),n[1]=We(this.month,2),n[2]=We(this.day,2),n[3]=We(this.hour,2),n[4]=We(this.minute,2),n[5]=We(this.second,2),n[6]="Z",n.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}}}bf=Ui;H.UTCTime=bf;Ui.NAME="UTCTime";var kf;class Rs extends Ui{constructor(e={}){var n;super(e),(n=this.millisecond)!==null&&n!==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 n=!1,i="",r="",s=0,o,c=0,l=0;if(e[e.length-1]==="Z")i=e.substring(0,e.length-1),n=!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(n){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,_=i.indexOf("+"),k="";if(_===-1&&(_=i.indexOf("-"),g=-1),_!==-1){if(k=i.substring(_+1),i=i.substring(0,_),k.length!==2&&k.length!==4)throw new Error("Wrong input string for conversion");let h=parseInt(k.substring(0,2),10);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");if(c=g*h,k.length===4){if(h=parseInt(k.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(n===!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 n=[];return n.push(We(this.year,4)),n.push(We(this.month,2)),n.push(We(this.day,2)),n.push(We(this.hour,2)),n.push(We(this.minute,2)),n.push(We(this.second,2)),this.millisecond!==0&&(n.push("."),n.push(We(this.millisecond,3))),n.push("Z"),n.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}kf=Rs;H.GeneralizedTime=kf;Rs.NAME="GeneralizedTime";var xf;class Ec extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}xf=Ec;H.DATE=xf;Ec.NAME="DATE";var Sf;class Cc extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Sf=Cc;H.TimeOfDay=Sf;Cc.NAME="TimeOfDay";var Af;class zc extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Af=zc;H.DateTime=Af;zc.NAME="DateTime";var If;class $c extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}If=$c;H.Duration=If;$c.NAME="Duration";var Ef;class jc extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Ef=jc;H.TIME=Ef;jc.NAME="TIME";class hn{constructor({name:e=Ve,optional:n=!1}={}){this.name=e,this.optional=n}}class Nc extends hn{constructor({value:e=[],...n}={}){super(n),this.value=e}}class jr extends hn{constructor({value:e=new hn,local:n=!1,...i}={}){super(i),this.value=e,this.local=n}}class $_{constructor({data:e=ks}={}){this.dataView=V.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=V.toUint8Array(e)}fromBER(e,n,i){const r=n+i;return this.dataView=V.toUint8Array(e).subarray(n,r),r}toBER(e){return this.dataView.slice().buffer}}function rn(t,e,n){if(n instanceof Nc){for(let s=0;s<n.value.length;s++)if(rn(t,e,n.value[s]).verified)return{verified:!0,result:t};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return n.hasOwnProperty(So)&&(s.name=n.name),s}}if(n instanceof hn)return n.hasOwnProperty(So)&&(t[n.name]=e),{verified:!0,result:t};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(n instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(v_ in n))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(x_ in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(S_ in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const i=n.idBlock.toBER(!1);if(i.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(n.idBlock.fromBER(i,0,i.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(n.idBlock.hasOwnProperty(w_)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:t};if(n.idBlock.hasOwnProperty(b_)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:t};if(n.idBlock.hasOwnProperty(k_)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:t};if(!(y_ in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:t};if(n.idBlock.isHexOnly){if(!(Zl in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=n.idBlock.valueHexView,o=e.idBlock.valueHexView;if(s.length!==o.length)return{verified:!1,result:t};for(let c=0;c<s.length;c++)if(s[c]!==o[1])return{verified:!1,result:t}}if(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ve),n.name&&(t[n.name]=e)),n instanceof H.Constructed){let s=0,o={verified:!1,result:{error:"Unknown error"}},c=n.valueBlock.value.length;if(c>0&&n.valueBlock.value[0]instanceof jr&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:t};if(e.valueBlock.value.length===0&&n.valueBlock.value.length!==0){let l=!0;for(let u=0;u<n.valueBlock.value.length;u++)l=l&&(n.valueBlock.value[u].optional||!1);return l?{verified:!0,result:t}:(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ve),n.name&&delete t[n.name]),t.error="Inconsistent object length",{verified:!1,result:t})}for(let l=0;l<c;l++)if(l-s>=e.valueBlock.value.length){if(n.valueBlock.value[l].optional===!1){const u={verified:!1,result:t};return t.error="Inconsistent length between ASN.1 data and schema",n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ve),n.name&&(delete t[n.name],u.name=n.name)),u}}else if(n.valueBlock.value[0]instanceof jr){if(o=rn(t,e.valueBlock.value[l],n.valueBlock.value[0].value),o.verified===!1)if(n.valueBlock.value[0].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ve),n.name&&delete t[n.name]),o;if(So in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let u={};A_ in n.valueBlock.value[0]&&n.valueBlock.value[0].local?u=e:u=t,typeof u[n.valueBlock.value[0].name]>"u"&&(u[n.valueBlock.value[0].name]=[]),u[n.valueBlock.value[0].name].push(e.valueBlock.value[l])}}else if(o=rn(t,e.valueBlock.value[l-s],n.valueBlock.value[l]),o.verified===!1)if(n.valueBlock.value[l].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ve),n.name&&delete t[n.name]),o;if(o.verified===!1){const l={verified:!1,result:t};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ve),n.name&&(delete t[n.name],l.name=n.name)),l}return{verified:!0,result:t}}if(n.primitiveSchema&&Zl in e.valueBlock){const s=Zn(e.valueBlock.valueHexView);if(s.offset===-1){const o={verified:!1,result:s.result};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ve),n.name&&(delete t[n.name],o.name=n.name)),o}return rn(t,s.result,n.primitiveSchema)}return{verified:!0,result:t}}function j_(t,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const n=Zn(V.toUint8Array(t));return n.offset===-1?{verified:!1,result:n.result}:rn(n.result,n.result,e)}const Cf=Object.freeze(Object.defineProperty({__proto__:null,Any:hn,BaseBlock:je,BaseStringBlock:xc,BitString:cn,BmpString:Is,Boolean:xs,CharacterString:Ts,Choice:Nc,Constructed:Me,DATE:Ec,DateTime:zc,Duration:$c,EndOfContent:Sc,Enumerated:Ss,GeneralString:Bs,GeneralizedTime:Rs,GraphicString:Os,HexBlock:xt,IA5String:Ns,Integer:wt,Null:fn,NumericString:Cs,ObjectIdentifier:As,OctetString:an,Primitive:Pi,PrintableString:zs,RawData:$_,RelativeObjectIdentifier:Ic,Repeated:jr,Sequence:Et,Set:Ct,TIME:jc,TeletexString:$s,TimeOfDay:Cc,UTCTime:Ui,UniversalString:Es,Utf8String:Rt,ValueBlock:Pe,VideotexString:js,ViewWriter:bs,VisibleString:Li,compareSchema:rn,fromBER:On,verifySchema:j_},Symbol.toStringTag,{value:"Module"}));var N;(function(t){t[t.Sequence=0]="Sequence",t[t.Set=1]="Set",t[t.Choice=2]="Choice"})(N||(N={}));var y;(function(t){t[t.Any=1]="Any",t[t.Boolean=2]="Boolean",t[t.OctetString=3]="OctetString",t[t.BitString=4]="BitString",t[t.Integer=5]="Integer",t[t.Enumerated=6]="Enumerated",t[t.ObjectIdentifier=7]="ObjectIdentifier",t[t.Utf8String=8]="Utf8String",t[t.BmpString=9]="BmpString",t[t.UniversalString=10]="UniversalString",t[t.NumericString=11]="NumericString",t[t.PrintableString=12]="PrintableString",t[t.TeletexString=13]="TeletexString",t[t.VideotexString=14]="VideotexString",t[t.IA5String=15]="IA5String",t[t.GraphicString=16]="GraphicString",t[t.VisibleString=17]="VisibleString",t[t.GeneralString=18]="GeneralString",t[t.CharacterString=19]="CharacterString",t[t.UTCTime=20]="UTCTime",t[t.GeneralizedTime=21]="GeneralizedTime",t[t.DATE=22]="DATE",t[t.TimeOfDay=23]="TimeOfDay",t[t.DateTime=24]="DateTime",t[t.Duration=25]="Duration",t[t.TIME=26]="TIME",t[t.Null=27]="Null"})(y||(y={}));class Ps{constructor(e,n=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(V.isBufferSource(e))this.unusedBits=n,this.value=V.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof cn))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 cn({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new cn({name:e})}toNumber(){let e="";const n=new Uint8Array(this.value);for(const i of n)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 n=e.toString(2);const i=n.length+7>>3;this.unusedBits=(i<<3)-n.length;const r=new Uint8Array(i);n=n.padStart(i<<3,"0").split("").reverse().join("");let s=0;for(;s<i;)r[s]=parseInt(n.slice(s<<3,(s<<3)+8),2),s++;this.value=r.buffer}}class oe{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):V.isBufferSource(e)?this.buffer=V.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof an))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new an({valueHex:this.buffer})}toSchema(e){return new an({name:e})}}const N_={fromASN:t=>t instanceof fn?null:t.valueBeforeDecodeView,toASN:t=>{if(t===null)return new fn;const e=On(t);if(e.result.error)throw new Error(e.result.error);return e.result}},O_={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new wt({value:+t})},B_={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new Ss({value:t})},me={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new wt({valueHex:t})},T_={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new cn({valueHex:t})},R_={fromASN:t=>t.valueBlock.toString(),toASN:t=>new As({value:t})},P_={fromASN:t=>t.valueBlock.value,toASN:t=>new xs({value:t})},Nr={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new an({valueHex:t})},L_={fromASN:t=>new oe(t.getValue()),toASN:t=>t.toASN()};function nt(t){return{fromASN:e=>e.valueBlock.value,toASN:e=>new t({value:e})}}const zf=nt(Rt),U_=nt(Is),V_=nt(Es),M_=nt(Cs),D_=nt(zs),F_=nt($s),H_=nt(js),q_=nt(Ns),K_=nt(Os),W_=nt(Li),G_=nt(Bs),J_=nt(Ts),Z_={fromASN:t=>t.toDate(),toASN:t=>new Ui({valueDate:t})},Y_={fromASN:t=>t.toDate(),toASN:t=>new Rs({valueDate:t})},X_={fromASN:()=>null,toASN:()=>new fn};function Oc(t){switch(t){case y.Any:return N_;case y.BitString:return T_;case y.BmpString:return U_;case y.Boolean:return P_;case y.CharacterString:return J_;case y.Enumerated:return B_;case y.GeneralString:return G_;case y.GeneralizedTime:return Y_;case y.GraphicString:return K_;case y.IA5String:return q_;case y.Integer:return O_;case y.Null:return X_;case y.NumericString:return M_;case y.ObjectIdentifier:return R_;case y.OctetString:return Nr;case y.PrintableString:return D_;case y.TeletexString:return F_;case y.UTCTime:return Z_;case y.UniversalString:return V_;case y.Utf8String:return zf;case y.VideotexString:return H_;case y.VisibleString:return W_;default:return null}}function It(t){return typeof t=="function"&&t.prototype?t.prototype.toASN&&t.prototype.fromASN?!0:It(t.prototype):!!(t&&typeof t=="object"&&"toASN"in t&&"fromASN"in t)}function $f(t){var e;if(t){const n=Object.getPrototypeOf(t);return((e=n==null?void 0:n.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:$f(n)}return!1}function Q_(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),i=new Uint8Array(e);for(let r=0;r<t.byteLength;r++)if(n[r]!==i[r])return!1;return!0}class em{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,n=!1){const i=this.items.get(e);if(!i)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(n&&!i.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return i}cache(e){const n=this.get(e);n.schema||(n.schema=this.create(e,!0))}createDefault(e){const n={type:N.Sequence,items:{}},i=this.findParentSchema(e);return i&&(Object.assign(n,i),n.items=Object.assign({},n.items,i.items)),n}create(e,n){const i=this.items.get(e)||this.createDefault(e),r=[];for(const s in i.items){const o=i.items[s],c=n?s:"";let l;if(typeof o.type=="number"){const p=y[o.type],g=Cf[p];if(!g)throw new Error(`Cannot get ASN1 class by name '${p}'`);l=new g({name:c})}else It(o.type)?l=new o.type().toSchema(c):o.optional?this.get(o.type).type===N.Choice?l=new hn({name:c}):(l=this.create(o.type,!1),l.name=c):l=new hn({name:c});const u=!!o.optional||o.defaultValue!==void 0;if(o.repeated){l.name="";const p=o.repeated==="set"?Ct:Et;l=new p({name:"",value:[new jr({name:c,value:l})]})}if(o.context!==null&&o.context!==void 0)if(o.implicit)if(typeof o.type=="number"||It(o.type)){const p=o.repeated?Me:Pi;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 Me({name:p?"":c,optional:u,idBlock:{tagClass:3,tagNumber:o.context},value:g}))}else r.push(new Me({optional:u,idBlock:{tagClass:3,tagNumber:o.context},value:[l]}));else l.optional=u,r.push(l)}switch(i.type){case N.Sequence:return new Et({value:r,name:""});case N.Set:return new Ct({value:r,name:""});case N.Choice:return new Nc({value:r,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,n){return this.items.set(e,n),this}findParentSchema(e){const n=Object.getPrototypeOf(e);return n?this.items.get(n)||this.findParentSchema(n):null}}const Xe=new em,B=t=>e=>{let n;Xe.has(e)?n=Xe.get(e):(n=Xe.createDefault(e),Xe.set(e,n)),Object.assign(n,t)},f=t=>(e,n)=>{let i;Xe.has(e.constructor)?i=Xe.get(e.constructor):(i=Xe.createDefault(e.constructor),Xe.set(e.constructor,i));const r=Object.assign({},t);if(typeof r.type=="number"&&!r.converter){const s=Oc(t.type);if(!s)throw new Error(`Cannot get default converter for property '${n}' of ${e.constructor.name}`);r.converter=s}i.items[n]=r};class Xl extends Error{constructor(){super(...arguments),this.schemas=[]}}class tm{static parse(e,n){const i=On(e);if(i.result.error)throw new Error(i.result.error);return this.fromASN(i.result,n)}static fromASN(e,n){var i;try{if(It(n))return new n().fromASN(e);const r=Xe.get(n);Xe.cache(n);let s=r.schema;if(e.constructor===Me&&r.type!==N.Choice){s=new Me({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:r.schema.valueBlock.value});for(const l in r.items)delete e[l]}const o=rn({},e,s);if(!o.verified)throw new Xl(`Data does not match to ${n.name} ASN1 schema. ${o.result.error}`);const c=new n;if($f(n)){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=Oc(l);if(!u)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,p=>u.fromASN(p))}else return n.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"||It(g)){const _=(i=p.converter)!==null&&i!==void 0?i:It(g)?new g:null;if(!_)throw new Error("Converter is empty");if(p.repeated)if(p.implicit){const k=p.repeated==="sequence"?Et:Ct,h=new k;h.valueBlock=u.valueBlock;const m=On(h.toBER(!1));if(m.offset===-1)throw new Error(`Cannot parse the child item. ${m.result.error}`);if(!("value"in m.result.valueBlock&&Array.isArray(m.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const b=m.result.valueBlock.value;c[l]=Array.from(b,S=>_.fromASN(S))}else c[l]=Array.from(u,k=>_.fromASN(k));else{let k=u;if(p.implicit){let h;if(It(g))h=new g().toSchema("");else{const m=y[g],b=Cf[m];if(!b)throw new Error(`Cannot get '${m}' class from asn1js module`);h=new b}h.valueBlock=k.valueBlock,k=On(h.toBER(!1)).result}c[l]=_.fromASN(k)}}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,_=>this.fromASN(_,g))}else c[l]=this.fromASN(u,g)}return c}catch(r){throw r instanceof Xl&&r.schemas.push(n.name),r}}}class Bc{static serialize(e){return e instanceof je?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&It(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const n=e.constructor,i=Xe.get(n);Xe.cache(n);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=Oc(i.itemType);if(!o)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);r=e.map(c=>o.toASN(c))}else r=e.map(o=>this.toAsnItem({type:i.itemType},"[]",n,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"&&Q_(this.serialize(c.defaultValue),this.serialize(l)))continue;const u=Bc.toAsnItem(c,o,n,l);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||It(c.type))){const p={};p.valueHex=u instanceof fn?u.valueBeforeDecodeView:u.valueBlock.toBER(),r.push(new Pi({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...p}))}else r.push(new Me({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:u.valueBlock.value}));else r.push(new Me({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 N.Sequence:s=new Et({value:r});break;case N.Set:s=new Ct({value:r});break;case N.Choice:if(!r[0])throw new Error(`Schema '${n.name}' has wrong data. Choice cannot be empty.`);s=r[0];break}return s}static toAsnItem(e,n,i,r){let s;if(typeof e.type=="number"){const o=e.converter;if(!o)throw new Error(`Property '${n}' 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"?Et:Ct;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"?Et:Ct;s=new c({value:o})}else s=this.toASN(r);return s}}class de extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const n of e)this.push(n)}}}class U{static serialize(e){return Bc.serialize(e)}static parse(e,n){return tm.parse(e,n)}static toString(e){const n=V.isBufferSource(e)?V.toArrayBuffer(e):U.serialize(e),i=On(n);if(i.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${i.result.error}`);return i.result.toString()}}function d(t,e,n,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,n):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,n,i);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(s=(r<3?o(s):r>3?o(e,n,s):o(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s}var jf={exports:{}};(function(t){(function(e){const n="(0?\\d+|0x[a-f0-9]+)",i={fourOctet:new RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,"i"),threeOctet:new RegExp(`^${n}\\.${n}\\.${n}$`,"i"),twoOctet:new RegExp(`^${n}\\.${n}$`,"i"),longValue:new RegExp(`^${n}$`,"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(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,"i")};function u(h,m){if(h.indexOf("::")!==h.lastIndexOf("::"))return null;let b=0,S=-1,O=(h.match(l.zoneIndex)||[])[0],T,K;for(O&&(O=O.substring(1),h=h.replace(/%.+$/,""));(S=h.indexOf(":",S+1))>=0;)b++;if(h.substr(0,2)==="::"&&b--,h.substr(-2,2)==="::"&&b--,b>m)return null;for(K=m-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)),m=function(){const ce=h.split(":"),he=[];for(let ue=0;ue<ce.length;ue++)he.push(parseInt(ce[ue],16));return he}(),{parts:m,zoneId:O}}function p(h,m,b,S){if(h.length!==m.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let O=0,T;for(;S>0;){if(T=b-S,T<0&&(T=0),h[O]>>T!==m[O]>>T)return!1;S-=b,O+=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 _(h,m){for(;h.length<m;)h=`0${h}`;return h}const k={};k.IPv4=function(){function h(m){if(m.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let b,S;for(b=0;b<m.length;b++)if(S=m[b],!(0<=S&&S<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=m}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(m,b){let S;if(b===void 0&&(S=m,m=S[0],b=S[1]),m.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return p(this.octets,m.octets,8,b)},h.prototype.prefixLengthFromSubnetMask=function(){let m=0,b=!1;const S={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let O,T,K;for(O=3;O>=0;O-=1)if(T=this.octets[O],T in S){if(K=S[T],b&&K!==0)return null;K!==8&&(b=!0),m+=K}else return null;return 32-m},h.prototype.range=function(){return k.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){return this.octets.slice(0)},h.prototype.toIPv4MappedAddress=function(){return k.IPv6.parse(`::ffff:${this.toString()}`)},h.prototype.toNormalizedString=function(){return this.toString()},h.prototype.toString=function(){return this.octets.join(".")},h}(),k.IPv4.broadcastAddressFromCIDR=function(h){try{const m=this.parseCIDR(h),b=m[0].toByteArray(),S=this.subnetMaskFromPrefixLength(m[1]).toByteArray(),O=[];let T=0;for(;T<4;)O.push(parseInt(b[T],10)|parseInt(S[T],10)^255),T++;return new this(O)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},k.IPv4.isIPv4=function(h){return this.parser(h)!==null},k.IPv4.isValid=function(h){try{return new this(this.parser(h)),!0}catch{return!1}},k.IPv4.isValidCIDR=function(h){try{return this.parseCIDR(h),!0}catch{return!1}},k.IPv4.isValidFourPartDecimal=function(h){return!!(k.IPv4.isValid(h)&&h.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},k.IPv4.networkAddressFromCIDR=function(h){let m,b,S,O,T;try{for(m=this.parseCIDR(h),S=m[0].toByteArray(),T=this.subnetMaskFromPrefixLength(m[1]).toByteArray(),O=[],b=0;b<4;)O.push(parseInt(S[b],10)&parseInt(T[b],10)),b++;return new this(O)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},k.IPv4.parse=function(h){const m=this.parser(h);if(m===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(m)},k.IPv4.parseCIDR=function(h){let m;if(m=h.match(/^(.+)\/(\d+)$/)){const b=parseInt(m[2]);if(b>=0&&b<=32){const S=[this.parse(m[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")},k.IPv4.parser=function(h){let m,b,S;if(m=h.match(i.fourOctet))return function(){const O=m.slice(1,6),T=[];for(let K=0;K<O.length;K++)b=O[K],T.push(g(b));return T}();if(m=h.match(i.longValue)){if(S=g(m[1]),S>4294967295||S<0)throw new Error("ipaddr: address outside defined range");return function(){const O=[];let T;for(T=0;T<=24;T+=8)O.push(S>>T&255);return O}().reverse()}else return(m=h.match(i.twoOctet))?function(){const O=m.slice(1,4),T=[];if(S=g(O[1]),S>16777215||S<0)throw new Error("ipaddr: address outside defined range");return T.push(g(O[0])),T.push(S>>16&255),T.push(S>>8&255),T.push(S&255),T}():(m=h.match(i.threeOctet))?function(){const O=m.slice(1,5),T=[];if(S=g(O[2]),S>65535||S<0)throw new Error("ipaddr: address outside defined range");return T.push(g(O[0])),T.push(g(O[1])),T.push(S>>8&255),T.push(S&255),T}():null},k.IPv4.subnetMaskFromPrefixLength=function(h){if(h=parseInt(h),h<0||h>32)throw new Error("ipaddr: invalid IPv4 prefix length");const m=[0,0,0,0];let b=0;const S=Math.floor(h/8);for(;b<S;)m[b]=255,b++;return S<4&&(m[S]=Math.pow(2,h%8)-1<<8-h%8),new this(m)},k.IPv6=function(){function h(m,b){let S,O;if(m.length===16)for(this.parts=[],S=0;S<=14;S+=2)this.parts.push(m[S]<<8|m[S+1]);else if(m.length===8)this.parts=m;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(S=0;S<this.parts.length;S++)if(O=this.parts[S],!(0<=O&&O<=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(m,b){let S;if(b===void 0&&(S=m,m=S[0],b=S[1]),m.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return p(this.parts,m.parts,16,b)},h.prototype.prefixLengthFromSubnetMask=function(){let m=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 O,T;for(let K=7;K>=0;K-=1)if(O=this.parts[K],O in S){if(T=S[O],b&&T!==0)return null;T!==16&&(b=!0),m+=T}else return null;return 128-m},h.prototype.range=function(){return k.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){let m;const b=[],S=this.parts;for(let O=0;O<S.length;O++)m=S[O],b.push(m>>8),b.push(m&255);return b},h.prototype.toFixedLengthString=function(){const m=(function(){const S=[];for(let O=0;O<this.parts.length;O++)S.push(_(this.parts[O].toString(16),4));return S}).call(this).join(":");let b="";return this.zoneId&&(b=`%${this.zoneId}`),m+b},h.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const m=this.parts.slice(-2),b=m[0],S=m[1];return new k.IPv4([b>>8,b&255,S>>8,S&255])},h.prototype.toNormalizedString=function(){const m=(function(){const S=[];for(let O=0;O<this.parts.length;O++)S.push(this.parts[O].toString(16));return S}).call(this).join(":");let b="";return this.zoneId&&(b=`%${this.zoneId}`),m+b},h.prototype.toRFC5952String=function(){const m=/((^|:)(0(:|$)){2,})/g,b=this.toNormalizedString();let S=0,O=-1,T;for(;T=m.exec(b);)T[0].length>O&&(S=T.index,O=T[0].length);return O<0?b:`${b.substring(0,S)}::${b.substring(S+O)}`},h.prototype.toString=function(){return this.toRFC5952String()},h}(),k.IPv6.broadcastAddressFromCIDR=function(h){try{const m=this.parseCIDR(h),b=m[0].toByteArray(),S=this.subnetMaskFromPrefixLength(m[1]).toByteArray(),O=[];let T=0;for(;T<16;)O.push(parseInt(b[T],10)|parseInt(S[T],10)^255),T++;return new this(O)}catch(m){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${m})`)}},k.IPv6.isIPv6=function(h){return this.parser(h)!==null},k.IPv6.isValid=function(h){if(typeof h=="string"&&h.indexOf(":")===-1)return!1;try{const m=this.parser(h);return new this(m.parts,m.zoneId),!0}catch{return!1}},k.IPv6.isValidCIDR=function(h){if(typeof h=="string"&&h.indexOf(":")===-1)return!1;try{return this.parseCIDR(h),!0}catch{return!1}},k.IPv6.networkAddressFromCIDR=function(h){let m,b,S,O,T;try{for(m=this.parseCIDR(h),S=m[0].toByteArray(),T=this.subnetMaskFromPrefixLength(m[1]).toByteArray(),O=[],b=0;b<16;)O.push(parseInt(S[b],10)&parseInt(T[b],10)),b++;return new this(O)}catch(K){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${K})`)}},k.IPv6.parse=function(h){const m=this.parser(h);if(m.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(m.parts,m.zoneId)},k.IPv6.parseCIDR=function(h){let m,b,S;if((b=h.match(/^(.+)\/(\d+)$/))&&(m=parseInt(b[2]),m>=0&&m<=128))return S=[this.parse(b[1]),m],Object.defineProperty(S,"toString",{value:function(){return this.join("/")}}),S;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},k.IPv6.parser=function(h){let m,b,S,O,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]||"",m=S[1],S[1].endsWith("::")||(m=m.slice(0,-1)),m=u(m+K,6),m.parts)){for(T=[parseInt(S[2]),parseInt(S[3]),parseInt(S[4]),parseInt(S[5])],b=0;b<T.length;b++)if(O=T[b],!(0<=O&&O<=255))return null;return m.parts.push(T[0]<<8|T[1]),m.parts.push(T[2]<<8|T[3]),{parts:m.parts,zoneId:m.zoneId}}return null},k.IPv6.subnetMaskFromPrefixLength=function(h){if(h=parseInt(h),h<0||h>128)throw new Error("ipaddr: invalid IPv6 prefix length");const m=[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;)m[b]=255,b++;return S<16&&(m[S]=Math.pow(2,h%8)-1<<8-h%8),new this(m)},k.fromByteArray=function(h){const m=h.length;if(m===4)return new k.IPv4(h);if(m===16)return new k.IPv6(h);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},k.isValid=function(h){return k.IPv6.isValid(h)||k.IPv4.isValid(h)},k.isValidCIDR=function(h){return k.IPv6.isValidCIDR(h)||k.IPv4.isValidCIDR(h)},k.parse=function(h){if(k.IPv6.isValid(h))return k.IPv6.parse(h);if(k.IPv4.isValid(h))return k.IPv4.parse(h);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},k.parseCIDR=function(h){try{return k.IPv6.parseCIDR(h)}catch{try{return k.IPv4.parseCIDR(h)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},k.process=function(h){const m=this.parse(h);return m.kind()==="ipv6"&&m.isIPv4MappedAddress()?m.toIPv4Address():m},k.subnetMatch=function(h,m,b){let S,O,T,K;b==null&&(b="unicast");for(O in m)if(Object.prototype.hasOwnProperty.call(m,O)){for(T=m[O],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 O}return b},t.exports?t.exports=k:e.ipaddr=k})(zr)})(jf);var Ql=jf.exports;class eu{static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const n=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}/${n}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const n=new Uint8Array(e);return Ql.fromByteArray(Array.from(n)).toString()}return this.decodeIP(G.ToHex(e))}static fromString(e){const n=Ql.parse(e);return new Uint8Array(n.toByteArray()).buffer}}var Wo,Go,Jo;let Ne=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};d([f({type:y.TeletexString})],Ne.prototype,"teletexString",void 0);d([f({type:y.PrintableString})],Ne.prototype,"printableString",void 0);d([f({type:y.UniversalString})],Ne.prototype,"universalString",void 0);d([f({type:y.Utf8String})],Ne.prototype,"utf8String",void 0);d([f({type:y.BmpString})],Ne.prototype,"bmpString",void 0);Ne=d([B({type:N.Choice})],Ne);let Ln=class extends Ne{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?G.ToHex(this.anyValue):super.toString())}};d([f({type:y.IA5String})],Ln.prototype,"ia5String",void 0);d([f({type:y.Any})],Ln.prototype,"anyValue",void 0);Ln=d([B({type:N.Choice})],Ln);class Ls{constructor(e={}){this.type="",this.value=new Ln,Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Ls.prototype,"type",void 0);d([f({type:Ln})],Ls.prototype,"value",void 0);let Un=Wo=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Wo.prototype)}};Un=Wo=d([B({type:N.Set,itemType:Ls})],Un);let Zo=Go=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Go.prototype)}};Zo=Go=d([B({type:N.Sequence,itemType:Un})],Zo);let ke=Jo=class extends Zo{constructor(e){super(e),Object.setPrototypeOf(this,Jo.prototype)}};ke=Jo=d([B({type:N.Sequence})],ke);const nm={fromASN:t=>eu.toString(Nr.fromASN(t)),toASN:t=>Nr.toASN(eu.fromString(t))};class xi{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],xi.prototype,"typeId",void 0);d([f({type:y.Any,context:0})],xi.prototype,"value",void 0);class Tc{constructor(e={}){this.partyName=new Ne,Object.assign(this,e)}}d([f({type:Ne,optional:!0,context:0,implicit:!0})],Tc.prototype,"nameAssigner",void 0);d([f({type:Ne,context:1,implicit:!0})],Tc.prototype,"partyName",void 0);let te=class{constructor(e={}){Object.assign(this,e)}};d([f({type:xi,context:0,implicit:!0})],te.prototype,"otherName",void 0);d([f({type:y.IA5String,context:1,implicit:!0})],te.prototype,"rfc822Name",void 0);d([f({type:y.IA5String,context:2,implicit:!0})],te.prototype,"dNSName",void 0);d([f({type:y.Any,context:3,implicit:!0})],te.prototype,"x400Address",void 0);d([f({type:ke,context:4,implicit:!1})],te.prototype,"directoryName",void 0);d([f({type:Tc,context:5})],te.prototype,"ediPartyName",void 0);d([f({type:y.IA5String,context:6,implicit:!0})],te.prototype,"uniformResourceIdentifier",void 0);d([f({type:y.OctetString,context:7,implicit:!0,converter:nm})],te.prototype,"iPAddress",void 0);d([f({type:y.ObjectIdentifier,context:8,implicit:!0})],te.prototype,"registeredID",void 0);te=d([B({type:N.Choice})],te);const Rc="1.3.6.1.5.5.7",im=`${Rc}.1`,Yn=`${Rc}.3`,Us=`${Rc}.48`,tu=`${Us}.1`,nu=`${Us}.2`,iu=`${Us}.3`,ru=`${Us}.5`,Jt="2.5.29";var Yo;const Xo=`${im}.1`;class Vi{constructor(e={}){this.accessMethod="",this.accessLocation=new te,Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Vi.prototype,"accessMethod",void 0);d([f({type:te})],Vi.prototype,"accessLocation",void 0);let jn=Yo=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Yo.prototype)}};jn=Yo=d([B({type:N.Sequence,itemType:Vi})],jn);const Qo=`${Jt}.35`;class Pc extends oe{}class sn{constructor(e={}){e&&Object.assign(this,e)}}d([f({type:Pc,context:0,optional:!0,implicit:!0})],sn.prototype,"keyIdentifier",void 0);d([f({type:te,context:1,optional:!0,implicit:!0,repeated:"sequence"})],sn.prototype,"authorityCertIssuer",void 0);d([f({type:y.Integer,context:2,optional:!0,implicit:!0,converter:me})],sn.prototype,"authorityCertSerialNumber",void 0);const Nf=`${Jt}.19`;class Or{constructor(e={}){this.cA=!1,Object.assign(this,e)}}d([f({type:y.Boolean,defaultValue:!1})],Or.prototype,"cA",void 0);d([f({type:y.Integer,optional:!0})],Or.prototype,"pathLenConstraint",void 0);var ea;let Re=ea=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ea.prototype)}};Re=ea=d([B({type:N.Sequence,itemType:te})],Re);var ta;let su=ta=class extends Re{constructor(e){super(e),Object.setPrototypeOf(this,ta.prototype)}};su=ta=d([B({type:N.Sequence})],su);var na;const Of=`${Jt}.32`;let zt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};d([f({type:y.IA5String})],zt.prototype,"ia5String",void 0);d([f({type:y.VisibleString})],zt.prototype,"visibleString",void 0);d([f({type:y.BmpString})],zt.prototype,"bmpString",void 0);d([f({type:y.Utf8String})],zt.prototype,"utf8String",void 0);zt=d([B({type:N.Choice})],zt);class Lc{constructor(e={}){this.organization=new zt,this.noticeNumbers=[],Object.assign(this,e)}}d([f({type:zt})],Lc.prototype,"organization",void 0);d([f({type:y.Integer,repeated:"sequence"})],Lc.prototype,"noticeNumbers",void 0);class Uc{constructor(e={}){Object.assign(this,e)}}d([f({type:Lc,optional:!0})],Uc.prototype,"noticeRef",void 0);d([f({type:zt,optional:!0})],Uc.prototype,"explicitText",void 0);let Br=class{constructor(e={}){Object.assign(this,e)}};d([f({type:y.IA5String})],Br.prototype,"cPSuri",void 0);d([f({type:Uc})],Br.prototype,"userNotice",void 0);Br=d([B({type:N.Choice})],Br);class Vc{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Vc.prototype,"policyQualifierId",void 0);d([f({type:y.Any})],Vc.prototype,"qualifier",void 0);class Vs{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Vs.prototype,"policyIdentifier",void 0);d([f({type:Vc,repeated:"sequence",optional:!0})],Vs.prototype,"policyQualifiers",void 0);let Tr=na=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,na.prototype)}};Tr=na=d([B({type:N.Sequence,itemType:Vs})],Tr);let Rr=class{constructor(e=0){this.value=e}};d([f({type:y.Integer})],Rr.prototype,"value",void 0);Rr=d([B({type:N.Choice})],Rr);let ou=class extends Rr{};ou=d([B({type:N.Choice})],ou);var ia;const ra=`${Jt}.31`;var at;(function(t){t[t.unused=1]="unused",t[t.keyCompromise=2]="keyCompromise",t[t.cACompromise=4]="cACompromise",t[t.affiliationChanged=8]="affiliationChanged",t[t.superseded=16]="superseded",t[t.cessationOfOperation=32]="cessationOfOperation",t[t.certificateHold=64]="certificateHold",t[t.privilegeWithdrawn=128]="privilegeWithdrawn",t[t.aACompromise=256]="aACompromise"})(at||(at={}));class Bf extends Ps{toJSON(){const e=[],n=this.toNumber();return n&at.aACompromise&&e.push("aACompromise"),n&at.affiliationChanged&&e.push("affiliationChanged"),n&at.cACompromise&&e.push("cACompromise"),n&at.certificateHold&&e.push("certificateHold"),n&at.cessationOfOperation&&e.push("cessationOfOperation"),n&at.keyCompromise&&e.push("keyCompromise"),n&at.privilegeWithdrawn&&e.push("privilegeWithdrawn"),n&at.superseded&&e.push("superseded"),n&at.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let gn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:te,context:0,repeated:"sequence",implicit:!0})],gn.prototype,"fullName",void 0);d([f({type:Un,context:1,implicit:!0})],gn.prototype,"nameRelativeToCRLIssuer",void 0);gn=d([B({type:N.Choice})],gn);class Xn{constructor(e={}){Object.assign(this,e)}}d([f({type:gn,context:0,optional:!0})],Xn.prototype,"distributionPoint",void 0);d([f({type:Bf,context:1,optional:!0,implicit:!0})],Xn.prototype,"reasons",void 0);d([f({type:te,context:2,optional:!0,repeated:"sequence",implicit:!0})],Xn.prototype,"cRLIssuer",void 0);let Bn=ia=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ia.prototype)}};Bn=ia=d([B({type:N.Sequence,itemType:Xn})],Bn);var sa;let au=sa=class extends Bn{constructor(e){super(e),Object.setPrototypeOf(this,sa.prototype)}};au=sa=d([B({type:N.Sequence,itemType:Xn})],au);class Be{constructor(e={}){this.onlyContainsUserCerts=Be.ONLY,this.onlyContainsCACerts=Be.ONLY,this.indirectCRL=Be.ONLY,this.onlyContainsAttributeCerts=Be.ONLY,Object.assign(this,e)}}Be.ONLY=!1;d([f({type:gn,context:0,optional:!0})],Be.prototype,"distributionPoint",void 0);d([f({type:y.Boolean,context:1,defaultValue:Be.ONLY,implicit:!0})],Be.prototype,"onlyContainsUserCerts",void 0);d([f({type:y.Boolean,context:2,defaultValue:Be.ONLY,implicit:!0})],Be.prototype,"onlyContainsCACerts",void 0);d([f({type:Bf,context:3,optional:!0,implicit:!0})],Be.prototype,"onlySomeReasons",void 0);d([f({type:y.Boolean,context:4,defaultValue:Be.ONLY,implicit:!0})],Be.prototype,"indirectCRL",void 0);d([f({type:y.Boolean,context:5,defaultValue:Be.ONLY,implicit:!0})],Be.prototype,"onlyContainsAttributeCerts",void 0);var gi;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(gi||(gi={}));let oa=class{constructor(e=gi.unspecified){this.reason=gi.unspecified,this.reason=e}toJSON(){return gi[this.reason]}toString(){return this.toJSON()}};d([f({type:y.Enumerated})],oa.prototype,"reason",void 0);oa=d([B({type:N.Choice})],oa);var aa;const Tf=`${Jt}.37`;let Pr=aa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,aa.prototype)}};Pr=aa=d([B({type:N.Sequence,itemType:y.ObjectIdentifier})],Pr);const rm=`${Yn}.1`,sm=`${Yn}.2`,om=`${Yn}.3`,am=`${Yn}.4`,cm=`${Yn}.8`,lm=`${Yn}.9`;let ca=class{constructor(e=new ArrayBuffer(0)){this.value=e}};d([f({type:y.Integer,converter:me})],ca.prototype,"value",void 0);ca=d([B({type:N.Choice})],ca);let la=class{constructor(e){this.value=new Date,e&&(this.value=e)}};d([f({type:y.GeneralizedTime})],la.prototype,"value",void 0);la=d([B({type:N.Choice})],la);var ua;let cu=ua=class extends Re{constructor(e){super(e),Object.setPrototypeOf(this,ua.prototype)}};cu=ua=d([B({type:N.Sequence})],cu);const Rf=`${Jt}.15`;var ct;(function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"})(ct||(ct={}));class Ao extends Ps{toJSON(){const e=this.toNumber(),n=[];return e&ct.cRLSign&&n.push("crlSign"),e&ct.dataEncipherment&&n.push("dataEncipherment"),e&ct.decipherOnly&&n.push("decipherOnly"),e&ct.digitalSignature&&n.push("digitalSignature"),e&ct.encipherOnly&&n.push("encipherOnly"),e&ct.keyAgreement&&n.push("keyAgreement"),e&ct.keyCertSign&&n.push("keyCertSign"),e&ct.keyEncipherment&&n.push("keyEncipherment"),e&ct.nonRepudiation&&n.push("nonRepudiation"),n}toString(){return`[${this.toJSON().join(", ")}]`}}var da;class Ms{constructor(e={}){this.base=new te,this.minimum=0,Object.assign(this,e)}}d([f({type:te})],Ms.prototype,"base",void 0);d([f({type:y.Integer,context:0,defaultValue:0,implicit:!0})],Ms.prototype,"minimum",void 0);d([f({type:y.Integer,context:1,optional:!0,implicit:!0})],Ms.prototype,"maximum",void 0);let Lr=da=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,da.prototype)}};Lr=da=d([B({type:N.Sequence,itemType:Ms})],Lr);class Pf{constructor(e={}){Object.assign(this,e)}}d([f({type:Lr,context:0,optional:!0,implicit:!0})],Pf.prototype,"permittedSubtrees",void 0);d([f({type:Lr,context:1,optional:!0,implicit:!0})],Pf.prototype,"excludedSubtrees",void 0);class Lf{constructor(e={}){Object.assign(this,e)}}d([f({type:y.Integer,context:0,implicit:!0,optional:!0,converter:me})],Lf.prototype,"requireExplicitPolicy",void 0);d([f({type:y.Integer,context:1,implicit:!0,optional:!0,converter:me})],Lf.prototype,"inhibitPolicyMapping",void 0);var pa;class Mc{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Mc.prototype,"issuerDomainPolicy",void 0);d([f({type:y.ObjectIdentifier})],Mc.prototype,"subjectDomainPolicy",void 0);let lu=pa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,pa.prototype)}};lu=pa=d([B({type:N.Sequence,itemType:Mc})],lu);var fa;const Uf=`${Jt}.17`;let ha=fa=class extends Re{constructor(e){super(e),Object.setPrototypeOf(this,fa.prototype)}};ha=fa=d([B({type:N.Sequence})],ha);let $t=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};d([f({type:y.ObjectIdentifier})],$t.prototype,"type",void 0);d([f({type:y.Any,repeated:"set"})],$t.prototype,"values",void 0);var ga;let uu=ga=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ga.prototype)}};uu=ga=d([B({type:N.Sequence,itemType:$t})],uu);const Vf=`${Jt}.14`;class Dt extends Pc{}class Mf{constructor(e={}){Object.assign(this,e)}}d([f({type:y.GeneralizedTime,context:0,implicit:!0,optional:!0})],Mf.prototype,"notBefore",void 0);d([f({type:y.GeneralizedTime,context:1,implicit:!0,optional:!0})],Mf.prototype,"notAfter",void 0);var _i;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate"})(_i||(_i={}));class Df extends Ps{toJSON(){const e=[],n=this.toNumber();return n&_i.pKIXCertificate&&e.push("pKIXCertificate"),n&_i.newExtensions&&e.push("newExtensions"),n&_i.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class Ff{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new Df,Object.assign(this,e)}}d([f({type:y.GeneralString})],Ff.prototype,"entrustVers",void 0);d([f({type:Df})],Ff.prototype,"entrustInfoFlags",void 0);var _a;let du=_a=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,_a.prototype)}};du=_a=d([B({type:N.Sequence,itemType:Vi})],du);class F{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof F&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Cp(e.parameters,this.parameters)||e.parameters===this.parameters)}}d([f({type:y.ObjectIdentifier})],F.prototype,"algorithm",void 0);d([f({type:y.Any,optional:!0})],F.prototype,"parameters",void 0);class lt{constructor(e={}){this.algorithm=new F,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:F})],lt.prototype,"algorithm",void 0);d([f({type:y.BitString})],lt.prototype,"subjectPublicKey",void 0);let $e=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){const n=new Date(e);n.getUTCFullYear()>2049?this.generalTime=n:this.utcTime=n}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})],$e.prototype,"utcTime",void 0);d([f({type:y.GeneralizedTime})],$e.prototype,"generalTime",void 0);$e=d([B({type:N.Choice})],$e);class Mi{constructor(e){this.notBefore=new $e(new Date),this.notAfter=new $e(new Date),e&&(this.notBefore=new $e(e.notBefore),this.notAfter=new $e(e.notAfter))}}d([f({type:$e})],Mi.prototype,"notBefore",void 0);d([f({type:$e})],Mi.prototype,"notAfter",void 0);var ma;let tt=class Hf{constructor(e={}){this.extnID="",this.critical=Hf.CRITICAL,this.extnValue=new oe,Object.assign(this,e)}};tt.CRITICAL=!1;d([f({type:y.ObjectIdentifier})],tt.prototype,"extnID",void 0);d([f({type:y.Boolean,defaultValue:tt.CRITICAL})],tt.prototype,"critical",void 0);d([f({type:oe})],tt.prototype,"extnValue",void 0);let qt=ma=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ma.prototype)}};qt=ma=d([B({type:N.Sequence,itemType:tt})],qt);var _n;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3"})(_n||(_n={}));class Ze{constructor(e={}){this.version=_n.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new F,this.issuer=new ke,this.validity=new Mi,this.subject=new ke,this.subjectPublicKeyInfo=new lt,Object.assign(this,e)}}d([f({type:y.Integer,context:0,defaultValue:_n.v1})],Ze.prototype,"version",void 0);d([f({type:y.Integer,converter:me})],Ze.prototype,"serialNumber",void 0);d([f({type:F})],Ze.prototype,"signature",void 0);d([f({type:ke})],Ze.prototype,"issuer",void 0);d([f({type:Mi})],Ze.prototype,"validity",void 0);d([f({type:ke})],Ze.prototype,"subject",void 0);d([f({type:lt})],Ze.prototype,"subjectPublicKeyInfo",void 0);d([f({type:y.BitString,context:1,implicit:!0,optional:!0})],Ze.prototype,"issuerUniqueID",void 0);d([f({type:y.BitString,context:2,implicit:!0,optional:!0})],Ze.prototype,"subjectUniqueID",void 0);d([f({type:qt,context:3,optional:!0})],Ze.prototype,"extensions",void 0);class mn{constructor(e={}){this.tbsCertificate=new Ze,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:Ze})],mn.prototype,"tbsCertificate",void 0);d([f({type:F})],mn.prototype,"signatureAlgorithm",void 0);d([f({type:y.BitString})],mn.prototype,"signatureValue",void 0);class Ds{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new $e,Object.assign(this,e)}}d([f({type:y.Integer,converter:me})],Ds.prototype,"userCertificate",void 0);d([f({type:$e})],Ds.prototype,"revocationDate",void 0);d([f({type:tt,optional:!0,repeated:"sequence"})],Ds.prototype,"crlEntryExtensions",void 0);class Pt{constructor(e={}){this.signature=new F,this.issuer=new ke,this.thisUpdate=new $e,Object.assign(this,e)}}d([f({type:y.Integer,optional:!0})],Pt.prototype,"version",void 0);d([f({type:F})],Pt.prototype,"signature",void 0);d([f({type:ke})],Pt.prototype,"issuer",void 0);d([f({type:$e})],Pt.prototype,"thisUpdate",void 0);d([f({type:$e,optional:!0})],Pt.prototype,"nextUpdate",void 0);d([f({type:Ds,repeated:"sequence",optional:!0})],Pt.prototype,"revokedCertificates",void 0);d([f({type:tt,optional:!0,context:0,repeated:"sequence"})],Pt.prototype,"crlExtensions",void 0);class Dc{constructor(e={}){this.tbsCertList=new Pt,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:Pt})],Dc.prototype,"tbsCertList",void 0);d([f({type:F})],Dc.prototype,"signatureAlgorithm",void 0);d([f({type:y.BitString})],Dc.prototype,"signature",void 0);class Qn{constructor(e={}){this.issuer=new ke,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:ke})],Qn.prototype,"issuer",void 0);d([f({type:y.Integer,converter:me})],Qn.prototype,"serialNumber",void 0);let Vn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Dt,context:0,implicit:!0})],Vn.prototype,"subjectKeyIdentifier",void 0);d([f({type:Qn})],Vn.prototype,"issuerAndSerialNumber",void 0);Vn=d([B({type:N.Choice})],Vn);var jt;(function(t){t[t.v0=0]="v0",t[t.v1=1]="v1",t[t.v2=2]="v2",t[t.v3=3]="v3",t[t.v4=4]="v4",t[t.v5=5]="v5"})(jt||(jt={}));let Si=class extends F{};Si=d([B({type:N.Sequence})],Si);let Ur=class extends F{};Ur=d([B({type:N.Sequence})],Ur);let bt=class extends F{};bt=d([B({type:N.Sequence})],bt);let Vr=class extends F{};Vr=d([B({type:N.Sequence})],Vr);let pu=class extends F{};pu=d([B({type:N.Sequence})],pu);let ya=class extends F{};ya=d([B({type:N.Sequence})],ya);let ei=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};d([f({type:y.ObjectIdentifier})],ei.prototype,"attrType",void 0);d([f({type:y.Any,repeated:"set"})],ei.prototype,"attrValues",void 0);var va;class St{constructor(e={}){this.version=jt.v0,this.sid=new Vn,this.digestAlgorithm=new Si,this.signatureAlgorithm=new Ur,this.signature=new oe,Object.assign(this,e)}}d([f({type:y.Integer})],St.prototype,"version",void 0);d([f({type:Vn})],St.prototype,"sid",void 0);d([f({type:Si})],St.prototype,"digestAlgorithm",void 0);d([f({type:ei,repeated:"set",context:0,implicit:!0,optional:!0})],St.prototype,"signedAttrs",void 0);d([f({type:Ur})],St.prototype,"signatureAlgorithm",void 0);d([f({type:oe})],St.prototype,"signature",void 0);d([f({type:ei,repeated:"set",context:1,implicit:!0,optional:!0})],St.prototype,"unsignedAttrs",void 0);let Mr=va=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,va.prototype)}};Mr=va=d([B({type:N.Set,itemType:St})],Mr);let fu=class extends $e{};fu=d([B({type:N.Choice})],fu);let hu=class extends St{};hu=d([B({type:N.Sequence})],hu);class Fc{constructor(e={}){this.acIssuer=new te,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}d([f({type:te})],Fc.prototype,"acIssuer",void 0);d([f({type:y.Integer})],Fc.prototype,"acSerial",void 0);d([f({type:$t,repeated:"sequence"})],Fc.prototype,"attrs",void 0);var wa;let Dr=wa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,wa.prototype)}};Dr=wa=d([B({type:N.Sequence,itemType:y.ObjectIdentifier})],Dr);class Fs{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}d([f({type:y.Integer,optional:!0})],Fs.prototype,"pathLenConstraint",void 0);d([f({type:Dr,implicit:!0,context:0,optional:!0})],Fs.prototype,"permittedAttrs",void 0);d([f({type:Dr,implicit:!0,context:1,optional:!0})],Fs.prototype,"excludedAttrs",void 0);d([f({type:y.Boolean,defaultValue:!0})],Fs.prototype,"permitUnSpecified",void 0);class An{constructor(e={}){this.issuer=new Re,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:Re})],An.prototype,"issuer",void 0);d([f({type:y.Integer,converter:me})],An.prototype,"serial",void 0);d([f({type:y.BitString,optional:!0})],An.prototype,"issuerUID",void 0);var ba;(function(t){t[t.publicKey=0]="publicKey",t[t.publicKeyCert=1]="publicKeyCert",t[t.otherObjectTypes=2]="otherObjectTypes"})(ba||(ba={}));class In{constructor(e={}){this.digestedObjectType=ba.publicKey,this.digestAlgorithm=new F,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.Enumerated})],In.prototype,"digestedObjectType",void 0);d([f({type:y.ObjectIdentifier,optional:!0})],In.prototype,"otherObjectTypeID",void 0);d([f({type:F})],In.prototype,"digestAlgorithm",void 0);d([f({type:y.BitString})],In.prototype,"objectDigest",void 0);class Hs{constructor(e={}){Object.assign(this,e)}}d([f({type:Re,optional:!0})],Hs.prototype,"issuerName",void 0);d([f({type:An,context:0,implicit:!0,optional:!0})],Hs.prototype,"baseCertificateID",void 0);d([f({type:In,context:1,implicit:!0,optional:!0})],Hs.prototype,"objectDigestInfo",void 0);let Mn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:te,repeated:"sequence"})],Mn.prototype,"v1Form",void 0);d([f({type:Hs,context:0,implicit:!0})],Mn.prototype,"v2Form",void 0);Mn=d([B({type:N.Choice})],Mn);class qs{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}d([f({type:y.GeneralizedTime})],qs.prototype,"notBeforeTime",void 0);d([f({type:y.GeneralizedTime})],qs.prototype,"notAfterTime",void 0);class Di{constructor(e={}){Object.assign(this,e)}}d([f({type:An,implicit:!0,context:0,optional:!0})],Di.prototype,"baseCertificateID",void 0);d([f({type:Re,implicit:!0,context:1,optional:!0})],Di.prototype,"entityName",void 0);d([f({type:In,implicit:!0,context:2,optional:!0})],Di.prototype,"objectDigestInfo",void 0);var ka;(function(t){t[t.v2=1]="v2"})(ka||(ka={}));class ht{constructor(e={}){this.version=ka.v2,this.holder=new Di,this.issuer=new Mn,this.signature=new F,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new qs,this.attributes=[],Object.assign(this,e)}}d([f({type:y.Integer})],ht.prototype,"version",void 0);d([f({type:Di})],ht.prototype,"holder",void 0);d([f({type:Mn})],ht.prototype,"issuer",void 0);d([f({type:F})],ht.prototype,"signature",void 0);d([f({type:y.Integer,converter:me})],ht.prototype,"serialNumber",void 0);d([f({type:qs})],ht.prototype,"attrCertValidityPeriod",void 0);d([f({type:$t,repeated:"sequence"})],ht.prototype,"attributes",void 0);d([f({type:y.BitString,optional:!0})],ht.prototype,"issuerUniqueID",void 0);d([f({type:qt,optional:!0})],ht.prototype,"extensions",void 0);class Ks{constructor(e={}){this.acinfo=new ht,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:ht})],Ks.prototype,"acinfo",void 0);d([f({type:F})],Ks.prototype,"signatureAlgorithm",void 0);d([f({type:y.BitString})],Ks.prototype,"signatureValue",void 0);var Fr;(function(t){t[t.unmarked=1]="unmarked",t[t.unclassified=2]="unclassified",t[t.restricted=4]="restricted",t[t.confidential=8]="confidential",t[t.secret=16]="secret",t[t.topSecret=32]="topSecret"})(Fr||(Fr={}));class xa extends Ps{}class Hc{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier,implicit:!0,context:0})],Hc.prototype,"type",void 0);d([f({type:y.Any,implicit:!0,context:1})],Hc.prototype,"value",void 0);class qc{constructor(e={}){this.policyId="",this.classList=new xa(Fr.unclassified),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],qc.prototype,"policyId",void 0);d([f({type:xa,defaultValue:new xa(Fr.unclassified)})],qc.prototype,"classList",void 0);d([f({type:Hc,repeated:"set"})],qc.prototype,"securityCategories",void 0);class Ws{constructor(e={}){Object.assign(this,e)}}d([f({type:oe})],Ws.prototype,"cotets",void 0);d([f({type:y.ObjectIdentifier})],Ws.prototype,"oid",void 0);d([f({type:y.Utf8String})],Ws.prototype,"string",void 0);class qf{constructor(e={}){this.values=[],Object.assign(this,e)}}d([f({type:Re,implicit:!0,context:0,optional:!0})],qf.prototype,"policyAuthority",void 0);d([f({type:Ws,repeated:"sequence"})],qf.prototype,"values",void 0);var Sa;class Gs{constructor(e={}){this.targetCertificate=new An,Object.assign(this,e)}}d([f({type:An})],Gs.prototype,"targetCertificate",void 0);d([f({type:te,optional:!0})],Gs.prototype,"targetName",void 0);d([f({type:In,optional:!0})],Gs.prototype,"certDigestInfo",void 0);let Dn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:te,context:0,implicit:!0})],Dn.prototype,"targetName",void 0);d([f({type:te,context:1,implicit:!0})],Dn.prototype,"targetGroup",void 0);d([f({type:Gs,context:2,implicit:!0})],Dn.prototype,"targetCert",void 0);Dn=d([B({type:N.Choice})],Dn);let Aa=Sa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Sa.prototype)}};Aa=Sa=d([B({type:N.Sequence,itemType:Dn})],Aa);var Ia;let gu=Ia=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ia.prototype)}};gu=Ia=d([B({type:N.Sequence,itemType:Aa})],gu);class Kf{constructor(e={}){Object.assign(this,e)}}d([f({type:Re,implicit:!0,context:0,optional:!0})],Kf.prototype,"roleAuthority",void 0);d([f({type:te,implicit:!0,context:1})],Kf.prototype,"roleName",void 0);class Kc{constructor(e={}){this.service=new te,this.ident=new te,Object.assign(this,e)}}d([f({type:te})],Kc.prototype,"service",void 0);d([f({type:te})],Kc.prototype,"ident",void 0);d([f({type:oe,optional:!0})],Kc.prototype,"authInfo",void 0);var Ea;class Wc{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Wc.prototype,"otherCertFormat",void 0);d([f({type:y.Any})],Wc.prototype,"otherCert",void 0);let Fn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:mn})],Fn.prototype,"certificate",void 0);d([f({type:Ks,context:2,implicit:!0})],Fn.prototype,"v2AttrCert",void 0);d([f({type:Wc,context:3,implicit:!0})],Fn.prototype,"other",void 0);Fn=d([B({type:N.Choice})],Fn);let Hr=Ea=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ea.prototype)}};Hr=Ea=d([B({type:N.Set,itemType:Fn})],Hr);class ti{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],ti.prototype,"contentType",void 0);d([f({type:y.Any,context:0})],ti.prototype,"content",void 0);let Ai=class{constructor(e={}){Object.assign(this,e)}};d([f({type:oe})],Ai.prototype,"single",void 0);d([f({type:y.Any})],Ai.prototype,"any",void 0);Ai=d([B({type:N.Choice})],Ai);class Js{constructor(e={}){this.eContentType="",Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Js.prototype,"eContentType",void 0);d([f({type:Ai,context:0,optional:!0})],Js.prototype,"eContent",void 0);let Ii=class{constructor(e={}){Object.assign(this,e)}};d([f({type:oe,context:0,implicit:!0,optional:!0})],Ii.prototype,"value",void 0);d([f({type:oe,converter:L_,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Ii.prototype,"constructedValue",void 0);Ii=d([B({type:N.Choice})],Ii);class Fi{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new Vr,Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Fi.prototype,"contentType",void 0);d([f({type:Vr})],Fi.prototype,"contentEncryptionAlgorithm",void 0);d([f({type:Ii,optional:!0})],Fi.prototype,"encryptedContent",void 0);class Zs{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Zs.prototype,"keyAttrId",void 0);d([f({type:y.Any,optional:!0})],Zs.prototype,"keyAttr",void 0);var Ca;class Ys{constructor(e={}){this.subjectKeyIdentifier=new Dt,Object.assign(this,e)}}d([f({type:Dt})],Ys.prototype,"subjectKeyIdentifier",void 0);d([f({type:y.GeneralizedTime,optional:!0})],Ys.prototype,"date",void 0);d([f({type:Zs,optional:!0})],Ys.prototype,"other",void 0);let Hn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Ys,context:0,implicit:!0,optional:!0})],Hn.prototype,"rKeyId",void 0);d([f({type:Qn,optional:!0})],Hn.prototype,"issuerAndSerialNumber",void 0);Hn=d([B({type:N.Choice})],Hn);class Gc{constructor(e={}){this.rid=new Hn,this.encryptedKey=new oe,Object.assign(this,e)}}d([f({type:Hn})],Gc.prototype,"rid",void 0);d([f({type:oe})],Gc.prototype,"encryptedKey",void 0);let qr=Ca=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ca.prototype)}};qr=Ca=d([B({type:N.Sequence,itemType:Gc})],qr);class Jc{constructor(e={}){this.algorithm=new F,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:F})],Jc.prototype,"algorithm",void 0);d([f({type:y.BitString})],Jc.prototype,"publicKey",void 0);let yn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Dt,context:0,implicit:!0,optional:!0})],yn.prototype,"subjectKeyIdentifier",void 0);d([f({type:Jc,context:1,implicit:!0,optional:!0})],yn.prototype,"originatorKey",void 0);d([f({type:Qn,optional:!0})],yn.prototype,"issuerAndSerialNumber",void 0);yn=d([B({type:N.Choice})],yn);class ni{constructor(e={}){this.version=jt.v3,this.originator=new yn,this.keyEncryptionAlgorithm=new bt,this.recipientEncryptedKeys=new qr,Object.assign(this,e)}}d([f({type:y.Integer})],ni.prototype,"version",void 0);d([f({type:yn,context:0})],ni.prototype,"originator",void 0);d([f({type:oe,context:1,optional:!0})],ni.prototype,"ukm",void 0);d([f({type:bt})],ni.prototype,"keyEncryptionAlgorithm",void 0);d([f({type:qr})],ni.prototype,"recipientEncryptedKeys",void 0);let qn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Dt,context:0,implicit:!0})],qn.prototype,"subjectKeyIdentifier",void 0);d([f({type:Qn})],qn.prototype,"issuerAndSerialNumber",void 0);qn=d([B({type:N.Choice})],qn);class Hi{constructor(e={}){this.version=jt.v0,this.rid=new qn,this.keyEncryptionAlgorithm=new bt,this.encryptedKey=new oe,Object.assign(this,e)}}d([f({type:y.Integer})],Hi.prototype,"version",void 0);d([f({type:qn})],Hi.prototype,"rid",void 0);d([f({type:bt})],Hi.prototype,"keyEncryptionAlgorithm",void 0);d([f({type:oe})],Hi.prototype,"encryptedKey",void 0);class qi{constructor(e={}){this.keyIdentifier=new oe,Object.assign(this,e)}}d([f({type:oe})],qi.prototype,"keyIdentifier",void 0);d([f({type:y.GeneralizedTime,optional:!0})],qi.prototype,"date",void 0);d([f({type:Zs,optional:!0})],qi.prototype,"other",void 0);class Ki{constructor(e={}){this.version=jt.v4,this.kekid=new qi,this.keyEncryptionAlgorithm=new bt,this.encryptedKey=new oe,Object.assign(this,e)}}d([f({type:y.Integer})],Ki.prototype,"version",void 0);d([f({type:qi})],Ki.prototype,"kekid",void 0);d([f({type:bt})],Ki.prototype,"keyEncryptionAlgorithm",void 0);d([f({type:oe})],Ki.prototype,"encryptedKey",void 0);class Wi{constructor(e={}){this.version=jt.v0,this.keyEncryptionAlgorithm=new bt,this.encryptedKey=new oe,Object.assign(this,e)}}d([f({type:y.Integer})],Wi.prototype,"version",void 0);d([f({type:ya,context:0,optional:!0})],Wi.prototype,"keyDerivationAlgorithm",void 0);d([f({type:bt})],Wi.prototype,"keyEncryptionAlgorithm",void 0);d([f({type:oe})],Wi.prototype,"encryptedKey",void 0);class Zc{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Zc.prototype,"oriType",void 0);d([f({type:y.Any})],Zc.prototype,"oriValue",void 0);let Kt=class{constructor(e={}){Object.assign(this,e)}};d([f({type:Hi,optional:!0})],Kt.prototype,"ktri",void 0);d([f({type:ni,context:1,implicit:!0,optional:!0})],Kt.prototype,"kari",void 0);d([f({type:Ki,context:2,implicit:!0,optional:!0})],Kt.prototype,"kekri",void 0);d([f({type:Wi,context:3,implicit:!0,optional:!0})],Kt.prototype,"pwri",void 0);d([f({type:Zc,context:4,implicit:!0,optional:!0})],Kt.prototype,"ori",void 0);Kt=d([B({type:N.Choice})],Kt);var za;let Kr=za=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,za.prototype)}};Kr=za=d([B({type:N.Set,itemType:Kt})],Kr);var $a;class Xs{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],Xs.prototype,"otherRevInfoFormat",void 0);d([f({type:y.Any})],Xs.prototype,"otherRevInfo",void 0);let Wr=class{constructor(e={}){this.other=new Xs,Object.assign(this,e)}};d([f({type:Xs,context:1,implicit:!0})],Wr.prototype,"other",void 0);Wr=d([B({type:N.Choice})],Wr);let Gr=$a=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,$a.prototype)}};Gr=$a=d([B({type:N.Set,itemType:Wr})],Gr);class Yc{constructor(e={}){Object.assign(this,e)}}d([f({type:Hr,context:0,implicit:!0,optional:!0})],Yc.prototype,"certs",void 0);d([f({type:Gr,context:1,implicit:!0,optional:!0})],Yc.prototype,"crls",void 0);var ja;let Na=ja=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ja.prototype)}};Na=ja=d([B({type:N.Set,itemType:ei})],Na);class Gi{constructor(e={}){this.version=jt.v0,this.recipientInfos=new Kr,this.encryptedContentInfo=new Fi,Object.assign(this,e)}}d([f({type:y.Integer})],Gi.prototype,"version",void 0);d([f({type:Yc,context:0,implicit:!0,optional:!0})],Gi.prototype,"originatorInfo",void 0);d([f({type:Kr})],Gi.prototype,"recipientInfos",void 0);d([f({type:Fi})],Gi.prototype,"encryptedContentInfo",void 0);d([f({type:Na,context:1,implicit:!0,optional:!0})],Gi.prototype,"unprotectedAttrs",void 0);const um="1.2.840.113549.1.7.2";var Oa;let Jr=Oa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Oa.prototype)}};Jr=Oa=d([B({type:N.Set,itemType:Si})],Jr);class ii{constructor(e={}){this.version=jt.v0,this.digestAlgorithms=new Jr,this.encapContentInfo=new Js,this.signerInfos=new Mr,Object.assign(this,e)}}d([f({type:y.Integer})],ii.prototype,"version",void 0);d([f({type:Jr})],ii.prototype,"digestAlgorithms",void 0);d([f({type:Js})],ii.prototype,"encapContentInfo",void 0);d([f({type:Hr,context:0,implicit:!0,optional:!0})],ii.prototype,"certificates",void 0);d([f({type:Gr,context:1,implicit:!0,optional:!0})],ii.prototype,"crls",void 0);d([f({type:Mr})],ii.prototype,"signerInfos",void 0);const Ei="1.2.840.10045.2.1",Xc="1.2.840.10045.4.1",Wf="1.2.840.10045.4.3.1",Qc="1.2.840.10045.4.3.2",el="1.2.840.10045.4.3.3",tl="1.2.840.10045.4.3.4",_u="1.2.840.10045.3.1.7",mu="1.3.132.0.34",yu="1.3.132.0.35";function Ji(t){return new F({algorithm:t})}const dm=Ji(Xc);Ji(Wf);const pm=Ji(Qc),fm=Ji(el),hm=Ji(tl);let Ci=class{constructor(e={}){Object.assign(this,e)}};d([f({type:y.ObjectIdentifier})],Ci.prototype,"fieldType",void 0);d([f({type:y.Any})],Ci.prototype,"parameters",void 0);Ci=d([B({type:N.Sequence})],Ci);class gm extends oe{}let Kn=class{constructor(e={}){Object.assign(this,e)}};d([f({type:y.OctetString})],Kn.prototype,"a",void 0);d([f({type:y.OctetString})],Kn.prototype,"b",void 0);d([f({type:y.BitString,optional:!0})],Kn.prototype,"seed",void 0);Kn=d([B({type:N.Sequence})],Kn);var Ba;(function(t){t[t.ecpVer1=1]="ecpVer1"})(Ba||(Ba={}));let Nt=class{constructor(e={}){this.version=Ba.ecpVer1,Object.assign(this,e)}};d([f({type:y.Integer})],Nt.prototype,"version",void 0);d([f({type:Ci})],Nt.prototype,"fieldID",void 0);d([f({type:Kn})],Nt.prototype,"curve",void 0);d([f({type:gm})],Nt.prototype,"base",void 0);d([f({type:y.Integer,converter:me})],Nt.prototype,"order",void 0);d([f({type:y.Integer,optional:!0})],Nt.prototype,"cofactor",void 0);Nt=d([B({type:N.Sequence})],Nt);let Wt=class{constructor(e={}){Object.assign(this,e)}};d([f({type:y.ObjectIdentifier})],Wt.prototype,"namedCurve",void 0);d([f({type:y.Null})],Wt.prototype,"implicitCurve",void 0);d([f({type:Nt})],Wt.prototype,"specifiedCurve",void 0);Wt=d([B({type:N.Choice})],Wt);class Qs{constructor(e={}){this.version=1,this.privateKey=new oe,Object.assign(this,e)}}d([f({type:y.Integer})],Qs.prototype,"version",void 0);d([f({type:oe})],Qs.prototype,"privateKey",void 0);d([f({type:Wt,context:0,optional:!0})],Qs.prototype,"parameters",void 0);d([f({type:y.BitString,context:1,optional:!0})],Qs.prototype,"publicKey",void 0);class Zr{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.Integer,converter:me})],Zr.prototype,"r",void 0);d([f({type:y.Integer,converter:me})],Zr.prototype,"s",void 0);const He="1.2.840.113549.1.1",vn=`${He}.1`,_m=`${He}.7`,mm=`${He}.9`,mi=`${He}.10`,ym=`${He}.2`,vm=`${He}.4`,Yr=`${He}.5`,wm=`${He}.14`,Ta=`${He}.11`,Xr=`${He}.12`,Qr=`${He}.13`,Gf=`${He}.15`,Jf=`${He}.16`,es="1.3.14.3.2.26",Zf="2.16.840.1.101.3.4.2.4",ts="2.16.840.1.101.3.4.2.1",ns="2.16.840.1.101.3.4.2.2",is="2.16.840.1.101.3.4.2.3",bm="2.16.840.1.101.3.4.2.5",km="2.16.840.1.101.3.4.2.6",xm="1.2.840.113549.2.2",Sm="1.2.840.113549.2.5",eo=`${He}.8`;function Ae(t){return new F({algorithm:t,parameters:null})}Ae(xm);Ae(Sm);const wn=Ae(es);Ae(Zf);Ae(ts);Ae(ns);Ae(is);Ae(bm);Ae(km);const Yf=new F({algorithm:eo,parameters:U.serialize(wn)}),Xf=new F({algorithm:mm,parameters:U.serialize(Nr.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Ae(vn);Ae(ym);Ae(vm);Ae(Yr);Ae(Gf);Ae(Jf);Ae(Xr);Ae(Qr);Ae(Gf);Ae(Jf);class to{constructor(e={}){this.hashAlgorithm=new F(wn),this.maskGenAlgorithm=new F({algorithm:eo,parameters:U.serialize(wn)}),this.pSourceAlgorithm=new F(Xf),Object.assign(this,e)}}d([f({type:F,context:0,defaultValue:wn})],to.prototype,"hashAlgorithm",void 0);d([f({type:F,context:1,defaultValue:Yf})],to.prototype,"maskGenAlgorithm",void 0);d([f({type:F,context:2,defaultValue:Xf})],to.prototype,"pSourceAlgorithm",void 0);new F({algorithm:_m,parameters:U.serialize(new to)});class bn{constructor(e={}){this.hashAlgorithm=new F(wn),this.maskGenAlgorithm=new F({algorithm:eo,parameters:U.serialize(wn)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}d([f({type:F,context:0,defaultValue:wn})],bn.prototype,"hashAlgorithm",void 0);d([f({type:F,context:1,defaultValue:Yf})],bn.prototype,"maskGenAlgorithm",void 0);d([f({type:y.Integer,context:2,defaultValue:20})],bn.prototype,"saltLength",void 0);d([f({type:y.Integer,context:3,defaultValue:1})],bn.prototype,"trailerField",void 0);new F({algorithm:mi,parameters:U.serialize(new bn)});class no{constructor(e={}){this.digestAlgorithm=new F,this.digest=new oe,Object.assign(this,e)}}d([f({type:F})],no.prototype,"digestAlgorithm",void 0);d([f({type:oe})],no.prototype,"digest",void 0);var Ra;class io{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:me})],io.prototype,"prime",void 0);d([f({type:y.Integer,converter:me})],io.prototype,"exponent",void 0);d([f({type:y.Integer,converter:me})],io.prototype,"coefficient",void 0);let Pa=Ra=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ra.prototype)}};Pa=Ra=d([B({type:N.Sequence,itemType:io})],Pa);class At{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})],At.prototype,"version",void 0);d([f({type:y.Integer,converter:me})],At.prototype,"modulus",void 0);d([f({type:y.Integer,converter:me})],At.prototype,"publicExponent",void 0);d([f({type:y.Integer,converter:me})],At.prototype,"privateExponent",void 0);d([f({type:y.Integer,converter:me})],At.prototype,"prime1",void 0);d([f({type:y.Integer,converter:me})],At.prototype,"prime2",void 0);d([f({type:y.Integer,converter:me})],At.prototype,"exponent1",void 0);d([f({type:y.Integer,converter:me})],At.prototype,"exponent2",void 0);d([f({type:y.Integer,converter:me})],At.prototype,"coefficient",void 0);d([f({type:Pa,optional:!0})],At.prototype,"otherPrimeInfos",void 0);class nl{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.Integer,converter:me})],nl.prototype,"modulus",void 0);d([f({type:y.Integer,converter:me})],nl.prototype,"publicExponent",void 0);var La;(function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"})(La||(La={}));const Ue=La;/*! *****************************************************************************
|
|
79
|
+
`)}`:`${n} :`}}yf=De;q.Constructed=yf;De.NAME="CONSTRUCTED";class vf extends Le{fromBER(e,n,i){return n}toBER(e){return ht}}vf.override="EndOfContentValueBlock";var wf;class Gc extends je{constructor(e={}){super(e,vf),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}wf=Gc;q.EndOfContent=wf;Gc.NAME=$i;var bf;class mn extends je{constructor(e={}){super(e,Le),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,n,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,n+i>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):n+i}toBER(e,n){const i=new ArrayBuffer(2);if(!e){const r=new Uint8Array(i);r[0]=5,r[1]=0}return n&&n.write(i),i}onAsciiEncoding(){return`${this.constructor.NAME}`}}bf=mn;q.Null=bf;mn.NAME="NULL";class kf extends At(Le){constructor({value:e,...n}={}){super(n),n.valueHex?this.valueHexView=M.toUint8Array(n.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,n,i){const r=M.toUint8Array(e);return Rt(this,r,n,i)?(this.valueHexView=r.subarray(n,n+i),i>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,uf.call(this),this.blockLength=i,n+i):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}kf.NAME="BooleanValueBlock";var xf;class Hs extends je{constructor(e={}){super(e,kf),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}`}}xf=Hs;q.Boolean=xf;Hs.NAME="BOOLEAN";class Sf extends At(Ht){constructor({isConstructed:e=!1,...n}={}){super(n),this.isConstructed=e}fromBER(e,n,i){let r=0;if(this.isConstructed){if(this.isHexOnly=!1,r=Ht.prototype.fromBER.call(this,e,n,i),r===-1)return r;for(let s=0;s<this.value.length;s++){const o=this.value[s].constructor.NAME;if(o===$i){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(o!==df)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,r=super.fromBER(e,n,i),this.blockLength=i;return r}toBER(e,n){return this.isConstructed?Ht.prototype.toBER.call(this,e,n):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}Sf.NAME="OctetStringValueBlock";var Af;let un=class Ef extends je{constructor({idBlock:e={},lenBlock:n={},...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:{...n,isIndefiniteForm:!!i.isIndefiniteForm},...i},Sf),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,n,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),n;if(!this.valueBlock.isConstructed){const s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(n,n+i);try{if(s.byteLength){const o=ei(s,0,s.byteLength);o.offset!==-1&&o.offset===i&&(this.valueBlock.value=[o.result])}}catch{}}return super.fromBER(e,n,i)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?De.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${G.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const n of this.valueBlock.value)n instanceof Ef&&e.push(n.valueBlock.valueHexView);return M.concat(e)}};Af=un;q.OctetString=Af;un.NAME=df;class If extends At(Ht){constructor({unusedBits:e=0,isConstructed:n=!1,...i}={}){super(i),this.unusedBits=e,this.isConstructed=n,this.blockLength=this.valueHexView.byteLength}fromBER(e,n,i){if(!i)return n;let r=-1;if(this.isConstructed){if(r=Ht.prototype.fromBER.call(this,e,n,i),r===-1)return r;for(const c of this.value){const l=c.constructor.NAME;if(l===$i){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(l!==pf)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=M.toUint8Array(e);if(!Rt(this,s,n,i))return-1;const o=s.subarray(n,n+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=ei(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,n+i}toBER(e,n){if(this.isConstructed)return Ht.prototype.toBER.call(this,e,n);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return ht;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}}}If.NAME="BitStringValueBlock";var Cf;let dn=class extends je{constructor({idBlock:e={},lenBlock:n={},...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:{...n,isIndefiniteForm:!!i.isIndefiniteForm},...i},If),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,n,i){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,n,i)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return De.prototype.onAsciiEncoding.call(this);{const e=[],n=this.valueBlock.valueHexView;for(const r of n)e.push(r.toString(2).padStart(8,"0"));const i=e.join("");return`${this.constructor.NAME} : ${i.substring(0,i.length-this.valueBlock.unusedBits)}`}}};Cf=dn;q.BitString=Cf;dn.NAME=pf;var $f;function x_(t,e){const n=new Uint8Array([0]),i=new Uint8Array(t),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 f=0;for(let m=p;m>=0;m--,f++){switch(!0){case f<c.length:u=s[o-f]+c[l-f]+n[0];break;default:u=s[o-f]+n[0]}switch(n[0]=u/10,!0){case f>=s.length:s=pa(new Uint8Array([u%10]),s);break;default:s[o-f]=u%10}}return n[0]>0&&(s=pa(n,s)),s}function Au(t){if(t>=gi.length)for(let e=gi.length;e<=t;e++){const n=new Uint8Array([0]);let i=gi[e-1].slice(0);for(let r=i.length-1;r>=0;r--){const s=new Uint8Array([(i[r]<<1)+n[0]]);n[0]=s[0]/10,i[r]=s[0]%10}n[0]>0&&(i=pa(n,i)),gi.push(i)}return gi[t]}function S_(t,e){let n=0;const i=new Uint8Array(t),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 f=l;f>=0;f--,p++)switch(u=s[o-p]-c[l-p]-n,!0){case u<0:n=1,s[o-p]=u+10;break;default:n=0,s[o-p]=u}if(n>0)for(let f=o-l+1;f>=0;f--,p++)if(u=s[o-p]-n,u<0)n=1,s[o-p]=u+10;else{n=0,s[o-p]=u;break}return s.slice()}class Jc extends At(Le){constructor({value:e,...n}={}){super(n),this._valueDec=0,n.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=uf.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(d_(e))}get valueDec(){return this._valueDec}fromDER(e,n,i,r=0){const s=this.fromBER(e,n,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 n=this.valueHexView;switch(!0){case(n[0]&128)!==0:{const i=new Uint8Array(this.valueHexView.length+1);i[0]=0,i.set(n,1),this.valueHexView=i}break;case(n[0]===0&&(n[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,n,i){const r=super.fromBER(e,n,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 n=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:n=S_(Au(i),n),o="-";break;default:n=x_(n,Au(i))}i++,r>>=1}}for(let l=0;l<n.length;l++)n[l]&&(c=!0),c&&(o+=xu.charAt(n[l]));return c===!1&&(o+=xu.charAt(0)),o}}$f=Jc;Jc.NAME="IntegerValueBlock";Object.defineProperty($f.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var zf;class bt extends je{constructor(e={}){super(e,Jc),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Gr(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Gr();const n=BigInt(e),i=new Ms,r=n.toString(16).replace(/^-/,""),s=new Uint8Array(G.FromHex(r));if(n<0){const c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;const u=BigInt(`0x${G.ToHex(c)}`)+n,p=M.toUint8Array(G.FromHex(u.toString(16)));p[0]|=128,i.write(p)}else s[0]&128&&i.write(new Uint8Array([0])),i.write(s);return new bt({valueHex:i.final()})}convertToDER(){const e=new bt({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new bt({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}zf=bt;q.Integer=zf;bt.NAME="INTEGER";var Nf;class Fs extends bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}Nf=Fs;q.Enumerated=Nf;Fs.NAME="ENUMERATED";class fa extends At(Le){constructor({valueDec:e=-1,isFirstSid:n=!1,...i}={}){super(i),this.valueDec=e,this.isFirstSid=n}fromBER(e,n,i){if(!i)return n;const r=M.toUint8Array(e);if(!Rt(this,r,n,i))return-1;const s=r.subarray(n,n+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=Vn(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}set valueBigInt(e){Gr();let n=BigInt(e).toString(2);for(;n.length%7;)n="0"+n;const i=new Uint8Array(n.length/7);for(let r=0;r<i.length;r++)i[r]=parseInt(n.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 n=gn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",ht;const i=new Uint8Array(n.byteLength);if(!e){const r=new Uint8Array(n),s=n.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=G.ToHex(this.valueHexView);else if(this.isFirstSid){let n=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",n-=40):(e="2.",n-=80),e+=n.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}fa.NAME="sidBlock";class jf extends Le{constructor({value:e=Me,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,i){let r=n;for(;i>0;){const s=new fa;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 n=[];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,ht;n.push(r)}return Kc(n)}fromString(e){this.value=[];let n=0,i=0,r="",s=!1;do if(i=e.indexOf(".",n),i===-1?r=e.substring(n):r=e.substring(n,i),n=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 fa;if(r>Number.MAX_SAFE_INTEGER){Gr();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="",n=!1;for(let i=0;i<this.value.length;i++){n=this.value[i].isHexOnly;let r=this.value[i].toString();i!==0&&(e=`${e}.`),n?(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 n=0;n<this.value.length;n++)e.sidArray.push(this.value[n].toJSON());return e}}jf.NAME="ObjectIdentifierValueBlock";var Of;class qs extends je{constructor(e={}){super(e,jf),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()}}}Of=qs;q.ObjectIdentifier=Of;qs.NAME="OBJECT IDENTIFIER";class ha extends At(In){constructor({valueDec:e=0,...n}={}){super(n),this.valueDec=e}fromBER(e,n,i){if(i===0)return n;const r=M.toUint8Array(e);if(!Rt(this,r,n,i))return-1;const s=r.subarray(n,n+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=Vn(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+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 n=gn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",ht;const i=new Uint8Array(n.byteLength);if(!e){const r=new Uint8Array(n),s=n.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=G.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}ha.NAME="relativeSidBlock";class Bf extends Le{constructor({value:e=Me,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,i){let r=n;for(;i>0;){const s=new ha;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,n){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,ht;i.push(s)}return Kc(i)}fromString(e){this.value=[];let n=0,i=0,r="";do{i=e.indexOf(".",n),i===-1?r=e.substring(n):r=e.substring(n,i),n=i+1;const s=new ha;if(s.valueDec=parseInt(r,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(i!==-1);return!0}toString(){let e="",n=!1;for(let i=0;i<this.value.length;i++){n=this.value[i].isHexOnly;let r=this.value[i].toString();i!==0&&(e=`${e}.`),n&&(r=`{${r}}`),e+=r}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let n=0;n<this.value.length;n++)e.sidArray.push(this.value[n].toJSON());return e}}Bf.NAME="RelativeObjectIdentifierValueBlock";var Tf;class Zc extends je{constructor(e={}){super(e,Bf),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()}}}Tf=Zc;q.RelativeObjectIdentifier=Tf;Zc.NAME="RelativeObjectIdentifier";var Pf;class zt extends De{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}Pf=zt;q.Sequence=Pf;zt.NAME="SEQUENCE";var Rf;let Nt=class extends De{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Rf=Nt;q.Set=Rf;Nt.NAME="SET";class Lf extends At(Le){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Me}toJSON(){return{...super.toJSON(),value:this.value}}}Lf.NAME="StringValueBlock";class Uf extends Lf{}Uf.NAME="SimpleStringValueBlock";class Ze extends Wc{constructor({...e}={}){super(e,Uf)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,M.toUint8Array(e))}fromString(e){const n=e.length,i=this.valueBlock.valueHexView=new Uint8Array(n);for(let r=0;r<n;r++)i[r]=e.charCodeAt(r);this.valueBlock.value=e}}Ze.NAME="SIMPLE STRING";class Vf extends Ze{fromBuffer(e){this.valueBlock.valueHexView=M.toUint8Array(e);try{this.valueBlock.value=G.ToUtf8String(e)}catch(n){this.warnings.push(`Error during "decodeURIComponent": ${n}, using raw string`),this.valueBlock.value=G.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(G.FromUtf8String(e)),this.valueBlock.value=e}}Vf.NAME="Utf8StringValueBlock";var Mf;class Lt extends Vf{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}Mf=Lt;q.Utf8String=Mf;Lt.NAME="UTF8String";class Df extends Ze{fromBuffer(e){this.valueBlock.value=G.ToUtf16String(e),this.valueBlock.valueHexView=M.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(G.FromUtf16String(e))}}Df.NAME="BmpStringValueBlock";var Hf;class Ks extends Df{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Hf=Ks;q.BmpString=Hf;Ks.NAME="BMPString";class Ff extends Ze{fromBuffer(e){const n=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),i=new Uint8Array(n);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(n))}fromString(e){const n=e.length,i=this.valueBlock.valueHexView=new Uint8Array(n*4);for(let r=0;r<n;r++){const s=gn(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}}Ff.NAME="UniversalStringValueBlock";var qf;class Ws extends Ff{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}qf=Ws;q.UniversalString=qf;Ws.NAME="UniversalString";var Kf;class Gs extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Kf=Gs;q.NumericString=Kf;Gs.NAME="NumericString";var Wf;class Js extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Wf=Js;q.PrintableString=Wf;Js.NAME="PrintableString";var Gf;class Zs extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Gf=Zs;q.TeletexString=Gf;Zs.NAME="TeletexString";var Jf;class Ys extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Jf=Ys;q.VideotexString=Jf;Ys.NAME="VideotexString";var Zf;class Xs extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Zf=Xs;q.IA5String=Zf;Xs.NAME="IA5String";var Yf;class Qs extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Yf=Qs;q.GraphicString=Yf;Qs.NAME="GraphicString";var Xf;class Gi extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Xf=Gi;q.VisibleString=Xf;Gi.NAME="VisibleString";var Qf;class eo extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Qf=eo;q.GeneralString=Qf;eo.NAME="GeneralString";var eh;class to extends Ze{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}eh=to;q.CharacterString=eh;to.NAME="CharacterString";var th;class Ji extends Gi{constructor({value:e,valueDate:n,...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)}n&&(this.fromDate(n),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,M.toUint8Array(e)))}toBuffer(){const e=this.toString(),n=new ArrayBuffer(e.length),i=new Uint8Array(n);for(let r=0;r<e.length;r++)i[r]=e.charCodeAt(r);return n}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 n=new Array(7);return n[0]=Ge(this.year<2e3?this.year-1900:this.year-2e3,2),n[1]=Ge(this.month,2),n[2]=Ge(this.day,2),n[3]=Ge(this.hour,2),n[4]=Ge(this.minute,2),n[5]=Ge(this.second,2),n[6]="Z",n.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}}}th=Ji;q.UTCTime=th;Ji.NAME="UTCTime";var nh;class no extends Ji{constructor(e={}){var n;super(e),(n=this.millisecond)!==null&&n!==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 n=!1,i="",r="",s=0,o,c=0,l=0;if(e[e.length-1]==="Z")i=e.substring(0,e.length-1),n=!0;else{const f=new Number(e[e.length-1]);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");i=e}if(n){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 f=1,m=i.indexOf("+"),v="";if(m===-1&&(m=i.indexOf("-"),f=-1),m!==-1){if(v=i.substring(m+1),i=i.substring(0,m),v.length!==2&&v.length!==4)throw new Error("Wrong input string for conversion");let h=parseInt(v.substring(0,2),10);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");if(c=f*h,v.length===4){if(h=parseInt(v.substring(2,4),10),isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");l=f*h}}}let u=i.indexOf(".");if(u===-1&&(u=i.indexOf(",")),u!==-1){const f=new Number(`0${i.substring(u)}`);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");s=f.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 f=60*s;this.minute=Math.floor(f),f=60*(f-this.minute),this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case r.length===12:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){let f=60*s;this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case r.length===14:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,u!==-1){const f=1e3*s;this.millisecond=Math.floor(f)}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 f=1;f<p.length;f++)switch(f){case 1:this.year=parseInt(p[f],10);break;case 2:this.month=parseInt(p[f],10);break;case 3:this.day=parseInt(p[f],10);break;case 4:this.hour=parseInt(p[f],10)+c;break;case 5:this.minute=parseInt(p[f],10)+l;break;case 6:this.second=parseInt(p[f],10);break;default:throw new Error("Wrong input string for conversion")}if(n===!1){const f=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=f.getUTCFullYear(),this.month=f.getUTCMonth(),this.day=f.getUTCDay(),this.hour=f.getUTCHours(),this.minute=f.getUTCMinutes(),this.second=f.getUTCSeconds(),this.millisecond=f.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const n=[];return n.push(Ge(this.year,4)),n.push(Ge(this.month,2)),n.push(Ge(this.day,2)),n.push(Ge(this.hour,2)),n.push(Ge(this.minute,2)),n.push(Ge(this.second,2)),this.millisecond!==0&&(n.push("."),n.push(Ge(this.millisecond,3))),n.push("Z"),n.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}nh=no;q.GeneralizedTime=nh;no.NAME="GeneralizedTime";var ih;class Yc extends Lt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}ih=Yc;q.DATE=ih;Yc.NAME="DATE";var rh;class Xc extends Lt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}rh=Xc;q.TimeOfDay=rh;Xc.NAME="TimeOfDay";var sh;class Qc extends Lt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}sh=Qc;q.DateTime=sh;Qc.NAME="DateTime";var oh;class el extends Lt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}oh=el;q.Duration=oh;el.NAME="Duration";var ah;class tl extends Lt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}ah=tl;q.TIME=ah;tl.NAME="TIME";class _n{constructor({name:e=Me,optional:n=!1}={}){this.name=e,this.optional=n}}class nl extends _n{constructor({value:e=[],...n}={}){super(n),this.value=e}}class Jr extends _n{constructor({value:e=new _n,local:n=!1,...i}={}){super(i),this.value=e,this.local=n}}class A_{constructor({data:e=Ds}={}){this.dataView=M.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=M.toUint8Array(e)}fromBER(e,n,i){const r=n+i;return this.dataView=M.toUint8Array(e).subarray(n,r),r}toBER(e){return this.dataView.slice().buffer}}function an(t,e,n){if(n instanceof nl){for(let s=0;s<n.value.length;s++)if(an(t,e,n.value[s]).verified)return{verified:!0,result:t};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return n.hasOwnProperty(Do)&&(s.name=n.name),s}}if(n instanceof _n)return n.hasOwnProperty(Do)&&(t[n.name]=e),{verified:!0,result:t};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(n instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(h_ in n))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(y_ in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(v_ in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const i=n.idBlock.toBER(!1);if(i.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(n.idBlock.fromBER(i,0,i.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(n.idBlock.hasOwnProperty(g_)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:t};if(n.idBlock.hasOwnProperty(m_)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:t};if(n.idBlock.hasOwnProperty(__)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:t};if(!(f_ in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:t};if(n.idBlock.isHexOnly){if(!(Su in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=n.idBlock.valueHexView,o=e.idBlock.valueHexView;if(s.length!==o.length)return{verified:!1,result:t};for(let c=0;c<s.length;c++)if(s[c]!==o[1])return{verified:!1,result:t}}if(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&(t[n.name]=e)),n instanceof q.Constructed){let s=0,o={verified:!1,result:{error:"Unknown error"}},c=n.valueBlock.value.length;if(c>0&&n.valueBlock.value[0]instanceof Jr&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:t};if(e.valueBlock.value.length===0&&n.valueBlock.value.length!==0){let l=!0;for(let u=0;u<n.valueBlock.value.length;u++)l=l&&(n.valueBlock.value[u].optional||!1);return l?{verified:!0,result:t}:(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&delete t[n.name]),t.error="Inconsistent object length",{verified:!1,result:t})}for(let l=0;l<c;l++)if(l-s>=e.valueBlock.value.length){if(n.valueBlock.value[l].optional===!1){const u={verified:!1,result:t};return t.error="Inconsistent length between ASN.1 data and schema",n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&(delete t[n.name],u.name=n.name)),u}}else if(n.valueBlock.value[0]instanceof Jr){if(o=an(t,e.valueBlock.value[l],n.valueBlock.value[0].value),o.verified===!1)if(n.valueBlock.value[0].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&delete t[n.name]),o;if(Do in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let u={};w_ in n.valueBlock.value[0]&&n.valueBlock.value[0].local?u=e:u=t,typeof u[n.valueBlock.value[0].name]>"u"&&(u[n.valueBlock.value[0].name]=[]),u[n.valueBlock.value[0].name].push(e.valueBlock.value[l])}}else if(o=an(t,e.valueBlock.value[l-s],n.valueBlock.value[l]),o.verified===!1)if(n.valueBlock.value[l].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&delete t[n.name]),o;if(o.verified===!1){const l={verified:!1,result:t};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&(delete t[n.name],l.name=n.name)),l}return{verified:!0,result:t}}if(n.primitiveSchema&&Su in e.valueBlock){const s=ei(e.valueBlock.valueHexView);if(s.offset===-1){const o={verified:!1,result:s.result};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Me),n.name&&(delete t[n.name],o.name=n.name)),o}return an(t,s.result,n.primitiveSchema)}return{verified:!0,result:t}}function E_(t,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const n=ei(M.toUint8Array(t));return n.offset===-1?{verified:!1,result:n.result}:an(n.result,n.result,e)}const ch=Object.freeze(Object.defineProperty({__proto__:null,Any:_n,BaseBlock:je,BaseStringBlock:Wc,BitString:dn,BmpString:Ks,Boolean:Hs,CharacterString:to,Choice:nl,Constructed:De,DATE:Yc,DateTime:Qc,Duration:el,EndOfContent:Gc,Enumerated:Fs,GeneralString:eo,GeneralizedTime:no,GraphicString:Qs,HexBlock:At,IA5String:Xs,Integer:bt,Null:mn,NumericString:Gs,ObjectIdentifier:qs,OctetString:un,Primitive:Wi,PrintableString:Js,RawData:A_,RelativeObjectIdentifier:Zc,Repeated:Jr,Sequence:zt,Set:Nt,TIME:tl,TeletexString:Zs,TimeOfDay:Xc,UTCTime:Ji,UniversalString:Ws,Utf8String:Lt,ValueBlock:Le,VideotexString:Ys,ViewWriter:Ms,VisibleString:Gi,compareSchema:an,fromBER:Rn,verifySchema:E_},Symbol.toStringTag,{value:"Module"}));var T;(function(t){t[t.Sequence=0]="Sequence",t[t.Set=1]="Set",t[t.Choice=2]="Choice"})(T||(T={}));var w;(function(t){t[t.Any=1]="Any",t[t.Boolean=2]="Boolean",t[t.OctetString=3]="OctetString",t[t.BitString=4]="BitString",t[t.Integer=5]="Integer",t[t.Enumerated=6]="Enumerated",t[t.ObjectIdentifier=7]="ObjectIdentifier",t[t.Utf8String=8]="Utf8String",t[t.BmpString=9]="BmpString",t[t.UniversalString=10]="UniversalString",t[t.NumericString=11]="NumericString",t[t.PrintableString=12]="PrintableString",t[t.TeletexString=13]="TeletexString",t[t.VideotexString=14]="VideotexString",t[t.IA5String=15]="IA5String",t[t.GraphicString=16]="GraphicString",t[t.VisibleString=17]="VisibleString",t[t.GeneralString=18]="GeneralString",t[t.CharacterString=19]="CharacterString",t[t.UTCTime=20]="UTCTime",t[t.GeneralizedTime=21]="GeneralizedTime",t[t.DATE=22]="DATE",t[t.TimeOfDay=23]="TimeOfDay",t[t.DateTime=24]="DateTime",t[t.Duration=25]="Duration",t[t.TIME=26]="TIME",t[t.Null=27]="Null"})(w||(w={}));class io{constructor(e,n=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(M.isBufferSource(e))this.unusedBits=n,this.value=M.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof dn))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 dn({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new dn({name:e})}toNumber(){let e="";const n=new Uint8Array(this.value);for(const i of n)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 n=e.toString(2);const i=n.length+7>>3;this.unusedBits=(i<<3)-n.length;const r=new Uint8Array(i);n=n.padStart(i<<3,"0").split("").reverse().join("");let s=0;for(;s<i;)r[s]=parseInt(n.slice(s<<3,(s<<3)+8),2),s++;this.value=r.buffer}}class ae{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):M.isBufferSource(e)?this.buffer=M.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof un))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new un({valueHex:this.buffer})}toSchema(e){return new un({name:e})}}const I_={fromASN:t=>t instanceof mn?null:t.valueBeforeDecodeView,toASN:t=>{if(t===null)return new mn;const e=Rn(t);if(e.result.error)throw new Error(e.result.error);return e.result}},C_={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new bt({value:+t})},$_={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new Fs({value:t})},_e={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new bt({valueHex:t})},z_={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new dn({valueHex:t})},N_={fromASN:t=>t.valueBlock.toString(),toASN:t=>new qs({value:t})},j_={fromASN:t=>t.valueBlock.value,toASN:t=>new Hs({value:t})},Zr={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new un({valueHex:t})},O_={fromASN:t=>new ae(t.getValue()),toASN:t=>t.toASN()};function it(t){return{fromASN:e=>e.valueBlock.value,toASN:e=>new t({value:e})}}const lh=it(Lt),B_=it(Ks),T_=it(Ws),P_=it(Gs),R_=it(Js),L_=it(Zs),U_=it(Ys),V_=it(Xs),M_=it(Qs),D_=it(Gi),H_=it(eo),F_=it(to),q_={fromASN:t=>t.toDate(),toASN:t=>new Ji({valueDate:t})},K_={fromASN:t=>t.toDate(),toASN:t=>new no({valueDate:t})},W_={fromASN:()=>null,toASN:()=>new mn};function il(t){switch(t){case w.Any:return I_;case w.BitString:return z_;case w.BmpString:return B_;case w.Boolean:return j_;case w.CharacterString:return F_;case w.Enumerated:return $_;case w.GeneralString:return H_;case w.GeneralizedTime:return K_;case w.GraphicString:return M_;case w.IA5String:return V_;case w.Integer:return C_;case w.Null:return W_;case w.NumericString:return P_;case w.ObjectIdentifier:return N_;case w.OctetString:return Zr;case w.PrintableString:return R_;case w.TeletexString:return L_;case w.UTCTime:return q_;case w.UniversalString:return T_;case w.Utf8String:return lh;case w.VideotexString:return U_;case w.VisibleString:return D_;default:return null}}function $t(t){return typeof t=="function"&&t.prototype?t.prototype.toASN&&t.prototype.fromASN?!0:$t(t.prototype):!!(t&&typeof t=="object"&&"toASN"in t&&"fromASN"in t)}function uh(t){var e;if(t){const n=Object.getPrototypeOf(t);return((e=n==null?void 0:n.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:uh(n)}return!1}function G_(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),i=new Uint8Array(e);for(let r=0;r<t.byteLength;r++)if(n[r]!==i[r])return!1;return!0}class J_{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,n=!1){const i=this.items.get(e);if(!i)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(n&&!i.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return i}cache(e){const n=this.get(e);n.schema||(n.schema=this.create(e,!0))}createDefault(e){const n={type:T.Sequence,items:{}},i=this.findParentSchema(e);return i&&(Object.assign(n,i),n.items=Object.assign({},n.items,i.items)),n}create(e,n){const i=this.items.get(e)||this.createDefault(e),r=[];for(const s in i.items){const o=i.items[s],c=n?s:"";let l;if(typeof o.type=="number"){const p=w[o.type],f=ch[p];if(!f)throw new Error(`Cannot get ASN1 class by name '${p}'`);l=new f({name:c})}else $t(o.type)?l=new o.type().toSchema(c):o.optional?this.get(o.type).type===T.Choice?l=new _n({name:c}):(l=this.create(o.type,!1),l.name=c):l=new _n({name:c});const u=!!o.optional||o.defaultValue!==void 0;if(o.repeated){l.name="";const p=o.repeated==="set"?Nt:zt;l=new p({name:"",value:[new Jr({name:c,value:l})]})}if(o.context!==null&&o.context!==void 0)if(o.implicit)if(typeof o.type=="number"||$t(o.type)){const p=o.repeated?De:Wi;r.push(new p({name:c,optional:u,idBlock:{tagClass:3,tagNumber:o.context}}))}else{this.cache(o.type);const p=!!o.repeated;let f=p?l:this.get(o.type,!0).schema;f="valueBlock"in f?f.valueBlock.value:f.value,r.push(new De({name:p?"":c,optional:u,idBlock:{tagClass:3,tagNumber:o.context},value:f}))}else r.push(new De({optional:u,idBlock:{tagClass:3,tagNumber:o.context},value:[l]}));else l.optional=u,r.push(l)}switch(i.type){case T.Sequence:return new zt({value:r,name:""});case T.Set:return new Nt({value:r,name:""});case T.Choice:return new nl({value:r,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,n){return this.items.set(e,n),this}findParentSchema(e){const n=Object.getPrototypeOf(e);return n?this.items.get(n)||this.findParentSchema(n):null}}const Qe=new J_,P=t=>e=>{let n;Qe.has(e)?n=Qe.get(e):(n=Qe.createDefault(e),Qe.set(e,n)),Object.assign(n,t)},g=t=>(e,n)=>{let i;Qe.has(e.constructor)?i=Qe.get(e.constructor):(i=Qe.createDefault(e.constructor),Qe.set(e.constructor,i));const r=Object.assign({},t);if(typeof r.type=="number"&&!r.converter){const s=il(t.type);if(!s)throw new Error(`Cannot get default converter for property '${n}' of ${e.constructor.name}`);r.converter=s}i.items[n]=r};class Eu extends Error{constructor(){super(...arguments),this.schemas=[]}}class Z_{static parse(e,n){const i=Rn(e);if(i.result.error)throw new Error(i.result.error);return this.fromASN(i.result,n)}static fromASN(e,n){var i;try{if($t(n))return new n().fromASN(e);const r=Qe.get(n);Qe.cache(n);let s=r.schema;if(e.constructor===De&&r.type!==T.Choice){s=new De({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:r.schema.valueBlock.value});for(const l in r.items)delete e[l]}const o=an({},e,s);if(!o.verified)throw new Eu(`Data does not match to ${n.name} ASN1 schema. ${o.result.error}`);const c=new n;if(uh(n)){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=il(l);if(!u)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,p=>u.fromASN(p))}else return n.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],f=p.type;if(typeof f=="number"||$t(f)){const m=(i=p.converter)!==null&&i!==void 0?i:$t(f)?new f:null;if(!m)throw new Error("Converter is empty");if(p.repeated)if(p.implicit){const v=p.repeated==="sequence"?zt:Nt,h=new v;h.valueBlock=u.valueBlock;const _=Rn(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 y=_.result.valueBlock.value;c[l]=Array.from(y,x=>m.fromASN(x))}else c[l]=Array.from(u,v=>m.fromASN(v));else{let v=u;if(p.implicit){let h;if($t(f))h=new f().toSchema("");else{const _=w[f],y=ch[_];if(!y)throw new Error(`Cannot get '${_}' class from asn1js module`);h=new y}h.valueBlock=v.valueBlock,v=Rn(h.toBER(!1)).result}c[l]=m.fromASN(v)}}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,f))}else c[l]=this.fromASN(u,f)}return c}catch(r){throw r instanceof Eu&&r.schemas.push(n.name),r}}}class rl{static serialize(e){return e instanceof je?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&$t(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const n=e.constructor,i=Qe.get(n);Qe.cache(n);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=il(i.itemType);if(!o)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);r=e.map(c=>o.toASN(c))}else r=e.map(o=>this.toAsnItem({type:i.itemType},"[]",n,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"&&G_(this.serialize(c.defaultValue),this.serialize(l)))continue;const u=rl.toAsnItem(c,o,n,l);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||$t(c.type))){const p={};p.valueHex=u instanceof mn?u.valueBeforeDecodeView:u.valueBlock.toBER(),r.push(new Wi({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...p}))}else r.push(new De({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:u.valueBlock.value}));else r.push(new De({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 T.Sequence:s=new zt({value:r});break;case T.Set:s=new Nt({value:r});break;case T.Choice:if(!r[0])throw new Error(`Schema '${n.name}' has wrong data. Choice cannot be empty.`);s=r[0];break}return s}static toAsnItem(e,n,i,r){let s;if(typeof e.type=="number"){const o=e.converter;if(!o)throw new Error(`Property '${n}' doesn't have converter for type ${w[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"?zt:Nt;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"?zt:Nt;s=new c({value:o})}else s=this.toASN(r);return s}}class de extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const n of e)this.push(n)}}}class V{static serialize(e){return rl.serialize(e)}static parse(e,n){return Z_.parse(e,n)}static toString(e){const n=M.isBufferSource(e)?M.toArrayBuffer(e):V.serialize(e),i=Rn(n);if(i.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${i.result.error}`);return i.result.toString()}}function d(t,e,n,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,n):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,n,i);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(s=(r<3?o(s):r>3?o(e,n,s):o(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s}var dh={exports:{}};(function(t){(function(e){const n="(0?\\d+|0x[a-f0-9]+)",i={fourOctet:new RegExp(`^${n}\\.${n}\\.${n}\\.${n}$`,"i"),threeOctet:new RegExp(`^${n}\\.${n}\\.${n}$`,"i"),twoOctet:new RegExp(`^${n}\\.${n}$`,"i"),longValue:new RegExp(`^${n}$`,"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(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${n}\\.${n}\\.${n}\\.${n}(${o})?$`,"i")};function u(h,_){if(h.indexOf("::")!==h.lastIndexOf("::"))return null;let y=0,x=-1,C=(h.match(l.zoneIndex)||[])[0],j,R;for(C&&(C=C.substring(1),h=h.replace(/%.+$/,""));(x=h.indexOf(":",x+1))>=0;)y++;if(h.substr(0,2)==="::"&&y--,h.substr(-2,2)==="::"&&y--,y>_)return null;for(R=_-y,j=":";R--;)j+="0:";return h=h.replace("::",j),h[0]===":"&&(h=h.slice(1)),h[h.length-1]===":"&&(h=h.slice(0,-1)),_=function(){const ee=h.split(":"),pe=[];for(let le=0;le<ee.length;le++)pe.push(parseInt(ee[le],16));return pe}(),{parts:_,zoneId:C}}function p(h,_,y,x){if(h.length!==_.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let C=0,j;for(;x>0;){if(j=y-x,j<0&&(j=0),h[C]>>j!==_[C]>>j)return!1;x-=y,C+=1}return!0}function f(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 v={};v.IPv4=function(){function h(_){if(_.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let y,x;for(y=0;y<_.length;y++)if(x=_[y],!(0<=x&&x<=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(_,y){let x;if(y===void 0&&(x=_,_=x[0],y=x[1]),_.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return p(this.octets,_.octets,8,y)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,y=!1;const x={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let C,j,R;for(C=3;C>=0;C-=1)if(j=this.octets[C],j in x){if(R=x[j],y&&R!==0)return null;R!==8&&(y=!0),_+=R}else return null;return 32-_},h.prototype.range=function(){return v.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){return this.octets.slice(0)},h.prototype.toIPv4MappedAddress=function(){return v.IPv6.parse(`::ffff:${this.toString()}`)},h.prototype.toNormalizedString=function(){return this.toString()},h.prototype.toString=function(){return this.octets.join(".")},h}(),v.IPv4.broadcastAddressFromCIDR=function(h){try{const _=this.parseCIDR(h),y=_[0].toByteArray(),x=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[];let j=0;for(;j<4;)C.push(parseInt(y[j],10)|parseInt(x[j],10)^255),j++;return new this(C)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},v.IPv4.isIPv4=function(h){return this.parser(h)!==null},v.IPv4.isValid=function(h){try{return new this(this.parser(h)),!0}catch{return!1}},v.IPv4.isValidCIDR=function(h){try{return this.parseCIDR(h),!0}catch{return!1}},v.IPv4.isValidFourPartDecimal=function(h){return!!(v.IPv4.isValid(h)&&h.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},v.IPv4.networkAddressFromCIDR=function(h){let _,y,x,C,j;try{for(_=this.parseCIDR(h),x=_[0].toByteArray(),j=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[],y=0;y<4;)C.push(parseInt(x[y],10)&parseInt(j[y],10)),y++;return new this(C)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},v.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(_)},v.IPv4.parseCIDR=function(h){let _;if(_=h.match(/^(.+)\/(\d+)$/)){const y=parseInt(_[2]);if(y>=0&&y<=32){const x=[this.parse(_[1]),y];return Object.defineProperty(x,"toString",{value:function(){return this.join("/")}}),x}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},v.IPv4.parser=function(h){let _,y,x;if(_=h.match(i.fourOctet))return function(){const C=_.slice(1,6),j=[];for(let R=0;R<C.length;R++)y=C[R],j.push(f(y));return j}();if(_=h.match(i.longValue)){if(x=f(_[1]),x>4294967295||x<0)throw new Error("ipaddr: address outside defined range");return function(){const C=[];let j;for(j=0;j<=24;j+=8)C.push(x>>j&255);return C}().reverse()}else return(_=h.match(i.twoOctet))?function(){const C=_.slice(1,4),j=[];if(x=f(C[1]),x>16777215||x<0)throw new Error("ipaddr: address outside defined range");return j.push(f(C[0])),j.push(x>>16&255),j.push(x>>8&255),j.push(x&255),j}():(_=h.match(i.threeOctet))?function(){const C=_.slice(1,5),j=[];if(x=f(C[2]),x>65535||x<0)throw new Error("ipaddr: address outside defined range");return j.push(f(C[0])),j.push(f(C[1])),j.push(x>>8&255),j.push(x&255),j}():null},v.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 y=0;const x=Math.floor(h/8);for(;y<x;)_[y]=255,y++;return x<4&&(_[x]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},v.IPv6=function(){function h(_,y){let x,C;if(_.length===16)for(this.parts=[],x=0;x<=14;x+=2)this.parts.push(_[x]<<8|_[x+1]);else if(_.length===8)this.parts=_;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(x=0;x<this.parts.length;x++)if(C=this.parts[x],!(0<=C&&C<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");y&&(this.zoneId=y)}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(_,y){let x;if(y===void 0&&(x=_,_=x[0],y=x[1]),_.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return p(this.parts,_.parts,16,y)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,y=!1;const x={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 C,j;for(let R=7;R>=0;R-=1)if(C=this.parts[R],C in x){if(j=x[C],y&&j!==0)return null;j!==16&&(y=!0),_+=j}else return null;return 128-_},h.prototype.range=function(){return v.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){let _;const y=[],x=this.parts;for(let C=0;C<x.length;C++)_=x[C],y.push(_>>8),y.push(_&255);return y},h.prototype.toFixedLengthString=function(){const _=(function(){const x=[];for(let C=0;C<this.parts.length;C++)x.push(m(this.parts[C].toString(16),4));return x}).call(this).join(":");let y="";return this.zoneId&&(y=`%${this.zoneId}`),_+y},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),y=_[0],x=_[1];return new v.IPv4([y>>8,y&255,x>>8,x&255])},h.prototype.toNormalizedString=function(){const _=(function(){const x=[];for(let C=0;C<this.parts.length;C++)x.push(this.parts[C].toString(16));return x}).call(this).join(":");let y="";return this.zoneId&&(y=`%${this.zoneId}`),_+y},h.prototype.toRFC5952String=function(){const _=/((^|:)(0(:|$)){2,})/g,y=this.toNormalizedString();let x=0,C=-1,j;for(;j=_.exec(y);)j[0].length>C&&(x=j.index,C=j[0].length);return C<0?y:`${y.substring(0,x)}::${y.substring(x+C)}`},h.prototype.toString=function(){return this.toRFC5952String()},h}(),v.IPv6.broadcastAddressFromCIDR=function(h){try{const _=this.parseCIDR(h),y=_[0].toByteArray(),x=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[];let j=0;for(;j<16;)C.push(parseInt(y[j],10)|parseInt(x[j],10)^255),j++;return new this(C)}catch(_){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${_})`)}},v.IPv6.isIPv6=function(h){return this.parser(h)!==null},v.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}},v.IPv6.isValidCIDR=function(h){if(typeof h=="string"&&h.indexOf(":")===-1)return!1;try{return this.parseCIDR(h),!0}catch{return!1}},v.IPv6.networkAddressFromCIDR=function(h){let _,y,x,C,j;try{for(_=this.parseCIDR(h),x=_[0].toByteArray(),j=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[],y=0;y<16;)C.push(parseInt(x[y],10)&parseInt(j[y],10)),y++;return new this(C)}catch(R){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${R})`)}},v.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)},v.IPv6.parseCIDR=function(h){let _,y,x;if((y=h.match(/^(.+)\/(\d+)$/))&&(_=parseInt(y[2]),_>=0&&_<=128))return x=[this.parse(y[1]),_],Object.defineProperty(x,"toString",{value:function(){return this.join("/")}}),x;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},v.IPv6.parser=function(h){let _,y,x,C,j,R;if(x=h.match(l.deprecatedTransitional))return this.parser(`::ffff:${x[1]}`);if(l.native.test(h))return u(h,8);if((x=h.match(l.transitional))&&(R=x[6]||"",_=x[1],x[1].endsWith("::")||(_=_.slice(0,-1)),_=u(_+R,6),_.parts)){for(j=[parseInt(x[2]),parseInt(x[3]),parseInt(x[4]),parseInt(x[5])],y=0;y<j.length;y++)if(C=j[y],!(0<=C&&C<=255))return null;return _.parts.push(j[0]<<8|j[1]),_.parts.push(j[2]<<8|j[3]),{parts:_.parts,zoneId:_.zoneId}}return null},v.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 y=0;const x=Math.floor(h/8);for(;y<x;)_[y]=255,y++;return x<16&&(_[x]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},v.fromByteArray=function(h){const _=h.length;if(_===4)return new v.IPv4(h);if(_===16)return new v.IPv6(h);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},v.isValid=function(h){return v.IPv6.isValid(h)||v.IPv4.isValid(h)},v.isValidCIDR=function(h){return v.IPv6.isValidCIDR(h)||v.IPv4.isValidCIDR(h)},v.parse=function(h){if(v.IPv6.isValid(h))return v.IPv6.parse(h);if(v.IPv4.isValid(h))return v.IPv4.parse(h);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},v.parseCIDR=function(h){try{return v.IPv6.parseCIDR(h)}catch{try{return v.IPv4.parseCIDR(h)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},v.process=function(h){const _=this.parse(h);return _.kind()==="ipv6"&&_.isIPv4MappedAddress()?_.toIPv4Address():_},v.subnetMatch=function(h,_,y){let x,C,j,R;y==null&&(y="unicast");for(C in _)if(Object.prototype.hasOwnProperty.call(_,C)){for(j=_[C],j[0]&&!(j[0]instanceof Array)&&(j=[j]),x=0;x<j.length;x++)if(R=j[x],h.kind()===R[0].kind()&&h.match.apply(h,R))return C}return y},t.exports?t.exports=v:e.ipaddr=v})(Wr)})(dh);var Iu=dh.exports;class Cu{static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const n=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}/${n}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const n=new Uint8Array(e);return Iu.fromByteArray(Array.from(n)).toString()}return this.decodeIP(G.ToHex(e))}static fromString(e){const n=Iu.parse(e);return new Uint8Array(n.toByteArray()).buffer}}var ga,ma,_a;let Oe=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};d([g({type:w.TeletexString})],Oe.prototype,"teletexString",void 0);d([g({type:w.PrintableString})],Oe.prototype,"printableString",void 0);d([g({type:w.UniversalString})],Oe.prototype,"universalString",void 0);d([g({type:w.Utf8String})],Oe.prototype,"utf8String",void 0);d([g({type:w.BmpString})],Oe.prototype,"bmpString",void 0);Oe=d([P({type:T.Choice})],Oe);let Mn=class extends Oe{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?G.ToHex(this.anyValue):super.toString())}};d([g({type:w.IA5String})],Mn.prototype,"ia5String",void 0);d([g({type:w.Any})],Mn.prototype,"anyValue",void 0);Mn=d([P({type:T.Choice})],Mn);class ro{constructor(e={}){this.type="",this.value=new Mn,Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],ro.prototype,"type",void 0);d([g({type:Mn})],ro.prototype,"value",void 0);let Dn=ga=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ga.prototype)}};Dn=ga=d([P({type:T.Set,itemType:ro})],Dn);let ya=ma=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ma.prototype)}};ya=ma=d([P({type:T.Sequence,itemType:Dn})],ya);let ke=_a=class extends ya{constructor(e){super(e),Object.setPrototypeOf(this,_a.prototype)}};ke=_a=d([P({type:T.Sequence})],ke);const Y_={fromASN:t=>Cu.toString(Zr.fromASN(t)),toASN:t=>Zr.toASN(Cu.fromString(t))};class zi{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],zi.prototype,"typeId",void 0);d([g({type:w.Any,context:0})],zi.prototype,"value",void 0);class sl{constructor(e={}){this.partyName=new Oe,Object.assign(this,e)}}d([g({type:Oe,optional:!0,context:0,implicit:!0})],sl.prototype,"nameAssigner",void 0);d([g({type:Oe,context:1,implicit:!0})],sl.prototype,"partyName",void 0);let ne=class{constructor(e={}){Object.assign(this,e)}};d([g({type:zi,context:0,implicit:!0})],ne.prototype,"otherName",void 0);d([g({type:w.IA5String,context:1,implicit:!0})],ne.prototype,"rfc822Name",void 0);d([g({type:w.IA5String,context:2,implicit:!0})],ne.prototype,"dNSName",void 0);d([g({type:w.Any,context:3,implicit:!0})],ne.prototype,"x400Address",void 0);d([g({type:ke,context:4,implicit:!1})],ne.prototype,"directoryName",void 0);d([g({type:sl,context:5})],ne.prototype,"ediPartyName",void 0);d([g({type:w.IA5String,context:6,implicit:!0})],ne.prototype,"uniformResourceIdentifier",void 0);d([g({type:w.OctetString,context:7,implicit:!0,converter:Y_})],ne.prototype,"iPAddress",void 0);d([g({type:w.ObjectIdentifier,context:8,implicit:!0})],ne.prototype,"registeredID",void 0);ne=d([P({type:T.Choice})],ne);const ol="1.3.6.1.5.5.7",X_=`${ol}.1`,ti=`${ol}.3`,so=`${ol}.48`,$u=`${so}.1`,zu=`${so}.2`,Nu=`${so}.3`,ju=`${so}.5`,Xt="2.5.29";var va;const wa=`${X_}.1`;class Zi{constructor(e={}){this.accessMethod="",this.accessLocation=new ne,Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],Zi.prototype,"accessMethod",void 0);d([g({type:ne})],Zi.prototype,"accessLocation",void 0);let Tn=va=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,va.prototype)}};Tn=va=d([P({type:T.Sequence,itemType:Zi})],Tn);const ba=`${Xt}.35`;class al extends ae{}class cn{constructor(e={}){e&&Object.assign(this,e)}}d([g({type:al,context:0,optional:!0,implicit:!0})],cn.prototype,"keyIdentifier",void 0);d([g({type:ne,context:1,optional:!0,implicit:!0,repeated:"sequence"})],cn.prototype,"authorityCertIssuer",void 0);d([g({type:w.Integer,context:2,optional:!0,implicit:!0,converter:_e})],cn.prototype,"authorityCertSerialNumber",void 0);const ph=`${Xt}.19`;class Yr{constructor(e={}){this.cA=!1,Object.assign(this,e)}}d([g({type:w.Boolean,defaultValue:!1})],Yr.prototype,"cA",void 0);d([g({type:w.Integer,optional:!0})],Yr.prototype,"pathLenConstraint",void 0);var ka;let Re=ka=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ka.prototype)}};Re=ka=d([P({type:T.Sequence,itemType:ne})],Re);var xa;let Ou=xa=class extends Re{constructor(e){super(e),Object.setPrototypeOf(this,xa.prototype)}};Ou=xa=d([P({type:T.Sequence})],Ou);var Sa;const fh=`${Xt}.32`;let jt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};d([g({type:w.IA5String})],jt.prototype,"ia5String",void 0);d([g({type:w.VisibleString})],jt.prototype,"visibleString",void 0);d([g({type:w.BmpString})],jt.prototype,"bmpString",void 0);d([g({type:w.Utf8String})],jt.prototype,"utf8String",void 0);jt=d([P({type:T.Choice})],jt);class cl{constructor(e={}){this.organization=new jt,this.noticeNumbers=[],Object.assign(this,e)}}d([g({type:jt})],cl.prototype,"organization",void 0);d([g({type:w.Integer,repeated:"sequence"})],cl.prototype,"noticeNumbers",void 0);class ll{constructor(e={}){Object.assign(this,e)}}d([g({type:cl,optional:!0})],ll.prototype,"noticeRef",void 0);d([g({type:jt,optional:!0})],ll.prototype,"explicitText",void 0);let Xr=class{constructor(e={}){Object.assign(this,e)}};d([g({type:w.IA5String})],Xr.prototype,"cPSuri",void 0);d([g({type:ll})],Xr.prototype,"userNotice",void 0);Xr=d([P({type:T.Choice})],Xr);class ul{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],ul.prototype,"policyQualifierId",void 0);d([g({type:w.Any})],ul.prototype,"qualifier",void 0);class oo{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],oo.prototype,"policyIdentifier",void 0);d([g({type:ul,repeated:"sequence",optional:!0})],oo.prototype,"policyQualifiers",void 0);let Qr=Sa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Sa.prototype)}};Qr=Sa=d([P({type:T.Sequence,itemType:oo})],Qr);let es=class{constructor(e=0){this.value=e}};d([g({type:w.Integer})],es.prototype,"value",void 0);es=d([P({type:T.Choice})],es);let Bu=class extends es{};Bu=d([P({type:T.Choice})],Bu);var Aa;const Ea=`${Xt}.31`;var ct;(function(t){t[t.unused=1]="unused",t[t.keyCompromise=2]="keyCompromise",t[t.cACompromise=4]="cACompromise",t[t.affiliationChanged=8]="affiliationChanged",t[t.superseded=16]="superseded",t[t.cessationOfOperation=32]="cessationOfOperation",t[t.certificateHold=64]="certificateHold",t[t.privilegeWithdrawn=128]="privilegeWithdrawn",t[t.aACompromise=256]="aACompromise"})(ct||(ct={}));class hh extends io{toJSON(){const e=[],n=this.toNumber();return n&ct.aACompromise&&e.push("aACompromise"),n&ct.affiliationChanged&&e.push("affiliationChanged"),n&ct.cACompromise&&e.push("cACompromise"),n&ct.certificateHold&&e.push("certificateHold"),n&ct.cessationOfOperation&&e.push("cessationOfOperation"),n&ct.keyCompromise&&e.push("keyCompromise"),n&ct.privilegeWithdrawn&&e.push("privilegeWithdrawn"),n&ct.superseded&&e.push("superseded"),n&ct.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let yn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ne,context:0,repeated:"sequence",implicit:!0})],yn.prototype,"fullName",void 0);d([g({type:Dn,context:1,implicit:!0})],yn.prototype,"nameRelativeToCRLIssuer",void 0);yn=d([P({type:T.Choice})],yn);class ni{constructor(e={}){Object.assign(this,e)}}d([g({type:yn,context:0,optional:!0})],ni.prototype,"distributionPoint",void 0);d([g({type:hh,context:1,optional:!0,implicit:!0})],ni.prototype,"reasons",void 0);d([g({type:ne,context:2,optional:!0,repeated:"sequence",implicit:!0})],ni.prototype,"cRLIssuer",void 0);let Ln=Aa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Aa.prototype)}};Ln=Aa=d([P({type:T.Sequence,itemType:ni})],Ln);var Ia;let Tu=Ia=class extends Ln{constructor(e){super(e),Object.setPrototypeOf(this,Ia.prototype)}};Tu=Ia=d([P({type:T.Sequence,itemType:ni})],Tu);class Te{constructor(e={}){this.onlyContainsUserCerts=Te.ONLY,this.onlyContainsCACerts=Te.ONLY,this.indirectCRL=Te.ONLY,this.onlyContainsAttributeCerts=Te.ONLY,Object.assign(this,e)}}Te.ONLY=!1;d([g({type:yn,context:0,optional:!0})],Te.prototype,"distributionPoint",void 0);d([g({type:w.Boolean,context:1,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"onlyContainsUserCerts",void 0);d([g({type:w.Boolean,context:2,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"onlyContainsCACerts",void 0);d([g({type:hh,context:3,optional:!0,implicit:!0})],Te.prototype,"onlySomeReasons",void 0);d([g({type:w.Boolean,context:4,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"indirectCRL",void 0);d([g({type:w.Boolean,context:5,defaultValue:Te.ONLY,implicit:!0})],Te.prototype,"onlyContainsAttributeCerts",void 0);var ki;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(ki||(ki={}));let Ca=class{constructor(e=ki.unspecified){this.reason=ki.unspecified,this.reason=e}toJSON(){return ki[this.reason]}toString(){return this.toJSON()}};d([g({type:w.Enumerated})],Ca.prototype,"reason",void 0);Ca=d([P({type:T.Choice})],Ca);var $a;const gh=`${Xt}.37`;let ts=$a=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,$a.prototype)}};ts=$a=d([P({type:T.Sequence,itemType:w.ObjectIdentifier})],ts);const Q_=`${ti}.1`,e0=`${ti}.2`,t0=`${ti}.3`,n0=`${ti}.4`,i0=`${ti}.8`,r0=`${ti}.9`;let za=class{constructor(e=new ArrayBuffer(0)){this.value=e}};d([g({type:w.Integer,converter:_e})],za.prototype,"value",void 0);za=d([P({type:T.Choice})],za);let Na=class{constructor(e){this.value=new Date,e&&(this.value=e)}};d([g({type:w.GeneralizedTime})],Na.prototype,"value",void 0);Na=d([P({type:T.Choice})],Na);var ja;let Pu=ja=class extends Re{constructor(e){super(e),Object.setPrototypeOf(this,ja.prototype)}};Pu=ja=d([P({type:T.Sequence})],Pu);const mh=`${Xt}.15`;var lt;(function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"})(lt||(lt={}));class Ho extends io{toJSON(){const e=this.toNumber(),n=[];return e<.cRLSign&&n.push("crlSign"),e<.dataEncipherment&&n.push("dataEncipherment"),e<.decipherOnly&&n.push("decipherOnly"),e<.digitalSignature&&n.push("digitalSignature"),e<.encipherOnly&&n.push("encipherOnly"),e<.keyAgreement&&n.push("keyAgreement"),e<.keyCertSign&&n.push("keyCertSign"),e<.keyEncipherment&&n.push("keyEncipherment"),e<.nonRepudiation&&n.push("nonRepudiation"),n}toString(){return`[${this.toJSON().join(", ")}]`}}var Oa;class ao{constructor(e={}){this.base=new ne,this.minimum=0,Object.assign(this,e)}}d([g({type:ne})],ao.prototype,"base",void 0);d([g({type:w.Integer,context:0,defaultValue:0,implicit:!0})],ao.prototype,"minimum",void 0);d([g({type:w.Integer,context:1,optional:!0,implicit:!0})],ao.prototype,"maximum",void 0);let ns=Oa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Oa.prototype)}};ns=Oa=d([P({type:T.Sequence,itemType:ao})],ns);class _h{constructor(e={}){Object.assign(this,e)}}d([g({type:ns,context:0,optional:!0,implicit:!0})],_h.prototype,"permittedSubtrees",void 0);d([g({type:ns,context:1,optional:!0,implicit:!0})],_h.prototype,"excludedSubtrees",void 0);class yh{constructor(e={}){Object.assign(this,e)}}d([g({type:w.Integer,context:0,implicit:!0,optional:!0,converter:_e})],yh.prototype,"requireExplicitPolicy",void 0);d([g({type:w.Integer,context:1,implicit:!0,optional:!0,converter:_e})],yh.prototype,"inhibitPolicyMapping",void 0);var Ba;class dl{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],dl.prototype,"issuerDomainPolicy",void 0);d([g({type:w.ObjectIdentifier})],dl.prototype,"subjectDomainPolicy",void 0);let Ru=Ba=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ba.prototype)}};Ru=Ba=d([P({type:T.Sequence,itemType:dl})],Ru);var Ta;const vh=`${Xt}.17`;let Pa=Ta=class extends Re{constructor(e){super(e),Object.setPrototypeOf(this,Ta.prototype)}};Pa=Ta=d([P({type:T.Sequence})],Pa);let Ot=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};d([g({type:w.ObjectIdentifier})],Ot.prototype,"type",void 0);d([g({type:w.Any,repeated:"set"})],Ot.prototype,"values",void 0);var Ra;let Lu=Ra=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ra.prototype)}};Lu=Ra=d([P({type:T.Sequence,itemType:Ot})],Lu);const wh=`${Xt}.14`;class Ft extends al{}class bh{constructor(e={}){Object.assign(this,e)}}d([g({type:w.GeneralizedTime,context:0,implicit:!0,optional:!0})],bh.prototype,"notBefore",void 0);d([g({type:w.GeneralizedTime,context:1,implicit:!0,optional:!0})],bh.prototype,"notAfter",void 0);var xi;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate"})(xi||(xi={}));class kh extends io{toJSON(){const e=[],n=this.toNumber();return n&xi.pKIXCertificate&&e.push("pKIXCertificate"),n&xi.newExtensions&&e.push("newExtensions"),n&xi.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class xh{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new kh,Object.assign(this,e)}}d([g({type:w.GeneralString})],xh.prototype,"entrustVers",void 0);d([g({type:kh})],xh.prototype,"entrustInfoFlags",void 0);var La;let Uu=La=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,La.prototype)}};Uu=La=d([P({type:T.Sequence,itemType:Zi})],Uu);class F{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof F&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&lf(e.parameters,this.parameters)||e.parameters===this.parameters)}}d([g({type:w.ObjectIdentifier})],F.prototype,"algorithm",void 0);d([g({type:w.Any,optional:!0})],F.prototype,"parameters",void 0);class ut{constructor(e={}){this.algorithm=new F,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:F})],ut.prototype,"algorithm",void 0);d([g({type:w.BitString})],ut.prototype,"subjectPublicKey",void 0);let Ne=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){const n=new Date(e);n.getUTCFullYear()>2049?this.generalTime=n:this.utcTime=n}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([g({type:w.UTCTime})],Ne.prototype,"utcTime",void 0);d([g({type:w.GeneralizedTime})],Ne.prototype,"generalTime",void 0);Ne=d([P({type:T.Choice})],Ne);class Yi{constructor(e){this.notBefore=new Ne(new Date),this.notAfter=new Ne(new Date),e&&(this.notBefore=new Ne(e.notBefore),this.notAfter=new Ne(e.notAfter))}}d([g({type:Ne})],Yi.prototype,"notBefore",void 0);d([g({type:Ne})],Yi.prototype,"notAfter",void 0);var Ua;let nt=class Sh{constructor(e={}){this.extnID="",this.critical=Sh.CRITICAL,this.extnValue=new ae,Object.assign(this,e)}};nt.CRITICAL=!1;d([g({type:w.ObjectIdentifier})],nt.prototype,"extnID",void 0);d([g({type:w.Boolean,defaultValue:nt.CRITICAL})],nt.prototype,"critical",void 0);d([g({type:ae})],nt.prototype,"extnValue",void 0);let Gt=Ua=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ua.prototype)}};Gt=Ua=d([P({type:T.Sequence,itemType:nt})],Gt);var vn;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3"})(vn||(vn={}));class Ye{constructor(e={}){this.version=vn.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new F,this.issuer=new ke,this.validity=new Yi,this.subject=new ke,this.subjectPublicKeyInfo=new ut,Object.assign(this,e)}}d([g({type:w.Integer,context:0,defaultValue:vn.v1})],Ye.prototype,"version",void 0);d([g({type:w.Integer,converter:_e})],Ye.prototype,"serialNumber",void 0);d([g({type:F})],Ye.prototype,"signature",void 0);d([g({type:ke})],Ye.prototype,"issuer",void 0);d([g({type:Yi})],Ye.prototype,"validity",void 0);d([g({type:ke})],Ye.prototype,"subject",void 0);d([g({type:ut})],Ye.prototype,"subjectPublicKeyInfo",void 0);d([g({type:w.BitString,context:1,implicit:!0,optional:!0})],Ye.prototype,"issuerUniqueID",void 0);d([g({type:w.BitString,context:2,implicit:!0,optional:!0})],Ye.prototype,"subjectUniqueID",void 0);d([g({type:Gt,context:3,optional:!0})],Ye.prototype,"extensions",void 0);class wn{constructor(e={}){this.tbsCertificate=new Ye,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:Ye})],wn.prototype,"tbsCertificate",void 0);d([g({type:F})],wn.prototype,"signatureAlgorithm",void 0);d([g({type:w.BitString})],wn.prototype,"signatureValue",void 0);class co{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Ne,Object.assign(this,e)}}d([g({type:w.Integer,converter:_e})],co.prototype,"userCertificate",void 0);d([g({type:Ne})],co.prototype,"revocationDate",void 0);d([g({type:nt,optional:!0,repeated:"sequence"})],co.prototype,"crlEntryExtensions",void 0);class Ut{constructor(e={}){this.signature=new F,this.issuer=new ke,this.thisUpdate=new Ne,Object.assign(this,e)}}d([g({type:w.Integer,optional:!0})],Ut.prototype,"version",void 0);d([g({type:F})],Ut.prototype,"signature",void 0);d([g({type:ke})],Ut.prototype,"issuer",void 0);d([g({type:Ne})],Ut.prototype,"thisUpdate",void 0);d([g({type:Ne,optional:!0})],Ut.prototype,"nextUpdate",void 0);d([g({type:co,repeated:"sequence",optional:!0})],Ut.prototype,"revokedCertificates",void 0);d([g({type:nt,optional:!0,context:0,repeated:"sequence"})],Ut.prototype,"crlExtensions",void 0);class pl{constructor(e={}){this.tbsCertList=new Ut,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:Ut})],pl.prototype,"tbsCertList",void 0);d([g({type:F})],pl.prototype,"signatureAlgorithm",void 0);d([g({type:w.BitString})],pl.prototype,"signature",void 0);class ii{constructor(e={}){this.issuer=new ke,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:ke})],ii.prototype,"issuer",void 0);d([g({type:w.Integer,converter:_e})],ii.prototype,"serialNumber",void 0);let Hn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Ft,context:0,implicit:!0})],Hn.prototype,"subjectKeyIdentifier",void 0);d([g({type:ii})],Hn.prototype,"issuerAndSerialNumber",void 0);Hn=d([P({type:T.Choice})],Hn);var Bt;(function(t){t[t.v0=0]="v0",t[t.v1=1]="v1",t[t.v2=2]="v2",t[t.v3=3]="v3",t[t.v4=4]="v4",t[t.v5=5]="v5"})(Bt||(Bt={}));let Ni=class extends F{};Ni=d([P({type:T.Sequence})],Ni);let is=class extends F{};is=d([P({type:T.Sequence})],is);let kt=class extends F{};kt=d([P({type:T.Sequence})],kt);let rs=class extends F{};rs=d([P({type:T.Sequence})],rs);let Vu=class extends F{};Vu=d([P({type:T.Sequence})],Vu);let Va=class extends F{};Va=d([P({type:T.Sequence})],Va);let ri=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};d([g({type:w.ObjectIdentifier})],ri.prototype,"attrType",void 0);d([g({type:w.Any,repeated:"set"})],ri.prototype,"attrValues",void 0);var Ma;class Et{constructor(e={}){this.version=Bt.v0,this.sid=new Hn,this.digestAlgorithm=new Ni,this.signatureAlgorithm=new is,this.signature=new ae,Object.assign(this,e)}}d([g({type:w.Integer})],Et.prototype,"version",void 0);d([g({type:Hn})],Et.prototype,"sid",void 0);d([g({type:Ni})],Et.prototype,"digestAlgorithm",void 0);d([g({type:ri,repeated:"set",context:0,implicit:!0,optional:!0})],Et.prototype,"signedAttrs",void 0);d([g({type:is})],Et.prototype,"signatureAlgorithm",void 0);d([g({type:ae})],Et.prototype,"signature",void 0);d([g({type:ri,repeated:"set",context:1,implicit:!0,optional:!0})],Et.prototype,"unsignedAttrs",void 0);let ss=Ma=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ma.prototype)}};ss=Ma=d([P({type:T.Set,itemType:Et})],ss);let Mu=class extends Ne{};Mu=d([P({type:T.Choice})],Mu);let Du=class extends Et{};Du=d([P({type:T.Sequence})],Du);class fl{constructor(e={}){this.acIssuer=new ne,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}d([g({type:ne})],fl.prototype,"acIssuer",void 0);d([g({type:w.Integer})],fl.prototype,"acSerial",void 0);d([g({type:Ot,repeated:"sequence"})],fl.prototype,"attrs",void 0);var Da;let os=Da=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Da.prototype)}};os=Da=d([P({type:T.Sequence,itemType:w.ObjectIdentifier})],os);class lo{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}d([g({type:w.Integer,optional:!0})],lo.prototype,"pathLenConstraint",void 0);d([g({type:os,implicit:!0,context:0,optional:!0})],lo.prototype,"permittedAttrs",void 0);d([g({type:os,implicit:!0,context:1,optional:!0})],lo.prototype,"excludedAttrs",void 0);d([g({type:w.Boolean,defaultValue:!0})],lo.prototype,"permitUnSpecified",void 0);class Cn{constructor(e={}){this.issuer=new Re,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:Re})],Cn.prototype,"issuer",void 0);d([g({type:w.Integer,converter:_e})],Cn.prototype,"serial",void 0);d([g({type:w.BitString,optional:!0})],Cn.prototype,"issuerUID",void 0);var Ha;(function(t){t[t.publicKey=0]="publicKey",t[t.publicKeyCert=1]="publicKeyCert",t[t.otherObjectTypes=2]="otherObjectTypes"})(Ha||(Ha={}));class $n{constructor(e={}){this.digestedObjectType=Ha.publicKey,this.digestAlgorithm=new F,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.Enumerated})],$n.prototype,"digestedObjectType",void 0);d([g({type:w.ObjectIdentifier,optional:!0})],$n.prototype,"otherObjectTypeID",void 0);d([g({type:F})],$n.prototype,"digestAlgorithm",void 0);d([g({type:w.BitString})],$n.prototype,"objectDigest",void 0);class uo{constructor(e={}){Object.assign(this,e)}}d([g({type:Re,optional:!0})],uo.prototype,"issuerName",void 0);d([g({type:Cn,context:0,implicit:!0,optional:!0})],uo.prototype,"baseCertificateID",void 0);d([g({type:$n,context:1,implicit:!0,optional:!0})],uo.prototype,"objectDigestInfo",void 0);let Fn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ne,repeated:"sequence"})],Fn.prototype,"v1Form",void 0);d([g({type:uo,context:0,implicit:!0})],Fn.prototype,"v2Form",void 0);Fn=d([P({type:T.Choice})],Fn);class po{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}d([g({type:w.GeneralizedTime})],po.prototype,"notBeforeTime",void 0);d([g({type:w.GeneralizedTime})],po.prototype,"notAfterTime",void 0);class Xi{constructor(e={}){Object.assign(this,e)}}d([g({type:Cn,implicit:!0,context:0,optional:!0})],Xi.prototype,"baseCertificateID",void 0);d([g({type:Re,implicit:!0,context:1,optional:!0})],Xi.prototype,"entityName",void 0);d([g({type:$n,implicit:!0,context:2,optional:!0})],Xi.prototype,"objectDigestInfo",void 0);var Fa;(function(t){t[t.v2=1]="v2"})(Fa||(Fa={}));class gt{constructor(e={}){this.version=Fa.v2,this.holder=new Xi,this.issuer=new Fn,this.signature=new F,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new po,this.attributes=[],Object.assign(this,e)}}d([g({type:w.Integer})],gt.prototype,"version",void 0);d([g({type:Xi})],gt.prototype,"holder",void 0);d([g({type:Fn})],gt.prototype,"issuer",void 0);d([g({type:F})],gt.prototype,"signature",void 0);d([g({type:w.Integer,converter:_e})],gt.prototype,"serialNumber",void 0);d([g({type:po})],gt.prototype,"attrCertValidityPeriod",void 0);d([g({type:Ot,repeated:"sequence"})],gt.prototype,"attributes",void 0);d([g({type:w.BitString,optional:!0})],gt.prototype,"issuerUniqueID",void 0);d([g({type:Gt,optional:!0})],gt.prototype,"extensions",void 0);class fo{constructor(e={}){this.acinfo=new gt,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:gt})],fo.prototype,"acinfo",void 0);d([g({type:F})],fo.prototype,"signatureAlgorithm",void 0);d([g({type:w.BitString})],fo.prototype,"signatureValue",void 0);var as;(function(t){t[t.unmarked=1]="unmarked",t[t.unclassified=2]="unclassified",t[t.restricted=4]="restricted",t[t.confidential=8]="confidential",t[t.secret=16]="secret",t[t.topSecret=32]="topSecret"})(as||(as={}));class qa extends io{}class hl{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier,implicit:!0,context:0})],hl.prototype,"type",void 0);d([g({type:w.Any,implicit:!0,context:1})],hl.prototype,"value",void 0);class gl{constructor(e={}){this.policyId="",this.classList=new qa(as.unclassified),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],gl.prototype,"policyId",void 0);d([g({type:qa,defaultValue:new qa(as.unclassified)})],gl.prototype,"classList",void 0);d([g({type:hl,repeated:"set"})],gl.prototype,"securityCategories",void 0);class ho{constructor(e={}){Object.assign(this,e)}}d([g({type:ae})],ho.prototype,"cotets",void 0);d([g({type:w.ObjectIdentifier})],ho.prototype,"oid",void 0);d([g({type:w.Utf8String})],ho.prototype,"string",void 0);class Ah{constructor(e={}){this.values=[],Object.assign(this,e)}}d([g({type:Re,implicit:!0,context:0,optional:!0})],Ah.prototype,"policyAuthority",void 0);d([g({type:ho,repeated:"sequence"})],Ah.prototype,"values",void 0);var Ka;class go{constructor(e={}){this.targetCertificate=new Cn,Object.assign(this,e)}}d([g({type:Cn})],go.prototype,"targetCertificate",void 0);d([g({type:ne,optional:!0})],go.prototype,"targetName",void 0);d([g({type:$n,optional:!0})],go.prototype,"certDigestInfo",void 0);let qn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ne,context:0,implicit:!0})],qn.prototype,"targetName",void 0);d([g({type:ne,context:1,implicit:!0})],qn.prototype,"targetGroup",void 0);d([g({type:go,context:2,implicit:!0})],qn.prototype,"targetCert",void 0);qn=d([P({type:T.Choice})],qn);let Wa=Ka=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ka.prototype)}};Wa=Ka=d([P({type:T.Sequence,itemType:qn})],Wa);var Ga;let Hu=Ga=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ga.prototype)}};Hu=Ga=d([P({type:T.Sequence,itemType:Wa})],Hu);class Eh{constructor(e={}){Object.assign(this,e)}}d([g({type:Re,implicit:!0,context:0,optional:!0})],Eh.prototype,"roleAuthority",void 0);d([g({type:ne,implicit:!0,context:1})],Eh.prototype,"roleName",void 0);class ml{constructor(e={}){this.service=new ne,this.ident=new ne,Object.assign(this,e)}}d([g({type:ne})],ml.prototype,"service",void 0);d([g({type:ne})],ml.prototype,"ident",void 0);d([g({type:ae,optional:!0})],ml.prototype,"authInfo",void 0);var Ja;class _l{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],_l.prototype,"otherCertFormat",void 0);d([g({type:w.Any})],_l.prototype,"otherCert",void 0);let Kn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:wn})],Kn.prototype,"certificate",void 0);d([g({type:fo,context:2,implicit:!0})],Kn.prototype,"v2AttrCert",void 0);d([g({type:_l,context:3,implicit:!0})],Kn.prototype,"other",void 0);Kn=d([P({type:T.Choice})],Kn);let cs=Ja=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ja.prototype)}};cs=Ja=d([P({type:T.Set,itemType:Kn})],cs);class si{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],si.prototype,"contentType",void 0);d([g({type:w.Any,context:0})],si.prototype,"content",void 0);let ji=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ae})],ji.prototype,"single",void 0);d([g({type:w.Any})],ji.prototype,"any",void 0);ji=d([P({type:T.Choice})],ji);class mo{constructor(e={}){this.eContentType="",Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],mo.prototype,"eContentType",void 0);d([g({type:ji,context:0,optional:!0})],mo.prototype,"eContent",void 0);let Oi=class{constructor(e={}){Object.assign(this,e)}};d([g({type:ae,context:0,implicit:!0,optional:!0})],Oi.prototype,"value",void 0);d([g({type:ae,converter:O_,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Oi.prototype,"constructedValue",void 0);Oi=d([P({type:T.Choice})],Oi);class Qi{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new rs,Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],Qi.prototype,"contentType",void 0);d([g({type:rs})],Qi.prototype,"contentEncryptionAlgorithm",void 0);d([g({type:Oi,optional:!0})],Qi.prototype,"encryptedContent",void 0);class _o{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],_o.prototype,"keyAttrId",void 0);d([g({type:w.Any,optional:!0})],_o.prototype,"keyAttr",void 0);var Za;class yo{constructor(e={}){this.subjectKeyIdentifier=new Ft,Object.assign(this,e)}}d([g({type:Ft})],yo.prototype,"subjectKeyIdentifier",void 0);d([g({type:w.GeneralizedTime,optional:!0})],yo.prototype,"date",void 0);d([g({type:_o,optional:!0})],yo.prototype,"other",void 0);let Wn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:yo,context:0,implicit:!0,optional:!0})],Wn.prototype,"rKeyId",void 0);d([g({type:ii,optional:!0})],Wn.prototype,"issuerAndSerialNumber",void 0);Wn=d([P({type:T.Choice})],Wn);class yl{constructor(e={}){this.rid=new Wn,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:Wn})],yl.prototype,"rid",void 0);d([g({type:ae})],yl.prototype,"encryptedKey",void 0);let ls=Za=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Za.prototype)}};ls=Za=d([P({type:T.Sequence,itemType:yl})],ls);class vl{constructor(e={}){this.algorithm=new F,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:F})],vl.prototype,"algorithm",void 0);d([g({type:w.BitString})],vl.prototype,"publicKey",void 0);let bn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Ft,context:0,implicit:!0,optional:!0})],bn.prototype,"subjectKeyIdentifier",void 0);d([g({type:vl,context:1,implicit:!0,optional:!0})],bn.prototype,"originatorKey",void 0);d([g({type:ii,optional:!0})],bn.prototype,"issuerAndSerialNumber",void 0);bn=d([P({type:T.Choice})],bn);class oi{constructor(e={}){this.version=Bt.v3,this.originator=new bn,this.keyEncryptionAlgorithm=new kt,this.recipientEncryptedKeys=new ls,Object.assign(this,e)}}d([g({type:w.Integer})],oi.prototype,"version",void 0);d([g({type:bn,context:0})],oi.prototype,"originator",void 0);d([g({type:ae,context:1,optional:!0})],oi.prototype,"ukm",void 0);d([g({type:kt})],oi.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ls})],oi.prototype,"recipientEncryptedKeys",void 0);let Gn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:Ft,context:0,implicit:!0})],Gn.prototype,"subjectKeyIdentifier",void 0);d([g({type:ii})],Gn.prototype,"issuerAndSerialNumber",void 0);Gn=d([P({type:T.Choice})],Gn);class er{constructor(e={}){this.version=Bt.v0,this.rid=new Gn,this.keyEncryptionAlgorithm=new kt,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:w.Integer})],er.prototype,"version",void 0);d([g({type:Gn})],er.prototype,"rid",void 0);d([g({type:kt})],er.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ae})],er.prototype,"encryptedKey",void 0);class tr{constructor(e={}){this.keyIdentifier=new ae,Object.assign(this,e)}}d([g({type:ae})],tr.prototype,"keyIdentifier",void 0);d([g({type:w.GeneralizedTime,optional:!0})],tr.prototype,"date",void 0);d([g({type:_o,optional:!0})],tr.prototype,"other",void 0);class nr{constructor(e={}){this.version=Bt.v4,this.kekid=new tr,this.keyEncryptionAlgorithm=new kt,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:w.Integer})],nr.prototype,"version",void 0);d([g({type:tr})],nr.prototype,"kekid",void 0);d([g({type:kt})],nr.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ae})],nr.prototype,"encryptedKey",void 0);class ir{constructor(e={}){this.version=Bt.v0,this.keyEncryptionAlgorithm=new kt,this.encryptedKey=new ae,Object.assign(this,e)}}d([g({type:w.Integer})],ir.prototype,"version",void 0);d([g({type:Va,context:0,optional:!0})],ir.prototype,"keyDerivationAlgorithm",void 0);d([g({type:kt})],ir.prototype,"keyEncryptionAlgorithm",void 0);d([g({type:ae})],ir.prototype,"encryptedKey",void 0);class wl{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],wl.prototype,"oriType",void 0);d([g({type:w.Any})],wl.prototype,"oriValue",void 0);let Jt=class{constructor(e={}){Object.assign(this,e)}};d([g({type:er,optional:!0})],Jt.prototype,"ktri",void 0);d([g({type:oi,context:1,implicit:!0,optional:!0})],Jt.prototype,"kari",void 0);d([g({type:nr,context:2,implicit:!0,optional:!0})],Jt.prototype,"kekri",void 0);d([g({type:ir,context:3,implicit:!0,optional:!0})],Jt.prototype,"pwri",void 0);d([g({type:wl,context:4,implicit:!0,optional:!0})],Jt.prototype,"ori",void 0);Jt=d([P({type:T.Choice})],Jt);var Ya;let us=Ya=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ya.prototype)}};us=Ya=d([P({type:T.Set,itemType:Jt})],us);var Xa;class vo{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],vo.prototype,"otherRevInfoFormat",void 0);d([g({type:w.Any})],vo.prototype,"otherRevInfo",void 0);let ds=class{constructor(e={}){this.other=new vo,Object.assign(this,e)}};d([g({type:vo,context:1,implicit:!0})],ds.prototype,"other",void 0);ds=d([P({type:T.Choice})],ds);let ps=Xa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Xa.prototype)}};ps=Xa=d([P({type:T.Set,itemType:ds})],ps);class bl{constructor(e={}){Object.assign(this,e)}}d([g({type:cs,context:0,implicit:!0,optional:!0})],bl.prototype,"certs",void 0);d([g({type:ps,context:1,implicit:!0,optional:!0})],bl.prototype,"crls",void 0);var Qa;let ec=Qa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Qa.prototype)}};ec=Qa=d([P({type:T.Set,itemType:ri})],ec);class rr{constructor(e={}){this.version=Bt.v0,this.recipientInfos=new us,this.encryptedContentInfo=new Qi,Object.assign(this,e)}}d([g({type:w.Integer})],rr.prototype,"version",void 0);d([g({type:bl,context:0,implicit:!0,optional:!0})],rr.prototype,"originatorInfo",void 0);d([g({type:us})],rr.prototype,"recipientInfos",void 0);d([g({type:Qi})],rr.prototype,"encryptedContentInfo",void 0);d([g({type:ec,context:1,implicit:!0,optional:!0})],rr.prototype,"unprotectedAttrs",void 0);const s0="1.2.840.113549.1.7.2";var tc;let fs=tc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,tc.prototype)}};fs=tc=d([P({type:T.Set,itemType:Ni})],fs);class ai{constructor(e={}){this.version=Bt.v0,this.digestAlgorithms=new fs,this.encapContentInfo=new mo,this.signerInfos=new ss,Object.assign(this,e)}}d([g({type:w.Integer})],ai.prototype,"version",void 0);d([g({type:fs})],ai.prototype,"digestAlgorithms",void 0);d([g({type:mo})],ai.prototype,"encapContentInfo",void 0);d([g({type:cs,context:0,implicit:!0,optional:!0})],ai.prototype,"certificates",void 0);d([g({type:ps,context:1,implicit:!0,optional:!0})],ai.prototype,"crls",void 0);d([g({type:ss})],ai.prototype,"signerInfos",void 0);const Bi="1.2.840.10045.2.1",kl="1.2.840.10045.4.1",Ih="1.2.840.10045.4.3.1",xl="1.2.840.10045.4.3.2",Sl="1.2.840.10045.4.3.3",Al="1.2.840.10045.4.3.4",Fu="1.2.840.10045.3.1.7",qu="1.3.132.0.34",Ku="1.3.132.0.35";function sr(t){return new F({algorithm:t})}const o0=sr(kl);sr(Ih);const a0=sr(xl),c0=sr(Sl),l0=sr(Al);let Ti=class{constructor(e={}){Object.assign(this,e)}};d([g({type:w.ObjectIdentifier})],Ti.prototype,"fieldType",void 0);d([g({type:w.Any})],Ti.prototype,"parameters",void 0);Ti=d([P({type:T.Sequence})],Ti);class u0 extends ae{}let Jn=class{constructor(e={}){Object.assign(this,e)}};d([g({type:w.OctetString})],Jn.prototype,"a",void 0);d([g({type:w.OctetString})],Jn.prototype,"b",void 0);d([g({type:w.BitString,optional:!0})],Jn.prototype,"seed",void 0);Jn=d([P({type:T.Sequence})],Jn);var nc;(function(t){t[t.ecpVer1=1]="ecpVer1"})(nc||(nc={}));let Tt=class{constructor(e={}){this.version=nc.ecpVer1,Object.assign(this,e)}};d([g({type:w.Integer})],Tt.prototype,"version",void 0);d([g({type:Ti})],Tt.prototype,"fieldID",void 0);d([g({type:Jn})],Tt.prototype,"curve",void 0);d([g({type:u0})],Tt.prototype,"base",void 0);d([g({type:w.Integer,converter:_e})],Tt.prototype,"order",void 0);d([g({type:w.Integer,optional:!0})],Tt.prototype,"cofactor",void 0);Tt=d([P({type:T.Sequence})],Tt);let Zt=class{constructor(e={}){Object.assign(this,e)}};d([g({type:w.ObjectIdentifier})],Zt.prototype,"namedCurve",void 0);d([g({type:w.Null})],Zt.prototype,"implicitCurve",void 0);d([g({type:Tt})],Zt.prototype,"specifiedCurve",void 0);Zt=d([P({type:T.Choice})],Zt);class wo{constructor(e={}){this.version=1,this.privateKey=new ae,Object.assign(this,e)}}d([g({type:w.Integer})],wo.prototype,"version",void 0);d([g({type:ae})],wo.prototype,"privateKey",void 0);d([g({type:Zt,context:0,optional:!0})],wo.prototype,"parameters",void 0);d([g({type:w.BitString,context:1,optional:!0})],wo.prototype,"publicKey",void 0);class hs{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.Integer,converter:_e})],hs.prototype,"r",void 0);d([g({type:w.Integer,converter:_e})],hs.prototype,"s",void 0);const qe="1.2.840.113549.1.1",kn=`${qe}.1`,d0=`${qe}.7`,p0=`${qe}.9`,Si=`${qe}.10`,f0=`${qe}.2`,h0=`${qe}.4`,gs=`${qe}.5`,g0=`${qe}.14`,ic=`${qe}.11`,ms=`${qe}.12`,_s=`${qe}.13`,Ch=`${qe}.15`,$h=`${qe}.16`,ys="1.3.14.3.2.26",zh="2.16.840.1.101.3.4.2.4",vs="2.16.840.1.101.3.4.2.1",ws="2.16.840.1.101.3.4.2.2",bs="2.16.840.1.101.3.4.2.3",m0="2.16.840.1.101.3.4.2.5",_0="2.16.840.1.101.3.4.2.6",y0="1.2.840.113549.2.2",v0="1.2.840.113549.2.5",bo=`${qe}.8`;function Ee(t){return new F({algorithm:t,parameters:null})}Ee(y0);Ee(v0);const xn=Ee(ys);Ee(zh);Ee(vs);Ee(ws);Ee(bs);Ee(m0);Ee(_0);const Nh=new F({algorithm:bo,parameters:V.serialize(xn)}),jh=new F({algorithm:p0,parameters:V.serialize(Zr.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Ee(kn);Ee(f0);Ee(h0);Ee(gs);Ee(Ch);Ee($h);Ee(ms);Ee(_s);Ee(Ch);Ee($h);class ko{constructor(e={}){this.hashAlgorithm=new F(xn),this.maskGenAlgorithm=new F({algorithm:bo,parameters:V.serialize(xn)}),this.pSourceAlgorithm=new F(jh),Object.assign(this,e)}}d([g({type:F,context:0,defaultValue:xn})],ko.prototype,"hashAlgorithm",void 0);d([g({type:F,context:1,defaultValue:Nh})],ko.prototype,"maskGenAlgorithm",void 0);d([g({type:F,context:2,defaultValue:jh})],ko.prototype,"pSourceAlgorithm",void 0);new F({algorithm:d0,parameters:V.serialize(new ko)});class Sn{constructor(e={}){this.hashAlgorithm=new F(xn),this.maskGenAlgorithm=new F({algorithm:bo,parameters:V.serialize(xn)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}d([g({type:F,context:0,defaultValue:xn})],Sn.prototype,"hashAlgorithm",void 0);d([g({type:F,context:1,defaultValue:Nh})],Sn.prototype,"maskGenAlgorithm",void 0);d([g({type:w.Integer,context:2,defaultValue:20})],Sn.prototype,"saltLength",void 0);d([g({type:w.Integer,context:3,defaultValue:1})],Sn.prototype,"trailerField",void 0);new F({algorithm:Si,parameters:V.serialize(new Sn)});class xo{constructor(e={}){this.digestAlgorithm=new F,this.digest=new ae,Object.assign(this,e)}}d([g({type:F})],xo.prototype,"digestAlgorithm",void 0);d([g({type:ae})],xo.prototype,"digest",void 0);var rc;class So{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.Integer,converter:_e})],So.prototype,"prime",void 0);d([g({type:w.Integer,converter:_e})],So.prototype,"exponent",void 0);d([g({type:w.Integer,converter:_e})],So.prototype,"coefficient",void 0);let sc=rc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,rc.prototype)}};sc=rc=d([P({type:T.Sequence,itemType:So})],sc);class It{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([g({type:w.Integer})],It.prototype,"version",void 0);d([g({type:w.Integer,converter:_e})],It.prototype,"modulus",void 0);d([g({type:w.Integer,converter:_e})],It.prototype,"publicExponent",void 0);d([g({type:w.Integer,converter:_e})],It.prototype,"privateExponent",void 0);d([g({type:w.Integer,converter:_e})],It.prototype,"prime1",void 0);d([g({type:w.Integer,converter:_e})],It.prototype,"prime2",void 0);d([g({type:w.Integer,converter:_e})],It.prototype,"exponent1",void 0);d([g({type:w.Integer,converter:_e})],It.prototype,"exponent2",void 0);d([g({type:w.Integer,converter:_e})],It.prototype,"coefficient",void 0);d([g({type:sc,optional:!0})],It.prototype,"otherPrimeInfos",void 0);class El{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.Integer,converter:_e})],El.prototype,"modulus",void 0);d([g({type:w.Integer,converter:_e})],El.prototype,"publicExponent",void 0);var oc;(function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"})(oc||(oc={}));const Ve=oc;/*! *****************************************************************************
|
|
80
80
|
Copyright (c) Microsoft Corporation.
|
|
81
81
|
|
|
82
82
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -89,9 +89,9 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
89
89
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
90
90
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
91
91
|
PERFORMANCE OF THIS SOFTWARE.
|
|
92
|
-
***************************************************************************** */var
|
|
92
|
+
***************************************************************************** */var ac=function(t,e){return ac=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var r in i)i.hasOwnProperty(r)&&(n[r]=i[r])},ac(t,e)};function Il(t,e){ac(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function w0(t,e,n,i){function r(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function c(p){try{u(i.next(p))}catch(f){o(f)}}function l(p){try{u(i.throw(p))}catch(f){o(f)}}function u(p){p.done?s(p.value):r(p.value).then(c,l)}u((i=i.apply(t,[])).next())})}function b0(t,e){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(u){return function(p){return l([u,p])}}function l(u){if(i)throw new TypeError("Generator is already executing.");for(;n;)try{if(i=1,r&&(s=u[0]&2?r.return:u[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,u[1])).done)return s;switch(r=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return n.label++,{value:u[1],done:!1};case 5:n.label++,r=u[1],u=[0];continue;case 7:u=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){n.label=u[1];break}if(u[0]===6&&n.label<s[1]){n.label=s[1],s=u;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(u);break}s[2]&&n.ops.pop(),n.trys.pop();continue}u=e.call(t,n)}catch(p){u=[6,p],r=0}finally{i=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function _r(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ks(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var i=n.call(t),r,s=[],o;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(c){o={error:c}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function sn(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(ks(arguments[e]));return t}var k0="injectionTokens";function x0(t){var e=Reflect.getMetadata("design:paramtypes",t)||[],n=Reflect.getOwnMetadata(k0,t)||{};return Object.keys(n).forEach(function(i){e[+i]=n[i]}),e}function Oh(t){return!!t.useClass}function cc(t){return!!t.useFactory}var Bh=function(){function t(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return t.prototype.createProxy=function(e){var n=this,i={},r=!1,s,o=function(){return r||(s=e(n.wrap()),r=!0),s};return new Proxy(i,this.createHandler(o))},t.prototype.createHandler=function(e){var n={},i=function(r){n[r]=function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];s[0]=e();var c=Reflect[r];return c.apply(void 0,sn(s))}};return this.reflectMethods.forEach(i),n},t}();function jn(t){return typeof t=="string"||typeof t=="symbol"}function S0(t){return typeof t=="object"&&"token"in t&&"multiple"in t}function Wu(t){return typeof t=="object"&&"token"in t&&"transform"in t}function A0(t){return typeof t=="function"||t instanceof Bh}function Er(t){return!!t.useToken}function Ir(t){return t.useValue!=null}function E0(t){return Oh(t)||Ir(t)||Er(t)||cc(t)}var Cl=function(){function t(){this._registryMap=new Map}return t.prototype.entries=function(){return this._registryMap.entries()},t.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},t.prototype.get=function(e){this.ensure(e);var n=this._registryMap.get(e);return n[n.length-1]||null},t.prototype.set=function(e,n){this.ensure(e),this._registryMap.get(e).push(n)},t.prototype.setAll=function(e,n){this._registryMap.set(e,n)},t.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},t.prototype.clear=function(){this._registryMap.clear()},t.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},t}(),I0=function(t){Il(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Cl),Gu=function(){function t(){this.scopedResolutions=new Map}return t}();function C0(t,e){if(t===null)return"at position #"+e;var n=t.split(",")[e].trim();return'"'+n+'" at position #'+e}function $0(t,e,n){return n===void 0&&(n=" "),sn([t],e.message.split(`
|
|
93
93
|
`).map(function(i){return n+i})).join(`
|
|
94
|
-
`)}function Tm(t,e,n){var i=rs(t.toString().match(/constructor\(([\w, ]+)\)/)||[],2),r=i[1],s=r===void 0?null:r,o=Om(s,e);return Bm("Cannot inject the dependency "+o+' of "'+t.name+'" constructor. Reason:',n)}function Rm(t){if(typeof t.dispose!="function")return!1;var e=t.dispose;return!(e.length>0)}var Pm=function(t){il(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(rl),Lm=function(t){il(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(rl),Um=function(){function t(){this.preResolution=new Pm,this.postResolution=new Lm}return t}(),th=new Map,Vm=function(){function t(e){this.parent=e,this._registry=new Nm,this.interceptors=new Um,this.disposed=!1,this.disposables=new Set}return t.prototype.register=function(e,n,i){i===void 0&&(i={lifecycle:Ue.Transient}),this.ensureNotDisposed();var r;if(jm(n)?r=n:r={useClass:n},fr(r))for(var s=[e],o=r;o!=null;){var c=o.useToken;if(s.includes(c))throw new Error("Token registration cycle detected! "+tn(s,[c]).join(" -> "));s.push(c);var l=this._registry.get(c);l&&fr(l.provider)?o=l.provider:o=null}if((i.lifecycle===Ue.Singleton||i.lifecycle==Ue.ContainerScoped||i.lifecycle==Ue.ResolutionScoped)&&(hr(r)||Va(r)))throw new Error('Cannot use lifecycle "'+Ue[i.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:r,options:i}),this},t.prototype.registerType=function(e,n){return this.ensureNotDisposed(),zn(n)?this.register(e,{useToken:n}):this.register(e,{useClass:n})},t.prototype.registerInstance=function(e,n){return this.ensureNotDisposed(),this.register(e,{useValue:n})},t.prototype.registerSingleton=function(e,n){if(this.ensureNotDisposed(),zn(e)){if(zn(n))return this.register(e,{useToken:n},{lifecycle:Ue.Singleton});if(n)return this.register(e,{useClass:n},{lifecycle:Ue.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var i=e;return n&&!zn(n)&&(i=n),this.register(e,{useClass:i},{lifecycle:Ue.Singleton})},t.prototype.resolve=function(e,n){n===void 0&&(n=new wu),this.ensureNotDisposed();var i=this.getRegistration(e);if(!i&&zn(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),i){var r=this.resolveRegistration(i,n);return this.executePostResolutionInterceptor(e,r,"Single"),r}if($m(e)){var r=this.construct(e,n);return this.executePostResolutionInterceptor(e,r,"Single"),r}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},t.prototype.executePreResolutionInterceptor=function(e,n){var i,r;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var o=sr(this.interceptors.preResolution.getAll(e)),c=o.next();!c.done;c=o.next()){var l=c.value;l.options.frequency!="Once"&&s.push(l),l.callback(e,n)}}catch(u){i={error:u}}finally{try{c&&!c.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}this.interceptors.preResolution.setAll(e,s)}},t.prototype.executePostResolutionInterceptor=function(e,n,i){var r,s;if(this.interceptors.postResolution.has(e)){var o=[];try{for(var c=sr(this.interceptors.postResolution.getAll(e)),l=c.next();!l.done;l=c.next()){var u=l.value;u.options.frequency!="Once"&&o.push(u),u.callback(e,n,i)}}catch(p){r={error:p}}finally{try{l&&!l.done&&(s=c.return)&&s.call(c)}finally{if(r)throw r.error}}this.interceptors.postResolution.setAll(e,o)}},t.prototype.resolveRegistration=function(e,n){if(this.ensureNotDisposed(),e.options.lifecycle===Ue.ResolutionScoped&&n.scopedResolutions.has(e))return n.scopedResolutions.get(e);var i=e.options.lifecycle===Ue.Singleton,r=e.options.lifecycle===Ue.ContainerScoped,s=i||r,o;return hr(e.provider)?o=e.provider.useValue:fr(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,n)):this.resolve(e.provider.useToken,n):Qf(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,n)):this.construct(e.provider.useClass,n):Va(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,n),e.options.lifecycle===Ue.ResolutionScoped&&n.scopedResolutions.set(e,o),o},t.prototype.resolveAll=function(e,n){var i=this;n===void 0&&(n=new wu),this.ensureNotDisposed();var r=this.getAllRegistrations(e);if(!r&&zn(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),r){var s=r.map(function(c){return i.resolveRegistration(c,n)});return this.executePostResolutionInterceptor(e,s,"All"),s}var o=[this.construct(e,n)];return this.executePostResolutionInterceptor(e,o,"All"),o},t.prototype.isRegistered=function(e,n){return n===void 0&&(n=!1),this.ensureNotDisposed(),this._registry.has(e)||n&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},t.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},t.prototype.clearInstances=function(){var e,n;this.ensureNotDisposed();try{for(var i=sr(this._registry.entries()),r=i.next();!r.done;r=i.next()){var s=rs(r.value,2),o=s[0],c=s[1];this._registry.setAll(o,c.filter(function(l){return!hr(l.provider)}).map(function(l){return l.instance=void 0,l}))}}catch(l){e={error:l}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},t.prototype.createChildContainer=function(){var e,n;this.ensureNotDisposed();var i=new t(this);try{for(var r=sr(this._registry.entries()),s=r.next();!s.done;s=r.next()){var o=rs(s.value,2),c=o[0],l=o[1];l.some(function(u){var p=u.options;return p.lifecycle===Ue.ContainerScoped})&&i._registry.setAll(c,l.map(function(u){return u.options.lifecycle===Ue.ContainerScoped?{provider:u.provider,options:u.options}:u}))}}catch(u){e={error:u}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return i},t.prototype.beforeResolution=function(e,n,i){i===void 0&&(i={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:n,options:i})},t.prototype.afterResolution=function(e,n,i){i===void 0&&(i={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:n,options:i})},t.prototype.dispose=function(){return Am(this,void 0,void 0,function(){var e;return Im(this,function(n){switch(n.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(i){var r=i.dispose();r&&e.push(r)}),[4,Promise.all(e)];case 1:return n.sent(),[2]}})})},t.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},t.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},t.prototype.construct=function(e,n){var i=this;if(e instanceof eh)return e.createProxy(function(s){return i.resolve(s,n)});var r=function(){var s=th.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var o=s.map(i.resolveParams(n,e));return new(e.bind.apply(e,tn([void 0],o)))}();return Rm(r)&&this.disposables.add(r),r},t.prototype.resolveParams=function(e,n){var i=this;return function(r,s){var o,c,l;try{return zm(r)?vu(r)?r.multiple?(o=i.resolve(r.transform)).transform.apply(o,tn([i.resolveAll(r.token)],r.transformArgs)):(c=i.resolve(r.transform)).transform.apply(c,tn([i.resolve(r.token,e)],r.transformArgs)):r.multiple?i.resolveAll(r.token):i.resolve(r.token,e):vu(r)?(l=i.resolve(r.transform,e)).transform.apply(l,tn([i.resolve(r.token,e)],r.transformArgs)):i.resolve(r,e)}catch(u){throw new Error(Tm(n,s,u))}}},t.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},t}(),Oe=new Vm;function ro(){return function(t){th.set(t,Cm(t))}}if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var Ma;class so{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}d([f({type:y.ObjectIdentifier})],so.prototype,"attrId",void 0);d([f({type:y.Any,repeated:"set"})],so.prototype,"attrValues",void 0);let bu=Ma=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ma.prototype)}};bu=Ma=d([B({type:N.Sequence,itemType:so})],bu);var Da;let ku=Da=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Da.prototype)}};ku=Da=d([B({type:N.Sequence,itemType:ti})],ku);class nh{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],nh.prototype,"certId",void 0);d([f({type:y.Any,context:0})],nh.prototype,"certValue",void 0);class ih{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],ih.prototype,"crlId",void 0);d([f({type:y.Any,context:0})],ih.prototype,"crltValue",void 0);class rh extends oe{}let oo=class{constructor(e={}){this.encryptionAlgorithm=new F,this.encryptedData=new rh,Object.assign(this,e)}};d([f({type:F})],oo.prototype,"encryptionAlgorithm",void 0);d([f({type:rh})],oo.prototype,"encryptedData",void 0);var Fa,Ha;(function(t){t[t.v1=0]="v1"})(Ha||(Ha={}));class sh extends oe{}let qa=Fa=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Fa.prototype)}};qa=Fa=d([B({type:N.Sequence,itemType:$t})],qa);class Zi{constructor(e={}){this.version=Ha.v1,this.privateKeyAlgorithm=new F,this.privateKey=new sh,Object.assign(this,e)}}d([f({type:y.Integer})],Zi.prototype,"version",void 0);d([f({type:F})],Zi.prototype,"privateKeyAlgorithm",void 0);d([f({type:sh})],Zi.prototype,"privateKey",void 0);d([f({type:qa,implicit:!0,context:0,optional:!0})],Zi.prototype,"attributes",void 0);let xu=class extends Zi{};xu=d([B({type:N.Sequence})],xu);let Su=class extends oo{};Su=d([B({type:N.Sequence})],Su);class oh{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],oh.prototype,"secretTypeId",void 0);d([f({type:y.Any,context:0})],oh.prototype,"secretValue",void 0);class Yi{constructor(e={}){this.mac=new no,this.macSalt=new oe,this.iterations=1,Object.assign(this,e)}}d([f({type:no})],Yi.prototype,"mac",void 0);d([f({type:oe})],Yi.prototype,"macSalt",void 0);d([f({type:y.Integer,defaultValue:1})],Yi.prototype,"iterations",void 0);class ao{constructor(e={}){this.version=3,this.authSafe=new ti,this.macData=new Yi,Object.assign(this,e)}}d([f({type:y.Integer})],ao.prototype,"version",void 0);d([f({type:ti})],ao.prototype,"authSafe",void 0);d([f({type:Yi,optional:!0})],ao.prototype,"macData",void 0);var Ka;class co{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:y.ObjectIdentifier})],co.prototype,"bagId",void 0);d([f({type:y.Any,context:0})],co.prototype,"bagValue",void 0);d([f({type:so,repeated:"set",optional:!0})],co.prototype,"bagAttributes",void 0);let Au=Ka=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ka.prototype)}};Au=Ka=d([B({type:N.Sequence,itemType:co})],Au);var Wa,Ga,Ja;const ah="1.2.840.113549.1.9",ch=`${ah}.7`,sl=`${ah}.14`;let ss=class extends Ne{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};d([f({type:y.IA5String})],ss.prototype,"ia5String",void 0);ss=d([B({type:N.Choice})],ss);let Iu=class extends ti{};Iu=d([B({type:N.Sequence})],Iu);let Eu=class extends ao{};Eu=d([B({type:N.Sequence})],Eu);let Cu=class extends oo{};Cu=d([B({type:N.Sequence})],Cu);let Za=class{constructor(e=""){this.value=e}toString(){return this.value}};d([f({type:y.IA5String})],Za.prototype,"value",void 0);Za=d([B({type:N.Choice})],Za);let zu=class extends ss{};zu=d([B({type:N.Choice})],zu);let $u=class extends Ne{};$u=d([B({type:N.Choice})],$u);let Ya=class{constructor(e=new Date){this.value=e}};d([f({type:y.GeneralizedTime})],Ya.prototype,"value",void 0);Ya=d([B({type:N.Choice})],Ya);let ju=class extends Ne{};ju=d([B({type:N.Choice})],ju);let Xa=class{constructor(e="M"){this.value=e}toString(){return this.value}};d([f({type:y.PrintableString})],Xa.prototype,"value",void 0);Xa=d([B({type:N.Choice})],Xa);let os=class{constructor(e=""){this.value=e}toString(){return this.value}};d([f({type:y.PrintableString})],os.prototype,"value",void 0);os=d([B({type:N.Choice})],os);let Nu=class extends os{};Nu=d([B({type:N.Choice})],Nu);let Ou=class extends Ne{};Ou=d([B({type:N.Choice})],Ou);let Qa=class{constructor(e=""){this.value=e}toString(){return this.value}};d([f({type:y.ObjectIdentifier})],Qa.prototype,"value",void 0);Qa=d([B({type:N.Choice})],Qa);let Bu=class extends $e{};Bu=d([B({type:N.Choice})],Bu);let ec=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};d([f({type:y.Integer})],ec.prototype,"value",void 0);ec=d([B({type:N.Choice})],ec);let Tu=class extends St{};Tu=d([B({type:N.Sequence})],Tu);let as=class extends Ne{};as=d([B({type:N.Choice})],as);let Ru=Wa=class extends qt{constructor(e){super(e),Object.setPrototypeOf(this,Wa.prototype)}};Ru=Wa=d([B({type:N.Sequence})],Ru);let Pu=Ga=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ga.prototype)}};Pu=Ga=d([B({type:N.Set,itemType:ei})],Pu);let tc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([f({type:y.BmpString})],tc.prototype,"value",void 0);tc=d([B({type:N.Choice})],tc);let nc=class extends F{};nc=d([B({type:N.Sequence})],nc);let Lu=Ja=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ja.prototype)}};Lu=Ja=d([B({type:N.Sequence,itemType:nc})],Lu);var ic;let cs=ic=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,ic.prototype)}};cs=ic=d([B({type:N.Sequence,itemType:$t})],cs);class ri{constructor(e={}){this.version=0,this.subject=new ke,this.subjectPKInfo=new lt,this.attributes=new cs,Object.assign(this,e)}}d([f({type:y.Integer})],ri.prototype,"version",void 0);d([f({type:ke})],ri.prototype,"subject",void 0);d([f({type:lt})],ri.prototype,"subjectPKInfo",void 0);d([f({type:cs,implicit:!0,context:0})],ri.prototype,"attributes",void 0);class zi{constructor(e={}){this.certificationRequestInfo=new ri,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([f({type:ri})],zi.prototype,"certificationRequestInfo",void 0);d([f({type:F})],zi.prototype,"signatureAlgorithm",void 0);d([f({type:y.BitString})],zi.prototype,"signature",void 0);/*!
|
|
94
|
+
`)}function z0(t,e,n){var i=ks(t.toString().match(/constructor\(([\w, ]+)\)/)||[],2),r=i[1],s=r===void 0?null:r,o=C0(s,e);return $0("Cannot inject the dependency "+o+' of "'+t.name+'" constructor. Reason:',n)}function N0(t){if(typeof t.dispose!="function")return!1;var e=t.dispose;return!(e.length>0)}var j0=function(t){Il(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Cl),O0=function(t){Il(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Cl),B0=function(){function t(){this.preResolution=new j0,this.postResolution=new O0}return t}(),Th=new Map,T0=function(){function t(e){this.parent=e,this._registry=new I0,this.interceptors=new B0,this.disposed=!1,this.disposables=new Set}return t.prototype.register=function(e,n,i){i===void 0&&(i={lifecycle:Ve.Transient}),this.ensureNotDisposed();var r;if(E0(n)?r=n:r={useClass:n},Er(r))for(var s=[e],o=r;o!=null;){var c=o.useToken;if(s.includes(c))throw new Error("Token registration cycle detected! "+sn(s,[c]).join(" -> "));s.push(c);var l=this._registry.get(c);l&&Er(l.provider)?o=l.provider:o=null}if((i.lifecycle===Ve.Singleton||i.lifecycle==Ve.ContainerScoped||i.lifecycle==Ve.ResolutionScoped)&&(Ir(r)||cc(r)))throw new Error('Cannot use lifecycle "'+Ve[i.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:r,options:i}),this},t.prototype.registerType=function(e,n){return this.ensureNotDisposed(),jn(n)?this.register(e,{useToken:n}):this.register(e,{useClass:n})},t.prototype.registerInstance=function(e,n){return this.ensureNotDisposed(),this.register(e,{useValue:n})},t.prototype.registerSingleton=function(e,n){if(this.ensureNotDisposed(),jn(e)){if(jn(n))return this.register(e,{useToken:n},{lifecycle:Ve.Singleton});if(n)return this.register(e,{useClass:n},{lifecycle:Ve.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var i=e;return n&&!jn(n)&&(i=n),this.register(e,{useClass:i},{lifecycle:Ve.Singleton})},t.prototype.resolve=function(e,n){n===void 0&&(n=new Gu),this.ensureNotDisposed();var i=this.getRegistration(e);if(!i&&jn(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),i){var r=this.resolveRegistration(i,n);return this.executePostResolutionInterceptor(e,r,"Single"),r}if(A0(e)){var r=this.construct(e,n);return this.executePostResolutionInterceptor(e,r,"Single"),r}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},t.prototype.executePreResolutionInterceptor=function(e,n){var i,r;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var o=_r(this.interceptors.preResolution.getAll(e)),c=o.next();!c.done;c=o.next()){var l=c.value;l.options.frequency!="Once"&&s.push(l),l.callback(e,n)}}catch(u){i={error:u}}finally{try{c&&!c.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}this.interceptors.preResolution.setAll(e,s)}},t.prototype.executePostResolutionInterceptor=function(e,n,i){var r,s;if(this.interceptors.postResolution.has(e)){var o=[];try{for(var c=_r(this.interceptors.postResolution.getAll(e)),l=c.next();!l.done;l=c.next()){var u=l.value;u.options.frequency!="Once"&&o.push(u),u.callback(e,n,i)}}catch(p){r={error:p}}finally{try{l&&!l.done&&(s=c.return)&&s.call(c)}finally{if(r)throw r.error}}this.interceptors.postResolution.setAll(e,o)}},t.prototype.resolveRegistration=function(e,n){if(this.ensureNotDisposed(),e.options.lifecycle===Ve.ResolutionScoped&&n.scopedResolutions.has(e))return n.scopedResolutions.get(e);var i=e.options.lifecycle===Ve.Singleton,r=e.options.lifecycle===Ve.ContainerScoped,s=i||r,o;return Ir(e.provider)?o=e.provider.useValue:Er(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,n)):this.resolve(e.provider.useToken,n):Oh(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,n)):this.construct(e.provider.useClass,n):cc(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,n),e.options.lifecycle===Ve.ResolutionScoped&&n.scopedResolutions.set(e,o),o},t.prototype.resolveAll=function(e,n){var i=this;n===void 0&&(n=new Gu),this.ensureNotDisposed();var r=this.getAllRegistrations(e);if(!r&&jn(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),r){var s=r.map(function(c){return i.resolveRegistration(c,n)});return this.executePostResolutionInterceptor(e,s,"All"),s}var o=[this.construct(e,n)];return this.executePostResolutionInterceptor(e,o,"All"),o},t.prototype.isRegistered=function(e,n){return n===void 0&&(n=!1),this.ensureNotDisposed(),this._registry.has(e)||n&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},t.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},t.prototype.clearInstances=function(){var e,n;this.ensureNotDisposed();try{for(var i=_r(this._registry.entries()),r=i.next();!r.done;r=i.next()){var s=ks(r.value,2),o=s[0],c=s[1];this._registry.setAll(o,c.filter(function(l){return!Ir(l.provider)}).map(function(l){return l.instance=void 0,l}))}}catch(l){e={error:l}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},t.prototype.createChildContainer=function(){var e,n;this.ensureNotDisposed();var i=new t(this);try{for(var r=_r(this._registry.entries()),s=r.next();!s.done;s=r.next()){var o=ks(s.value,2),c=o[0],l=o[1];l.some(function(u){var p=u.options;return p.lifecycle===Ve.ContainerScoped})&&i._registry.setAll(c,l.map(function(u){return u.options.lifecycle===Ve.ContainerScoped?{provider:u.provider,options:u.options}:u}))}}catch(u){e={error:u}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return i},t.prototype.beforeResolution=function(e,n,i){i===void 0&&(i={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:n,options:i})},t.prototype.afterResolution=function(e,n,i){i===void 0&&(i={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:n,options:i})},t.prototype.dispose=function(){return w0(this,void 0,void 0,function(){var e;return b0(this,function(n){switch(n.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(i){var r=i.dispose();r&&e.push(r)}),[4,Promise.all(e)];case 1:return n.sent(),[2]}})})},t.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},t.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},t.prototype.construct=function(e,n){var i=this;if(e instanceof Bh)return e.createProxy(function(s){return i.resolve(s,n)});var r=function(){var s=Th.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var o=s.map(i.resolveParams(n,e));return new(e.bind.apply(e,sn([void 0],o)))}();return N0(r)&&this.disposables.add(r),r},t.prototype.resolveParams=function(e,n){var i=this;return function(r,s){var o,c,l;try{return S0(r)?Wu(r)?r.multiple?(o=i.resolve(r.transform)).transform.apply(o,sn([i.resolveAll(r.token)],r.transformArgs)):(c=i.resolve(r.transform)).transform.apply(c,sn([i.resolve(r.token,e)],r.transformArgs)):r.multiple?i.resolveAll(r.token):i.resolve(r.token,e):Wu(r)?(l=i.resolve(r.transform,e)).transform.apply(l,sn([i.resolve(r.token,e)],r.transformArgs)):i.resolve(r,e)}catch(u){throw new Error(z0(n,s,u))}}},t.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},t}(),Be=new T0;function Ao(){return function(t){Th.set(t,x0(t))}}if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var lc;class Eo{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}d([g({type:w.ObjectIdentifier})],Eo.prototype,"attrId",void 0);d([g({type:w.Any,repeated:"set"})],Eo.prototype,"attrValues",void 0);let Ju=lc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,lc.prototype)}};Ju=lc=d([P({type:T.Sequence,itemType:Eo})],Ju);var uc;let Zu=uc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,uc.prototype)}};Zu=uc=d([P({type:T.Sequence,itemType:si})],Zu);class Ph{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],Ph.prototype,"certId",void 0);d([g({type:w.Any,context:0})],Ph.prototype,"certValue",void 0);class Rh{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],Rh.prototype,"crlId",void 0);d([g({type:w.Any,context:0})],Rh.prototype,"crltValue",void 0);class Lh extends ae{}let Io=class{constructor(e={}){this.encryptionAlgorithm=new F,this.encryptedData=new Lh,Object.assign(this,e)}};d([g({type:F})],Io.prototype,"encryptionAlgorithm",void 0);d([g({type:Lh})],Io.prototype,"encryptedData",void 0);var dc,pc;(function(t){t[t.v1=0]="v1"})(pc||(pc={}));class Uh extends ae{}let fc=dc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,dc.prototype)}};fc=dc=d([P({type:T.Sequence,itemType:Ot})],fc);class or{constructor(e={}){this.version=pc.v1,this.privateKeyAlgorithm=new F,this.privateKey=new Uh,Object.assign(this,e)}}d([g({type:w.Integer})],or.prototype,"version",void 0);d([g({type:F})],or.prototype,"privateKeyAlgorithm",void 0);d([g({type:Uh})],or.prototype,"privateKey",void 0);d([g({type:fc,implicit:!0,context:0,optional:!0})],or.prototype,"attributes",void 0);let Yu=class extends or{};Yu=d([P({type:T.Sequence})],Yu);let Xu=class extends Io{};Xu=d([P({type:T.Sequence})],Xu);class Vh{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],Vh.prototype,"secretTypeId",void 0);d([g({type:w.Any,context:0})],Vh.prototype,"secretValue",void 0);class ar{constructor(e={}){this.mac=new xo,this.macSalt=new ae,this.iterations=1,Object.assign(this,e)}}d([g({type:xo})],ar.prototype,"mac",void 0);d([g({type:ae})],ar.prototype,"macSalt",void 0);d([g({type:w.Integer,defaultValue:1})],ar.prototype,"iterations",void 0);class Co{constructor(e={}){this.version=3,this.authSafe=new si,this.macData=new ar,Object.assign(this,e)}}d([g({type:w.Integer})],Co.prototype,"version",void 0);d([g({type:si})],Co.prototype,"authSafe",void 0);d([g({type:ar,optional:!0})],Co.prototype,"macData",void 0);var hc;class $o{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:w.ObjectIdentifier})],$o.prototype,"bagId",void 0);d([g({type:w.Any,context:0})],$o.prototype,"bagValue",void 0);d([g({type:Eo,repeated:"set",optional:!0})],$o.prototype,"bagAttributes",void 0);let Qu=hc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,hc.prototype)}};Qu=hc=d([P({type:T.Sequence,itemType:$o})],Qu);var gc,mc,_c;const Mh="1.2.840.113549.1.9",Dh=`${Mh}.7`,$l=`${Mh}.14`;let xs=class extends Oe{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};d([g({type:w.IA5String})],xs.prototype,"ia5String",void 0);xs=d([P({type:T.Choice})],xs);let ed=class extends si{};ed=d([P({type:T.Sequence})],ed);let td=class extends Co{};td=d([P({type:T.Sequence})],td);let nd=class extends Io{};nd=d([P({type:T.Sequence})],nd);let yc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:w.IA5String})],yc.prototype,"value",void 0);yc=d([P({type:T.Choice})],yc);let id=class extends xs{};id=d([P({type:T.Choice})],id);let rd=class extends Oe{};rd=d([P({type:T.Choice})],rd);let vc=class{constructor(e=new Date){this.value=e}};d([g({type:w.GeneralizedTime})],vc.prototype,"value",void 0);vc=d([P({type:T.Choice})],vc);let sd=class extends Oe{};sd=d([P({type:T.Choice})],sd);let wc=class{constructor(e="M"){this.value=e}toString(){return this.value}};d([g({type:w.PrintableString})],wc.prototype,"value",void 0);wc=d([P({type:T.Choice})],wc);let Ss=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:w.PrintableString})],Ss.prototype,"value",void 0);Ss=d([P({type:T.Choice})],Ss);let od=class extends Ss{};od=d([P({type:T.Choice})],od);let ad=class extends Oe{};ad=d([P({type:T.Choice})],ad);let bc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:w.ObjectIdentifier})],bc.prototype,"value",void 0);bc=d([P({type:T.Choice})],bc);let cd=class extends Ne{};cd=d([P({type:T.Choice})],cd);let kc=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};d([g({type:w.Integer})],kc.prototype,"value",void 0);kc=d([P({type:T.Choice})],kc);let ld=class extends Et{};ld=d([P({type:T.Sequence})],ld);let As=class extends Oe{};As=d([P({type:T.Choice})],As);let ud=gc=class extends Gt{constructor(e){super(e),Object.setPrototypeOf(this,gc.prototype)}};ud=gc=d([P({type:T.Sequence})],ud);let dd=mc=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,mc.prototype)}};dd=mc=d([P({type:T.Set,itemType:ri})],dd);let xc=class{constructor(e=""){this.value=e}toString(){return this.value}};d([g({type:w.BmpString})],xc.prototype,"value",void 0);xc=d([P({type:T.Choice})],xc);let Sc=class extends F{};Sc=d([P({type:T.Sequence})],Sc);let pd=_c=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,_c.prototype)}};pd=_c=d([P({type:T.Sequence,itemType:Sc})],pd);var Ac;let Es=Ac=class extends de{constructor(e){super(e),Object.setPrototypeOf(this,Ac.prototype)}};Es=Ac=d([P({type:T.Sequence,itemType:Ot})],Es);class ci{constructor(e={}){this.version=0,this.subject=new ke,this.subjectPKInfo=new ut,this.attributes=new Es,Object.assign(this,e)}}d([g({type:w.Integer})],ci.prototype,"version",void 0);d([g({type:ke})],ci.prototype,"subject",void 0);d([g({type:ut})],ci.prototype,"subjectPKInfo",void 0);d([g({type:Es,implicit:!0,context:0})],ci.prototype,"attributes",void 0);class Pi{constructor(e={}){this.certificationRequestInfo=new ci,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}d([g({type:ci})],Pi.prototype,"certificationRequestInfo",void 0);d([g({type:F})],Pi.prototype,"signatureAlgorithm",void 0);d([g({type:w.BitString})],Pi.prototype,"signature",void 0);/*!
|
|
95
95
|
* MIT License
|
|
96
96
|
*
|
|
97
97
|
* Copyright (c) Peculiar Ventures. All rights reserved.
|
|
@@ -114,21 +114,21 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
114
114
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
115
115
|
* SOFTWARE.
|
|
116
116
|
*
|
|
117
|
-
*/const
|
|
118
|
-
`)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,n=0){const i=[];let r=this.pad(n++),s="";const o=e[
|
|
119
|
-
`).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return
|
|
120
|
-
`)}else{if(!n)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:n,rawData:
|
|
121
|
-
`)}}Ge.CertificateTag="CERTIFICATE";Ge.CrlTag="CRL";Ge.CertificateRequestTag="CERTIFICATE REQUEST";Ge.PublicKeyTag="PUBLIC KEY";Ge.PrivateKeyTag="PRIVATE KEY";class Ot extends Yt{static isAsnEncoded(e){return V.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(Ge.isPem(e))return Ge.decode(e)[0];if(G.isHex(e))return G.FromHex(e);if(G.isBase64(e))return G.FromBase64(e);if(G.isBase64Url(e))return G.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const n=G.ToBinary(e);return Ge.isPem(n)?Ge.decode(n)[0]:G.isHex(n)?G.FromHex(n):G.isBase64(n)?G.FromBase64(n):G.isBase64Url(n)?G.FromBase64Url(n):V.toArrayBuffer(e)}}constructor(...e){Ot.isAsnEncoded(e[0])?super(Ot.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return Ge.encode(this.rawData,this.tag);default:return super.toString(e)}}}class ut extends Ot{static async create(e,n=ze.get()){if(e instanceof ut)return e;if(Ut.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const i=await n.subtle.exportKey("spki",e);return new ut(i)}else{if(e.publicKey)return e.publicKey;if(V.isBufferSource(e))return new ut(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Ot.isAsnEncoded(e)?super(e,lt):super(e),this.tag=Ge.PublicKeyTag}async export(...e){let n,i=["verify"],r={hash:"SHA-256",...this.algorithm};e.length>1?(r=e[0]||r,i=e[1]||i,n=e[2]||ze.get()):n=e[0]||ze.get();let s=this.rawData;const o=U.parse(this.rawData,lt);return o.algorithm.algorithm===mi&&(s=t0(o,s)),n.subtle.importKey("spki",s,r,!0,i)}onInit(e){const n=Oe.resolve(kn),i=this.algorithm=n.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case vn:{const r=U.parse(e.subjectPublicKey,nl),s=V.toUint8Array(r.modulus);i.publicExponent=V.toUint8Array(r.publicExponent),i.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var n;let i,r="SHA-1";return e.length>=1&&!(!((n=e[0])===null||n===void 0)&&n.subtle)?(r=e[0]||r,i=e[1]||ze.get()):i=e[0]||ze.get(),await i.subtle.digest(r,this.rawData)}async getKeyIdentifier(...e){let n,i="SHA-1";e.length===1?typeof e[0]=="string"?(i=e[0],n=ze.get()):n=e[0]:e.length===2?(i=e[0],n=e[1]):n=ze.get();const r=U.parse(this.rawData,lt);return await n.subtle.digest(i,r.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),n=U.parse(this.rawData,lt);switch(e.Algorithm=xn.serializeAlgorithm(n.algorithm),n.algorithm.algorithm){case Ei:e["EC Point"]=n.subjectPublicKey;break;case vn:default:e["Raw Data"]=n.subjectPublicKey}return e}}function t0(t,e){return t.algorithm=new F({algorithm:vn,parameters:null}),e=U.serialize(t),e}class Oi extends it{static async create(e,n=!1,i=ze.get()){if("name"in e&&"serialNumber"in e)return new Oi(e,n);const s=await(await ut.create(e,i)).getKeyIdentifier(i);return new Oi(G.ToHex(s),n)}constructor(...e){if(V.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const n=new sn({keyIdentifier:new Pc(G.FromHex(e[0]))});super(Qo,e[1],U.serialize(n))}else{const n=e[0],i=n.name instanceof ji?U.parse(n.name.rawData,Re):n.name,r=new sn({authorityCertIssuer:i,authorityCertSerialNumber:G.FromHex(n.serialNumber)});super(Qo,e[1],U.serialize(r))}}onInit(e){super.onInit(e);const n=U.parse(e.extnValue,sn);n.keyIdentifier&&(this.keyId=G.ToHex(n.keyIdentifier)),(n.authorityCertIssuer||n.authorityCertSerialNumber)&&(this.certId={name:n.authorityCertIssuer||[],serialNumber:n.authorityCertSerialNumber?G.ToHex(n.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),n=U.parse(this.value,sn);return n.authorityCertIssuer&&(e["Authority Issuer"]=new ji(n.authorityCertIssuer).toTextObject()),n.authorityCertSerialNumber&&(e["Authority Serial Number"]=n.authorityCertSerialNumber),n.keyIdentifier&&(e[""]=n.keyIdentifier),e}}Oi.NAME="Authority Key Identifier";class ol extends it{constructor(...e){if(V.isBufferSource(e[0])){super(e[0]);const n=U.parse(this.value,Or);this.ca=n.cA,this.pathLength=n.pathLenConstraint}else{const n=new Or({cA:e[0],pathLenConstraint:e[1]});super(Nf,e[2],U.serialize(n)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}}ol.NAME="Basic Constraints";var yd;(function(t){t.serverAuth="1.3.6.1.5.5.7.3.1",t.clientAuth="1.3.6.1.5.5.7.3.2",t.codeSigning="1.3.6.1.5.5.7.3.3",t.emailProtection="1.3.6.1.5.5.7.3.4",t.timeStamping="1.3.6.1.5.5.7.3.8",t.ocspSigning="1.3.6.1.5.5.7.3.9"})(yd||(yd={}));class al extends it{constructor(...e){if(V.isBufferSource(e[0])){super(e[0]);const n=U.parse(this.value,Pr);this.usages=n.map(i=>i)}else{const n=new Pr(e[0]);super(Tf,e[1],U.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(n=>Zt.toString(n)).join(", "),e}}al.NAME="Extended Key Usages";var ls;(function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"})(ls||(ls={}));class cl extends it{constructor(...e){if(V.isBufferSource(e[0])){super(e[0]);const n=U.parse(this.value,Ao);this.usages=n.toNumber()}else{const n=new Ao(e[0]);super(Rf,e[1],U.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=U.parse(this.value,Ao);return e[""]=n.toJSON().join(", "),e}}cl.NAME="Key Usages";class Qi extends it{static async create(e,n=!1,i=ze.get()){const s=await(await ut.create(e,i)).getKeyIdentifier(i);return new Qi(G.ToHex(s),n)}constructor(...e){if(V.isBufferSource(e[0])){super(e[0]);const n=U.parse(this.value,Dt);this.keyId=G.ToHex(n)}else{const n=typeof e[0]=="string"?G.FromHex(e[0]):e[0],i=new Dt(n);super(Vf,e[1],U.serialize(i)),this.keyId=G.ToHex(n)}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=U.parse(this.value,Dt);return e[""]=n,e}}Qi.NAME="Subject Key Identifier";class hh extends it{constructor(...e){V.isBufferSource(e[0])?super(e[0]):super(Uf,e[1],new ji(e[0]||[]).rawData)}onInit(e){super.onInit(e);const n=U.parse(e.extnValue,ha);this.names=new ji(n)}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.names.toTextObject();for(const i in n)e[i]=n[i];return e}}hh.NAME="Subject Alternative Name";class rt{static register(e,n){this.items.set(e,n)}static create(e){const n=new it(e),i=this.items.get(n.type);return i?new i(e):n}}rt.items=new Map;class gh extends it{constructor(...e){var n;if(V.isBufferSource(e[0])){super(e[0]);const i=U.parse(this.value,Tr);this.policies=i.map(r=>r.policyIdentifier)}else{const i=e[0],r=(n=e[1])!==null&&n!==void 0?n:!1,s=new Tr(i.map(o=>new Vs({policyIdentifier:o})));super(Of,r,U.serialize(s)),this.policies=i}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(n=>new le("",{},Zt.toString(n))),e}}gh.NAME="Certificate Policies";rt.register(Of,gh);class _h extends it{constructor(...e){var n;if(V.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const r=e[0].map(o=>new Xn({distributionPoint:new gn({fullName:[new te({uniformResourceIdentifier:o})]})})),s=new Bn(r);super(ra,e[1],U.serialize(s))}else{const i=new Bn(e[0]);super(ra,e[1],U.serialize(i))}(n=this.distributionPoints)!==null&&n!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const n=U.parse(e.extnValue,Bn);this.distributionPoints=n}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(n=>{var i;const r={};return n.distributionPoint&&(r[""]=(i=n.distributionPoint.fullName)===null||i===void 0?void 0:i.map(s=>new Vt(s).toString()).join(", ")),n.reasons&&(r.Reasons=n.reasons.toString()),n.cRLIssuer&&(r["CRL Issuer"]=n.cRLIssuer.map(s=>s.toString()).join(", ")),r}),e}}_h.NAME="CRL Distribution Points";class mh extends it{constructor(...e){var n,i,r,s;if(V.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof jn){const o=new jn(e[0]);super(Xo,e[1],U.serialize(o))}else{const o=e[0],c=new jn;cr(c,o,tu,"ocsp"),cr(c,o,nu,"caIssuers"),cr(c,o,iu,"timeStamping"),cr(c,o,ru,"caRepository"),super(Xo,e[1],U.serialize(c))}(n=this.ocsp)!==null&&n!==void 0||(this.ocsp=[]),(i=this.caIssuers)!==null&&i!==void 0||(this.caIssuers=[]),(r=this.timeStamping)!==null&&r!==void 0||(this.timeStamping=[]),(s=this.caRepository)!==null&&s!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],U.parse(e.extnValue,jn).forEach(i=>{switch(i.accessMethod){case tu:this.ocsp.push(new Vt(i.accessLocation));break;case nu:this.caIssuers.push(new Vt(i.accessLocation));break;case iu:this.timeStamping.push(new Vt(i.accessLocation));break;case ru:this.caRepository.push(new Vt(i.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&ar(e,"OCSP",this.ocsp),this.caIssuers.length&&ar(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&ar(e,"Time Stamping",this.timeStamping),this.caRepository.length&&ar(e,"CA Repository",this.caRepository),e}}mh.NAME="Authority Info Access";function ar(t,e,n){if(n.length===1)t[e]=n[0].toTextObject();else{const i=new le("");n.forEach((r,s)=>{const o=r.toTextObject(),c=`${o[le.NAME]} ${s+1}`;let l=i[c];Array.isArray(l)||(l=[],i[c]=l),l.push(o)}),t[e]=i}}function cr(t,e,n,i){const r=e[i];r&&(Array.isArray(r)?r:[r]).forEach(o=>{typeof o=="string"&&(o=new Vt("url",o)),t.push(new Vi({accessMethod:n,accessLocation:U.parse(o.rawData,te)}))})}class si extends Yt{constructor(...e){let n;if(V.isBufferSource(e[0]))n=V.toArrayBuffer(e[0]);else{const i=e[0],r=Array.isArray(e[1])?e[1].map(s=>V.toArrayBuffer(s)):[];n=U.serialize(new $t({type:i,values:r}))}super(n,$t)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(n=>new le("",{"":n})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[le.NAME]===si.NAME&&(e[le.NAME]=Zt.toString(this.type)),e}}si.NAME="Attribute";class yh extends si{constructor(...e){var n;if(V.isBufferSource(e[0]))super(e[0]);else{const i=new as({printableString:e[0]});super(ch,[U.serialize(i)])}(n=this.password)!==null&&n!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const n=U.parse(this.values[0],as);this.password=n.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[le.VALUE]=this.password,e}}yh.NAME="Challenge Password";class ll extends si{constructor(...e){var n;if(V.isBufferSource(e[0]))super(e[0]);else{const i=e[0],r=new qt;for(const s of i)r.push(U.parse(s.rawData,tt));super(sl,[U.serialize(r)])}(n=this.items)!==null&&n!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const n=U.parse(this.values[0],qt);this.items=n.map(i=>rt.create(U.serialize(i)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.items.map(i=>i.toTextObject());for(const i of n)e[i[le.NAME]]=i;return e}}ll.NAME="Extensions";class lo{static register(e,n){this.items.set(e,n)}static create(e){const n=new si(e),i=this.items.get(n.type);return i?new i(e):n}}lo.items=new Map;const er="crypto.signatureFormatter";class n0{toAsnSignature(e,n){return V.toArrayBuffer(n)}toWebSignature(e,n){return V.toArrayBuffer(n)}}var _r;let rc=_r=class{static createPssParams(e,n){const i=_r.getHashAlgorithm(e);return i?new bn({hashAlgorithm:i,maskGenAlgorithm:new F({algorithm:eo,parameters:U.serialize(i)}),saltLength:n}):null}static getHashAlgorithm(e){const n=Oe.resolve(kn);return typeof e=="string"?n.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?n.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let n;if(typeof e.hash=="string")n=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")n=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(n.toLowerCase()){case"sha-1":return new F({algorithm:Yr,parameters:null});case"sha-256":return new F({algorithm:Ta,parameters:null});case"sha-384":return new F({algorithm:Xr,parameters:null});case"sha-512":return new F({algorithm:Qr,parameters:null})}}else return new F({algorithm:vn,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");const n=_r.createPssParams(e.hash,e.saltLength);if(!n)throw new Error("Cannot create PSS parameters");return new F({algorithm:mi,parameters:U.serialize(n)})}else return new F({algorithm:mi,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case vn:return{name:"RSASSA-PKCS1-v1_5"};case Yr:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Ta:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Xr:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Qr:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case mi:if(e.parameters){const n=U.parse(e.parameters,bn);return{name:"RSA-PSS",hash:Oe.resolve(kn).toWebAlgorithm(n.hashAlgorithm),saltLength:n.saltLength}}else return{name:"RSA-PSS"}}return null}};rc=_r=d([ro()],rc);Oe.registerSingleton(Xi,rc);let sc=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new F({algorithm:es});case"sha-256":return new F({algorithm:ts});case"sha-384":return new F({algorithm:ns});case"sha-512":return new F({algorithm:is})}return null}toWebAlgorithm(e){switch(e.algorithm){case es:return{name:"SHA-1"};case ts:return{name:"SHA-256"};case ns:return{name:"SHA-384"};case is:return{name:"SHA-512"}}return null}};sc=d([ro()],sc);Oe.registerSingleton(Xi,sc);class et{addPadding(e,n){const i=V.toUint8Array(n),r=new Uint8Array(e);return r.set(i,e-i.length),r}removePadding(e,n=!1){let i=V.toUint8Array(e);for(let r=0;r<i.length;r++)if(i[r]){i=i.slice(r);break}if(n&&i[0]>127){const r=new Uint8Array(i.length+1);return r.set(i,1),r.buffer}return i.buffer}toAsnSignature(e,n){if(e.name==="ECDSA"){const i=e.namedCurve,r=et.namedCurveSize.get(i)||et.defaultNamedCurveSize,s=new Zr,o=V.toUint8Array(n);return s.r=this.removePadding(o.slice(0,r),!0),s.s=this.removePadding(o.slice(r,r+r),!0),U.serialize(s)}return null}toWebSignature(e,n){if(e.name==="ECDSA"){const i=U.parse(n,Zr),r=e.namedCurve,s=et.namedCurveSize.get(r)||et.defaultNamedCurveSize,o=this.addPadding(s,this.removePadding(i.r)),c=this.addPadding(s,this.removePadding(i.s));return g_(o,c)}return null}}et.namedCurveSize=new Map;et.defaultNamedCurveSize=32;const Oo="1.3.101.110",vd="1.3.101.111",Bo="1.3.101.112",wd="1.3.101.113";let oc=class{toAsnAlgorithm(e){let n=null;switch(e.name.toLowerCase()){case"ed25519":n=Bo;break;case"x25519":n=Oo;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":n=Bo;break;case"ed448":n=wd;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":n=Oo;break;case"x448":n=vd;break}}return n?new F({algorithm:n}):null}toWebAlgorithm(e){switch(e.algorithm){case Bo:return{name:"Ed25519"};case wd:return{name:"EdDSA",namedCurve:"Ed448"};case Oo:return{name:"X25519"};case vd:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};oc=d([ro()],oc);Oe.registerSingleton(Xi,oc);class i0 extends Ot{constructor(e){Ot.isAsnEncoded(e)?super(e,zi):super(e),this.tag=Ge.CertificateRequestTag}onInit(e){this.tbs=U.serialize(e.certificationRequestInfo),this.publicKey=new ut(e.certificationRequestInfo.subjectPKInfo);const n=Oe.resolve(kn);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(r=>lo.create(U.serialize(r)));const i=this.getAttribute(sl);this.extensions=[],i instanceof ll&&(this.extensions=i.items),this.subjectName=new Qe(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(const n of this.attributes)if(n.type===e)return n;return null}getAttributes(e){return this.attributes.filter(n=>n.type===e)}getExtension(e){for(const n of this.extensions)if(n.type===e)return n;return null}getExtensions(e){return this.extensions.filter(n=>n.type===e)}async verify(e=ze.get()){const n={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(n,["verify"],e),r=Oe.resolveAll(er).reverse();let s=null;for(const c of r)if(s=c.toWebSignature(n,this.signature),s)break;if(!s)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,i,s,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),n=U.parse(this.rawData,zi),i=n.certificationRequestInfo,r=new le("",{Version:`${_n[i.version]} (${i.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new le("");for(const o of this.attributes){const c=o.toTextObject();s[c[le.NAME]]=c}r.Attributes=s}return e.Data=r,e.Signature=new le("",{Algorithm:xn.serializeAlgorithm(n.signatureAlgorithm),"":n.signature}),e}}i0.NAME="PKCS#10 Certificate Request";class ul extends Ot{constructor(e){Ot.isAsnEncoded(e)?super(e,mn):super(e),this.tag=Ge.CertificateTag}onInit(e){const n=e.tbsCertificate;this.tbs=U.serialize(n),this.serialNumber=G.ToHex(n.serialNumber),this.subjectName=new Qe(n.subject),this.subject=new Qe(n.subject).toString(),this.issuerName=new Qe(n.issuer),this.issuer=this.issuerName.toString();const i=Oe.resolve(kn);this.signatureAlgorithm=i.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const r=n.validity.notBefore.utcTime||n.validity.notBefore.generalTime;if(!r)throw new Error("Cannot get 'notBefore' value");this.notBefore=r;const s=n.validity.notAfter.utcTime||n.validity.notAfter.generalTime;if(!s)throw new Error("Cannot get 'notAfter' value");this.notAfter=s,this.extensions=[],n.extensions&&(this.extensions=n.extensions.map(o=>rt.create(U.serialize(o)))),this.publicKey=new ut(n.subjectPublicKeyInfo)}getExtension(e){for(const n of this.extensions)if(typeof e=="string"){if(n.type===e)return n}else if(n instanceof e)return n;return null}getExtensions(e){return this.extensions.filter(n=>typeof e=="string"?n.type===e:n instanceof e)}async verify(e={},n=ze.get()){let i,r;const s=e.publicKey;try{if(!s)i={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(i,["verify"],n);else if("publicKey"in s)i={...s.publicKey.algorithm,...this.signatureAlgorithm},r=await s.publicKey.export(i,["verify"],n);else if(s instanceof ut)i={...s.algorithm,...this.signatureAlgorithm},r=await s.export(i,["verify"],n);else if(V.isBufferSource(s)){const u=new ut(s);i={...u.algorithm,...this.signatureAlgorithm},r=await u.export(i,["verify"],n)}else i={...s.algorithm,...this.signatureAlgorithm},r=s}catch{return!1}const o=Oe.resolveAll(er).reverse();let c=null;for(const u of o)if(c=u.toWebSignature(i,this.signature),c)break;if(!c)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const l=await n.subtle.verify(this.signatureAlgorithm,r,c,this.tbs);if(e.signatureOnly)return l;{const p=(e.date||new Date).getTime();return l&&this.notBefore.getTime()<p&&p<this.notAfter.getTime()}}async getThumbprint(...e){let n,i="SHA-1";return e[0]&&(e[0].subtle?n=e[0]:(i=e[0]||i,n=e[1])),n??(n=ze.get()),await n.subtle.digest(i,this.rawData)}async isSelfSigned(e=ze.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),n=U.parse(this.rawData,mn),i=n.tbsCertificate,r=new le("",{Version:`${_n[i.version]} (${i.version})`,"Serial Number":i.serialNumber,"Signature Algorithm":xn.serializeAlgorithm(i.signature),Issuer:this.issuer,Validity:new le("",{"Not Before":i.validity.notBefore.getTime(),"Not After":i.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(i.issuerUniqueID&&(r["Issuer Unique ID"]=i.issuerUniqueID),i.subjectUniqueID&&(r["Subject Unique ID"]=i.subjectUniqueID),this.extensions.length){const s=new le("");for(const o of this.extensions){const c=o.toTextObject();s[c[le.NAME]]=c}r.Extensions=s}return e.Data=r,e.Signature=new le("",{Algorithm:xn.serializeAlgorithm(n.signatureAlgorithm),"":n.signatureValue}),e}}ul.NAME="Certificate";class r0{static async createSelfSigned(e,n=ze.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},n)}static async create(e,n=ze.get()){var i;let r;e.publicKey instanceof ut?r=e.publicKey.rawData:"publicKey"in e.publicKey?r=e.publicKey.publicKey.rawData:V.isBufferSource(e.publicKey)?r=e.publicKey:r=await n.subtle.exportKey("spki",e.publicKey);const s=e.serialNumber?V.toUint8Array(G.FromHex(e.serialNumber)):n.getRandomValues(new Uint8Array(16));s[0]>127&&(s[0]&=127),s.length>1&&s[0]===0&&(s[1]|=128);const o=e.notBefore||new Date,c=e.notAfter||new Date(o.getTime()+31536e6),l=new mn({tbsCertificate:new Ze({version:_n.v3,serialNumber:s,validity:new Mi({notBefore:o,notAfter:c}),extensions:new qt(((i=e.extensions)===null||i===void 0?void 0:i.map(b=>U.parse(b.rawData,tt)))||[]),subjectPublicKeyInfo:U.parse(r,lt)})});if(e.subject){const b=e.subject instanceof Qe?e.subject:new Qe(e.subject);l.tbsCertificate.subject=U.parse(b.toArrayBuffer(),ke)}if(e.issuer){const b=e.issuer instanceof Qe?e.issuer:new Qe(e.issuer);l.tbsCertificate.issuer=U.parse(b.toArrayBuffer(),ke)}const u={hash:"SHA-256"},p="signingKey"in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},g=Oe.resolve(kn);l.tbsCertificate.signature=l.signatureAlgorithm=g.toAsnAlgorithm(p);const _=U.serialize(l.tbsCertificate),k="signingKey"in e?await n.subtle.sign(p,e.signingKey,_):e.signature,h=Oe.resolveAll(er).reverse();let m=null;for(const b of h)if(m=b.toAsnSignature(p,k),m)break;if(!m)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return l.signatureValue=m,new ul(U.serialize(l))}}var bd;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(bd||(bd={}));rt.register(Nf,ol);rt.register(Tf,al);rt.register(Rf,cl);rt.register(Vf,Qi);rt.register(Qo,Oi);rt.register(Uf,hh);rt.register(ra,_h);rt.register(Xo,mh);lo.register(ch,yh);lo.register(sl,ll);Oe.registerSingleton(er,n0);Oe.registerSingleton(er,et);et.namedCurveSize.set("P-256",32);et.namedCurveSize.set("K-256",32);et.namedCurveSize.set("P-384",48);et.namedCurveSize.set("P-521",66);const kd="0123456789abcdef";function ac(t){const e=new Uint8Array(t);let n="";for(let i=0;i<e.length;i++){const r=e[i]>>4;n+=kd[r];const s=e[i]&15;n+=kd[s]}return n}class vh{constructor(e,n){Q(this,"alphabet");Q(this,"padding");Q(this,"decodeMap",new Map);if(e.length!==32)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let i=0;i<e.length;i++)this.decodeMap.set(e[i],i)}encode(e,n){let i="",r=0,s=0;for(let c=0;c<e.length;c++)for(r=r<<8|e[c],s+=8;s>=5;)s-=5,i+=this.alphabet[r>>s&31];if(s>0&&(i+=this.alphabet[r<<5-s&31]),(n==null?void 0:n.includePadding)??!0){const c=(8-i.length%8)%8;for(let l=0;l<c;l++)i+="="}return i}decode(e,n){const i=(n==null?void 0:n.strict)??!0,r=Math.ceil(e.length/8),s=[];for(let o=0;o<r;o++){let c=0;const l=[];for(let p=0;p<8;p++){const g=e[o*8+p];if(g==="="){if(o+1!==r)throw new Error(`Invalid character: ${g}`);c+=1;continue}if(g===void 0){if(i)throw new Error("Invalid data");c+=1;continue}const _=this.decodeMap.get(g)??null;if(_===null)throw new Error(`Invalid character: ${g}`);l.push(_)}if(c===8||c===7||c===5||c===2)throw new Error("Invalid padding");const u=(l[0]<<3)+(l[1]>>2);if(s.push(u),c<6){const p=((l[1]&3)<<6)+(l[2]<<1)+(l[3]>>4);s.push(p)}if(c<4){const p=((l[3]&255)<<4)+(l[4]>>1);s.push(p)}if(c<3){const p=((l[4]&1)<<7)+(l[5]<<2)+(l[6]>>3);s.push(p)}if(c<1){const p=((l[6]&7)<<5)+l[7];s.push(p)}}return Uint8Array.from(s)}}new vh("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new vh("0123456789ABCDEFGHIJKLMNOPQRSTUV");class wh{constructor(e,n){Q(this,"alphabet");Q(this,"padding");Q(this,"decodeMap",new Map);if(e.length!==64)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let i=0;i<e.length;i++)this.decodeMap.set(e[i],i)}encode(e,n){let i="",r=0,s=0;for(let c=0;c<e.length;c++)for(r=r<<8|e[c],s+=8;s>=6;)s+=-6,i+=this.alphabet[r>>s&63];if(s>0&&(i+=this.alphabet[r<<6-s&63]),(n==null?void 0:n.includePadding)??!0){const c=(4-i.length%4)%4;for(let l=0;l<c;l++)i+="="}return i}decode(e,n){const i=(n==null?void 0:n.strict)??!0,r=Math.ceil(e.length/4),s=[];for(let o=0;o<r;o++){let c=0,l=0;for(let u=0;u<4;u++){const p=e[o*4+u];if(p==="="){if(o+1!==r)throw new Error(`Invalid character: ${p}`);c+=1;continue}if(p===void 0){if(i)throw new Error("Invalid data");c+=1;continue}const g=this.decodeMap.get(p)??null;if(g===null)throw new Error(`Invalid character: ${p}`);l+=g<<6*(3-u)}s.push(l>>16&255),c<2&&s.push(l>>8&255),c<1&&s.push(l&255)}return Uint8Array.from(s)}}const s0=new wh("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),ln=new wh("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");class o0{constructor(e){Q(this,"hash");this.hash=e}async verify(e,n,i){const r=await crypto.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["verify"]);return await crypto.subtle.verify("RSASSA-PKCS1-v1_5",r,n,i)}async sign(e,n){const i=await crypto.subtle.importKey("pkcs8",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["sign"]);return await crypto.subtle.sign("RSASSA-PKCS1-v1_5",i,n)}async generateKeyPair(e){const n=await crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",hash:this.hash,modulusLength:e??2048,publicExponent:new Uint8Array([1,0,1])},!0,["sign"]),i=await crypto.subtle.exportKey("pkcs8",n.privateKey),r=await crypto.subtle.exportKey("spki",n.publicKey);return{privateKey:i,publicKey:r}}}async function bh(t){return await crypto.subtle.digest("SHA-256",t)}async function cc(t){const e={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",publicExponent:new Uint8Array([1,0,1]),modulusLength:2048},n=await crypto.subtle.generateKey(e,!0,["sign","verify"]),i=De(),r=ac(new TextEncoder().encode(i)),s=await r0.createSelfSigned({serialNumber:r,name:t.name,notBefore:new Date,notAfter:new Date(Date.now()+365*24*60*60*1e3),signingAlgorithm:e,keys:n,extensions:[new ol(!0,2,!0),new al(["1.3.6.1.5.5.7.3.1"],!0),new cl(ls.keyCertSign|ls.cRLSign,!0),await Qi.create(n.publicKey)]}),o=await crypto.subtle.exportKey("pkcs8",n.privateKey),c=s.toString("pem"),l=await c0(s),u=ac(await s.getThumbprint()),p=a0("PRIVATE",o);return{kid:s.serialNumber,cert:c,thumbprint:u,fingerprint:l,pkcs7:p}}function a0(t,e){const n=s0.encode(new Uint8Array(e));let i=`-----BEGIN ${t} KEY-----\r
|
|
117
|
+
*/const cr="crypto.algorithm";class P0{getAlgorithms(){return Be.resolveAll(cr)}toAsnAlgorithm(e){({...e});for(const n of this.getAlgorithms()){const i=n.toAsnAlgorithm(e);if(i)return i}if(/^[0-9.]+$/.test(e.name)){const n=new F({algorithm:e.name});if("parameters"in e){const i=e;n.parameters=i.parameters}return n}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(const i of this.getAlgorithms()){const r=i.toWebAlgorithm(e);if(r)return r}return{name:e.algorithm,parameters:e.parameters}}}const An="crypto.algorithmProvider";Be.registerSingleton(An,P0);var Cr;const Ke="1.3.36.3.3.2.8.1.1",fd=`${Ke}.1`,hd=`${Ke}.2`,gd=`${Ke}.3`,md=`${Ke}.4`,_d=`${Ke}.5`,yd=`${Ke}.6`,vd=`${Ke}.7`,wd=`${Ke}.8`,bd=`${Ke}.9`,kd=`${Ke}.10`,xd=`${Ke}.11`,Sd=`${Ke}.12`,Ad=`${Ke}.13`,Ed=`${Ke}.14`,Id="brainpoolP160r1",Cd="brainpoolP160t1",$d="brainpoolP192r1",zd="brainpoolP192t1",Nd="brainpoolP224r1",jd="brainpoolP224t1",Od="brainpoolP256r1",Bd="brainpoolP256t1",Td="brainpoolP320r1",Pd="brainpoolP320t1",Rd="brainpoolP384r1",Ld="brainpoolP384t1",Ud="brainpoolP512r1",Vd="brainpoolP512t1",ye="ECDSA";let Ri=Cr=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case ye.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return o0;case"sha-256":return a0;case"sha-384":return c0;case"sha-512":return l0}else if("namedCurve"in e){let n="";switch(e.namedCurve){case"P-256":n=Fu;break;case"K-256":n=Cr.SECP256K1;break;case"P-384":n=qu;break;case"P-521":n=Ku;break;case Id:n=fd;break;case Cd:n=hd;break;case $d:n=gd;break;case zd:n=md;break;case Nd:n=_d;break;case jd:n=yd;break;case Od:n=vd;break;case Bd:n=wd;break;case Td:n=bd;break;case Pd:n=kd;break;case Rd:n=xd;break;case Ld:n=Sd;break;case Ud:n=Ad;break;case Vd:n=Ed;break}if(n)return new F({algorithm:Bi,parameters:V.serialize(new Zt({namedCurve:n}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case kl:return{name:ye,hash:{name:"SHA-1"}};case xl:return{name:ye,hash:{name:"SHA-256"}};case Sl:return{name:ye,hash:{name:"SHA-384"}};case Al:return{name:ye,hash:{name:"SHA-512"}};case Bi:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(V.parse(e.parameters,Zt).namedCurve){case Fu:return{name:ye,namedCurve:"P-256"};case Cr.SECP256K1:return{name:ye,namedCurve:"K-256"};case qu:return{name:ye,namedCurve:"P-384"};case Ku:return{name:ye,namedCurve:"P-521"};case fd:return{name:ye,namedCurve:Id};case hd:return{name:ye,namedCurve:Cd};case gd:return{name:ye,namedCurve:$d};case md:return{name:ye,namedCurve:zd};case _d:return{name:ye,namedCurve:Nd};case yd:return{name:ye,namedCurve:jd};case vd:return{name:ye,namedCurve:Od};case wd:return{name:ye,namedCurve:Bd};case bd:return{name:ye,namedCurve:Td};case kd:return{name:ye,namedCurve:Pd};case xd:return{name:ye,namedCurve:Rd};case Sd:return{name:ye,namedCurve:Ld};case Ad:return{name:ye,namedCurve:Ud};case Ed:return{name:ye,namedCurve:Vd}}}}return null}};Ri.SECP256K1="1.3.132.0.10";Ri=Cr=d([Ao()],Ri);Be.registerSingleton(cr,Ri);const Hh=Symbol("name"),Fh=Symbol("value");class ue{constructor(e,n={},i=""){this[Hh]=e,this[Fh]=i;for(const r in n)this[r]=n[r]}}ue.NAME=Hh;ue.VALUE=Fh;class R0{static toTextObject(e){const n=new ue("Algorithm Identifier",{},Qt.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case Bi:{const i=new Ri().toWebAlgorithm(e);i&&"namedCurve"in i?n["Named Curve"]=i.namedCurve:n.Parameters=e.parameters;break}default:n.Parameters=e.parameters}return n}}class Qt{static toString(e){const n=this.items[e];return n||e}}Qt.items={[ys]:"sha1",[zh]:"sha224",[vs]:"sha256",[ws]:"sha384",[bs]:"sha512",[kn]:"rsaEncryption",[gs]:"sha1WithRSAEncryption",[g0]:"sha224WithRSAEncryption",[ic]:"sha256WithRSAEncryption",[ms]:"sha384WithRSAEncryption",[_s]:"sha512WithRSAEncryption",[Bi]:"ecPublicKey",[kl]:"ecdsaWithSHA1",[Ih]:"ecdsaWithSHA224",[xl]:"ecdsaWithSHA256",[Sl]:"ecdsaWithSHA384",[Al]:"ecdsaWithSHA512",[Q_]:"TLS WWW server authentication",[e0]:"TLS WWW client authentication",[t0]:"Code Signing",[n0]:"E-mail Protection",[i0]:"Time Stamping",[r0]:"OCSP Signing",[s0]:"Signed Data"};class En{static serialize(e){return this.serializeObj(e).join(`
|
|
118
|
+
`)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,n=0){const i=[];let r=this.pad(n++),s="";const o=e[ue.VALUE];o&&(s=` ${o}`),i.push(`${r}${e[ue.NAME]}:${s}`),r=this.pad(n);for(const c in e){if(typeof c=="symbol")continue;const l=e[c],u=c?`${c}: `:"";if(typeof l=="string"||typeof l=="number"||typeof l=="boolean")i.push(`${r}${u}${l}`);else if(l instanceof Date)i.push(`${r}${u}${l.toUTCString()}`);else if(Array.isArray(l))for(const p of l)p[ue.NAME]=c,i.push(...this.serializeObj(p,n));else if(l instanceof ue)l[ue.NAME]=c,i.push(...this.serializeObj(l,n));else if(M.isBufferSource(l))c?(i.push(`${r}${u}`),i.push(...this.serializeBufferSource(l,n+1))):i.push(...this.serializeBufferSource(l,n));else if("toTextObject"in l){const p=l.toTextObject();p[ue.NAME]=c,i.push(...this.serializeObj(p,n))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return i}static serializeBufferSource(e,n=0){const i=this.pad(n),r=M.toUint8Array(e),s=[];for(let o=0;o<r.length;){const c=[];for(let l=0;l<16&&o<r.length;l++){l===8&&c.push("");const u=r[o++].toString(16).padStart(2,"0");c.push(u)}s.push(`${i}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}En.oidSerializer=Qt;En.algorithmSerializer=R0;class en{constructor(...e){if(e.length===1){const n=e[0];this.rawData=V.serialize(n),this.onInit(n)}else{const n=V.parse(e[0],e[1]);this.rawData=M.toArrayBuffer(e[0]),this.onInit(n)}}equal(e){return e instanceof en?lf(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return V.toString(this.rawData);case"text":return En.serialize(this.toTextObject());case"hex":return G.ToHex(this.rawData);case"base64":return G.ToBase64(this.rawData);case"base64url":return G.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){const e=this.toTextObjectEmpty();return e[""]=this.rawData,e}toTextObjectEmpty(e){return new ue(this.getTextName(),{},e)}}en.NAME="ASN";class rt extends en{constructor(...e){let n;M.isBufferSource(e[0])?n=M.toArrayBuffer(e[0]):n=V.serialize(new nt({extnID:e[0],critical:e[1],extnValue:new ae(M.toArrayBuffer(e[2]))})),super(n,nt)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.value,e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty(this.critical?"critical":void 0);return e[ue.NAME]===rt.NAME&&(e[ue.NAME]=Qt.toString(this.type)),e}}var qh;class Mt{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[qh]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(Mt.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(Mt.DEFAULT,global.crypto)}clear(){this.items.clear()}delete(e){return this.items.delete(e)}forEach(e,n){return this.items.forEach(e,n)}has(e){return this.items.has(e)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(e=Mt.DEFAULT){const n=this.items.get(e.toLowerCase());if(!n)throw new Error(`Cannot get Crypto by name '${e}'`);return n}set(e,n){if(typeof e=="string"){if(!n)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),n)}else this.items.set(Mt.DEFAULT,e);return this}}qh=Symbol.toStringTag;Mt.DEFAULT="default";const ze=new Mt,L0=/^[0-2](?:\.[1-9][0-9]*)+$/;function U0(t){return new RegExp(L0).test(t)}class Kh{constructor(e={}){this.items={};for(const n in e)this.register(n,e[n])}get(e){return this.items[e]||null}findId(e){return U0(e)?e:this.get(e)}register(e,n){this.items[e]=n,this.items[n]=e}}const Fe=new Kh;Fe.register("CN","2.5.4.3");Fe.register("L","2.5.4.7");Fe.register("ST","2.5.4.8");Fe.register("O","2.5.4.10");Fe.register("OU","2.5.4.11");Fe.register("C","2.5.4.6");Fe.register("DC","0.9.2342.19200300.100.1.25");Fe.register("E","1.2.840.113549.1.9.1");Fe.register("G","2.5.4.42");Fe.register("I","2.5.4.43");Fe.register("SN","2.5.4.4");Fe.register("T","2.5.4.12");function V0(t,e){return`\\${G.ToHex(G.FromUtf8String(e)).toUpperCase()}`}function M0(t){return t.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,V0)}class et{static isASCII(e){for(let n=0;n<e.length;n++)if(e.charCodeAt(n)>255)return!1;return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e,n={}){this.extraNames=new Kh,this.asn=new ke;for(const i in n)if(Object.prototype.hasOwnProperty.call(n,i)){const r=n[i];this.extraNames.register(i,r)}typeof e=="string"?this.asn=this.fromString(e):e instanceof ke?this.asn=e:M.isBufferSource(e)?this.asn=V.parse(e,ke):this.asn=this.fromJSON(e)}getField(e){const n=this.extraNames.findId(e)||Fe.findId(e),i=[];for(const r of this.asn)for(const s of r)s.type===n&&i.push(s.value.toString());return i}getName(e){return this.extraNames.get(e)||Fe.get(e)}toString(){return this.asn.map(e=>e.map(n=>{const i=this.getName(n.type)||n.type,r=n.value.anyValue?`#${G.ToHex(n.value.anyValue)}`:M0(n.value.toString());return`${i}=${r}`}).join("+")).join(", ")}toJSON(){var e;const n=[];for(const i of this.asn){const r={};for(const s of i){const o=this.getName(s.type)||s.type;(e=r[o])!==null&&e!==void 0||(r[o]=[]),r[o].push(s.value.anyValue?`#${G.ToHex(s.value.anyValue)}`:s.value.toString())}n.push(r)}return n}fromString(e){const n=new ke,i=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let r=null,s=",";for(;r=i.exec(`${e},`);){let[,o,c]=r;const l=c[c.length-1];(l===","||l==="+")&&(c=c.slice(0,c.length-1),r[3]=l);const u=r[3];o=this.getTypeOid(o);const p=this.createAttribute(o,c);s==="+"?n[n.length-1].push(p):n.push(new Dn([p])),s=u}return n}fromJSON(e){const n=new ke;for(const i of e){const r=new Dn;for(const s in i){const o=this.getTypeOid(s),c=i[s];for(const l of c){const u=this.createAttribute(o,l);r.push(u)}}n.push(r)}return n}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||""),!e)throw new Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(e,n){const i=new ro({type:e});if(typeof n=="object")for(const r in n)switch(r){case"ia5String":i.value.ia5String=n[r];break;case"utf8String":i.value.utf8String=n[r];break;case"universalString":i.value.universalString=n[r];break;case"bmpString":i.value.bmpString=n[r];break;case"printableString":i.value.printableString=n[r];break}else if(n[0]==="#")i.value.anyValue=G.FromHex(n.slice(1));else{const r=this.processStringValue(n);e===this.getName("E")||e===this.getName("DC")?i.value.ia5String=r:et.isPrintableString(r)?i.value.printableString=r:i.value.utf8String=r}return i}processStringValue(e){const n=/"(.*?[^\\])?"/.exec(e);return n&&(e=n[1]),e.replace(/\\0a/ig,`
|
|
119
|
+
`).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return V.serialize(this.asn)}async getThumbprint(...e){var n;let i,r="SHA-1";return e.length>=1&&!(!((n=e[0])===null||n===void 0)&&n.subtle)?(r=e[0]||r,i=e[1]||ze.get()):i=e[0]||ze.get(),await i.subtle.digest(r,this.toArrayBuffer())}}const Wh="Cannot initialize GeneralName from ASN.1 data.",Md=`${Wh} Unsupported string format in use.`,D0=`${Wh} Value doesn't match to GUID regular expression.`,Dd=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Hd="1.3.6.1.4.1.311.25.1",Fd="1.3.6.1.4.1.311.20.2.3",Fo="dns",qo="dn",Ko="email",Wo="ip",Go="url",Jo="guid",Zo="upn",yr="id";class Dt extends en{constructor(...e){let n;if(e.length===2)switch(e[0]){case qo:{const i=new et(e[1]).toArrayBuffer(),r=V.parse(i,ke);n=new ne({directoryName:r});break}case Fo:n=new ne({dNSName:e[1]});break;case Ko:n=new ne({rfc822Name:e[1]});break;case Jo:{const i=new RegExp(Dd,"i").exec(e[1]);if(!i)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const r=i.slice(1).map((s,o)=>o<3?G.ToHex(new Uint8Array(G.FromHex(s)).reverse()):s).join("");n=new ne({otherName:new zi({typeId:Hd,value:V.serialize(new ae(G.FromHex(r)))})});break}case Wo:n=new ne({iPAddress:e[1]});break;case yr:n=new ne({registeredID:e[1]});break;case Zo:{n=new ne({otherName:new zi({typeId:Fd,value:V.serialize(lh.toASN(e[1]))})});break}case Go:n=new ne({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else M.isBufferSource(e[0])?n=V.parse(e[0],ne):n=e[0];super(n)}onInit(e){if(e.dNSName!=null)this.type=Fo,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=Ko,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=Wo,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=Go,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=yr,this.value=e.registeredID;else if(e.directoryName!=null)this.type=qo,this.value=new et(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===Hd){this.type=Jo;const n=V.parse(e.otherName.value,ae),i=new RegExp(Dd,"i").exec(G.ToHex(n));if(!i)throw new Error(D0);this.value=i.slice(1).map((r,s)=>s<3?G.ToHex(new Uint8Array(G.FromHex(r)).reverse()):r).join("-")}else if(e.otherName.typeId===Fd)this.type=Zo,this.value=V.parse(e.otherName.value,Oe).toString();else throw new Error(Md);else throw new Error(Md)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case qo:case Fo:case Jo:case Wo:case yr:case Zo:case Go:e=this.type.toUpperCase();break;case Ko:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let n=this.value;return this.type===yr&&(n=Qt.toString(n)),new ue(e,void 0,n)}}class Li extends en{constructor(e){let n;if(e instanceof Re)n=e;else if(Array.isArray(e)){const i=[];for(const r of e)if(r instanceof ne)i.push(r);else{const s=V.parse(new Dt(r.type,r.value).rawData,ne);i.push(s)}n=new Re(i)}else if(M.isBufferSource(e))n=V.parse(e,Re);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(n)}onInit(e){const n=[];for(const i of e){let r=null;try{r=new Dt(i)}catch{continue}n.push(r)}this.items=n}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){const e=super.toTextObjectEmpty();for(const n of this.items){const i=n.toTextObject();let r=e[i[ue.NAME]];Array.isArray(r)||(r=[],e[i[ue.NAME]]=r),r.push(i)}return e}}Li.NAME="GeneralNames";const Ai="-{5}",Ui="\\n",H0=`[^${Ui}]+`,F0=`${Ai}BEGIN (${H0}(?=${Ai}))${Ai}`,q0=`${Ai}END \\1${Ai}`,Zn="\\n",K0=`[^:${Ui}]+`,W0=`(?:[^${Ui}]+${Zn}(?: +[^${Ui}]+${Zn})*)`,G0="[a-zA-Z0-9=+/]+",J0=`(?:${G0}${Zn})+`,qd=`${F0}${Zn}(?:((?:${K0}: ${W0})+))?${Zn}?(${J0})${q0}`;class Je{static isPem(e){return typeof e=="string"&&new RegExp(qd,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const n=new RegExp(qd,"g"),i=[];let r=null;for(;r=n.exec(e);){const s=r[3].replace(new RegExp(`[${Ui}]+`,"g"),""),o={type:r[1],headers:[],rawData:G.FromBase64(s)},c=r[2];if(c){const l=c.split(new RegExp(Zn,"g"));let u=null;for(const p of l){const[f,m]=p.split(/:(.*)/);if(m===void 0){if(!u)throw new Error("Cannot parse PEM string. Incorrect header value");u.value+=f.trim()}else u&&o.headers.push(u),u={key:f,value:m.trim()}}u&&o.headers.push(u)}i.push(o)}return i}static decode(e){return this.decodeWithHeaders(e).map(i=>i.rawData)}static decodeFirst(e){const n=this.decode(e);if(!n.length)throw new RangeError("PEM string doesn't contain any objects");return n[0]}static encode(e,n){if(Array.isArray(e)){const i=new Array;return n?e.forEach(r=>{if(!M.isBufferSource(r))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");i.push(this.encodeStruct({type:n,rawData:M.toArrayBuffer(r)}))}):e.forEach(r=>{if(!("type"in r))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");i.push(this.encodeStruct(r))}),i.join(`
|
|
120
|
+
`)}else{if(!n)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:n,rawData:M.toArrayBuffer(e)})}}static encodeStruct(e){var n;const i=e.type.toLocaleUpperCase(),r=[];if(r.push(`-----BEGIN ${i}-----`),!((n=e.headers)===null||n===void 0)&&n.length){for(const u of e.headers)r.push(`${u.key}: ${u.value}`);r.push("")}const s=G.ToBase64(e.rawData);let o,c=0;const l=Array();for(;c<s.length&&(s.length-c<64?o=s.substring(c):(o=s.substring(c,c+64),c+=64),o.length!==0);)if(l.push(o),o.length<64)break;return r.push(...l),r.push(`-----END ${i}-----`),r.join(`
|
|
121
|
+
`)}}Je.CertificateTag="CERTIFICATE";Je.CrlTag="CRL";Je.CertificateRequestTag="CERTIFICATE REQUEST";Je.PublicKeyTag="PUBLIC KEY";Je.PrivateKeyTag="PRIVATE KEY";class Pt extends en{static isAsnEncoded(e){return M.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(Je.isPem(e))return Je.decode(e)[0];if(G.isHex(e))return G.FromHex(e);if(G.isBase64(e))return G.FromBase64(e);if(G.isBase64Url(e))return G.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const n=G.ToBinary(e);return Je.isPem(n)?Je.decode(n)[0]:G.isHex(n)?G.FromHex(n):G.isBase64(n)?G.FromBase64(n):G.isBase64Url(n)?G.FromBase64Url(n):M.toArrayBuffer(e)}}constructor(...e){Pt.isAsnEncoded(e[0])?super(Pt.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return Je.encode(this.rawData,this.tag);default:return super.toString(e)}}}class dt extends Pt{static async create(e,n=ze.get()){if(e instanceof dt)return e;if(Mt.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const i=await n.subtle.exportKey("spki",e);return new dt(i)}else{if(e.publicKey)return e.publicKey;if(M.isBufferSource(e))return new dt(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Pt.isAsnEncoded(e)?super(e,ut):super(e),this.tag=Je.PublicKeyTag}async export(...e){let n,i=["verify"],r={hash:"SHA-256",...this.algorithm};e.length>1?(r=e[0]||r,i=e[1]||i,n=e[2]||ze.get()):n=e[0]||ze.get();let s=this.rawData;const o=V.parse(this.rawData,ut);return o.algorithm.algorithm===Si&&(s=Z0(o,s)),n.subtle.importKey("spki",s,r,!0,i)}onInit(e){const n=Be.resolve(An),i=this.algorithm=n.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case kn:{const r=V.parse(e.subjectPublicKey,El),s=M.toUint8Array(r.modulus);i.publicExponent=M.toUint8Array(r.publicExponent),i.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var n;let i,r="SHA-1";return e.length>=1&&!(!((n=e[0])===null||n===void 0)&&n.subtle)?(r=e[0]||r,i=e[1]||ze.get()):i=e[0]||ze.get(),await i.subtle.digest(r,this.rawData)}async getKeyIdentifier(...e){let n,i="SHA-1";e.length===1?typeof e[0]=="string"?(i=e[0],n=ze.get()):n=e[0]:e.length===2?(i=e[0],n=e[1]):n=ze.get();const r=V.parse(this.rawData,ut);return await n.subtle.digest(i,r.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),n=V.parse(this.rawData,ut);switch(e.Algorithm=En.serializeAlgorithm(n.algorithm),n.algorithm.algorithm){case Bi:e["EC Point"]=n.subjectPublicKey;break;case kn:default:e["Raw Data"]=n.subjectPublicKey}return e}}function Z0(t,e){return t.algorithm=new F({algorithm:kn,parameters:null}),e=V.serialize(t),e}class Vi extends rt{static async create(e,n=!1,i=ze.get()){if("name"in e&&"serialNumber"in e)return new Vi(e,n);const s=await(await dt.create(e,i)).getKeyIdentifier(i);return new Vi(G.ToHex(s),n)}constructor(...e){if(M.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const n=new cn({keyIdentifier:new al(G.FromHex(e[0]))});super(ba,e[1],V.serialize(n))}else{const n=e[0],i=n.name instanceof Li?V.parse(n.name.rawData,Re):n.name,r=new cn({authorityCertIssuer:i,authorityCertSerialNumber:G.FromHex(n.serialNumber)});super(ba,e[1],V.serialize(r))}}onInit(e){super.onInit(e);const n=V.parse(e.extnValue,cn);n.keyIdentifier&&(this.keyId=G.ToHex(n.keyIdentifier)),(n.authorityCertIssuer||n.authorityCertSerialNumber)&&(this.certId={name:n.authorityCertIssuer||[],serialNumber:n.authorityCertSerialNumber?G.ToHex(n.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),n=V.parse(this.value,cn);return n.authorityCertIssuer&&(e["Authority Issuer"]=new Li(n.authorityCertIssuer).toTextObject()),n.authorityCertSerialNumber&&(e["Authority Serial Number"]=n.authorityCertSerialNumber),n.keyIdentifier&&(e[""]=n.keyIdentifier),e}}Vi.NAME="Authority Key Identifier";class zl extends rt{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=V.parse(this.value,Yr);this.ca=n.cA,this.pathLength=n.pathLenConstraint}else{const n=new Yr({cA:e[0],pathLenConstraint:e[1]});super(ph,e[2],V.serialize(n)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}}zl.NAME="Basic Constraints";var Kd;(function(t){t.serverAuth="1.3.6.1.5.5.7.3.1",t.clientAuth="1.3.6.1.5.5.7.3.2",t.codeSigning="1.3.6.1.5.5.7.3.3",t.emailProtection="1.3.6.1.5.5.7.3.4",t.timeStamping="1.3.6.1.5.5.7.3.8",t.ocspSigning="1.3.6.1.5.5.7.3.9"})(Kd||(Kd={}));class Nl extends rt{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=V.parse(this.value,ts);this.usages=n.map(i=>i)}else{const n=new ts(e[0]);super(gh,e[1],V.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(n=>Qt.toString(n)).join(", "),e}}Nl.NAME="Extended Key Usages";var Is;(function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"})(Is||(Is={}));class jl extends rt{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=V.parse(this.value,Ho);this.usages=n.toNumber()}else{const n=new Ho(e[0]);super(mh,e[1],V.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=V.parse(this.value,Ho);return e[""]=n.toJSON().join(", "),e}}jl.NAME="Key Usages";class lr extends rt{static async create(e,n=!1,i=ze.get()){const s=await(await dt.create(e,i)).getKeyIdentifier(i);return new lr(G.ToHex(s),n)}constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=V.parse(this.value,Ft);this.keyId=G.ToHex(n)}else{const n=typeof e[0]=="string"?G.FromHex(e[0]):e[0],i=new Ft(n);super(wh,e[1],V.serialize(i)),this.keyId=G.ToHex(n)}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=V.parse(this.value,Ft);return e[""]=n,e}}lr.NAME="Subject Key Identifier";class Gh extends rt{constructor(...e){M.isBufferSource(e[0])?super(e[0]):super(vh,e[1],new Li(e[0]||[]).rawData)}onInit(e){super.onInit(e);const n=V.parse(e.extnValue,Pa);this.names=new Li(n)}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.names.toTextObject();for(const i in n)e[i]=n[i];return e}}Gh.NAME="Subject Alternative Name";class st{static register(e,n){this.items.set(e,n)}static create(e){const n=new rt(e),i=this.items.get(n.type);return i?new i(e):n}}st.items=new Map;class Jh extends rt{constructor(...e){var n;if(M.isBufferSource(e[0])){super(e[0]);const i=V.parse(this.value,Qr);this.policies=i.map(r=>r.policyIdentifier)}else{const i=e[0],r=(n=e[1])!==null&&n!==void 0?n:!1,s=new Qr(i.map(o=>new oo({policyIdentifier:o})));super(fh,r,V.serialize(s)),this.policies=i}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(n=>new ue("",{},Qt.toString(n))),e}}Jh.NAME="Certificate Policies";st.register(fh,Jh);class Zh extends rt{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const r=e[0].map(o=>new ni({distributionPoint:new yn({fullName:[new ne({uniformResourceIdentifier:o})]})})),s=new Ln(r);super(Ea,e[1],V.serialize(s))}else{const i=new Ln(e[0]);super(Ea,e[1],V.serialize(i))}(n=this.distributionPoints)!==null&&n!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const n=V.parse(e.extnValue,Ln);this.distributionPoints=n}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(n=>{var i;const r={};return n.distributionPoint&&(r[""]=(i=n.distributionPoint.fullName)===null||i===void 0?void 0:i.map(s=>new Dt(s).toString()).join(", ")),n.reasons&&(r.Reasons=n.reasons.toString()),n.cRLIssuer&&(r["CRL Issuer"]=n.cRLIssuer.map(s=>s.toString()).join(", ")),r}),e}}Zh.NAME="CRL Distribution Points";class Yh extends rt{constructor(...e){var n,i,r,s;if(M.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Tn){const o=new Tn(e[0]);super(wa,e[1],V.serialize(o))}else{const o=e[0],c=new Tn;wr(c,o,$u,"ocsp"),wr(c,o,zu,"caIssuers"),wr(c,o,Nu,"timeStamping"),wr(c,o,ju,"caRepository"),super(wa,e[1],V.serialize(c))}(n=this.ocsp)!==null&&n!==void 0||(this.ocsp=[]),(i=this.caIssuers)!==null&&i!==void 0||(this.caIssuers=[]),(r=this.timeStamping)!==null&&r!==void 0||(this.timeStamping=[]),(s=this.caRepository)!==null&&s!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],V.parse(e.extnValue,Tn).forEach(i=>{switch(i.accessMethod){case $u:this.ocsp.push(new Dt(i.accessLocation));break;case zu:this.caIssuers.push(new Dt(i.accessLocation));break;case Nu:this.timeStamping.push(new Dt(i.accessLocation));break;case ju:this.caRepository.push(new Dt(i.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&vr(e,"OCSP",this.ocsp),this.caIssuers.length&&vr(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&vr(e,"Time Stamping",this.timeStamping),this.caRepository.length&&vr(e,"CA Repository",this.caRepository),e}}Yh.NAME="Authority Info Access";function vr(t,e,n){if(n.length===1)t[e]=n[0].toTextObject();else{const i=new ue("");n.forEach((r,s)=>{const o=r.toTextObject(),c=`${o[ue.NAME]} ${s+1}`;let l=i[c];Array.isArray(l)||(l=[],i[c]=l),l.push(o)}),t[e]=i}}function wr(t,e,n,i){const r=e[i];r&&(Array.isArray(r)?r:[r]).forEach(o=>{typeof o=="string"&&(o=new Dt("url",o)),t.push(new Zi({accessMethod:n,accessLocation:V.parse(o.rawData,ne)}))})}class li extends en{constructor(...e){let n;if(M.isBufferSource(e[0]))n=M.toArrayBuffer(e[0]);else{const i=e[0],r=Array.isArray(e[1])?e[1].map(s=>M.toArrayBuffer(s)):[];n=V.serialize(new Ot({type:i,values:r}))}super(n,Ot)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(n=>new ue("",{"":n})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[ue.NAME]===li.NAME&&(e[ue.NAME]=Qt.toString(this.type)),e}}li.NAME="Attribute";class Xh extends li{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else{const i=new As({printableString:e[0]});super(Dh,[V.serialize(i)])}(n=this.password)!==null&&n!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const n=V.parse(this.values[0],As);this.password=n.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[ue.VALUE]=this.password,e}}Xh.NAME="Challenge Password";class Ol extends li{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else{const i=e[0],r=new Gt;for(const s of i)r.push(V.parse(s.rawData,nt));super($l,[V.serialize(r)])}(n=this.items)!==null&&n!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const n=V.parse(this.values[0],Gt);this.items=n.map(i=>st.create(V.serialize(i)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.items.map(i=>i.toTextObject());for(const i of n)e[i[ue.NAME]]=i;return e}}Ol.NAME="Extensions";class zo{static register(e,n){this.items.set(e,n)}static create(e){const n=new li(e),i=this.items.get(n.type);return i?new i(e):n}}zo.items=new Map;const ur="crypto.signatureFormatter";class Y0{toAsnSignature(e,n){return M.toArrayBuffer(n)}toWebSignature(e,n){return M.toArrayBuffer(n)}}var $r;let Ec=$r=class{static createPssParams(e,n){const i=$r.getHashAlgorithm(e);return i?new Sn({hashAlgorithm:i,maskGenAlgorithm:new F({algorithm:bo,parameters:V.serialize(i)}),saltLength:n}):null}static getHashAlgorithm(e){const n=Be.resolve(An);return typeof e=="string"?n.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?n.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let n;if(typeof e.hash=="string")n=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")n=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(n.toLowerCase()){case"sha-1":return new F({algorithm:gs,parameters:null});case"sha-256":return new F({algorithm:ic,parameters:null});case"sha-384":return new F({algorithm:ms,parameters:null});case"sha-512":return new F({algorithm:_s,parameters:null})}}else return new F({algorithm:kn,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");const n=$r.createPssParams(e.hash,e.saltLength);if(!n)throw new Error("Cannot create PSS parameters");return new F({algorithm:Si,parameters:V.serialize(n)})}else return new F({algorithm:Si,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case kn:return{name:"RSASSA-PKCS1-v1_5"};case gs:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case ic:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case ms:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case _s:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Si:if(e.parameters){const n=V.parse(e.parameters,Sn);return{name:"RSA-PSS",hash:Be.resolve(An).toWebAlgorithm(n.hashAlgorithm),saltLength:n.saltLength}}else return{name:"RSA-PSS"}}return null}};Ec=$r=d([Ao()],Ec);Be.registerSingleton(cr,Ec);let Ic=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new F({algorithm:ys});case"sha-256":return new F({algorithm:vs});case"sha-384":return new F({algorithm:ws});case"sha-512":return new F({algorithm:bs})}return null}toWebAlgorithm(e){switch(e.algorithm){case ys:return{name:"SHA-1"};case vs:return{name:"SHA-256"};case ws:return{name:"SHA-384"};case bs:return{name:"SHA-512"}}return null}};Ic=d([Ao()],Ic);Be.registerSingleton(cr,Ic);class tt{addPadding(e,n){const i=M.toUint8Array(n),r=new Uint8Array(e);return r.set(i,e-i.length),r}removePadding(e,n=!1){let i=M.toUint8Array(e);for(let r=0;r<i.length;r++)if(i[r]){i=i.slice(r);break}if(n&&i[0]>127){const r=new Uint8Array(i.length+1);return r.set(i,1),r.buffer}return i.buffer}toAsnSignature(e,n){if(e.name==="ECDSA"){const i=e.namedCurve,r=tt.namedCurveSize.get(i)||tt.defaultNamedCurveSize,s=new hs,o=M.toUint8Array(n);return s.r=this.removePadding(o.slice(0,r),!0),s.s=this.removePadding(o.slice(r,r+r),!0),V.serialize(s)}return null}toWebSignature(e,n){if(e.name==="ECDSA"){const i=V.parse(n,hs),r=e.namedCurve,s=tt.namedCurveSize.get(r)||tt.defaultNamedCurveSize,o=this.addPadding(s,this.removePadding(i.r)),c=this.addPadding(s,this.removePadding(i.s));return u_(o,c)}return null}}tt.namedCurveSize=new Map;tt.defaultNamedCurveSize=32;const Yo="1.3.101.110",Wd="1.3.101.111",Xo="1.3.101.112",Gd="1.3.101.113";let Cc=class{toAsnAlgorithm(e){let n=null;switch(e.name.toLowerCase()){case"ed25519":n=Xo;break;case"x25519":n=Yo;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":n=Xo;break;case"ed448":n=Gd;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":n=Yo;break;case"x448":n=Wd;break}}return n?new F({algorithm:n}):null}toWebAlgorithm(e){switch(e.algorithm){case Xo:return{name:"Ed25519"};case Gd:return{name:"EdDSA",namedCurve:"Ed448"};case Yo:return{name:"X25519"};case Wd:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Cc=d([Ao()],Cc);Be.registerSingleton(cr,Cc);class X0 extends Pt{constructor(e){Pt.isAsnEncoded(e)?super(e,Pi):super(e),this.tag=Je.CertificateRequestTag}onInit(e){this.tbs=V.serialize(e.certificationRequestInfo),this.publicKey=new dt(e.certificationRequestInfo.subjectPKInfo);const n=Be.resolve(An);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(r=>zo.create(V.serialize(r)));const i=this.getAttribute($l);this.extensions=[],i instanceof Ol&&(this.extensions=i.items),this.subjectName=new et(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(const n of this.attributes)if(n.type===e)return n;return null}getAttributes(e){return this.attributes.filter(n=>n.type===e)}getExtension(e){for(const n of this.extensions)if(n.type===e)return n;return null}getExtensions(e){return this.extensions.filter(n=>n.type===e)}async verify(e=ze.get()){const n={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(n,["verify"],e),r=Be.resolveAll(ur).reverse();let s=null;for(const c of r)if(s=c.toWebSignature(n,this.signature),s)break;if(!s)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,i,s,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),n=V.parse(this.rawData,Pi),i=n.certificationRequestInfo,r=new ue("",{Version:`${vn[i.version]} (${i.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new ue("");for(const o of this.attributes){const c=o.toTextObject();s[c[ue.NAME]]=c}r.Attributes=s}return e.Data=r,e.Signature=new ue("",{Algorithm:En.serializeAlgorithm(n.signatureAlgorithm),"":n.signature}),e}}X0.NAME="PKCS#10 Certificate Request";class Bl extends Pt{constructor(e){Pt.isAsnEncoded(e)?super(e,wn):super(e),this.tag=Je.CertificateTag}onInit(e){const n=e.tbsCertificate;this.tbs=V.serialize(n),this.serialNumber=G.ToHex(n.serialNumber),this.subjectName=new et(n.subject),this.subject=new et(n.subject).toString(),this.issuerName=new et(n.issuer),this.issuer=this.issuerName.toString();const i=Be.resolve(An);this.signatureAlgorithm=i.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const r=n.validity.notBefore.utcTime||n.validity.notBefore.generalTime;if(!r)throw new Error("Cannot get 'notBefore' value");this.notBefore=r;const s=n.validity.notAfter.utcTime||n.validity.notAfter.generalTime;if(!s)throw new Error("Cannot get 'notAfter' value");this.notAfter=s,this.extensions=[],n.extensions&&(this.extensions=n.extensions.map(o=>st.create(V.serialize(o)))),this.publicKey=new dt(n.subjectPublicKeyInfo)}getExtension(e){for(const n of this.extensions)if(typeof e=="string"){if(n.type===e)return n}else if(n instanceof e)return n;return null}getExtensions(e){return this.extensions.filter(n=>typeof e=="string"?n.type===e:n instanceof e)}async verify(e={},n=ze.get()){let i,r;const s=e.publicKey;try{if(!s)i={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(i,["verify"],n);else if("publicKey"in s)i={...s.publicKey.algorithm,...this.signatureAlgorithm},r=await s.publicKey.export(i,["verify"],n);else if(s instanceof dt)i={...s.algorithm,...this.signatureAlgorithm},r=await s.export(i,["verify"],n);else if(M.isBufferSource(s)){const u=new dt(s);i={...u.algorithm,...this.signatureAlgorithm},r=await u.export(i,["verify"],n)}else i={...s.algorithm,...this.signatureAlgorithm},r=s}catch{return!1}const o=Be.resolveAll(ur).reverse();let c=null;for(const u of o)if(c=u.toWebSignature(i,this.signature),c)break;if(!c)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const l=await n.subtle.verify(this.signatureAlgorithm,r,c,this.tbs);if(e.signatureOnly)return l;{const p=(e.date||new Date).getTime();return l&&this.notBefore.getTime()<p&&p<this.notAfter.getTime()}}async getThumbprint(...e){let n,i="SHA-1";return e[0]&&(e[0].subtle?n=e[0]:(i=e[0]||i,n=e[1])),n??(n=ze.get()),await n.subtle.digest(i,this.rawData)}async isSelfSigned(e=ze.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),n=V.parse(this.rawData,wn),i=n.tbsCertificate,r=new ue("",{Version:`${vn[i.version]} (${i.version})`,"Serial Number":i.serialNumber,"Signature Algorithm":En.serializeAlgorithm(i.signature),Issuer:this.issuer,Validity:new ue("",{"Not Before":i.validity.notBefore.getTime(),"Not After":i.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(i.issuerUniqueID&&(r["Issuer Unique ID"]=i.issuerUniqueID),i.subjectUniqueID&&(r["Subject Unique ID"]=i.subjectUniqueID),this.extensions.length){const s=new ue("");for(const o of this.extensions){const c=o.toTextObject();s[c[ue.NAME]]=c}r.Extensions=s}return e.Data=r,e.Signature=new ue("",{Algorithm:En.serializeAlgorithm(n.signatureAlgorithm),"":n.signatureValue}),e}}Bl.NAME="Certificate";class Q0{static async createSelfSigned(e,n=ze.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},n)}static async create(e,n=ze.get()){var i;let r;e.publicKey instanceof dt?r=e.publicKey.rawData:"publicKey"in e.publicKey?r=e.publicKey.publicKey.rawData:M.isBufferSource(e.publicKey)?r=e.publicKey:r=await n.subtle.exportKey("spki",e.publicKey);const s=e.serialNumber?M.toUint8Array(G.FromHex(e.serialNumber)):n.getRandomValues(new Uint8Array(16));s[0]>127&&(s[0]&=127),s.length>1&&s[0]===0&&(s[1]|=128);const o=e.notBefore||new Date,c=e.notAfter||new Date(o.getTime()+31536e6),l=new wn({tbsCertificate:new Ye({version:vn.v3,serialNumber:s,validity:new Yi({notBefore:o,notAfter:c}),extensions:new Gt(((i=e.extensions)===null||i===void 0?void 0:i.map(y=>V.parse(y.rawData,nt)))||[]),subjectPublicKeyInfo:V.parse(r,ut)})});if(e.subject){const y=e.subject instanceof et?e.subject:new et(e.subject);l.tbsCertificate.subject=V.parse(y.toArrayBuffer(),ke)}if(e.issuer){const y=e.issuer instanceof et?e.issuer:new et(e.issuer);l.tbsCertificate.issuer=V.parse(y.toArrayBuffer(),ke)}const u={hash:"SHA-256"},p="signingKey"in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},f=Be.resolve(An);l.tbsCertificate.signature=l.signatureAlgorithm=f.toAsnAlgorithm(p);const m=V.serialize(l.tbsCertificate),v="signingKey"in e?await n.subtle.sign(p,e.signingKey,m):e.signature,h=Be.resolveAll(ur).reverse();let _=null;for(const y of h)if(_=y.toAsnSignature(p,v),_)break;if(!_)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return l.signatureValue=_,new Bl(V.serialize(l))}}var Jd;(function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"})(Jd||(Jd={}));st.register(ph,zl);st.register(gh,Nl);st.register(mh,jl);st.register(wh,lr);st.register(ba,Vi);st.register(vh,Gh);st.register(Ea,Zh);st.register(wa,Yh);zo.register(Dh,Xh);zo.register($l,Ol);Be.registerSingleton(ur,Y0);Be.registerSingleton(ur,tt);tt.namedCurveSize.set("P-256",32);tt.namedCurveSize.set("K-256",32);tt.namedCurveSize.set("P-384",48);tt.namedCurveSize.set("P-521",66);const Zd="0123456789abcdef";function $c(t){const e=new Uint8Array(t);let n="";for(let i=0;i<e.length;i++){const r=e[i]>>4;n+=Zd[r];const s=e[i]&15;n+=Zd[s]}return n}class Qh{constructor(e,n){Q(this,"alphabet");Q(this,"padding");Q(this,"decodeMap",new Map);if(e.length!==32)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let i=0;i<e.length;i++)this.decodeMap.set(e[i],i)}encode(e,n){let i="",r=0,s=0;for(let c=0;c<e.length;c++)for(r=r<<8|e[c],s+=8;s>=5;)s-=5,i+=this.alphabet[r>>s&31];if(s>0&&(i+=this.alphabet[r<<5-s&31]),(n==null?void 0:n.includePadding)??!0){const c=(8-i.length%8)%8;for(let l=0;l<c;l++)i+="="}return i}decode(e,n){const i=(n==null?void 0:n.strict)??!0,r=Math.ceil(e.length/8),s=[];for(let o=0;o<r;o++){let c=0;const l=[];for(let p=0;p<8;p++){const f=e[o*8+p];if(f==="="){if(o+1!==r)throw new Error(`Invalid character: ${f}`);c+=1;continue}if(f===void 0){if(i)throw new Error("Invalid data");c+=1;continue}const m=this.decodeMap.get(f)??null;if(m===null)throw new Error(`Invalid character: ${f}`);l.push(m)}if(c===8||c===7||c===5||c===2)throw new Error("Invalid padding");const u=(l[0]<<3)+(l[1]>>2);if(s.push(u),c<6){const p=((l[1]&3)<<6)+(l[2]<<1)+(l[3]>>4);s.push(p)}if(c<4){const p=((l[3]&255)<<4)+(l[4]>>1);s.push(p)}if(c<3){const p=((l[4]&1)<<7)+(l[5]<<2)+(l[6]>>3);s.push(p)}if(c<1){const p=((l[6]&7)<<5)+l[7];s.push(p)}}return Uint8Array.from(s)}}new Qh("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new Qh("0123456789ABCDEFGHIJKLMNOPQRSTUV");class eg{constructor(e,n){Q(this,"alphabet");Q(this,"padding");Q(this,"decodeMap",new Map);if(e.length!==64)throw new Error("Invalid alphabet");if(this.alphabet=e,this.padding=(n==null?void 0:n.padding)??"=",this.alphabet.includes(this.padding)||this.padding.length!==1)throw new Error("Invalid padding");for(let i=0;i<e.length;i++)this.decodeMap.set(e[i],i)}encode(e,n){let i="",r=0,s=0;for(let c=0;c<e.length;c++)for(r=r<<8|e[c],s+=8;s>=6;)s+=-6,i+=this.alphabet[r>>s&63];if(s>0&&(i+=this.alphabet[r<<6-s&63]),(n==null?void 0:n.includePadding)??!0){const c=(4-i.length%4)%4;for(let l=0;l<c;l++)i+="="}return i}decode(e,n){const i=(n==null?void 0:n.strict)??!0,r=Math.ceil(e.length/4),s=[];for(let o=0;o<r;o++){let c=0,l=0;for(let u=0;u<4;u++){const p=e[o*4+u];if(p==="="){if(o+1!==r)throw new Error(`Invalid character: ${p}`);c+=1;continue}if(p===void 0){if(i)throw new Error("Invalid data");c+=1;continue}const f=this.decodeMap.get(p)??null;if(f===null)throw new Error(`Invalid character: ${p}`);l+=f<<6*(3-u)}s.push(l>>16&255),c<2&&s.push(l>>8&255),c<1&&s.push(l&255)}return Uint8Array.from(s)}}const ey=new eg("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),pn=new eg("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");class ty{constructor(e){Q(this,"hash");this.hash=e}async verify(e,n,i){const r=await crypto.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["verify"]);return await crypto.subtle.verify("RSASSA-PKCS1-v1_5",r,n,i)}async sign(e,n){const i=await crypto.subtle.importKey("pkcs8",e,{name:"RSASSA-PKCS1-v1_5",hash:this.hash},!1,["sign"]);return await crypto.subtle.sign("RSASSA-PKCS1-v1_5",i,n)}async generateKeyPair(e){const n=await crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",hash:this.hash,modulusLength:e??2048,publicExponent:new Uint8Array([1,0,1])},!0,["sign"]),i=await crypto.subtle.exportKey("pkcs8",n.privateKey),r=await crypto.subtle.exportKey("spki",n.publicKey);return{privateKey:i,publicKey:r}}}async function tg(t){return await crypto.subtle.digest("SHA-256",t)}async function zc(t){const e={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256",publicExponent:new Uint8Array([1,0,1]),modulusLength:2048},n=await crypto.subtle.generateKey(e,!0,["sign","verify"]),i=He(),r=$c(new TextEncoder().encode(i)),s=await Q0.createSelfSigned({serialNumber:r,name:t.name,notBefore:new Date,notAfter:new Date(Date.now()+365*24*60*60*1e3),signingAlgorithm:e,keys:n,extensions:[new zl(!0,2,!0),new Nl(["1.3.6.1.5.5.7.3.1"],!0),new jl(Is.keyCertSign|Is.cRLSign,!0),await lr.create(n.publicKey)]}),o=await crypto.subtle.exportKey("pkcs8",n.privateKey),c=s.toString("pem"),l=await iy(s),u=$c(await s.getThumbprint()),p=ny("PRIVATE",o);return{kid:s.serialNumber,cert:c,thumbprint:u,fingerprint:l,pkcs7:p}}function ny(t,e){const n=ey.encode(new Uint8Array(e));let i=`-----BEGIN ${t} KEY-----\r
|
|
122
122
|
`,r=0;for(;r<n.length;)r+64<=n.length?i+=n.substr(r,64)+`\r
|
|
123
123
|
`:i+=n.substr(r)+`\r
|
|
124
124
|
`,r+=64;return i+=`-----END ${t} KEY-----\r
|
|
125
|
-
`,i}async function c0(t){const e=await t.publicKey.export(),n=await crypto.subtle.exportKey("jwk",e),i=JSON.stringify(n,Object.keys(n).sort()),s=new TextEncoder().encode(i);return ac(await bh(s))}const l0=1e3*60*60*24,u0=new a.OpenAPIHono().openapi(a.createRoute({tags:["keys"],method:"get",path:"/signing",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.array(Fo)}},description:"List of keys"}}}),async t=>{const n=(await t.env.data.keys.list()).filter(i=>"cert"in i).map(i=>i);return t.json(n)}).openapi(a.createRoute({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({kid:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Fo}},description:"The requested key"}}}),async t=>{const{kid:e}=t.req.valid("param"),i=(await t.env.data.keys.list()).find(r=>r.kid===e);if(!i)throw new j(404,{message:"Key not found"});return t.json(i)}).openapi(a.createRoute({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async t=>{const e=await t.env.data.keys.list();for await(const i of e)await t.env.data.keys.update(i.kid,{revoked_at:new Date(Date.now()+l0).toISOString()});const n=await cc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(n),t.text("OK",{status:201})}).openapi(a.createRoute({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({kid:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async t=>{const{kid:e}=t.req.valid("param");if(!await t.env.data.keys.update(e,{revoked_at:new Date().toISOString()}))throw new j(404,{message:"Key not found"});const i=await cc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(i),t.text("OK")}),d0=new a.OpenAPIHono().openapi(a.createRoute({tags:["users"],method:"get",path:"/",request:{query:a.z.object({email:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:a.z.array(gc)}},description:"List of users"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{email:n}=t.req.valid("query"),r=(await Ep(t.env.data.users,e,n)).filter(s=>!s.linked_to);return t.json(r)}),p0=Gt.extend({clients:a.z.array(nn)}),f0=new a.OpenAPIHono().openapi(a.createRoute({tags:["clients"],method:"get",path:"/",request:{query:dn,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([p0,a.z.array(nn)])}},description:"List of clients"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:i,include_totals:r,sort:s,q:o}=t.req.valid("query"),l=(await t.env.data.applications.list(e,{page:n,per_page:i,include_totals:r,sort:Jn(s),q:o})).applications;return r?t.json({clients:l,start:0,limit:10,length:l.length}):t.json(l)}).openapi(a.createRoute({tags:["clients"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:nn}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=(await t.env.data.applications.list(e,{page:1,per_page:0,include_totals:!1})).applications.find(s=>s.id===n);if(!r)throw new j(404);return t.json(r)}).openapi(a.createRoute({tags:["clients"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.applications.remove(e,n))throw new j(404,{message:"Application not found"});return t.text("OK")}).openapi(a.createRoute({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(Sr.shape).partial()}}},params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:nn}},description:"The update application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=t.req.valid("json");await t.env.data.applications.update(e,n,r);const s=await t.env.data.applications.get(e,n);if(!s)throw new j(404,{message:"Application not found"});return t.json(s)}).openapi(a.createRoute({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(Sr.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:a.z.object(nn.shape)}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),i={...n,id:n.id||De(),client_secret:n.client_secret||De()},r=await t.env.data.applications.create(e,i);return t.json(r,{status:201})});a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()});_s.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());const h0=Gt.extend({tenants:a.z.array(Nn)}),g0=new a.OpenAPIHono().openapi(a.createRoute({tags:["tenants"],method:"get",path:"/",request:{query:dn},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:a.z.union([a.z.array(Nn),h0])}},description:"List of tenants"}}}),async t=>{const{page:e,per_page:n,include_totals:i,sort:r,q:s}=t.req.valid("query"),o=await t.env.data.tenants.list({page:e,per_page:n,include_totals:i,sort:Jn(r),q:s});return i?t.json(o):t.json(o.tenants)}).openapi(a.createRoute({tags:["tenants"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Nn}},description:"A tenant"}}}),async t=>{const{id:e}=t.req.valid("param"),n=await t.env.data.tenants.get(e);if(!n)throw new j(404);return t.json(n)}).openapi(a.createRoute({tags:["tenants"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{id:e}=t.req.valid("param");return await t.env.data.tenants.remove(e),t.text("OK")}).openapi(a.createRoute({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(Ir.shape).partial()}}},params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{id:e}=t.req.valid("param"),n=t.req.valid("json");return await t.env.data.tenants.update(e,n),t.text("OK")}).openapi(a.createRoute({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(Ir.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Nn}},description:"An tenant"}}}),async t=>{const e=t.req.valid("json"),n=await t.env.data.tenants.create(e);return t.json(n,{status:201})}),_0=Gt.extend({logs:a.z.array(Cr)}),m0=new a.OpenAPIHono().openapi(a.createRoute({tags:["logs"],method:"get",path:"/",request:{query:dn,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(Cr),_0])}},description:"List of log rows"}}}),async t=>{const{page:e,per_page:n,include_totals:i,sort:r,q:s}=t.req.valid("query"),{"tenant-id":o}=t.req.valid("header"),c=await t.env.data.logs.list(o,{page:e,per_page:n,include_totals:i,sort:Jn(r),q:s});return i?t.json(c):t.json(c.logs)}).openapi(a.createRoute({tags:["logs"],method:"get",path:"/{id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Cr}},description:"A log entry"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=await t.env.data.logs.get(e,n);if(!i)throw new j(404);return t.json(i)}),y0=Gt.extend({hooks:a.z.array($n)}),v0=new a.OpenAPIHono().openapi(a.createRoute({tags:["hooks"],method:"get",path:"/",request:{query:dn,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($n),y0])}},description:"List of hooks"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:i,include_totals:r,sort:s,q:o}=t.req.valid("query"),c=await t.env.data.hooks.list(e,{page:n,per_page:i,include_totals:r,sort:Jn(s),q:o});return r?t.json(c):t.json(c.hooks)}).openapi(a.createRoute({tags:["hooks"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Er.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:$n}},description:"The created hook"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),i=await t.env.data.hooks.create(e,n);return t.json(i,{status:201})}).openapi(a.createRoute({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Er.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:$n.shape}},description:"The updated hook"},404:{description:"Hook not found"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param"),i=t.req.valid("json");await t.env.data.hooks.update(e,n,i);const r=await t.env.data.hooks.get(e,n);if(!r)throw new j(404,{message:"Hook not found"});return t.json(r)}).openapi(a.createRoute({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:$n}},description:"A hook"},404:{description:"Hook not found"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param"),i=await t.env.data.hooks.get(e,n);if(!i)throw new j(404,{message:"Hook not found"});return t.json(i)}).openapi(a.createRoute({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{description:"A hook"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param");if(!await t.env.data.hooks.remove(e,n))throw new j(404,{message:"Hook not found"});return t.text("OK")}),w0=Gt.extend({connections:a.z.array(Lt)}),b0=new a.OpenAPIHono().openapi(a.createRoute({tags:["connections"],method:"get",path:"/",request:{query:dn,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(Lt),w0])}},description:"List of connectionss"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:i,include_totals:r=!1,sort:s,q:o}=t.req.valid("query"),c=await t.env.data.connections.list(e,{page:n,per_page:i,include_totals:r,sort:Jn(s),q:o});return r?t.json(c):t.json(c.connections)}).openapi(a.createRoute({tags:["connections"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Lt}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=await t.env.data.connections.get(e,n);if(!i)throw new j(404);return t.json(i)}).openapi(a.createRoute({tags:["connections"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.connections.remove(e,n))throw new j(404,{message:"Connection not found"});return t.text("OK")}).openapi(a.createRoute({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(Ar.shape).partial()}}},params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Lt}},description:"The updated connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=t.req.valid("json");if(!await t.env.data.connections.update(e,n,i))throw new j(404,{message:"Connection not found"});const s=await t.env.data.connections.get(e,n);if(!s)throw new j(404,{message:"Connection not found"});return t.json(s)}).openapi(a.createRoute({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(Ar.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Lt}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),i=await t.env.data.connections.create(e,n);return t.json(i,{status:201})}),k0=new a.OpenAPIHono().openapi(a.createRoute({tags:["prompts"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:dr}},description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.promptSettings.get(e);return n?t.json(n):t.json(dr.parse({}))}).openapi(a.createRoute({tags:["prompts"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(dr.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Prompts settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),i=await t.env.data.promptSettings.get(e);return Object.assign(i,n),await t.env.data.promptSettings.set(e,i),t.json(i)});let xd=!1;function kh(t){t.use(async(e,n)=>(xd||(t.openAPIRegistry.registerComponent("securitySchemes","Bearer",{type:"oauth2",scheme:"bearer",flows:{implicit:{authorizationUrl:`${e.env.AUTH_URL}/authorize`,scopes:{openid:"Basic user information",email:"User email",profile:"User profile information"}}}}),xd=!0),await n()))}a.z.object({alg:a.z.literal("RS256"),kty:a.z.literal("RSA"),use:a.z.literal("sig"),n:a.z.string(),e:a.z.string(),kid:a.z.string(),x5t:a.z.string(),x5c:a.z.array(a.z.string())});async function x0(t){try{const e=await t.JWKS_SERVICE.fetch(t.JWKS_URL);if(!e.ok)throw new Error("Failed to fetch jwks");return(await e.json()).keys}catch(e){throw new j(500,{message:`Failed to fetch jwks: ${e.message}`})}}async function S0(t,e){const i=new TextEncoder().encode([e.raw.header,e.raw.payload].join(".")),r=new Uint8Array(Array.from(e.signature).map(l=>l.charCodeAt(0))),o=(await x0(t.env)).find(l=>l.kid===e.header.kid);if(!o)return console.log("No matching kid found"),!1;const c=await crypto.subtle.importKey("jwk",o,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",c,r,i)}function A0(t){const[e,n,i]=t.split(".");if(!e||!n||!i)return null;const r=JSON.parse(atob(e)),s=JSON.parse(atob(n)),o=atob(i.replace(/-/g,"+").replace(/_/g,"/"));return{header:r,payload:s,signature:o,raw:{header:e,payload:n,signature:i}}}function xh(t){return async(e,n)=>{var r,s,o;const i=t.openAPIRegistry.definitions.find(c=>"route"in c&&c.route.path===e.req.path&&c.route.method.toUpperCase()===e.req.method);if(i&&"route"in i){const c=(s=(r=i.route.security)==null?void 0:r[0])==null?void 0:s.Bearer;if(!(c!=null&&c.length))return await n();const l=e.req.header("authorization")||"",[u,p]=l.split(" ");if((u==null?void 0:u.toLowerCase())!=="bearer"||!p)throw new j(401,{message:"Missing bearer token"});const g=A0(p);if(!g||!await S0(e,g))throw new j(403,{message:"Invalid JWT signature"});e.set("user_id",g.payload.sub),e.set("user",g.payload);const _=g.payload.permissions||[],k=((o=g.payload.scope)==null?void 0:o.split(" "))||[];if(c.length&&!(c.some(h=>_.includes(h))||c.some(h=>k.includes(h))))throw new j(403,{message:"Unauthorized"})}return await n()}}const I0=new a.OpenAPIHono().openapi(a.createRoute({tags:["emails"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:pr}},description:"Email provider"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.emailProviders.get(e);if(!n)throw new j(404,{message:"Email provider not found"});return t.json(n)}).openapi(a.createRoute({tags:["emails"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(pr.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.emailProviders.create(e,n),t.text("OK",{status:201})}).openapi(a.createRoute({tags:["emails"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(pr.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.emailProviders.update(e,n),t.text("OK")}),E0=new a.OpenAPIHono().openapi(a.createRoute({tags:["sessions"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:ys}},description:"A session"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=await t.env.data.sessions.get(e,n);if(!i)throw new j(404);return t.json(i)}).openapi(a.createRoute({tags:["sessions"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.sessions.remove(e,n))throw new j(404,{message:"Session not found"});return t.text("OK")}).openapi(a.createRoute({tags:["sessions"],method:"post",path:"/{id}/revoke",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{202:{description:"Sesssion deletion status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.sessions.update(e,n,{revoked_at:new Date().toDateString()}))throw new j(404,{message:"Session not found"});return t.text("Session deletion request accepted.",{status:202})}),C0=new a.OpenAPIHono().openapi(a.createRoute({tags:["refresh_tokens"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:yc}},description:"A session"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=await t.env.data.refreshTokens.get(e,n);if(!i)throw new j(404);return t.json(i)}).openapi(a.createRoute({tags:["refresh_tokens"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.refreshTokens.remove(e,n))throw new j(404,{message:"Session not found"});return t.text("OK")});function z0(){const t=new a.OpenAPIHono;t.use(xh(t));const e=t.route("/branding",Gg).route("/email/providers",I0).route("/users",u_).route("/keys",u0).route("/users-by-email",d0).route("/clients",f0).route("/tenants",g0).route("/logs",m0).route("/hooks",v0).route("/connections",b0).route("/prompts",k0).route("/sessions",E0).route("/refresh_tokens",C0);return kh(e),e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),e}function $0(t,e){Object.keys(e).forEach(n=>{const i=e[n];i!=null&&i.length&&t.searchParams.set(n,i)})}function Gn(t){var e,n,i;return{auth0Client:(e=t.query("auth0Client"))==null?void 0:e.slice(0,255),ip:(n=t.header("x-real-ip"))==null?void 0:n.slice(0,45),useragent:(i=t.header("user-agent"))==null?void 0:i.slice(0,512)}}const lr=60*5,uo=30*24*60*60,us=24*60*60,j0="auth-token",lc=30*60*1e3,N0=5*60,O0=5*60;var Sd;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Sd||(Sd={}));var Ad;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(Ad||(Ad={}));function B0(t){return Ah(t,T0,Bi.Include)}function Sh(t){return Ah(t,R0,Bi.None)}function Ah(t,e,n){let i="";for(let r=0;r<t.byteLength;r+=3){let s=0,o=0;for(let c=0;c<3&&r+c<t.byteLength;c++)s=s<<8|t[r+c],o+=8;for(let c=0;c<4;c++)o>=6?(i+=e[s>>o-6&63],o-=6):o>0?(i+=e[s<<6-o&63],o=0):n===Bi.Include&&(i+="=")}return i}const T0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",R0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var Bi;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Bi||(Bi={}));var Id;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(Id||(Id={}));class P0{uint8(e,n){if(e.byteLength<n+1)throw new TypeError("Insufficient bytes");return e[n]}uint16(e,n){if(e.byteLength<n+2)throw new TypeError("Insufficient bytes");return e[n]<<8|e[n+1]}uint32(e,n){if(e.byteLength<n+4)throw new TypeError("Insufficient bytes");let i=0;for(let r=0;r<4;r++)i|=e[n+r]<<24-r*8;return i}uint64(e,n){if(e.byteLength<n+8)throw new TypeError("Insufficient bytes");let i=0n;for(let r=0;r<8;r++)i|=BigInt(e[n+r])<<BigInt(56-r*8);return i}putUint8(e,n,i){if(e.length<i+1)throw new TypeError("Not enough space");if(n<0||n>255)throw new TypeError("Invalid uint8 value");e[i]=n}putUint16(e,n,i){if(e.length<i+2)throw new TypeError("Not enough space");if(n<0||n>65535)throw new TypeError("Invalid uint16 value");e[i]=n>>8,e[i+1]=n&255}putUint32(e,n,i){if(e.length<i+4)throw new TypeError("Not enough space");if(n<0||n>4294967295)throw new TypeError("Invalid uint32 value");for(let r=0;r<4;r++)e[i+r]=n>>(3-r)*8&255}putUint64(e,n,i){if(e.length<i+8)throw new TypeError("Not enough space");if(n<0||n>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let r=0;r<8;r++)e[i+r]=Number(n>>BigInt((7-r)*8)&0xffn)}}const Ed=new P0;function mt(t,e){return(t<<32-e|t>>>e)>>>0}function L0(t){const e=new U0;return e.update(t),e.digest()}class U0{constructor(){Q(this,"blockSize",64);Q(this,"size",32);Q(this,"blocks",new Uint8Array(64));Q(this,"currentBlockSize",0);Q(this,"H",new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]));Q(this,"l",0n);Q(this,"w",new Uint32Array(64))}update(e){if(this.l+=BigInt(e.byteLength)*8n,this.currentBlockSize+e.byteLength<64){this.blocks.set(e,this.currentBlockSize),this.currentBlockSize+=e.byteLength;return}let n=0;if(this.currentBlockSize>0){const i=e.slice(0,64-this.currentBlockSize);this.blocks.set(i,this.currentBlockSize),this.process(),n+=i.byteLength,this.currentBlockSize=0}for(;n+64<=e.byteLength;){const i=e.slice(n,n+64);this.blocks.set(i),this.process(),n+=64}if(e.byteLength-n>0){const i=e.slice(n);this.blocks.set(i),this.currentBlockSize=i.byteLength}}digest(){this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8&&(this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0),this.blocks.fill(0,this.currentBlockSize),Ed.putUint64(this.blocks,this.l,this.blockSize-8),this.process();const e=new Uint8Array(32);for(let n=0;n<8;n++)Ed.putUint32(e,this.H[n],n*4);return e}process(){for(let u=0;u<16;u++)this.w[u]=(this.blocks[u*4]<<24|this.blocks[u*4+1]<<16|this.blocks[u*4+2]<<8|this.blocks[u*4+3])>>>0;for(let u=16;u<64;u++){const p=(mt(this.w[u-2],17)^mt(this.w[u-2],19)^this.w[u-2]>>>10)>>>0,g=(mt(this.w[u-15],7)^mt(this.w[u-15],18)^this.w[u-15]>>>3)>>>0;this.w[u]=p+this.w[u-7]+g+this.w[u-16]|0}let e=this.H[0],n=this.H[1],i=this.H[2],r=this.H[3],s=this.H[4],o=this.H[5],c=this.H[6],l=this.H[7];for(let u=0;u<64;u++){const p=(mt(s,6)^mt(s,11)^mt(s,25))>>>0,g=(s&o^~s&c)>>>0,_=l+p+g+V0[u]+this.w[u]|0,k=(mt(e,2)^mt(e,13)^mt(e,22))>>>0,h=(e&n^e&i^n&i)>>>0,m=k+h|0;l=c,c=o,o=s,s=r+_|0,r=i,i=n,n=e,e=_+m|0}this.H[0]=e+this.H[0]|0,this.H[1]=n+this.H[1]|0,this.H[2]=i+this.H[2]|0,this.H[3]=r+this.H[3]|0,this.H[4]=s+this.H[4]|0,this.H[5]=o+this.H[5]|0,this.H[6]=c+this.H[6]|0,this.H[7]=l+this.H[7]|0}}const V0=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);new BigUint64Array([0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n]);class M0{constructor(e){Q(this,"data");this.data=e}tokenType(){if("token_type"in this.data&&typeof this.data.token_type=="string")return this.data.token_type;throw new Error("Missing or invalid 'token_type' field")}accessToken(){if("access_token"in this.data&&typeof this.data.access_token=="string")return this.data.access_token;throw new Error("Missing or invalid 'access_token' field")}accessTokenExpiresInSeconds(){if("expires_in"in this.data&&typeof this.data.expires_in=="number")return this.data.expires_in;throw new Error("Missing or invalid 'expires_in' field")}accessTokenExpiresAt(){return new Date(Date.now()+this.accessTokenExpiresInSeconds()*1e3)}hasRefreshToken(){return"refresh_token"in this.data&&typeof this.data.refresh_token=="string"}refreshToken(){if("refresh_token"in this.data&&typeof this.data.refresh_token=="string")return this.data.refresh_token;throw new Error("Missing or invalid 'refresh_token' field")}hasScopes(){return"scope"in this.data&&typeof this.data.scope=="string"}scopes(){if("scope"in this.data&&typeof this.data.scope=="string")return this.data.scope.split(" ");throw new Error("Missing or invalid 'scope' field")}idToken(){if("id_token"in this.data&&typeof this.data.id_token=="string")return this.data.id_token;throw new Error("Missing or invalid field 'id_token'")}}function D0(t){const e=L0(new TextEncoder().encode(t));return Sh(e)}function F0(){const t=new Uint8Array(32);return crypto.getRandomValues(t),Sh(t)}function vi(t,e){const n=new TextEncoder().encode(e.toString()),i=new Request(t,{method:"POST",body:n});return i.headers.set("Content-Type","application/x-www-form-urlencoded"),i.headers.set("Accept","application/json"),i.headers.set("User-Agent","arctic"),i.headers.set("Content-Length",n.byteLength.toString()),i}function To(t,e){const n=new TextEncoder().encode(`${t}:${e}`);return B0(n)}async function ds(t){let e;try{e=await fetch(t)}catch(n){throw new Eh(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new mr(e.status)}if(typeof n!="object"||n===null)throw new Tn(e.status,n);let i;try{i=Ih(n)}catch{throw new Tn(e.status,n)}throw i}if(e.status===200){let n;try{n=await e.json()}catch{throw new mr(e.status)}if(typeof n!="object"||n===null)throw new Tn(e.status,n);return new M0(n)}throw e.body!==null&&await e.body.cancel(),new mr(e.status)}async function H0(t){let e;try{e=await fetch(t)}catch(n){throw new Eh(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new Tn(e.status,null)}if(typeof n!="object"||n===null)throw new Tn(e.status,n);let i;try{i=Ih(n)}catch{throw new Tn(e.status,n)}throw i}if(e.status===200){e.body!==null&&await e.body.cancel();return}throw e.body!==null&&await e.body.cancel(),new mr(e.status)}function Ih(t){let e;if("error"in t&&typeof t.error=="string")e=t.error;else throw new Error("Invalid error response");let n=null,i=null,r=null;if("error_description"in t){if(typeof t.error_description!="string")throw new Error("Invalid data");n=t.error_description}if("error_uri"in t){if(typeof t.error_uri!="string")throw new Error("Invalid data");i=t.error_uri}if("state"in t){if(typeof t.state!="string")throw new Error("Invalid data");r=t.state}return new q0(e,n,i,r)}class Eh extends Error{constructor(e){super("Failed to send request",{cause:e})}}class q0 extends Error{constructor(n,i,r,s){super(`OAuth request error: ${n}`);Q(this,"code");Q(this,"description");Q(this,"uri");Q(this,"state");this.code=n,this.description=i,this.uri=r,this.state=s}}class mr extends Error{constructor(n){super("Unexpected error response");Q(this,"status");this.status=n}}class Tn extends Error{constructor(n,i){super("Unexpected error response body");Q(this,"status");Q(this,"data");this.status=n,this.data=i}}class dl{constructor(e,n,i){Q(this,"clientId");Q(this,"clientPassword");Q(this,"redirectURI");this.clientId=e,this.clientPassword=n,this.redirectURI=i}createAuthorizationURL(e,n,i){const r=new URL(e);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&r.searchParams.set("redirect_uri",this.redirectURI),r.searchParams.set("state",n),i.length>0&&r.searchParams.set("scope",i.join(" ")),r}createAuthorizationURLWithPKCE(e,n,i,r,s){const o=new URL(e);if(o.searchParams.set("response_type","code"),o.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&o.searchParams.set("redirect_uri",this.redirectURI),o.searchParams.set("state",n),i===Ti.S256){const c=D0(r);o.searchParams.set("code_challenge_method","S256"),o.searchParams.set("code_challenge",c)}else i===Ti.Plain&&(o.searchParams.set("code_challenge_method","plain"),o.searchParams.set("code_challenge",r));return s.length>0&&o.searchParams.set("scope",s.join(" ")),o}async validateAuthorizationCode(e,n,i){const r=new URLSearchParams;r.set("grant_type","authorization_code"),r.set("code",n),this.redirectURI!==null&&r.set("redirect_uri",this.redirectURI),i!==null&&r.set("code_verifier",i),this.clientPassword===null&&r.set("client_id",this.clientId);const s=vi(e,r);if(this.clientPassword!==null){const c=To(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await ds(s)}async refreshAccessToken(e,n,i){const r=new URLSearchParams;r.set("grant_type","refresh_token"),r.set("refresh_token",n),this.clientPassword===null&&r.set("client_id",this.clientId),i.length>0&&r.set("scope",i.join(" "));const s=vi(e,r);if(this.clientPassword!==null){const c=To(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await ds(s)}async revokeToken(e,n){const i=new URLSearchParams;i.set("token",n),this.clientPassword===null&&i.set("client_id",this.clientId);const r=vi(e,i);if(this.clientPassword!==null){const s=To(this.clientId,this.clientPassword);r.headers.set("Authorization",`Basic ${s}`)}await H0(r)}}var Ti;(function(t){t[t.S256=0]="S256",t[t.Plain=1]="Plain"})(Ti||(Ti={}));var Cd;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Cd||(Cd={}));var zd;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(zd||(zd={}));function wi(t){return K0(t,W0,ps.None)}function K0(t,e,n){let i="";for(let r=0;r<t.byteLength;r+=3){let s=0,o=0;for(let c=0;c<3&&r+c<t.byteLength;c++)s=s<<8|t[r+c],o+=8;for(let c=0;c<4;c++)o>=6?(i+=e[s>>o-6&63],o-=6):o>0?(i+=e[s<<6-o&63],o=0):n===ps.Include&&(i+="=")}return i}const W0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var ps;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(ps||(ps={}));var $d;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})($d||($d={}));function G0(t,e,n){const i=wi(new TextEncoder().encode(t)),r=wi(new TextEncoder().encode(e)),s=wi(n);return i+"."+r+"."+s}function J0(t,e){const n=wi(new TextEncoder().encode(t)),i=wi(new TextEncoder().encode(e)),r=n+"."+i;return new TextEncoder().encode(r)}const Z0="https://appleid.apple.com/auth/authorize",Y0="https://appleid.apple.com/auth/token";class Ch{constructor(e,n,i,r,s){Q(this,"clientId");Q(this,"teamId");Q(this,"keyId");Q(this,"pkcs8PrivateKey");Q(this,"redirectURI");this.clientId=e,this.teamId=n,this.keyId=i,this.pkcs8PrivateKey=r,this.redirectURI=s}createAuthorizationURL(e,n){const i=new URL(Z0);return i.searchParams.set("response_type","code"),i.searchParams.set("client_id",this.clientId),i.searchParams.set("state",e),n.length>0&&i.searchParams.set("scope",n.join(" ")),i.searchParams.set("redirect_uri",this.redirectURI),i}async validateAuthorizationCode(e){const n=new URLSearchParams;n.set("grant_type","authorization_code"),n.set("code",e),n.set("redirect_uri",this.redirectURI),n.set("client_id",this.clientId);const i=await this.createClientSecret();n.set("client_secret",i);const r=vi(Y0,n);return await ds(r)}async createClientSecret(){const e=await crypto.subtle.importKey("pkcs8",this.pkcs8PrivateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),n=Math.floor(Date.now()/1e3),i=JSON.stringify({typ:"JWT",alg:"ES256",kid:this.keyId}),r=JSON.stringify({iss:this.teamId,exp:n+5*60,aud:["https://appleid.apple.com"],sub:this.clientId,iat:n}),s=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},e,J0(i,r)));return G0(i,r,s)}}const X0="https://www.facebook.com/v16.0/dialog/oauth",Q0="https://graph.facebook.com/v16.0/oauth/access_token";class zh{constructor(e,n,i){Q(this,"clientId");Q(this,"clientSecret");Q(this,"redirectURI");this.clientId=e,this.clientSecret=n,this.redirectURI=i}createAuthorizationURL(e,n){const i=new URL(X0);return i.searchParams.set("response_type","code"),i.searchParams.set("client_id",this.clientId),i.searchParams.set("state",e),n.length>0&&i.searchParams.set("scope",n.join(" ")),i.searchParams.set("redirect_uri",this.redirectURI),i}async validateAuthorizationCode(e){const n=new URLSearchParams;n.set("grant_type","authorization_code"),n.set("code",e),n.set("redirect_uri",this.redirectURI),n.set("client_id",this.clientId),n.set("client_secret",this.clientSecret);const i=vi(Q0,n);return await ds(i)}}const ey="https://accounts.google.com/o/oauth2/v2/auth",jd="https://oauth2.googleapis.com/token",ty="https://oauth2.googleapis.com/revoke";let $h=class{constructor(e,n,i){Q(this,"client");this.client=new dl(e,n,i)}createAuthorizationURL(e,n,i){return this.client.createAuthorizationURLWithPKCE(ey,e,Ti.S256,n,i)}async validateAuthorizationCode(e,n){return await this.client.validateAuthorizationCode(jd,e,n)}async refreshAccessToken(e){return await this.client.refreshAccessToken(jd,e,[])}async revokeToken(e){await this.client.revokeToken(ty,e)}};class pl{constructor(e,n){Q(this,"value");Q(this,"unit");this.value=e,this.unit=n}milliseconds(){return this.unit==="ms"?this.value:this.unit==="s"?this.value*1e3:this.unit==="m"?this.value*1e3*60:this.unit==="h"?this.value*1e3*60*60:this.unit==="d"?this.value*1e3*60*60*24:this.value*1e3*60*60*24*7}seconds(){return this.milliseconds()/1e3}transform(e){return new pl(Math.round(this.milliseconds()*e),"ms")}}async function Nd(t,e,n,i){const r={alg:t,typ:"JWT",...i==null?void 0:i.headers},s={...n};(i==null?void 0:i.audiences)!==void 0&&(s.aud=i.audiences),(i==null?void 0:i.subject)!==void 0&&(s.sub=i.subject),(i==null?void 0:i.issuer)!==void 0&&(s.iss=i.issuer),(i==null?void 0:i.jwtId)!==void 0&&(s.jti=i.jwtId),(i==null?void 0:i.expiresIn)!==void 0&&(s.exp=Math.floor(Date.now()/1e3)+i.expiresIn.seconds()),(i==null?void 0:i.notBefore)!==void 0&&(s.nbf=Math.floor(i.notBefore.getTime()/1e3)),s.iat=Math.floor(Date.now()/1e3);const o=new TextEncoder,c=ln.encode(o.encode(JSON.stringify(r)),{includePadding:!1}),l=ln.encode(o.encode(JSON.stringify(s)),{includePadding:!1}),u=o.encode([c,l].join(".")),p=await iy(t).sign(e,u),g=ln.encode(new Uint8Array(p),{includePadding:!1});return[c,l,g].join(".")}function ny(t){const e=t.split(".");return e.length!==3?null:e}function fl(t){const e=ny(t);if(!e)return null;const n=new TextDecoder,i=ln.decode(e[0],{strict:!1}),r=ln.decode(e[1],{strict:!1}),s=JSON.parse(n.decode(i));if(typeof s!="object"||s===null||!("alg"in s)||!ry(s.alg)||"typ"in s&&s.typ!=="JWT")return null;const o=JSON.parse(n.decode(r));if(typeof o!="object"||o===null)return null;const c={algorithm:s.alg,expiresAt:null,subject:null,issuedAt:null,issuer:null,jwtId:null,audiences:null,notBefore:null};if("exp"in o){if(typeof o.exp!="number")return null;c.expiresAt=new Date(o.exp*1e3)}if("iss"in o){if(typeof o.iss!="string")return null;c.issuer=o.iss}if("sub"in o){if(typeof o.sub!="string")return null;c.subject=o.sub}if("aud"in o)if(Array.isArray(o.aud)){for(const l of o.aud)if(typeof l!="string")return null;c.audiences=o.aud}else{if(typeof o.aud!="string")return null;c.audiences=[o.aud]}if("nbf"in o){if(typeof o.nbf!="number")return null;c.notBefore=new Date(o.nbf*1e3)}if("iat"in o){if(typeof o.iat!="number")return null;c.issuedAt=new Date(o.iat*1e3)}if("jti"in o){if(typeof o.jti!="string")return null;c.jwtId=o.jti}return{value:t,header:{...s,typ:"JWT",alg:s.alg},payload:{...o},parts:e,...c}}function iy(t){return new o0(sy[t])}function ry(t){return typeof t!="string"?!1:["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512","PS256","PS384","PS512"].includes(t)}const sy={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"},po=a.z.object({iss:a.z.string().url(),sub:a.z.string(),aud:a.z.string(),exp:a.z.number(),email:a.z.string().optional(),given_name:a.z.string().optional(),family_name:a.z.string().optional(),name:a.z.string().optional(),iat:a.z.number(),auth_time:a.z.number().optional(),nonce:a.z.string().optional(),acr:a.z.string().optional(),amr:a.z.array(a.z.string()).optional(),azp:a.z.string().optional(),at_hash:a.z.string().optional(),c_hash:a.z.string().optional()}).passthrough();po.omit({iat:!0,auth_time:!0,nonce:!0,acr:!0,amr:!0,azp:!0,at_hash:!0,c_hash:!0});function oy(t){return t.ISSUER}function kt(t){return t.UNIVERSAL_LOGIN_URL||`${t.ISSUER}u/`}function Ce(t){return t.OAUTH_API_URL||t.ISSUER}function jh(t){const{options:e}=t;if(!e||!e.client_id||!e.team_id||!e.kid||!e.app_secret)throw new Error("Missing required Apple authentication parameters");const n=Buffer.from(e.app_secret,"utf-8"),i=n.toString().replace(/-----BEGIN PRIVATE KEY-----|-----END PRIVATE KEY-----|\s/g,""),r=Uint8Array.from(Buffer.from(i,"base64"));return n.fill(0),{options:e,keyArray:r}}async function ay(t,e){var l,u;const{options:n,keyArray:i}=jh(e),r=new Ch(n.client_id,n.team_id,n.kid,i,`${Ce(t.env)}callback`),s=De(),o=await r.createAuthorizationURL(s,((l=n.scope)==null?void 0:l.split(" "))||["name","email"]);return(((u=n.scope)==null?void 0:u.split(" "))||["name","email"]).some(p=>["email","name"].includes(p))&&o.searchParams.set("response_mode","form_post"),{redirectUrl:o.href,code:s}}async function cy(t,e,n){const{options:i,keyArray:r}=jh(e),o=await new Ch(i.client_id,i.team_id,i.kid,r,`${Ce(t.env)}callback`).validateAuthorizationCode(n),c=fl(o.idToken());if(!c)throw new Error("Invalid ID token");const l=po.parse(c.payload);return{sub:l.sub,email:l.email,given_name:l.given_name,family_name:l.family_name,name:l.name,picture:l.picture,locale:l.locale}}const ly=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:ay,validateAuthorizationCodeAndGetUser:cy},Symbol.toStringTag,{value:"Module"}));async function uy(t,e){var o;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const i=new zh(n.client_id,n.client_secret,`${Ce(t.env)}callback`),r=De();return{redirectUrl:i.createAuthorizationURL(r,((o=n.scope)==null?void 0:o.split(" "))||["email"]).href,code:r}}async function dy(t,e,n){const{options:i}=e;if(!(i!=null&&i.client_id)||!i.client_secret)throw new Error("Missing required authentication parameters");const s=await new zh(i.client_id,i.client_secret,`${Ce(t.env)}callback`).validateAuthorizationCode(n),o=await fetch("https://graph.facebook.com/v16.0/me?fields=id,email,name",{headers:{Authorization:`Bearer ${s.accessToken()}`}});if(!o.ok)throw new Error("Failed to fetch user info");const c=await o.json();return t.set("log",`Userinfo: ${JSON.stringify(c)}`),{sub:c.id,email:c.email,name:c.name}}const py=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:uy,validateAuthorizationCodeAndGetUser:dy},Symbol.toStringTag,{value:"Module"}));async function fy(t,e){var c;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required Google authentication parameters");const i=new $h(n.client_id,n.client_secret,`${Ce(t.env)}callback`),r=De(),s=F0();return{redirectUrl:i.createAuthorizationURL(r,s,((c=n.scope)==null?void 0:c.split(" "))??["email","profile"]).href,code:r,codeVerifier:s}}async function hy(t,e,n,i){const{options:r}=e;if(!(r!=null&&r.client_id)||!r.client_secret||!i)throw new Error("Missing required authentication parameters");const o=await new $h(r.client_id,r.client_secret,`${Ce(t.env)}callback`).validateAuthorizationCode(n,i);console.log("got here");const c=fl(o.idToken());if(!c)throw new Error("Invalid ID token");const l=po.parse(c.payload);return{sub:l.sub,email:l.email,given_name:l.given_name,family_name:l.family_name,name:l.name,picture:l.picture,locale:l.locale}}const gy=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:fy,validateAuthorizationCodeAndGetUser:hy},Symbol.toStringTag,{value:"Module"}));async function _y(t,e){var o;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const i=new dl(n.client_id,n.client_secret,`${Ce(t.env)}callback`),r=De(),s=i.createAuthorizationURL("https://api.vipps.no/access-management-1.0/access/oauth2/auth",r,((o=n.scope)==null?void 0:o.split(" "))||["openid","email","phoneNumber","name","address","birthDate"]);return s.searchParams.set("response_type","code"),s.searchParams.set("response_mode","query"),{redirectUrl:s.href,code:r}}async function my(t,e,n){const{options:i}=e;if(!(i!=null&&i.client_id)||!i.client_secret)throw new Error("Missing required authentication parameters");const s=await new dl(i.client_id,i.client_secret,`${Ce(t.env)}callback`).validateAuthorizationCode("https://api.vipps.no/access-management-1.0/access/oauth2/token",n,null),o=fl(s.idToken());if(!o)throw new Error("Invalid ID token");const c=po.parse(o.payload);if(typeof c.msn!="string")throw new Error("msn not available in id token");const l=await fetch("https://api.vipps.no/vipps-userinfo-api/userinfo",{headers:{Authorization:`Bearer ${s.accessToken()}`,"Merchant-Serial-Number":c.msn}});if(!l.ok)throw new j(400,{message:"Failed to get user from vipps"});return await l.json()}const yy=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:_y,validateAuthorizationCodeAndGetUser:my},Symbol.toStringTag,{value:"Module"}));function Nh(t,e){const n=t.env.STRATEGIES||{},r={apple:ly,facebook:py,"google-oauth2":gy,vipps:yy,...n}[e];if(!r)throw new Error(`Strategy ${e} not found`);return r}async function fo(t,e){const n=await t.data.clients.get(e);if(!n)throw new j(403,{message:"Client not found"});const i=t.DEFAULT_CLIENT_ID?await t.data.clients.get(t.DEFAULT_CLIENT_ID):void 0,r=await t.data.connections.list(n.tenant.id),s=t.DEFAULT_TENANT_ID?await t.data.connections.list(t.DEFAULT_TENANT_ID):{connections:[]},o=r.connections.map(c=>{var p;const l=(p=s.connections)==null?void 0:p.find(g=>g.name===c.name);return l!=null&&l.options?Lt.parse({...l||{},...c,options:{...l.options||{},...c.options}}):c}).filter(c=>c);return{...n,web_origins:[...(i==null?void 0:i.web_origins)||[],...n.web_origins||[],`${kt(t)}login`],allowed_logout_urls:[...(i==null?void 0:i.allowed_logout_urls)||[],...n.allowed_logout_urls||[],t.ISSUER],callbacks:[...(i==null?void 0:i.callbacks)||[],...n.callbacks||[],`${kt(t)}info`],connections:o,domains:[...n.domains||[],...(i==null?void 0:i.domains)||[]],tenant:{...(i==null?void 0:i.tenant)||{},...n.tenant}}}function ho(t,e=[],n={}){try{const i=new URL(t);return e.some(r=>{try{return vy(i,new URL(r),n.allowPathWildcards)}catch{return!1}})}catch{return!1}}function vy(t,e,n){if(t.protocol!==e.protocol)return!1;if(n&&e.pathname.includes("*")){const i=e.pathname.replace(/\*/g,".*").replace(/\//g,"\\/");if(!new RegExp(`^${i}$`).test(t.pathname))return!1}else if(t.pathname!==e.pathname)return!1;if(e.hostname.startsWith("*.")&&e.hostname.split(".").length>2&&["http:","https:"].includes(e.protocol)){const i=e.hostname.split(".").slice(1).join(".");return t.hostname.endsWith(i)}return t.hostname===e.hostname}function wy(t){try{const n=/-----BEGIN (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----([^-]*)-----END (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----/.exec(t);if(!n||!n[1])throw new Error("Invalid PEM format");return Uint8Array.from(atob(n[1].replace(/\s/g,"")),i=>i.charCodeAt(0)).buffer}finally{t=t.replace(/./g,"\0")}}async function by(t,e){if(e==="plain")return t;const n=new TextEncoder().encode(t),i=await bh(n);return ln.encode(new Uint8Array(i),{includePadding:!1})}function Oh(t,e,n){const i=[];return i.push([encodeURIComponent(t),encodeURIComponent(e)]),(n==null?void 0:n.domain)!==void 0&&i.push(["Domain",n.domain]),(n==null?void 0:n.expires)!==void 0&&i.push(["Expires",n.expires.toUTCString()]),n!=null&&n.httpOnly&&i.push(["HttpOnly"]),(n==null?void 0:n.maxAge)!==void 0&&i.push(["Max-Age",n.maxAge.toString()]),(n==null?void 0:n.path)!==void 0&&i.push(["Path",n.path]),(n==null?void 0:n.sameSite)==="lax"&&i.push(["SameSite","Lax"]),(n==null?void 0:n.sameSite)==="none"&&i.push(["SameSite","None"]),(n==null?void 0:n.sameSite)==="strict"&&i.push(["SameSite","Strict"]),n!=null&&n.secure&&i.push(["Secure"]),i.map(r=>r.join("=")).join("; ")}function ky(t){const e=new Map,n=t.split("; ");for(const i of n){const r=i.split("="),s=r[0],o=r[1]??"";s&&e.set(decodeURIComponent(s),decodeURIComponent(o))}return e}function hl(t){return`${t}-${j0}`}function Bh(t,e){return e?(console.log("cookieHeaders",e),ky(e).get(hl(t))):void 0}function xy(t){const e={path:"/",httpOnly:!0,secure:!0,maxAge:0};return Oh(hl(t),"",{...e,sameSite:"none"})}function Th(t,e){const n={path:"/",httpOnly:!0,secure:!0,maxAge:uo};return Oh(hl(t),e,{...n,sameSite:"none"})}var gl={},go={};(function(t){const e=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",n=e+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",i="["+e+"]["+n+"]*",r=new RegExp("^"+i+"$"),s=function(c,l){const u=[];let p=l.exec(c);for(;p;){const g=[];g.startIndex=l.lastIndex-p[0].length;const _=p.length;for(let k=0;k<_;k++)g.push(p[k]);u.push(g),p=l.exec(c)}return u},o=function(c){const l=r.exec(c);return!(l===null||typeof l>"u")};t.isExist=function(c){return typeof c<"u"},t.isEmptyObject=function(c){return Object.keys(c).length===0},t.merge=function(c,l,u){if(l){const p=Object.keys(l),g=p.length;for(let _=0;_<g;_++)u==="strict"?c[p[_]]=[l[p[_]]]:c[p[_]]=l[p[_]]}},t.getValue=function(c){return t.isExist(c)?c:""},t.isName=o,t.getAllMatches=s,t.nameRegexp=i})(go);const _l=go,Sy={allowBooleanAttributes:!1,unpairedTags:[]};gl.validate=function(t,e){e=Object.assign({},Sy,e);const n=[];let i=!1,r=!1;t[0]==="\uFEFF"&&(t=t.substr(1));for(let s=0;s<t.length;s++)if(t[s]==="<"&&t[s+1]==="?"){if(s+=2,s=Bd(t,s),s.err)return s}else if(t[s]==="<"){let o=s;if(s++,t[s]==="!"){s=Td(t,s);continue}else{let c=!1;t[s]==="/"&&(c=!0,s++);let l="";for(;s<t.length&&t[s]!==">"&&t[s]!==" "&&t[s]!==" "&&t[s]!==`
|
|
126
|
-
`&&t[s]!=="\r";s++)l+=t[s];if(l=l.trim(),l[l.length-1]==="/"&&(l=l.substring(0,l.length-1),s--),!
|
|
127
|
-
`||t==="\r"}function
|
|
128
|
-
`);const e=new
|
|
129
|
-
`;function
|
|
125
|
+
`,i}async function iy(t){const e=await t.publicKey.export(),n=await crypto.subtle.exportKey("jwk",e),i=JSON.stringify(n,Object.keys(n).sort()),s=new TextEncoder().encode(i);return $c(await tg(s))}const ry=1e3*60*60*24,sy=new a.OpenAPIHono().openapi(a.createRoute({tags:["keys"],method:"get",path:"/signing",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.array(da)}},description:"List of keys"}}}),async t=>{const n=(await t.env.data.keys.list()).filter(i=>"cert"in i).map(i=>i);return t.json(n)}).openapi(a.createRoute({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({kid:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:da}},description:"The requested key"}}}),async t=>{const{kid:e}=t.req.valid("param"),i=(await t.env.data.keys.list()).find(r=>r.kid===e);if(!i)throw new O(404,{message:"Key not found"});return t.json(i)}).openapi(a.createRoute({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async t=>{const e=await t.env.data.keys.list();for await(const i of e)await t.env.data.keys.update(i.kid,{revoked_at:new Date(Date.now()+ry).toISOString()});const n=await zc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(n),t.text("OK",{status:201})}).openapi(a.createRoute({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({kid:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async t=>{const{kid:e}=t.req.valid("param");if(!await t.env.data.keys.update(e,{revoked_at:new Date().toISOString()}))throw new O(404,{message:"Key not found"});const i=await zc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(i),t.text("OK")}),oy=new a.OpenAPIHono().openapi(a.createRoute({tags:["users"],method:"get",path:"/",request:{query:a.z.object({email:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:a.z.array(Uc)}},description:"List of users"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{email:n}=t.req.valid("query"),r=(await cf(t.env.data.users,e,n)).filter(s=>!s.linked_to);return t.json(r)}),ay=Yt.extend({clients:a.z.array(on)}),cy=new a.OpenAPIHono().openapi(a.createRoute({tags:["clients"],method:"get",path:"/",request:{query:hn,headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:a.z.union([ay,a.z.array(on)])}},description:"List of clients"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:i,include_totals:r,sort:s,q:o}=t.req.valid("query"),l=(await t.env.data.applications.list(e,{page:n,per_page:i,include_totals:r,sort:Qn(s),q:o})).applications;return r?t.json({clients:l,start:0,limit:10,length:l.length}):t.json(l)}).openapi(a.createRoute({tags:["clients"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:on}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=(await t.env.data.applications.list(e,{page:1,per_page:0,include_totals:!1})).applications.find(s=>s.id===n);if(!r)throw new O(404);return t.json(r)}).openapi(a.createRoute({tags:["clients"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.applications.remove(e,n))throw new O(404,{message:"Application not found"});return t.text("OK")}).openapi(a.createRoute({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(Dr.shape).partial()}}},params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:on}},description:"The update application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=t.req.valid("json");await t.env.data.applications.update(e,n,r);const s=await t.env.data.applications.get(e,n);if(!s)throw new O(404,{message:"Application not found"});return t.json(s)}).openapi(a.createRoute({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(Dr.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:a.z.object(on.shape)}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),i={...n,id:n.id||He(),client_secret:n.client_secret||He()},r=await t.env.data.applications.create(e,i);return t.json(r,{status:201})});a.z.object({start:a.z.number(),limit:a.z.number(),length:a.z.number()});Rs.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());const ly=Yt.extend({tenants:a.z.array(Pn)}),uy=new a.OpenAPIHono().openapi(a.createRoute({tags:["tenants"],method:"get",path:"/",request:{query:hn},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:a.z.union([a.z.array(Pn),ly])}},description:"List of tenants"}}}),async t=>{const{page:e,per_page:n,include_totals:i,sort:r,q:s}=t.req.valid("query"),o=await t.env.data.tenants.list({page:e,per_page:n,include_totals:i,sort:Qn(r),q:s});return i?t.json(o):t.json(o.tenants)}).openapi(a.createRoute({tags:["tenants"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Pn}},description:"A tenant"}}}),async t=>{const{id:e}=t.req.valid("param"),n=await t.env.data.tenants.get(e);if(!n)throw new O(404);return t.json(n)}).openapi(a.createRoute({tags:["tenants"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{id:e}=t.req.valid("param");return await t.env.data.tenants.remove(e),t.text("OK")}).openapi(a.createRoute({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(Fr.shape).partial()}}},params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{id:e}=t.req.valid("param"),n=t.req.valid("json");return await t.env.data.tenants.update(e,n),t.text("OK")}).openapi(a.createRoute({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(Fr.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Pn}},description:"An tenant"}}}),async t=>{const e=t.req.valid("json"),n=await t.env.data.tenants.create(e);return t.json(n,{status:201})}),dy=Yt.extend({logs:a.z.array(Kr)}),py=new a.OpenAPIHono().openapi(a.createRoute({tags:["logs"],method:"get",path:"/",request:{query:hn,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(Kr),dy])}},description:"List of log rows"}}}),async t=>{const{page:e,per_page:n,include_totals:i,sort:r,q:s}=t.req.valid("query"),{"tenant-id":o}=t.req.valid("header"),c=await t.env.data.logs.list(o,{page:e,per_page:n,include_totals:i,sort:Qn(r),q:s});return i?t.json(c):t.json(c.logs)}).openapi(a.createRoute({tags:["logs"],method:"get",path:"/{id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Kr}},description:"A log entry"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=await t.env.data.logs.get(e,n);if(!i)throw new O(404);return t.json(i)}),fy=Yt.extend({hooks:a.z.array(Bn)}),hy=new a.OpenAPIHono().openapi(a.createRoute({tags:["hooks"],method:"get",path:"/",request:{query:hn,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(Bn),fy])}},description:"List of hooks"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:i,include_totals:r,sort:s,q:o}=t.req.valid("query"),c=await t.env.data.hooks.list(e,{page:n,per_page:i,include_totals:r,sort:Qn(s),q:o});return r?t.json(c):t.json(c.hooks)}).openapi(a.createRoute({tags:["hooks"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(qr.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Bn}},description:"The created hook"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),i=await t.env.data.hooks.create(e,n);return t.json(i,{status:201})}).openapi(a.createRoute({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.z.string()}),body:{content:{"application/json":{schema:a.z.object(qr.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Bn.shape}},description:"The updated hook"},404:{description:"Hook not found"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param"),i=t.req.valid("json");await t.env.data.hooks.update(e,n,i);const r=await t.env.data.hooks.get(e,n);if(!r)throw new O(404,{message:"Hook not found"});return t.json(r)}).openapi(a.createRoute({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Bn}},description:"A hook"},404:{description:"Hook not found"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param"),i=await t.env.data.hooks.get(e,n);if(!i)throw new O(404,{message:"Hook not found"});return t.json(i)}).openapi(a.createRoute({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:a.z.object({"tenant-id":a.z.string()}),params:a.z.object({hook_id:a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{description:"A hook"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{hook_id:n}=t.req.valid("param");if(!await t.env.data.hooks.remove(e,n))throw new O(404,{message:"Hook not found"});return t.text("OK")}),gy=Yt.extend({connections:a.z.array(Vt)}),my=new a.OpenAPIHono().openapi(a.createRoute({tags:["connections"],method:"get",path:"/",request:{query:hn,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(Vt),gy])}},description:"List of connectionss"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:i,include_totals:r=!1,sort:s,q:o}=t.req.valid("query"),c=await t.env.data.connections.list(e,{page:n,per_page:i,include_totals:r,sort:Qn(s),q:o});return r?t.json(c):t.json(c.connections)}).openapi(a.createRoute({tags:["connections"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Vt}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=await t.env.data.connections.get(e,n);if(!i)throw new O(404);return t.json(i)}).openapi(a.createRoute({tags:["connections"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.connections.remove(e,n))throw new O(404,{message:"Connection not found"});return t.text("OK")}).openapi(a.createRoute({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:a.z.object(Hr.shape).partial()}}},params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Vt}},description:"The updated connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=t.req.valid("json");if(!await t.env.data.connections.update(e,n,i))throw new O(404,{message:"Connection not found"});const s=await t.env.data.connections.get(e,n);if(!s)throw new O(404,{message:"Connection not found"});return t.json(s)}).openapi(a.createRoute({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.object(Hr.shape)}}},headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Vt}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),i=await t.env.data.connections.create(e,n);return t.json(i,{status:201})}),_y=new a.OpenAPIHono().openapi(a.createRoute({tags:["prompts"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Sr}},description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.promptSettings.get(e);return n?t.json(n):t.json(Sr.parse({}))}).openapi(a.createRoute({tags:["prompts"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Sr.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Prompts settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),i=await t.env.data.promptSettings.get(e);return Object.assign(i,n),await t.env.data.promptSettings.set(e,i),t.json(i)});let Yd=!1;function ng(t){t.use(async(e,n)=>(Yd||(t.openAPIRegistry.registerComponent("securitySchemes","Bearer",{type:"oauth2",scheme:"bearer",flows:{implicit:{authorizationUrl:`${e.env.AUTH_URL}/authorize`,scopes:{openid:"Basic user information",email:"User email",profile:"User profile information"}}}}),Yd=!0),await n()))}a.z.object({alg:a.z.literal("RS256"),kty:a.z.literal("RSA"),use:a.z.literal("sig"),n:a.z.string(),e:a.z.string(),kid:a.z.string(),x5t:a.z.string(),x5c:a.z.array(a.z.string())});async function yy(t){try{const e=await t.JWKS_SERVICE.fetch(t.JWKS_URL);if(!e.ok)throw new Error("Failed to fetch jwks");return(await e.json()).keys}catch(e){throw new O(500,{message:`Failed to fetch jwks: ${e.message}`})}}async function vy(t,e){const i=new TextEncoder().encode([e.raw.header,e.raw.payload].join(".")),r=new Uint8Array(Array.from(e.signature).map(l=>l.charCodeAt(0))),o=(await yy(t.env)).find(l=>l.kid===e.header.kid);if(!o)return console.log("No matching kid found"),!1;const c=await crypto.subtle.importKey("jwk",o,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",c,r,i)}function wy(t){const[e,n,i]=t.split(".");if(!e||!n||!i)return null;const r=JSON.parse(atob(e)),s=JSON.parse(atob(n)),o=atob(i.replace(/-/g,"+").replace(/_/g,"/"));return{header:r,payload:s,signature:o,raw:{header:e,payload:n,signature:i}}}function ig(t){return async(e,n)=>{var r,s,o;const i=t.openAPIRegistry.definitions.find(c=>"route"in c&&c.route.path===e.req.path&&c.route.method.toUpperCase()===e.req.method);if(i&&"route"in i){const c=(s=(r=i.route.security)==null?void 0:r[0])==null?void 0:s.Bearer;if(!(c!=null&&c.length))return await n();const l=e.req.header("authorization")||"",[u,p]=l.split(" ");if((u==null?void 0:u.toLowerCase())!=="bearer"||!p)throw new O(401,{message:"Missing bearer token"});const f=wy(p);if(!f||!await vy(e,f))throw new O(403,{message:"Invalid JWT signature"});e.set("user_id",f.payload.sub),e.set("user",f.payload);const m=f.payload.permissions||[],v=((o=f.payload.scope)==null?void 0:o.split(" "))||[];if(c.length&&!(c.some(h=>m.includes(h))||c.some(h=>v.includes(h))))throw new O(403,{message:"Unauthorized"})}return await n()}}const by=new a.OpenAPIHono().openapi(a.createRoute({tags:["emails"],method:"get",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ar}},description:"Email provider"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.emailProviders.get(e);if(!n)throw new O(404,{message:"Email provider not found"});return t.json(n)}).openapi(a.createRoute({tags:["emails"],method:"post",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Ar.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.emailProviders.create(e,n),t.text("OK",{status:201})}).openapi(a.createRoute({tags:["emails"],method:"patch",path:"/",request:{headers:a.z.object({"tenant-id":a.z.string()}),body:{content:{"application/json":{schema:a.z.object(Ar.shape).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Branding settings"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");return await t.env.data.emailProviders.update(e,n),t.text("OK")}),ky=new a.OpenAPIHono().openapi(a.createRoute({tags:["sessions"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Us}},description:"A session"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=await t.env.data.sessions.get(e,n);if(!i)throw new O(404);return t.json(i)}).openapi(a.createRoute({tags:["sessions"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.sessions.remove(e,n))throw new O(404,{message:"Session not found"});return t.text("OK")}).openapi(a.createRoute({tags:["sessions"],method:"post",path:"/{id}/revoke",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{202:{description:"Sesssion deletion status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.sessions.update(e,n,{revoked_at:new Date().toDateString()}))throw new O(404,{message:"Session not found"});return t.text("Session deletion request accepted.",{status:202})}),xy=new a.OpenAPIHono().openapi(a.createRoute({tags:["refresh_tokens"],method:"get",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Dc}},description:"A session"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=await t.env.data.refreshTokens.get(e,n);if(!i)throw new O(404);return t.json(i)}).openapi(a.createRoute({tags:["refresh_tokens"],method:"delete",path:"/{id}",request:{params:a.z.object({id:a.z.string()}),headers:a.z.object({"tenant-id":a.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param");if(!await t.env.data.refreshTokens.remove(e,n))throw new O(404,{message:"Session not found"});return t.text("OK")});function Sy(){const t=new a.OpenAPIHono;t.use(ig(t));const e=t.route("/branding",Hm).route("/email/providers",by).route("/users",s_).route("/keys",sy).route("/users-by-email",oy).route("/clients",cy).route("/tenants",uy).route("/logs",py).route("/hooks",hy).route("/connections",my).route("/prompts",_y).route("/sessions",ky).route("/refresh_tokens",xy);return ng(e),e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"}}),e}function Ay(t,e){Object.keys(e).forEach(n=>{const i=e[n];i!=null&&i.length&&t.searchParams.set(n,i)})}function ui(t){var e,n,i;return{auth0Client:(e=t.query("auth0Client"))==null?void 0:e.slice(0,255),ip:(n=t.header("x-real-ip"))==null?void 0:n.slice(0,45),useragent:(i=t.header("user-agent"))==null?void 0:i.slice(0,512)}}const br=60*5,No=30*24*60*60,Cs=24*60*60,Ey="auth-token",Nc=30*60*1e3,Iy=5*60,Cy=5*60;var Xd;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Xd||(Xd={}));var Qd;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(Qd||(Qd={}));function $y(t){return sg(t,zy,Mi.Include)}function rg(t){return sg(t,Ny,Mi.None)}function sg(t,e,n){let i="";for(let r=0;r<t.byteLength;r+=3){let s=0,o=0;for(let c=0;c<3&&r+c<t.byteLength;c++)s=s<<8|t[r+c],o+=8;for(let c=0;c<4;c++)o>=6?(i+=e[s>>o-6&63],o-=6):o>0?(i+=e[s<<6-o&63],o=0):n===Mi.Include&&(i+="=")}return i}const zy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ny="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var Mi;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Mi||(Mi={}));var ep;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(ep||(ep={}));class jy{uint8(e,n){if(e.byteLength<n+1)throw new TypeError("Insufficient bytes");return e[n]}uint16(e,n){if(e.byteLength<n+2)throw new TypeError("Insufficient bytes");return e[n]<<8|e[n+1]}uint32(e,n){if(e.byteLength<n+4)throw new TypeError("Insufficient bytes");let i=0;for(let r=0;r<4;r++)i|=e[n+r]<<24-r*8;return i}uint64(e,n){if(e.byteLength<n+8)throw new TypeError("Insufficient bytes");let i=0n;for(let r=0;r<8;r++)i|=BigInt(e[n+r])<<BigInt(56-r*8);return i}putUint8(e,n,i){if(e.length<i+1)throw new TypeError("Not enough space");if(n<0||n>255)throw new TypeError("Invalid uint8 value");e[i]=n}putUint16(e,n,i){if(e.length<i+2)throw new TypeError("Not enough space");if(n<0||n>65535)throw new TypeError("Invalid uint16 value");e[i]=n>>8,e[i+1]=n&255}putUint32(e,n,i){if(e.length<i+4)throw new TypeError("Not enough space");if(n<0||n>4294967295)throw new TypeError("Invalid uint32 value");for(let r=0;r<4;r++)e[i+r]=n>>(3-r)*8&255}putUint64(e,n,i){if(e.length<i+8)throw new TypeError("Not enough space");if(n<0||n>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let r=0;r<8;r++)e[i+r]=Number(n>>BigInt((7-r)*8)&0xffn)}}const tp=new jy;function yt(t,e){return(t<<32-e|t>>>e)>>>0}function Oy(t){const e=new By;return e.update(t),e.digest()}class By{constructor(){Q(this,"blockSize",64);Q(this,"size",32);Q(this,"blocks",new Uint8Array(64));Q(this,"currentBlockSize",0);Q(this,"H",new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]));Q(this,"l",0n);Q(this,"w",new Uint32Array(64))}update(e){if(this.l+=BigInt(e.byteLength)*8n,this.currentBlockSize+e.byteLength<64){this.blocks.set(e,this.currentBlockSize),this.currentBlockSize+=e.byteLength;return}let n=0;if(this.currentBlockSize>0){const i=e.slice(0,64-this.currentBlockSize);this.blocks.set(i,this.currentBlockSize),this.process(),n+=i.byteLength,this.currentBlockSize=0}for(;n+64<=e.byteLength;){const i=e.slice(n,n+64);this.blocks.set(i),this.process(),n+=64}if(e.byteLength-n>0){const i=e.slice(n);this.blocks.set(i),this.currentBlockSize=i.byteLength}}digest(){this.blocks[this.currentBlockSize]=128,this.currentBlockSize+=1,64-this.currentBlockSize<8&&(this.blocks.fill(0,this.currentBlockSize),this.process(),this.currentBlockSize=0),this.blocks.fill(0,this.currentBlockSize),tp.putUint64(this.blocks,this.l,this.blockSize-8),this.process();const e=new Uint8Array(32);for(let n=0;n<8;n++)tp.putUint32(e,this.H[n],n*4);return e}process(){for(let u=0;u<16;u++)this.w[u]=(this.blocks[u*4]<<24|this.blocks[u*4+1]<<16|this.blocks[u*4+2]<<8|this.blocks[u*4+3])>>>0;for(let u=16;u<64;u++){const p=(yt(this.w[u-2],17)^yt(this.w[u-2],19)^this.w[u-2]>>>10)>>>0,f=(yt(this.w[u-15],7)^yt(this.w[u-15],18)^this.w[u-15]>>>3)>>>0;this.w[u]=p+this.w[u-7]+f+this.w[u-16]|0}let e=this.H[0],n=this.H[1],i=this.H[2],r=this.H[3],s=this.H[4],o=this.H[5],c=this.H[6],l=this.H[7];for(let u=0;u<64;u++){const p=(yt(s,6)^yt(s,11)^yt(s,25))>>>0,f=(s&o^~s&c)>>>0,m=l+p+f+Ty[u]+this.w[u]|0,v=(yt(e,2)^yt(e,13)^yt(e,22))>>>0,h=(e&n^e&i^n&i)>>>0,_=v+h|0;l=c,c=o,o=s,s=r+m|0,r=i,i=n,n=e,e=m+_|0}this.H[0]=e+this.H[0]|0,this.H[1]=n+this.H[1]|0,this.H[2]=i+this.H[2]|0,this.H[3]=r+this.H[3]|0,this.H[4]=s+this.H[4]|0,this.H[5]=o+this.H[5]|0,this.H[6]=c+this.H[6]|0,this.H[7]=l+this.H[7]|0}}const Ty=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);new BigUint64Array([0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n]);class Py{constructor(e){Q(this,"data");this.data=e}tokenType(){if("token_type"in this.data&&typeof this.data.token_type=="string")return this.data.token_type;throw new Error("Missing or invalid 'token_type' field")}accessToken(){if("access_token"in this.data&&typeof this.data.access_token=="string")return this.data.access_token;throw new Error("Missing or invalid 'access_token' field")}accessTokenExpiresInSeconds(){if("expires_in"in this.data&&typeof this.data.expires_in=="number")return this.data.expires_in;throw new Error("Missing or invalid 'expires_in' field")}accessTokenExpiresAt(){return new Date(Date.now()+this.accessTokenExpiresInSeconds()*1e3)}hasRefreshToken(){return"refresh_token"in this.data&&typeof this.data.refresh_token=="string"}refreshToken(){if("refresh_token"in this.data&&typeof this.data.refresh_token=="string")return this.data.refresh_token;throw new Error("Missing or invalid 'refresh_token' field")}hasScopes(){return"scope"in this.data&&typeof this.data.scope=="string"}scopes(){if("scope"in this.data&&typeof this.data.scope=="string")return this.data.scope.split(" ");throw new Error("Missing or invalid 'scope' field")}idToken(){if("id_token"in this.data&&typeof this.data.id_token=="string")return this.data.id_token;throw new Error("Missing or invalid field 'id_token'")}}function Ry(t){const e=Oy(new TextEncoder().encode(t));return rg(e)}function Ly(){const t=new Uint8Array(32);return crypto.getRandomValues(t),rg(t)}function Ei(t,e){const n=new TextEncoder().encode(e.toString()),i=new Request(t,{method:"POST",body:n});return i.headers.set("Content-Type","application/x-www-form-urlencoded"),i.headers.set("Accept","application/json"),i.headers.set("User-Agent","arctic"),i.headers.set("Content-Length",n.byteLength.toString()),i}function Qo(t,e){const n=new TextEncoder().encode(`${t}:${e}`);return $y(n)}async function $s(t){let e;try{e=await fetch(t)}catch(n){throw new ag(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new zr(e.status)}if(typeof n!="object"||n===null)throw new Un(e.status,n);let i;try{i=og(n)}catch{throw new Un(e.status,n)}throw i}if(e.status===200){let n;try{n=await e.json()}catch{throw new zr(e.status)}if(typeof n!="object"||n===null)throw new Un(e.status,n);return new Py(n)}throw e.body!==null&&await e.body.cancel(),new zr(e.status)}async function Uy(t){let e;try{e=await fetch(t)}catch(n){throw new ag(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new Un(e.status,null)}if(typeof n!="object"||n===null)throw new Un(e.status,n);let i;try{i=og(n)}catch{throw new Un(e.status,n)}throw i}if(e.status===200){e.body!==null&&await e.body.cancel();return}throw e.body!==null&&await e.body.cancel(),new zr(e.status)}function og(t){let e;if("error"in t&&typeof t.error=="string")e=t.error;else throw new Error("Invalid error response");let n=null,i=null,r=null;if("error_description"in t){if(typeof t.error_description!="string")throw new Error("Invalid data");n=t.error_description}if("error_uri"in t){if(typeof t.error_uri!="string")throw new Error("Invalid data");i=t.error_uri}if("state"in t){if(typeof t.state!="string")throw new Error("Invalid data");r=t.state}return new Vy(e,n,i,r)}class ag extends Error{constructor(e){super("Failed to send request",{cause:e})}}class Vy extends Error{constructor(n,i,r,s){super(`OAuth request error: ${n}`);Q(this,"code");Q(this,"description");Q(this,"uri");Q(this,"state");this.code=n,this.description=i,this.uri=r,this.state=s}}class zr extends Error{constructor(n){super("Unexpected error response");Q(this,"status");this.status=n}}class Un extends Error{constructor(n,i){super("Unexpected error response body");Q(this,"status");Q(this,"data");this.status=n,this.data=i}}class Tl{constructor(e,n,i){Q(this,"clientId");Q(this,"clientPassword");Q(this,"redirectURI");this.clientId=e,this.clientPassword=n,this.redirectURI=i}createAuthorizationURL(e,n,i){const r=new URL(e);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&r.searchParams.set("redirect_uri",this.redirectURI),r.searchParams.set("state",n),i.length>0&&r.searchParams.set("scope",i.join(" ")),r}createAuthorizationURLWithPKCE(e,n,i,r,s){const o=new URL(e);if(o.searchParams.set("response_type","code"),o.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&o.searchParams.set("redirect_uri",this.redirectURI),o.searchParams.set("state",n),i===Di.S256){const c=Ry(r);o.searchParams.set("code_challenge_method","S256"),o.searchParams.set("code_challenge",c)}else i===Di.Plain&&(o.searchParams.set("code_challenge_method","plain"),o.searchParams.set("code_challenge",r));return s.length>0&&o.searchParams.set("scope",s.join(" ")),o}async validateAuthorizationCode(e,n,i){const r=new URLSearchParams;r.set("grant_type","authorization_code"),r.set("code",n),this.redirectURI!==null&&r.set("redirect_uri",this.redirectURI),i!==null&&r.set("code_verifier",i),this.clientPassword===null&&r.set("client_id",this.clientId);const s=Ei(e,r);if(this.clientPassword!==null){const c=Qo(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await $s(s)}async refreshAccessToken(e,n,i){const r=new URLSearchParams;r.set("grant_type","refresh_token"),r.set("refresh_token",n),this.clientPassword===null&&r.set("client_id",this.clientId),i.length>0&&r.set("scope",i.join(" "));const s=Ei(e,r);if(this.clientPassword!==null){const c=Qo(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await $s(s)}async revokeToken(e,n){const i=new URLSearchParams;i.set("token",n),this.clientPassword===null&&i.set("client_id",this.clientId);const r=Ei(e,i);if(this.clientPassword!==null){const s=Qo(this.clientId,this.clientPassword);r.headers.set("Authorization",`Basic ${s}`)}await Uy(r)}}var Di;(function(t){t[t.S256=0]="S256",t[t.Plain=1]="Plain"})(Di||(Di={}));var np;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(np||(np={}));var ip;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(ip||(ip={}));function Ii(t){return My(t,Dy,zs.None)}function My(t,e,n){let i="";for(let r=0;r<t.byteLength;r+=3){let s=0,o=0;for(let c=0;c<3&&r+c<t.byteLength;c++)s=s<<8|t[r+c],o+=8;for(let c=0;c<4;c++)o>=6?(i+=e[s>>o-6&63],o-=6):o>0?(i+=e[s<<6-o&63],o=0):n===zs.Include&&(i+="=")}return i}const Dy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var zs;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(zs||(zs={}));var rp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(rp||(rp={}));function Hy(t,e,n){const i=Ii(new TextEncoder().encode(t)),r=Ii(new TextEncoder().encode(e)),s=Ii(n);return i+"."+r+"."+s}function Fy(t,e){const n=Ii(new TextEncoder().encode(t)),i=Ii(new TextEncoder().encode(e)),r=n+"."+i;return new TextEncoder().encode(r)}const qy="https://appleid.apple.com/auth/authorize",Ky="https://appleid.apple.com/auth/token";class cg{constructor(e,n,i,r,s){Q(this,"clientId");Q(this,"teamId");Q(this,"keyId");Q(this,"pkcs8PrivateKey");Q(this,"redirectURI");this.clientId=e,this.teamId=n,this.keyId=i,this.pkcs8PrivateKey=r,this.redirectURI=s}createAuthorizationURL(e,n){const i=new URL(qy);return i.searchParams.set("response_type","code"),i.searchParams.set("client_id",this.clientId),i.searchParams.set("state",e),n.length>0&&i.searchParams.set("scope",n.join(" ")),i.searchParams.set("redirect_uri",this.redirectURI),i}async validateAuthorizationCode(e){const n=new URLSearchParams;n.set("grant_type","authorization_code"),n.set("code",e),n.set("redirect_uri",this.redirectURI),n.set("client_id",this.clientId);const i=await this.createClientSecret();n.set("client_secret",i);const r=Ei(Ky,n);return await $s(r)}async createClientSecret(){const e=await crypto.subtle.importKey("pkcs8",this.pkcs8PrivateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),n=Math.floor(Date.now()/1e3),i=JSON.stringify({typ:"JWT",alg:"ES256",kid:this.keyId}),r=JSON.stringify({iss:this.teamId,exp:n+5*60,aud:["https://appleid.apple.com"],sub:this.clientId,iat:n}),s=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},e,Fy(i,r)));return Hy(i,r,s)}}const Wy="https://www.facebook.com/v16.0/dialog/oauth",Gy="https://graph.facebook.com/v16.0/oauth/access_token";class lg{constructor(e,n,i){Q(this,"clientId");Q(this,"clientSecret");Q(this,"redirectURI");this.clientId=e,this.clientSecret=n,this.redirectURI=i}createAuthorizationURL(e,n){const i=new URL(Wy);return i.searchParams.set("response_type","code"),i.searchParams.set("client_id",this.clientId),i.searchParams.set("state",e),n.length>0&&i.searchParams.set("scope",n.join(" ")),i.searchParams.set("redirect_uri",this.redirectURI),i}async validateAuthorizationCode(e){const n=new URLSearchParams;n.set("grant_type","authorization_code"),n.set("code",e),n.set("redirect_uri",this.redirectURI),n.set("client_id",this.clientId),n.set("client_secret",this.clientSecret);const i=Ei(Gy,n);return await $s(i)}}const Jy="https://accounts.google.com/o/oauth2/v2/auth",sp="https://oauth2.googleapis.com/token",Zy="https://oauth2.googleapis.com/revoke";let ug=class{constructor(e,n,i){Q(this,"client");this.client=new Tl(e,n,i)}createAuthorizationURL(e,n,i){return this.client.createAuthorizationURLWithPKCE(Jy,e,Di.S256,n,i)}async validateAuthorizationCode(e,n){return await this.client.validateAuthorizationCode(sp,e,n)}async refreshAccessToken(e){return await this.client.refreshAccessToken(sp,e,[])}async revokeToken(e){await this.client.revokeToken(Zy,e)}};class Pl{constructor(e,n){Q(this,"value");Q(this,"unit");this.value=e,this.unit=n}milliseconds(){return this.unit==="ms"?this.value:this.unit==="s"?this.value*1e3:this.unit==="m"?this.value*1e3*60:this.unit==="h"?this.value*1e3*60*60:this.unit==="d"?this.value*1e3*60*60*24:this.value*1e3*60*60*24*7}seconds(){return this.milliseconds()/1e3}transform(e){return new Pl(Math.round(this.milliseconds()*e),"ms")}}async function op(t,e,n,i){const r={alg:t,typ:"JWT",...i==null?void 0:i.headers},s={...n};(i==null?void 0:i.audiences)!==void 0&&(s.aud=i.audiences),(i==null?void 0:i.subject)!==void 0&&(s.sub=i.subject),(i==null?void 0:i.issuer)!==void 0&&(s.iss=i.issuer),(i==null?void 0:i.jwtId)!==void 0&&(s.jti=i.jwtId),(i==null?void 0:i.expiresIn)!==void 0&&(s.exp=Math.floor(Date.now()/1e3)+i.expiresIn.seconds()),(i==null?void 0:i.notBefore)!==void 0&&(s.nbf=Math.floor(i.notBefore.getTime()/1e3)),s.iat=Math.floor(Date.now()/1e3);const o=new TextEncoder,c=pn.encode(o.encode(JSON.stringify(r)),{includePadding:!1}),l=pn.encode(o.encode(JSON.stringify(s)),{includePadding:!1}),u=o.encode([c,l].join(".")),p=await Xy(t).sign(e,u),f=pn.encode(new Uint8Array(p),{includePadding:!1});return[c,l,f].join(".")}function Yy(t){const e=t.split(".");return e.length!==3?null:e}function Rl(t){const e=Yy(t);if(!e)return null;const n=new TextDecoder,i=pn.decode(e[0],{strict:!1}),r=pn.decode(e[1],{strict:!1}),s=JSON.parse(n.decode(i));if(typeof s!="object"||s===null||!("alg"in s)||!Qy(s.alg)||"typ"in s&&s.typ!=="JWT")return null;const o=JSON.parse(n.decode(r));if(typeof o!="object"||o===null)return null;const c={algorithm:s.alg,expiresAt:null,subject:null,issuedAt:null,issuer:null,jwtId:null,audiences:null,notBefore:null};if("exp"in o){if(typeof o.exp!="number")return null;c.expiresAt=new Date(o.exp*1e3)}if("iss"in o){if(typeof o.iss!="string")return null;c.issuer=o.iss}if("sub"in o){if(typeof o.sub!="string")return null;c.subject=o.sub}if("aud"in o)if(Array.isArray(o.aud)){for(const l of o.aud)if(typeof l!="string")return null;c.audiences=o.aud}else{if(typeof o.aud!="string")return null;c.audiences=[o.aud]}if("nbf"in o){if(typeof o.nbf!="number")return null;c.notBefore=new Date(o.nbf*1e3)}if("iat"in o){if(typeof o.iat!="number")return null;c.issuedAt=new Date(o.iat*1e3)}if("jti"in o){if(typeof o.jti!="string")return null;c.jwtId=o.jti}return{value:t,header:{...s,typ:"JWT",alg:s.alg},payload:{...o},parts:e,...c}}function Xy(t){return new ty(ev[t])}function Qy(t){return typeof t!="string"?!1:["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512","PS256","PS384","PS512"].includes(t)}const ev={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"},jo=a.z.object({iss:a.z.string().url(),sub:a.z.string(),aud:a.z.string(),exp:a.z.number(),email:a.z.string().optional(),given_name:a.z.string().optional(),family_name:a.z.string().optional(),name:a.z.string().optional(),iat:a.z.number(),auth_time:a.z.number().optional(),nonce:a.z.string().optional(),acr:a.z.string().optional(),amr:a.z.array(a.z.string()).optional(),azp:a.z.string().optional(),at_hash:a.z.string().optional(),c_hash:a.z.string().optional()}).passthrough();jo.omit({iat:!0,auth_time:!0,nonce:!0,acr:!0,amr:!0,azp:!0,at_hash:!0,c_hash:!0});function tv(t){return t.ISSUER}function xt(t){return t.UNIVERSAL_LOGIN_URL||`${t.ISSUER}u/`}function $e(t){return t.OAUTH_API_URL||t.ISSUER}function dg(t){const{options:e}=t;if(!e||!e.client_id||!e.team_id||!e.kid||!e.app_secret)throw new Error("Missing required Apple authentication parameters");const n=Buffer.from(e.app_secret,"utf-8"),i=n.toString().replace(/-----BEGIN PRIVATE KEY-----|-----END PRIVATE KEY-----|\s/g,""),r=Uint8Array.from(Buffer.from(i,"base64"));return n.fill(0),{options:e,keyArray:r}}async function nv(t,e){var l,u;const{options:n,keyArray:i}=dg(e),r=new cg(n.client_id,n.team_id,n.kid,i,`${$e(t.env)}callback`),s=He(),o=await r.createAuthorizationURL(s,((l=n.scope)==null?void 0:l.split(" "))||["name","email"]);return(((u=n.scope)==null?void 0:u.split(" "))||["name","email"]).some(p=>["email","name"].includes(p))&&o.searchParams.set("response_mode","form_post"),{redirectUrl:o.href,code:s}}async function iv(t,e,n){const{options:i,keyArray:r}=dg(e),o=await new cg(i.client_id,i.team_id,i.kid,r,`${$e(t.env)}callback`).validateAuthorizationCode(n),c=Rl(o.idToken());if(!c)throw new Error("Invalid ID token");const l=jo.parse(c.payload);return{sub:l.sub,email:l.email,given_name:l.given_name,family_name:l.family_name,name:l.name,picture:l.picture,locale:l.locale}}const rv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:nv,validateAuthorizationCodeAndGetUser:iv},Symbol.toStringTag,{value:"Module"}));async function sv(t,e){var o;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const i=new lg(n.client_id,n.client_secret,`${$e(t.env)}callback`),r=He();return{redirectUrl:i.createAuthorizationURL(r,((o=n.scope)==null?void 0:o.split(" "))||["email"]).href,code:r}}async function ov(t,e,n){const{options:i}=e;if(!(i!=null&&i.client_id)||!i.client_secret)throw new Error("Missing required authentication parameters");const s=await new lg(i.client_id,i.client_secret,`${$e(t.env)}callback`).validateAuthorizationCode(n),o=await fetch("https://graph.facebook.com/v16.0/me?fields=id,email,name",{headers:{Authorization:`Bearer ${s.accessToken()}`}});if(!o.ok)throw new Error("Failed to fetch user info");const c=await o.json();return t.set("log",`Userinfo: ${JSON.stringify(c)}`),{sub:c.id,email:c.email,name:c.name}}const av=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:sv,validateAuthorizationCodeAndGetUser:ov},Symbol.toStringTag,{value:"Module"}));async function cv(t,e){var c;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required Google authentication parameters");const i=new ug(n.client_id,n.client_secret,`${$e(t.env)}callback`),r=He(),s=Ly();return{redirectUrl:i.createAuthorizationURL(r,s,((c=n.scope)==null?void 0:c.split(" "))??["email","profile"]).href,code:r,codeVerifier:s}}async function lv(t,e,n,i){const{options:r}=e;if(!(r!=null&&r.client_id)||!r.client_secret||!i)throw new Error("Missing required authentication parameters");const o=await new ug(r.client_id,r.client_secret,`${$e(t.env)}callback`).validateAuthorizationCode(n,i);console.log("got here");const c=Rl(o.idToken());if(!c)throw new Error("Invalid ID token");const l=jo.parse(c.payload);return{sub:l.sub,email:l.email,given_name:l.given_name,family_name:l.family_name,name:l.name,picture:l.picture,locale:l.locale}}const uv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:cv,validateAuthorizationCodeAndGetUser:lv},Symbol.toStringTag,{value:"Module"}));async function dv(t,e){var o;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const i=new Tl(n.client_id,n.client_secret,`${$e(t.env)}callback`),r=He(),s=i.createAuthorizationURL("https://api.vipps.no/access-management-1.0/access/oauth2/auth",r,((o=n.scope)==null?void 0:o.split(" "))||["openid","email","phoneNumber","name","address","birthDate"]);return s.searchParams.set("response_type","code"),s.searchParams.set("response_mode","query"),{redirectUrl:s.href,code:r}}async function pv(t,e,n){const{options:i}=e;if(!(i!=null&&i.client_id)||!i.client_secret)throw new Error("Missing required authentication parameters");const s=await new Tl(i.client_id,i.client_secret,`${$e(t.env)}callback`).validateAuthorizationCode("https://api.vipps.no/access-management-1.0/access/oauth2/token",n,null),o=Rl(s.idToken());if(!o)throw new Error("Invalid ID token");const c=jo.parse(o.payload);if(typeof c.msn!="string")throw new Error("msn not available in id token");const l=await fetch("https://api.vipps.no/vipps-userinfo-api/userinfo",{headers:{Authorization:`Bearer ${s.accessToken()}`,"Merchant-Serial-Number":c.msn}});if(!l.ok)throw new O(400,{message:"Failed to get user from vipps"});return await l.json()}const fv=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:dv,validateAuthorizationCodeAndGetUser:pv},Symbol.toStringTag,{value:"Module"}));function pg(t,e){const n=t.env.STRATEGIES||{},r={apple:rv,facebook:av,"google-oauth2":uv,vipps:fv,...n}[e];if(!r)throw new Error(`Strategy ${e} not found`);return r}async function Oo(t,e){const n=await t.data.clients.get(e);if(!n)throw new O(403,{message:"Client not found"});const i=t.DEFAULT_CLIENT_ID?await t.data.clients.get(t.DEFAULT_CLIENT_ID):void 0,r=await t.data.connections.list(n.tenant.id),s=t.DEFAULT_TENANT_ID?await t.data.connections.list(t.DEFAULT_TENANT_ID):{connections:[]},o=r.connections.map(c=>{var p;const l=(p=s.connections)==null?void 0:p.find(f=>f.name===c.name);return l!=null&&l.options?Vt.parse({...l||{},...c,options:{...l.options||{},...c.options}}):c}).filter(c=>c);return{...n,web_origins:[...(i==null?void 0:i.web_origins)||[],...n.web_origins||[],`${xt(t)}login`],allowed_logout_urls:[...(i==null?void 0:i.allowed_logout_urls)||[],...n.allowed_logout_urls||[],t.ISSUER],callbacks:[...(i==null?void 0:i.callbacks)||[],...n.callbacks||[],`${xt(t)}info`],connections:o,domains:[...n.domains||[],...(i==null?void 0:i.domains)||[]],tenant:{...(i==null?void 0:i.tenant)||{},...n.tenant}}}function Bo(t,e=[],n={}){try{const i=new URL(t);return e.some(r=>{try{return hv(i,new URL(r),n.allowPathWildcards)}catch{return!1}})}catch{return!1}}function hv(t,e,n){if(t.protocol!==e.protocol)return!1;if(n&&e.pathname.includes("*")){const i=e.pathname.replace(/\*/g,".*").replace(/\//g,"\\/");if(!new RegExp(`^${i}$`).test(t.pathname))return!1}else if(t.pathname!==e.pathname)return!1;if(e.hostname.startsWith("*.")&&e.hostname.split(".").length>2&&["http:","https:"].includes(e.protocol)){const i=e.hostname.split(".").slice(1).join(".");return t.hostname.endsWith(i)}return t.hostname===e.hostname}function gv(t){try{const n=/-----BEGIN (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----([^-]*)-----END (?:RSA )?(?:PRIVATE|PUBLIC) KEY-----/.exec(t);if(!n||!n[1])throw new Error("Invalid PEM format");return Uint8Array.from(atob(n[1].replace(/\s/g,"")),i=>i.charCodeAt(0)).buffer}finally{t=t.replace(/./g,"\0")}}async function mv(t,e){if(e==="plain")return t;const n=new TextEncoder().encode(t),i=await tg(n);return pn.encode(new Uint8Array(i),{includePadding:!1})}function fg(t,e,n){const i=[];return i.push([encodeURIComponent(t),encodeURIComponent(e)]),(n==null?void 0:n.domain)!==void 0&&i.push(["Domain",n.domain]),(n==null?void 0:n.expires)!==void 0&&i.push(["Expires",n.expires.toUTCString()]),n!=null&&n.httpOnly&&i.push(["HttpOnly"]),(n==null?void 0:n.maxAge)!==void 0&&i.push(["Max-Age",n.maxAge.toString()]),(n==null?void 0:n.path)!==void 0&&i.push(["Path",n.path]),(n==null?void 0:n.sameSite)==="lax"&&i.push(["SameSite","Lax"]),(n==null?void 0:n.sameSite)==="none"&&i.push(["SameSite","None"]),(n==null?void 0:n.sameSite)==="strict"&&i.push(["SameSite","Strict"]),n!=null&&n.secure&&i.push(["Secure"]),i.map(r=>r.join("=")).join("; ")}function _v(t){const e=new Map,n=t.split("; ");for(const i of n){const r=i.split("="),s=r[0],o=r[1]??"";s&&e.set(decodeURIComponent(s),decodeURIComponent(o))}return e}function Ll(t){return`${t}-${Ey}`}function hg(t,e){return e?(console.log("cookieHeaders",e),_v(e).get(Ll(t))):void 0}function yv(t){const e={path:"/",httpOnly:!0,secure:!0,maxAge:0};return fg(Ll(t),"",{...e,sameSite:"none"})}function gg(t,e){const n={path:"/",httpOnly:!0,secure:!0,maxAge:No};return fg(Ll(t),e,{...n,sameSite:"none"})}var Ul={},To={};(function(t){const e=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",n=e+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",i="["+e+"]["+n+"]*",r=new RegExp("^"+i+"$"),s=function(c,l){const u=[];let p=l.exec(c);for(;p;){const f=[];f.startIndex=l.lastIndex-p[0].length;const m=p.length;for(let v=0;v<m;v++)f.push(p[v]);u.push(f),p=l.exec(c)}return u},o=function(c){const l=r.exec(c);return!(l===null||typeof l>"u")};t.isExist=function(c){return typeof c<"u"},t.isEmptyObject=function(c){return Object.keys(c).length===0},t.merge=function(c,l,u){if(l){const p=Object.keys(l),f=p.length;for(let m=0;m<f;m++)u==="strict"?c[p[m]]=[l[p[m]]]:c[p[m]]=l[p[m]]}},t.getValue=function(c){return t.isExist(c)?c:""},t.isName=o,t.getAllMatches=s,t.nameRegexp=i})(To);const Vl=To,vv={allowBooleanAttributes:!1,unpairedTags:[]};Ul.validate=function(t,e){e=Object.assign({},vv,e);const n=[];let i=!1,r=!1;t[0]==="\uFEFF"&&(t=t.substr(1));for(let s=0;s<t.length;s++)if(t[s]==="<"&&t[s+1]==="?"){if(s+=2,s=cp(t,s),s.err)return s}else if(t[s]==="<"){let o=s;if(s++,t[s]==="!"){s=lp(t,s);continue}else{let c=!1;t[s]==="/"&&(c=!0,s++);let l="";for(;s<t.length&&t[s]!==">"&&t[s]!==" "&&t[s]!==" "&&t[s]!==`
|
|
126
|
+
`&&t[s]!=="\r";s++)l+=t[s];if(l=l.trim(),l[l.length-1]==="/"&&(l=l.substring(0,l.length-1),s--),!Iv(l)){let f;return l.trim().length===0?f="Invalid space after '<'.":f="Tag '"+l+"' is an invalid name.",we("InvalidTag",f,Pe(t,s))}const u=kv(t,s);if(u===!1)return we("InvalidAttr","Attributes for '"+l+"' have open quote.",Pe(t,s));let p=u.value;if(s=u.index,p[p.length-1]==="/"){const f=s-p.length;p=p.substring(0,p.length-1);const m=up(p,e);if(m===!0)i=!0;else return we(m.err.code,m.err.msg,Pe(t,f+m.err.line))}else if(c)if(u.tagClosed){if(p.trim().length>0)return we("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",Pe(t,o));if(n.length===0)return we("InvalidTag","Closing tag '"+l+"' has not been opened.",Pe(t,o));{const f=n.pop();if(l!==f.tagName){let m=Pe(t,f.tagStartPos);return we("InvalidTag","Expected closing tag '"+f.tagName+"' (opened in line "+m.line+", col "+m.col+") instead of closing tag '"+l+"'.",Pe(t,o))}n.length==0&&(r=!0)}}else return we("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",Pe(t,s));else{const f=up(p,e);if(f!==!0)return we(f.err.code,f.err.msg,Pe(t,s-p.length+f.err.line));if(r===!0)return we("InvalidXml","Multiple possible root nodes found.",Pe(t,s));e.unpairedTags.indexOf(l)!==-1||n.push({tagName:l,tagStartPos:o}),i=!0}for(s++;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="!"){s++,s=lp(t,s);continue}else if(t[s+1]==="?"){if(s=cp(t,++s),s.err)return s}else break;else if(t[s]==="&"){const f=Av(t,s);if(f==-1)return we("InvalidChar","char '&' is not expected.",Pe(t,s));s=f}else if(r===!0&&!ap(t[s]))return we("InvalidXml","Extra text at the end",Pe(t,s));t[s]==="<"&&s--}}else{if(ap(t[s]))continue;return we("InvalidChar","char '"+t[s]+"' is not expected.",Pe(t,s))}if(i){if(n.length==1)return we("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",Pe(t,n[0].tagStartPos));if(n.length>0)return we("InvalidXml","Invalid '"+JSON.stringify(n.map(s=>s.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return we("InvalidXml","Start tag expected.",1);return!0};function ap(t){return t===" "||t===" "||t===`
|
|
127
|
+
`||t==="\r"}function cp(t,e){const n=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){const i=t.substr(n,e-n);if(e>5&&i==="xml")return we("InvalidXml","XML declaration allowed only at the start of the document.",Pe(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function lp(t,e){if(t.length>e+5&&t[e+1]==="-"&&t[e+2]==="-"){for(e+=3;e<t.length;e++)if(t[e]==="-"&&t[e+1]==="-"&&t[e+2]===">"){e+=2;break}}else if(t.length>e+8&&t[e+1]==="D"&&t[e+2]==="O"&&t[e+3]==="C"&&t[e+4]==="T"&&t[e+5]==="Y"&&t[e+6]==="P"&&t[e+7]==="E"){let n=1;for(e+=8;e<t.length;e++)if(t[e]==="<")n++;else if(t[e]===">"&&(n--,n===0))break}else if(t.length>e+9&&t[e+1]==="["&&t[e+2]==="C"&&t[e+3]==="D"&&t[e+4]==="A"&&t[e+5]==="T"&&t[e+6]==="A"&&t[e+7]==="["){for(e+=8;e<t.length;e++)if(t[e]==="]"&&t[e+1]==="]"&&t[e+2]===">"){e+=2;break}}return e}const wv='"',bv="'";function kv(t,e){let n="",i="",r=!1;for(;e<t.length;e++){if(t[e]===wv||t[e]===bv)i===""?i=t[e]:i!==t[e]||(i="");else if(t[e]===">"&&i===""){r=!0;break}n+=t[e]}return i!==""?!1:{value:n,index:e,tagClosed:r}}const xv=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function up(t,e){const n=Vl.getAllMatches(t,xv),i={};for(let r=0;r<n.length;r++){if(n[r][1].length===0)return we("InvalidAttr","Attribute '"+n[r][2]+"' has no space in starting.",mi(n[r]));if(n[r][3]!==void 0&&n[r][4]===void 0)return we("InvalidAttr","Attribute '"+n[r][2]+"' is without value.",mi(n[r]));if(n[r][3]===void 0&&!e.allowBooleanAttributes)return we("InvalidAttr","boolean attribute '"+n[r][2]+"' is not allowed.",mi(n[r]));const s=n[r][2];if(!Ev(s))return we("InvalidAttr","Attribute '"+s+"' is an invalid name.",mi(n[r]));if(!i.hasOwnProperty(s))i[s]=1;else return we("InvalidAttr","Attribute '"+s+"' is repeated.",mi(n[r]))}return!0}function Sv(t,e){let n=/\d/;for(t[e]==="x"&&(e++,n=/[\da-fA-F]/);e<t.length;e++){if(t[e]===";")return e;if(!t[e].match(n))break}return-1}function Av(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,Sv(t,e);let n=0;for(;e<t.length;e++,n++)if(!(t[e].match(/\w/)&&n<20)){if(t[e]===";")break;return-1}return e}function we(t,e,n){return{err:{code:t,msg:e,line:n.line||n,col:n.col}}}function Ev(t){return Vl.isName(t)}function Iv(t){return Vl.isName(t)}function Pe(t,e){const n=t.substring(0,e).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function mi(t){return t.startIndex+t[1].length}var Ml={};const mg={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,n){return t}},Cv=function(t){return Object.assign({},mg,t)};Ml.buildOptions=Cv;Ml.defaultOptions=mg;class $v{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,n){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:n})}addChild(e){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child})}}var zv=$v;const Nv=To;function jv(t,e){const n={};if(t[e+3]==="O"&&t[e+4]==="C"&&t[e+5]==="T"&&t[e+6]==="Y"&&t[e+7]==="P"&&t[e+8]==="E"){e=e+9;let i=1,r=!1,s=!1,o="";for(;e<t.length;e++)if(t[e]==="<"&&!s){if(r&&Tv(t,e)){e+=7;let c,l;[c,l,e]=Ov(t,e+1),l.indexOf("&")===-1&&(n[Uv(c)]={regx:RegExp(`&${c};`,"g"),val:l})}else if(r&&Pv(t,e))e+=8;else if(r&&Rv(t,e))e+=8;else if(r&&Lv(t,e))e+=9;else if(Bv)s=!0;else throw new Error("Invalid DOCTYPE");i++,o=""}else if(t[e]===">"){if(s?t[e-1]==="-"&&t[e-2]==="-"&&(s=!1,i--):i--,i===0)break}else t[e]==="["?r=!0:o+=t[e];if(i!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:n,i:e}}function Ov(t,e){let n="";for(;e<t.length&&t[e]!=="'"&&t[e]!=='"';e++)n+=t[e];if(n=n.trim(),n.indexOf(" ")!==-1)throw new Error("External entites are not supported");const i=t[e++];let r="";for(;e<t.length&&t[e]!==i;e++)r+=t[e];return[n,r,e]}function Bv(t,e){return t[e+1]==="!"&&t[e+2]==="-"&&t[e+3]==="-"}function Tv(t,e){return t[e+1]==="!"&&t[e+2]==="E"&&t[e+3]==="N"&&t[e+4]==="T"&&t[e+5]==="I"&&t[e+6]==="T"&&t[e+7]==="Y"}function Pv(t,e){return t[e+1]==="!"&&t[e+2]==="E"&&t[e+3]==="L"&&t[e+4]==="E"&&t[e+5]==="M"&&t[e+6]==="E"&&t[e+7]==="N"&&t[e+8]==="T"}function Rv(t,e){return t[e+1]==="!"&&t[e+2]==="A"&&t[e+3]==="T"&&t[e+4]==="T"&&t[e+5]==="L"&&t[e+6]==="I"&&t[e+7]==="S"&&t[e+8]==="T"}function Lv(t,e){return t[e+1]==="!"&&t[e+2]==="N"&&t[e+3]==="O"&&t[e+4]==="T"&&t[e+5]==="A"&&t[e+6]==="T"&&t[e+7]==="I"&&t[e+8]==="O"&&t[e+9]==="N"}function Uv(t){if(Nv.isName(t))return t;throw new Error(`Invalid entity name ${t}`)}var Vv=jv;const Mv=/^[-+]?0x[a-fA-F0-9]+$/,Dv=/^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt);!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);const Hv={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function Fv(t,e={}){if(e=Object.assign({},Hv,e),!t||typeof t!="string")return t;let n=t.trim();if(e.skipLike!==void 0&&e.skipLike.test(n))return t;if(e.hex&&Mv.test(n))return Number.parseInt(n,16);{const i=Dv.exec(n);if(i){const r=i[1],s=i[2];let o=qv(i[3]);const c=i[4]||i[6];if(!e.leadingZeros&&s.length>0&&r&&n[2]!==".")return t;if(!e.leadingZeros&&s.length>0&&!r&&n[1]!==".")return t;{const l=Number(n),u=""+l;return u.search(/[eE]/)!==-1||c?e.eNotation?l:t:n.indexOf(".")!==-1?u==="0"&&o===""||u===o||r&&u==="-"+o?l:t:s?o===u||r+o===u?l:t:n===u||n===r+u?l:t}}else return t}}function qv(t){return t&&t.indexOf(".")!==-1&&(t=t.replace(/0+$/,""),t==="."?t="0":t[0]==="."?t="0"+t:t[t.length-1]==="."&&(t=t.substr(0,t.length-1))),t}var Kv=Fv;function Wv(t){return typeof t=="function"?t:Array.isArray(t)?e=>{for(const n of t)if(typeof n=="string"&&e===n||n instanceof RegExp&&n.test(e))return!0}:()=>!1}var _g=Wv;const yg=To,_i=zv,Gv=Vv,Jv=Kv,Zv=_g;let Yv=class{constructor(e){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(n,i)=>String.fromCharCode(Number.parseInt(i,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(n,i)=>String.fromCharCode(Number.parseInt(i,16))}},this.addExternalEntities=Xv,this.parseXml=iw,this.parseTextData=Qv,this.resolveNameSpace=ew,this.buildAttributesMap=nw,this.isItStopNode=aw,this.replaceEntitiesValue=sw,this.readStopNodeData=lw,this.saveTextToParentTag=ow,this.addChild=rw,this.ignoreAttributesFn=Zv(this.options.ignoreAttributes)}};function Xv(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const i=e[n];this.lastEntities[i]={regex:new RegExp("&"+i+";","g"),val:t[i]}}}function Qv(t,e,n,i,r,s,o){if(t!==void 0&&(this.options.trimValues&&!i&&(t=t.trim()),t.length>0)){o||(t=this.replaceEntitiesValue(t));const c=this.options.tagValueProcessor(e,t,n,r,s);return c==null?t:typeof c!=typeof t||c!==t?c:this.options.trimValues?Oc(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?Oc(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function ew(t){if(this.options.removeNSPrefix){const e=t.split(":"),n=t.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(t=n+e[1])}return t}const tw=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function nw(t,e,n){if(this.options.ignoreAttributes!==!0&&typeof t=="string"){const i=yg.getAllMatches(t,tw),r=i.length,s={};for(let o=0;o<r;o++){const c=this.resolveNameSpace(i[o][1]);if(this.ignoreAttributesFn(c,e))continue;let l=i[o][4],u=this.options.attributeNamePrefix+c;if(c.length)if(this.options.transformAttributeName&&(u=this.options.transformAttributeName(u)),u==="__proto__"&&(u="#__proto__"),l!==void 0){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l);const p=this.options.attributeValueProcessor(c,l,e);p==null?s[u]=l:typeof p!=typeof l||p!==l?s[u]=p:s[u]=Oc(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[u]=!0)}if(!Object.keys(s).length)return;if(this.options.attributesGroupName){const o={};return o[this.options.attributesGroupName]=s,o}return s}}const iw=function(t){t=t.replace(/\r\n?/g,`
|
|
128
|
+
`);const e=new _i("!xml");let n=e,i="",r="";for(let s=0;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="/"){const c=ln(t,">",s,"Closing Tag is not closed.");let l=t.substring(s+2,c).trim();if(this.options.removeNSPrefix){const f=l.indexOf(":");f!==-1&&(l=l.substr(f+1))}this.options.transformTagName&&(l=this.options.transformTagName(l)),n&&(i=this.saveTextToParentTag(i,n,r));const u=r.substring(r.lastIndexOf(".")+1);if(l&&this.options.unpairedTags.indexOf(l)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${l}>`);let p=0;u&&this.options.unpairedTags.indexOf(u)!==-1?(p=r.lastIndexOf(".",r.lastIndexOf(".")-1),this.tagsNodeStack.pop()):p=r.lastIndexOf("."),r=r.substring(0,p),n=this.tagsNodeStack.pop(),i="",s=c}else if(t[s+1]==="?"){let c=jc(t,s,!1,"?>");if(!c)throw new Error("Pi Tag is not closed.");if(i=this.saveTextToParentTag(i,n,r),!(this.options.ignoreDeclaration&&c.tagName==="?xml"||this.options.ignorePiTags)){const l=new _i(c.tagName);l.add(this.options.textNodeName,""),c.tagName!==c.tagExp&&c.attrExpPresent&&(l[":@"]=this.buildAttributesMap(c.tagExp,r,c.tagName)),this.addChild(n,l,r)}s=c.closeIndex+1}else if(t.substr(s+1,3)==="!--"){const c=ln(t,"-->",s+4,"Comment is not closed.");if(this.options.commentPropName){const l=t.substring(s+4,c-2);i=this.saveTextToParentTag(i,n,r),n.add(this.options.commentPropName,[{[this.options.textNodeName]:l}])}s=c}else if(t.substr(s+1,2)==="!D"){const c=Gv(t,s);this.docTypeEntities=c.entities,s=c.i}else if(t.substr(s+1,2)==="!["){const c=ln(t,"]]>",s,"CDATA is not closed.")-2,l=t.substring(s+9,c);i=this.saveTextToParentTag(i,n,r);let u=this.parseTextData(l,n.tagname,r,!0,!1,!0,!0);u==null&&(u=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:l}]):n.add(this.options.textNodeName,u),s=c+2}else{let c=jc(t,s,this.options.removeNSPrefix),l=c.tagName;const u=c.rawTagName;let p=c.tagExp,f=c.attrExpPresent,m=c.closeIndex;this.options.transformTagName&&(l=this.options.transformTagName(l)),n&&i&&n.tagname!=="!xml"&&(i=this.saveTextToParentTag(i,n,r,!1));const v=n;if(v&&this.options.unpairedTags.indexOf(v.tagname)!==-1&&(n=this.tagsNodeStack.pop(),r=r.substring(0,r.lastIndexOf("."))),l!==e.tagname&&(r+=r?"."+l:l),this.isItStopNode(this.options.stopNodes,r,l)){let h="";if(p.length>0&&p.lastIndexOf("/")===p.length-1)l[l.length-1]==="/"?(l=l.substr(0,l.length-1),r=r.substr(0,r.length-1),p=l):p=p.substr(0,p.length-1),s=c.closeIndex;else if(this.options.unpairedTags.indexOf(l)!==-1)s=c.closeIndex;else{const y=this.readStopNodeData(t,u,m+1);if(!y)throw new Error(`Unexpected end of ${u}`);s=y.i,h=y.tagContent}const _=new _i(l);l!==p&&f&&(_[":@"]=this.buildAttributesMap(p,r,l)),h&&(h=this.parseTextData(h,l,r,!0,f,!0,!0)),r=r.substr(0,r.lastIndexOf(".")),_.add(this.options.textNodeName,h),this.addChild(n,_,r)}else{if(p.length>0&&p.lastIndexOf("/")===p.length-1){l[l.length-1]==="/"?(l=l.substr(0,l.length-1),r=r.substr(0,r.length-1),p=l):p=p.substr(0,p.length-1),this.options.transformTagName&&(l=this.options.transformTagName(l));const h=new _i(l);l!==p&&f&&(h[":@"]=this.buildAttributesMap(p,r,l)),this.addChild(n,h,r),r=r.substr(0,r.lastIndexOf("."))}else{const h=new _i(l);this.tagsNodeStack.push(n),l!==p&&f&&(h[":@"]=this.buildAttributesMap(p,r,l)),this.addChild(n,h,r),n=h}i="",s=m}}else i+=t[s];return e.child};function rw(t,e,n){const i=this.options.updateTag(e.tagname,n,e[":@"]);i===!1||(typeof i=="string"&&(e.tagname=i),t.addChild(e))}const sw=function(t){if(this.options.processEntities){for(let e in this.docTypeEntities){const n=this.docTypeEntities[e];t=t.replace(n.regx,n.val)}for(let e in this.lastEntities){const n=this.lastEntities[e];t=t.replace(n.regex,n.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){const n=this.htmlEntities[e];t=t.replace(n.regex,n.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function ow(t,e,n,i){return t&&(i===void 0&&(i=Object.keys(e.child).length===0),t=this.parseTextData(t,e.tagname,n,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,i),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function aw(t,e,n){const i="*."+n;for(const r in t){const s=t[r];if(i===s||e===s)return!0}return!1}function cw(t,e,n=">"){let i,r="";for(let s=e;s<t.length;s++){let o=t[s];if(i)o===i&&(i="");else if(o==='"'||o==="'")i=o;else if(o===n[0])if(n[1]){if(t[s+1]===n[1])return{data:r,index:s}}else return{data:r,index:s};else o===" "&&(o=" ");r+=o}}function ln(t,e,n,i){const r=t.indexOf(e,n);if(r===-1)throw new Error(i);return r+e.length-1}function jc(t,e,n,i=">"){const r=cw(t,e+1,i);if(!r)return;let s=r.data;const o=r.index,c=s.search(/\s/);let l=s,u=!0;c!==-1&&(l=s.substring(0,c),s=s.substring(c+1).trimStart());const p=l;if(n){const f=l.indexOf(":");f!==-1&&(l=l.substr(f+1),u=l!==r.data.substr(f+1))}return{tagName:l,tagExp:s,closeIndex:o,attrExpPresent:u,rawTagName:p}}function lw(t,e,n){const i=n;let r=1;for(;n<t.length;n++)if(t[n]==="<")if(t[n+1]==="/"){const s=ln(t,">",n,`${e} is not closed`);if(t.substring(n+2,s).trim()===e&&(r--,r===0))return{tagContent:t.substring(i,n),i:s};n=s}else if(t[n+1]==="?")n=ln(t,"?>",n+1,"StopNode is not closed.");else if(t.substr(n+1,3)==="!--")n=ln(t,"-->",n+3,"StopNode is not closed.");else if(t.substr(n+1,2)==="![")n=ln(t,"]]>",n,"StopNode is not closed.")-2;else{const s=jc(t,n,">");s&&((s&&s.tagName)===e&&s.tagExp[s.tagExp.length-1]!=="/"&&r++,n=s.closeIndex)}}function Oc(t,e,n){if(e&&typeof t=="string"){const i=t.trim();return i==="true"?!0:i==="false"?!1:Jv(t,n)}else return yg.isExist(t)?t:""}var uw=Yv,vg={};function dw(t,e){return wg(t,e)}function wg(t,e,n){let i;const r={};for(let s=0;s<t.length;s++){const o=t[s],c=pw(o);let l="";if(n===void 0?l=c:l=n+"."+c,c===e.textNodeName)i===void 0?i=o[c]:i+=""+o[c];else{if(c===void 0)continue;if(o[c]){let u=wg(o[c],e,l);const p=hw(u,e);o[":@"]?fw(u,o[":@"],l,e):Object.keys(u).length===1&&u[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?u=u[e.textNodeName]:Object.keys(u).length===0&&(e.alwaysCreateTextNode?u[e.textNodeName]="":u=""),r[c]!==void 0&&r.hasOwnProperty(c)?(Array.isArray(r[c])||(r[c]=[r[c]]),r[c].push(u)):e.isArray(c,l,p)?r[c]=[u]:r[c]=u}}}return typeof i=="string"?i.length>0&&(r[e.textNodeName]=i):i!==void 0&&(r[e.textNodeName]=i),r}function pw(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const i=e[n];if(i!==":@")return i}}function fw(t,e,n,i){if(e){const r=Object.keys(e),s=r.length;for(let o=0;o<s;o++){const c=r[o];i.isArray(c,n+"."+c,!0,!0)?t[c]=[e[c]]:t[c]=e[c]}}}function hw(t,e){const{textNodeName:n}=e,i=Object.keys(t).length;return!!(i===0||i===1&&(t[n]||typeof t[n]=="boolean"||t[n]===0))}vg.prettify=dw;const{buildOptions:gw}=Ml,mw=uw,{prettify:_w}=vg,yw=Ul;let vw=class{constructor(e){this.externalEntities={},this.options=gw(e)}parse(e,n){if(typeof e!="string")if(e.toString)e=e.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(n){n===!0&&(n={});const s=yw.validate(e,n);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}const i=new mw(this.options);i.addExternalEntities(this.externalEntities);const r=i.parseXml(e);return this.options.preserveOrder||r===void 0?r:_w(r,this.options)}addEntity(e,n){if(n.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if(n==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=n}};var ww=vw;const bw=`
|
|
129
|
+
`;function kw(t,e){let n="";return e.format&&e.indentBy.length>0&&(n=bw),bg(t,e,"",n)}function bg(t,e,n,i){let r="",s=!1;for(let o=0;o<t.length;o++){const c=t[o],l=xw(c);if(l===void 0)continue;let u="";if(n.length===0?u=l:u=`${n}.${l}`,l===e.textNodeName){let h=c[l];Sw(u,e)||(h=e.tagValueProcessor(l,h),h=kg(h,e)),s&&(r+=i),r+=h,s=!1;continue}else if(l===e.cdataPropName){s&&(r+=i),r+=`<![CDATA[${c[l][0][e.textNodeName]}]]>`,s=!1;continue}else if(l===e.commentPropName){r+=i+`<!--${c[l][0][e.textNodeName]}-->`,s=!0;continue}else if(l[0]==="?"){const h=dp(c[":@"],e),_=l==="?xml"?"":i;let y=c[l][0][e.textNodeName];y=y.length!==0?" "+y:"",r+=_+`<${l}${y}${h}?>`,s=!0;continue}let p=i;p!==""&&(p+=e.indentBy);const f=dp(c[":@"],e),m=i+`<${l}${f}`,v=bg(c[l],e,u,p);e.unpairedTags.indexOf(l)!==-1?e.suppressUnpairedNode?r+=m+">":r+=m+"/>":(!v||v.length===0)&&e.suppressEmptyNode?r+=m+"/>":v&&v.endsWith(">")?r+=m+`>${v}${i}</${l}>`:(r+=m+">",v&&i!==""&&(v.includes("/>")||v.includes("</"))?r+=i+e.indentBy+v+i:r+=v,r+=`</${l}>`),s=!0}return r}function xw(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const i=e[n];if(t.hasOwnProperty(i)&&i!==":@")return i}}function dp(t,e){let n="";if(t&&!e.ignoreAttributes)for(let i in t){if(!t.hasOwnProperty(i))continue;let r=e.attributeValueProcessor(i,t[i]);r=kg(r,e),r===!0&&e.suppressBooleanAttributes?n+=` ${i.substr(e.attributeNamePrefix.length)}`:n+=` ${i.substr(e.attributeNamePrefix.length)}="${r}"`}return n}function Sw(t,e){t=t.substr(0,t.length-e.textNodeName.length-1);let n=t.substr(t.lastIndexOf(".")+1);for(let i in e.stopNodes)if(e.stopNodes[i]===t||e.stopNodes[i]==="*."+n)return!0;return!1}function kg(t,e){if(t&&t.length>0&&e.processEntities)for(let n=0;n<e.entities.length;n++){const i=e.entities[n];t=t.replace(i.regex,i.val)}return t}var Aw=kw;const Ew=Aw,Iw=_g,Cw={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function tn(t){this.options=Object.assign({},Cw,t),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=Iw(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=Nw),this.processTextOrObjNode=$w,this.options.format?(this.indentate=zw,this.tagEndChar=`>
|
|
130
130
|
`,this.newLine=`
|
|
131
|
-
`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}
|
|
131
|
+
`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}tn.prototype.build=function(t){return this.options.preserveOrder?Ew(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0,[]).val)};tn.prototype.j2x=function(t,e,n){let i="",r="";const s=n.join(".");for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o))if(typeof t[o]>"u")this.isAttribute(o)&&(r+="");else if(t[o]===null)this.isAttribute(o)?r+="":o[0]==="?"?r+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:r+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if(t[o]instanceof Date)r+=this.buildTextValNode(t[o],o,"",e);else if(typeof t[o]!="object"){const c=this.isAttribute(o);if(c&&!this.ignoreAttributesFn(c,s))i+=this.buildAttrPairStr(c,""+t[o]);else if(!c)if(o===this.options.textNodeName){let l=this.options.tagValueProcessor(o,""+t[o]);r+=this.replaceEntitiesValue(l)}else r+=this.buildTextValNode(t[o],o,"",e)}else if(Array.isArray(t[o])){const c=t[o].length;let l="",u="";for(let p=0;p<c;p++){const f=t[o][p];if(!(typeof f>"u"))if(f===null)o[0]==="?"?r+=this.indentate(e)+"<"+o+"?"+this.tagEndChar:r+=this.indentate(e)+"<"+o+"/"+this.tagEndChar;else if(typeof f=="object")if(this.options.oneListGroup){const m=this.j2x(f,e+1,n.concat(o));l+=m.val,this.options.attributesGroupName&&f.hasOwnProperty(this.options.attributesGroupName)&&(u+=m.attrStr)}else l+=this.processTextOrObjNode(f,o,e,n);else if(this.options.oneListGroup){let m=this.options.tagValueProcessor(o,f);m=this.replaceEntitiesValue(m),l+=m}else l+=this.buildTextValNode(f,o,"",e)}this.options.oneListGroup&&(l=this.buildObjectNode(l,o,u,e)),r+=l}else if(this.options.attributesGroupName&&o===this.options.attributesGroupName){const c=Object.keys(t[o]),l=c.length;for(let u=0;u<l;u++)i+=this.buildAttrPairStr(c[u],""+t[o][c[u]])}else r+=this.processTextOrObjNode(t[o],o,e,n);return{attrStr:i,val:r}};tn.prototype.buildAttrPairStr=function(t,e){return e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&e==="true"?" "+t:" "+t+'="'+e+'"'};function $w(t,e,n,i){const r=this.j2x(t,n+1,i.concat(e));return t[this.options.textNodeName]!==void 0&&Object.keys(t).length===1?this.buildTextValNode(t[this.options.textNodeName],e,r.attrStr,n):this.buildObjectNode(r.val,e,r.attrStr,n)}tn.prototype.buildObjectNode=function(t,e,n,i){if(t==="")return e[0]==="?"?this.indentate(i)+"<"+e+n+"?"+this.tagEndChar:this.indentate(i)+"<"+e+n+this.closeTag(e)+this.tagEndChar;{let r="</"+e+this.tagEndChar,s="";return e[0]==="?"&&(s="?",r=""),(n||n==="")&&t.indexOf("<")===-1?this.indentate(i)+"<"+e+n+s+">"+t+r:this.options.commentPropName!==!1&&e===this.options.commentPropName&&s.length===0?this.indentate(i)+`<!--${t}-->`+this.newLine:this.indentate(i)+"<"+e+n+s+this.tagEndChar+t+this.indentate(i)+r}};tn.prototype.closeTag=function(t){let e="";return this.options.unpairedTags.indexOf(t)!==-1?this.options.suppressUnpairedNode||(e="/"):this.options.suppressEmptyNode?e="/":e=`></${t}`,e};tn.prototype.buildTextValNode=function(t,e,n,i){if(this.options.cdataPropName!==!1&&e===this.options.cdataPropName)return this.indentate(i)+`<![CDATA[${t}]]>`+this.newLine;if(this.options.commentPropName!==!1&&e===this.options.commentPropName)return this.indentate(i)+`<!--${t}-->`+this.newLine;if(e[0]==="?")return this.indentate(i)+"<"+e+n+"?"+this.tagEndChar;{let r=this.options.tagValueProcessor(e,t);return r=this.replaceEntitiesValue(r),r===""?this.indentate(i)+"<"+e+n+this.closeTag(e)+this.tagEndChar:this.indentate(i)+"<"+e+n+">"+r+"</"+e+this.tagEndChar}};tn.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const n=this.options.entities[e];t=t.replace(n.regex,n.val)}return t};function zw(t){return this.options.indentBy.repeat(t)}function Nw(t){return t.startsWith(this.options.attributeNamePrefix)&&t!==this.options.textNodeName?t.substr(this.attrPrefixLen):!1}var jw=tn;const Ow=Ul,Bw=ww,Tw=jw;var Pw={XMLParser:Bw,XMLValidator:Ow,XMLBuilder:Tw};function Rw(t,e,n){const i=n?`<input type="hidden" name="RelayState" value="${n}" />`:"",r=`
|
|
132
132
|
<!DOCTYPE html>
|
|
133
133
|
<html>
|
|
134
134
|
<body onload="document.forms[0].submit()">
|
|
@@ -146,7 +146,7 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
146
146
|
}};
|
|
147
147
|
<\/script>
|
|
148
148
|
</body>
|
|
149
|
-
</html>`;return new Response(r,{headers:{"Content-Type":"text/html"}})}async function Fv(t,e,n,i,r){var _,k,h;if(!n.redirect_uri)throw new j(400,{message:"Missing redirect_uri in authParams"});const[s]=await t.env.data.keys.list();if(!s)throw new j(500,{message:"No signing key found"});if(!((_=e.addons)!=null&&_.samlp))throw new j(400,{message:`SAML Addon is not enabled for client ${e.id}`});const{recipient:o,audience:c}=e.addons.samlp,l=n.state||"";if(!o||!l||!i||!n.state)throw new j(400,{message:"Missing recipient or inResponseTo"});const u=JSON.parse(n.state),p=new URL(n.redirect_uri),g=await Hv(t,{issuer:t.env.ISSUER,audience:c||n.client_id,destination:p.toString(),inResponseTo:u.requestId,userId:((h=(k=i.app_metadata)==null?void 0:k.vimeo)==null?void 0:h.user_id)||i.user_id,email:i.email,sessionIndex:r,signature:{privateKeyPem:s.pkcs7,cert:s.cert,kid:s.kid}});return Dv(p.toString(),g,u.relayState)}async function Hv(t,e){const n=e.notBefore||new Date().toISOString(),i=e.notAfter||new Date(new Date(n).getTime()+10*60*1e3).toISOString(),r=e.issueInstant||n,s=e.sessionNotOnOrAfter||i,o=e.responseId||`_${De()}`,c=e.assertionId||`_${De()}`,l=[{"samlp:Response":[{"saml:Issuer":[{"#text":e.issuer}]},{"samlp:Status":[{"samlp:StatusCode":[],":@":{"@_Value":"urn:oasis:names:tc:SAML:2.0:status:Success"}}]},{"saml:Assertion":[{"saml:Issuer":[{"#text":e.issuer}]},{"saml:Subject":[{"saml:NameID":[{"#text":e.email}],":@":{"@_Format":"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"}},{"saml:SubjectConfirmation":[{"saml:SubjectConfirmationData":[],":@":{"@_InResponseTo":e.inResponseTo,"@_NotOnOrAfter":i,"@_Recipient":e.destination}}],":@":{"@_Method":"urn:oasis:names:tc:SAML:2.0:cm:bearer"}}]},{"saml:Conditions":[{"saml:AudienceRestriction":[{"saml:Audience":[{"#text":e.audience}]}]}],":@":{"@_NotBefore":n,"@_NotOnOrAfter":i}},{"saml:AuthnStatement":[{"saml:AuthnContext":[{"saml:AuthnContextClassRef":[{"#text":"urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified"}]}]}],":@":{"@_AuthnInstant":r,"@_SessionIndex":e.sessionIndex,"@_SessionNotOnOrAfter":s}},{"saml:AttributeStatement":[{"saml:Attribute":[{"saml:AttributeValue":[{"#text":e.userId}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_FriendlyName":"persistent","@_Name":"id","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":e.email}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"email","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"manage-account"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"default-roles-master"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"offline_access"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"view-profile"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"uma_authorization"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"manage-account-links"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}}]}],":@":{"@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion","@_ID":c,"@_IssueInstant":r,"@_Version":"2.0"}}],":@":{"@_xmlns:samlp":"urn:oasis:names:tc:SAML:2.0:protocol","@_xmlns:saml":"urn:oasis:names:tc:SAML:2.0:assertion","@_Destination":e.destination,"@_ID":o,"@_InResponseTo":e.inResponseTo,"@_IssueInstant":r,"@_Version":"2.0"}}];let p=new Mv.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!0}).build(l);if(e.signature){const _=await fetch(t.env.SAML_SIGN_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({xmlContent:p,privateKey:e.signature.privateKeyPem,publicCert:e.signature.cert})});if(!_.ok)throw new Error(`Failed to sign SAML response: ${_.status}`);p=await _.text()}return e.encode===!1?p:btoa(p)}const Ld=["sub","iss","aud","exp","nbf","iat","jti"];async function yl(t,e){var m,b;const{authParams:n,user:i,client:r,session_id:s}=e,c=(await t.env.data.keys.list()).filter(S=>!S.revoked_at||new Date(S.revoked_at)>new Date),l=c[c.length-1];if(!(l!=null&&l.pkcs7))throw new j(500,{message:"No signing key available"});const u=wy(l.pkcs7),p={aud:n.audience||"default",scope:n.scope||"",sub:(i==null?void 0:i.user_id)||n.client_id,iss:t.env.ISSUER,tenant_id:t.var.tenant_id,sid:s},g=i&&((m=n.scope)!=null&&m.split(" ").includes("openid"))?{aud:n.client_id,sub:i.user_id,iss:t.env.ISSUER,sid:s,nonce:n.nonce,given_name:i.given_name,family_name:i.family_name,nickname:i.nickname,picture:i.picture,locale:i.locale,name:i.name,email:i.email,email_verified:i.email_verified}:void 0;(b=t.env.hooks)!=null&&b.onExecuteCredentialsExchange&&await t.env.hooks.onExecuteCredentialsExchange({client:r,user:i,scope:n.scope||"",grant_type:""},{accessToken:{setCustomClaim:(S,O)=>{if(Ld.includes(S))throw new Error(`Cannot overwrite reserved claim '${S}'`);p[S]=O}},idToken:{setCustomClaim:(S,O)=>{if(Ld.includes(S))throw new Error(`Cannot overwrite reserved claim '${S}'`);g&&(g[S]=O)}},access:{deny:S=>{throw new j(400,{message:`Access denied: ${S}`})}}});const _={includeIssuedTimestamp:!0,expiresIn:new pl(1,"d"),headers:{kid:l.kid}},k=await Nd("RS256",u,p,_),h=g?await Nd("RS256",u,g,_):void 0;return{access_token:k,refresh_token:e.refresh_token,id_token:h,token_type:"Bearer",expires_in:86400}}async function qv(t,e){const{client:n,scope:i,audience:r=n.tenant.audience,session_id:s}=e;return await t.env.data.refreshTokens.create(n.tenant.id,{id:De(),session_id:s,client_id:n.id,expires_at:new Date(Date.now()+uo*1e3).toISOString(),user_id:e.user.user_id,device:{last_ip:"",initial_ip:"",last_user_agent:"",initial_user_agent:"",initial_asn:"",last_asn:""},resource_servers:[{audience:r,scopes:i}],rotating:!1})}async function Fh(t,e){const{user:n,client:i,scope:r,audience:s}=e,o=await t.env.data.sessions.create(i.tenant.id,{id:De(),user_id:n.user_id,expires_at:new Date(Date.now()+uo*1e3).toISOString(),used_at:new Date().toISOString(),device:{last_ip:t.req.header("x-real-ip")||"",initial_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||"",initial_user_agent:t.req.header("user-agent")||"",initial_asn:"",last_asn:""},clients:[i.id]}),c=r!=null&&r.split(" ").includes("offline_access")?await qv(t,{...e,session_id:o.id,scope:r,audience:s}):void 0;return{...o,refresh_token:c}}async function oi(t,e){var g;const{authParams:n,user:i,client:r}=e,s=be(t,{type:_e.SUCCESS_LOGIN,description:`Successful login for ${i.user_id}`,userId:i.user_id});Ye(t,t.env.data.logs.create(r.tenant.id,s)),Ye(t,t.env.data.users.update(r.tenant.id,i.user_id,{last_login:new Date().toISOString(),last_ip:t.req.header("x-real-ip")||"",login_count:i.login_count+1}));let o=e.refreshToken,c=e.sessionId;if(!c){const _=await Fh(t,{user:i,client:r,scope:n.scope,audience:n.audience});c=_.id,o=(g=_.refresh_token)==null?void 0:g.id}if(e.authParams.response_mode===Ht.SAML_POST)return Fv(t,e.client,e.authParams,i,c);const l=await yl(t,{authParams:n,user:i,client:r,session_id:c,refresh_token:o}),u=new Headers({"set-cookie":Th(r.tenant.id,c)});if(n.response_mode===Ht.WEB_MESSAGE)return t.json(l,{headers:u});if((n.response_type||un.CODE)===un.CODE){if(!e.loginSession)throw new j(500,{message:"Login session not found"});const _=await t.env.data.codes.create(r.tenant.id,{code_id:De(),user_id:i.user_id,code_type:"authorization_code",login_id:e.loginSession.login_id,expires_at:new Date(Date.now()+N0*1e3).toISOString()});u.set("location",`${n.redirect_uri}?state=${e.authParams.state}&code=${_.code_id}`)}return new Response("Redirecting",{status:302,headers:u})}function Kv(t){return async(e,n)=>{if(!n.email||!n.email_verified)return t.users.create(e,n);const i=await vs({userAdapter:t.users,tenant_id:e,email:n.email});return i?(await t.users.create(e,{...n,linked_to:i.user_id}),i):t.users.create(e,n)}}async function Hh(t,e,n){for await(const i of e)if(!(await fetch(i.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})).ok){const s=be(t,{type:_e.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});await n.logs.create(t.var.tenant_id,s)}}function Wv(t,e){return async(n,i)=>{const{hooks:r}=await e.hooks.list(n);return await Hh(t,r,{tenant_id:n,user:i,trigger_id:"post-user-registration"}),i}}function Gv(t,e){return async(n,i)=>{const{hooks:r}=await e.hooks.list(n,{q:"trigger_id:pre-user-signup",page:0,per_page:100,include_totals:!1});await Hh(t,r,{tenant_id:n,email:i,trigger_id:"pre-user-signup"})}}function Jv(t,e){return async(n,i)=>{let r=await Kv(e)(n,i);return await Wv(t,e)(n,r),r}}async function qh(t,e,n,i){if(e.disable_sign_ups&&!await vs({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:i})){const s=be(t,{type:_e.FAILED_SIGNUP,description:"Public signup is disabled"});throw await t.env.data.logs.create(e.tenant.id,s),new j(400,{message:"Signups are disabled for this client"})}await Gv(t,n)(t.var.tenant_id||"",i)}function Zv(t,e){return{...e,users:{...e.users,create:Jv(t,e)}}}async function Yv(t,e,n,i){if(!i.state)throw new j(400,{message:"State not found"});const r=e.connections.find(l=>l.name===n);if(!r){t.set("client_id",e.id);const l=be(t,{type:_e.FAILED_LOGIN,description:"Connection not found"});throw await t.env.data.logs.create(e.tenant.id,l),new j(403,{message:"Connection Not Found"})}let s=await t.env.data.logins.get(e.tenant.id,i.state);s||(s=await t.env.data.logins.create(e.tenant.id,{expires_at:new Date(Date.now()+us*1e3).toISOString(),authParams:i,...Gn(t.req)}));const c=await Nh(t,r.strategy).getRedirect(t,r);return await t.env.data.codes.create(e.tenant.id,{login_id:s.login_id,code_id:c.code,code_type:"oauth2_state",connection_id:r.id,code_verifier:c.codeVerifier,expires_at:new Date(Date.now()+O0*1e3).toISOString()}),t.redirect(c.redirectUrl)}async function Ud(t,{code:e,state:n}){var h;const{env:i}=t,r=await i.data.codes.get(t.var.tenant_id||"",n,"oauth2_state");if(!r||!r.connection_id)throw new j(403,{message:"State not found"});const s=await i.data.logins.get(t.var.tenant_id||"",r.login_id);if(!s)throw new j(403,{message:"Session not found"});const o=await fo(i,s.authParams.client_id);t.set("client_id",o.id),t.set("tenant_id",o.tenant.id);const c=o.connections.find(m=>m.id===r.connection_id);if(!c){const m=be(t,{type:_e.FAILED_LOGIN,description:"Connection not found"});throw await i.data.logs.create(o.tenant.id,m),new j(403,{message:"Connection not found"})}if(t.set("connection",c.name),!s.authParams.redirect_uri){const m=be(t,{type:_e.FAILED_LOGIN,description:"Redirect URI not defined"});throw await i.data.logs.create(o.tenant.id,m),new j(403,{message:"Redirect URI not defined"})}if(!ho(s.authParams.redirect_uri,o.callbacks||[],{allowPathWildcards:!0})){const m=`Invalid redirect URI - ${s.authParams.redirect_uri}`,b=be(t,{type:_e.FAILED_LOGIN,description:m});throw await i.data.logs.create(o.tenant.id,b),new j(403,{message:m})}const u=await Nh(t,c.strategy).validateAuthorizationCodeAndGetUser(t,c,e,r.code_verifier),{sub:p,...g}=u;t.set("user_id",p);const _=((h=u.email)==null?void 0:h.toLocaleLowerCase())||`${c.name}.${p}@${new URL(t.env.ISSUER).hostname}`;t.set("username",_);let k=await ws({userAdapter:i.data.users,tenant_id:o.tenant.id,email:_,provider:c.name});if(!k){try{await qh(t,o,t.env.data,_)}catch(m){const b=m;throw new j(500,{message:`Failed to run preUserSignupHook: ${b.message}`})}k=await i.data.users.create(o.tenant.id,{user_id:`${c.name}|${p}`,email:_,name:_,provider:c.name,connection:c.name,email_verified:!0,last_ip:"",is_social:!0,last_login:new Date().toISOString(),profileData:JSON.stringify(g)}),t.set("user_id",k.user_id)}return oi(t,{client:o,authParams:s.authParams,loginSession:s,user:k})}async function Vd(t,e,n,i,r,s){const o=await t.env.data.codes.get(t.var.tenant_id||"",e,"oauth2_state");if(!o)throw new j(400,{message:"State not found"});const c=await t.env.data.logins.get(t.var.tenant_id,o.login_id);if(!c)throw new j(400,{message:"Login not found"});const{redirect_uri:l}=c.authParams;if(!l)throw new j(400,{message:"Redirect uri not found"});const u=be(t,{type:_e.FAILED_LOGIN,description:`Failed connection login: ${r} ${n}, ${i}`});Ye(t,t.env.data.logs.create(t.var.tenant_id,u));const p=new URL(l);return $0(p,{error:n,error_description:i,error_reason:s,error_code:r,state:c.authParams.state}),t.redirect(`${kt(t.env)}enter-email?state=${c.login_id}&error=${n}`)}const Xv=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string(),code:a.z.string().optional(),scope:a.z.string().optional(),hd:a.z.string().optional(),error:a.z.string().optional(),error_description:a.z.string().optional(),error_code:a.z.string().optional(),error_reason:a.z.string().optional()})},responses:{302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{state:e,code:n,error:i,error_description:r,error_code:s,error_reason:o}=t.req.valid("query");if(i)return Vd(t,e,i,r,s,o);if(!n)throw new j(400,{message:"Code is required"});return Ud(t,{code:n,state:e})}).openapi(a.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({state:a.z.string(),code:a.z.string().optional(),scope:a.z.string().optional(),hd:a.z.string().optional(),error:a.z.string().optional(),error_description:a.z.string().optional(),error_code:a.z.string().optional(),error_reason:a.z.string().optional()})}}}},responses:{302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{state:e,code:n,error:i,error_description:r,error_code:s,error_reason:o}=t.req.valid("form");if(i)return Vd(t,e,i,r,s,o);if(!n)throw new j(400,{message:"Code is required"});return Ud(t,{code:n,state:e})}),Qv=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:a.z.object({client_id:a.z.string(),returnTo:a.z.string().optional()}),header:a.z.object({cookie:a.z.string().optional()})},responses:{302:{description:"Log the user out"}}}),async t=>{const{client_id:e,returnTo:n}=t.req.valid("query"),i=await t.env.data.clients.get(e);if(!i)return t.text("OK");const r=await t.env.data.clients.get("DEFAULT_CLIENT");t.set("client_id",e),t.set("tenant_id",i.tenant.id);const s=n||t.req.header("referer");if(!s)return t.text("OK");if(!ho(s,[...i.allowed_logout_urls||[],...(r==null?void 0:r.allowed_logout_urls)||[]],{allowPathWildcards:!0}))throw new j(400,{message:"Invalid redirect uri"});const o=t.req.header("cookie");if(o){const l=Bh(i.tenant.id,o);if(l){const u=await t.env.data.sessions.get(i.tenant.id,l);if(u){const p=await t.env.data.users.get(i.tenant.id,u.user_id);p&&(t.set("user_id",p.user_id),t.set("connection",p.connection))}await t.env.data.sessions.remove(i.tenant.id,l)}}const c=be(t,{type:_e.SUCCESS_LOGOUT,description:"User successfully logged out"});return await t.env.data.logs.create(i.tenant.id,c),new Response("Redirecting",{status:302,headers:{"set-cookie":xy(i.tenant.id),location:s}})}),Md=a.z.object({sub:a.z.string(),email:a.z.string().optional(),family_name:a.z.string().optional(),given_name:a.z.string().optional(),email_verified:a.z.boolean()}),ew=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{},security:[{Bearer:["openid"]}],responses:{200:{content:{"application/json":{schema:Md}},description:"Userinfo"}}}),async t=>{if(!t.var.user)throw new j(404,{message:"User not found"});const e=await t.env.data.users.get(t.var.user.tenant_id,t.var.user.sub);if(!e)throw new j(404,{message:"User not found"});return t.json(Md.parse({...e,sub:e.user_id}))}),tw=new a.OpenAPIHono().openapi(a.createRoute({tags:["well known"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:pp}},description:"List of tenants"}}}),async t=>{const e=await t.env.data.keys.list(),n=await Promise.all(e.map(async i=>{const s=await new ul(i.cert).publicKey.export(),o=await crypto.subtle.exportKey("jwk",s);return mc.parse({...o,kid:i.kid})}));return t.json({keys:n},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${lr}, stale-while-revalidate=${lr*2}, stale-if-error=86400`}})}).openapi(a.createRoute({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Do}},description:"List of tenants"}}}),async t=>{const e=Do.parse({issuer:oy(t.env),authorization_endpoint:`${Ce(t.env)}authorize`,token_endpoint:`${Ce(t.env)}oauth/token`,device_authorization_endpoint:`${Ce(t.env)}oauth/device/code`,userinfo_endpoint:`${Ce(t.env)}userinfo`,mfa_challenge_endpoint:`${Ce(t.env)}mfa/challenge`,jwks_uri:`${Ce(t.env)}.well-known/jwks.json`,registration_endpoint:`${Ce(t.env)}oidc/register`,revocation_endpoint:`${Ce(t.env)}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return t.json(e,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${lr}, stale-while-revalidate=${lr*2}, stale-if-error=86400`}})});function yr(t,e){if(!t||!e||t.length!==e.length)return!1;let n=0;for(let i=0;i<t.length;i++)n|=t.charCodeAt(i)^e.charCodeAt(i);return n===0}const Kh=a.z.object({grant_type:a.z.literal("client_credentials"),scope:a.z.string().optional(),client_secret:a.z.string(),client_id:a.z.string(),audience:a.z.string().optional()});async function nw(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new j(403,{message:"Invalid client credentials"});if(n.client_secret&&!yr(n.client_secret,e.client_secret))throw new j(403,{message:"Invalid client credentials"});const i={client_id:n.id,scope:e.scope,audience:e.audience},r=await yl(t,{authParams:i,client:n});return t.json(r)}const iw=a.z.object({grant_type:a.z.literal("authorization_code"),client_id:a.z.string(),code:a.z.string(),redirect_uri:a.z.string().optional(),client_secret:a.z.string().optional(),code_verifier:a.z.string().optional()}).refine(t=>"client_secret"in t&&!("code_verifier"in t)||!("client_secret"in t)&&"code_verifier"in t,{message:"Must provide either client_secret (standard flow) or code_verifier/code_verifier_mode (PKCE flow), but not both"});async function rw(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new j(403,{message:"Client not found"});const i=await t.env.data.codes.get(n.tenant.id,e.code,"authorization_code");if(!i||!i.user_id)throw new j(403,{message:"Invalid client credentials"});if(new Date(i.expires_at)<new Date)throw new j(403,{message:"Code expired"});if(i.used_at)throw new j(403,{message:"Code already used"});const r=await t.env.data.logins.get(n.tenant.id,i.login_id);if(!r)throw new j(403,{message:"Invalid login"});if("client_secret"in e){const o=await t.env.data.clients.get("DEFAULT_CLIENT");if(!yr(n.client_secret,e.client_secret)&&!yr(o==null?void 0:o.client_secret,e.client_secret))throw new j(403,{message:"Invalid client credentials"})}else if("code_verifier"in e&&typeof e.code_verifier=="string"&&"code_challenge_method"in r.authParams&&typeof r.authParams.code_challenge_method=="string"){const o=await by(e.code_verifier,r.authParams.code_challenge_method);if(!yr(o,r.authParams.code_challenge||""))throw new j(403,{message:"Invalid client credentials"})}if(r.authParams.redirect_uri&&r.authParams.redirect_uri!==e.redirect_uri)throw new j(403,{message:"Invalid redirect uri"});const s=await t.env.data.users.get(n.tenant.id,i.user_id);if(!s)throw new j(403,{message:"User not found"});return await t.env.data.codes.used(n.tenant.id,e.code),oi(t,{user:s,client:n,loginSession:r,authParams:{...r.authParams,response_mode:Ht.WEB_MESSAGE}})}const sw=a.z.object({grant_type:a.z.literal("refresh_token"),client_id:a.z.string(),redirect_uri:a.z.string().optional(),refresh_token:a.z.string()});async function ow(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new j(403,{message:"Client not found"});const i=await t.env.data.refreshTokens.get(n.tenant.id,e.refresh_token);if(i){if(i.expires_at&&new Date(i.expires_at)<new Date||i.idle_expires_at&&new Date(i.idle_expires_at)<new Date)throw new j(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Refresh token has expired"})})}else throw new j(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Invalid refresh token"})});const r=await t.env.data.users.get(n.tenant.id,i.user_id);if(!r)throw new j(403,{message:"User not found"});const s=i.resource_servers[0];if(i.idle_expires_at){const o=new Date(Date.now()+2592e6);await t.env.data.refreshTokens.update(n.tenant.id,i.id,{idle_expires_at:o.toISOString(),last_exchanged_at:new Date().toISOString(),device:{...i.device,last_ip:t.req.header["x-real-ip"]||"",last_user_agent:t.req.header["user-agent"]||""}})}return oi(t,{user:r,client:n,refreshToken:i.id,sessionId:i.session_id,authParams:{client_id:n.id,audience:s==null?void 0:s.audience,scope:s==null?void 0:s.scopes,response_mode:Ht.WEB_MESSAGE}})}const Dd=a.z.object({client_id:a.z.string().optional(),client_secret:a.z.string().optional()}),aw=a.z.union([Kh.extend(Dd.shape),a.z.object({grant_type:a.z.literal("authorization_code"),client_id:a.z.string(),code:a.z.string(),redirect_uri:a.z.string(),code_verifier:a.z.string().min(43).max(128)}),a.z.object({grant_type:a.z.literal("authorization_code"),code:a.z.string(),redirect_uri:a.z.string().optional(),...Dd.shape}),a.z.object({grant_type:a.z.literal("refresh_token"),client_id:a.z.string(),refresh_token:a.z.string(),redirect_uri:a.z.string().optional()})]);function cw(t){if(!t)return{};const[e,n]=t.split(" ");if((e==null?void 0:e.toLowerCase())==="basic"&&n){const[i,r]=atob(n).split(":");return{client_id:i,client_secret:r}}return{}}const lw=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:aw}}}},responses:{200:{content:{"application/json":{schema:yp}},description:"Tokens"}}}),async t=>{const e=t.req.valid("form"),n=cw(t.req.header("Authorization")),i={...e,...n};if(!i.client_id)throw new j(400,{message:"client_id is required"});switch(e.grant_type){case hi.AuthorizationCode:return rw(t,iw.parse(i));case hi.ClientCredential:return nw(t,Kh.parse(i));case hi.RefreshToken:return ow(t,sw.parse(i));default:throw new j(400,{message:"Not implemented"})}});var vl={exports:{}};const wl=[{id:0,value:"Too weak",minDiversity:0,minLength:0},{id:1,value:"Weak",minDiversity:2,minLength:6},{id:2,value:"Medium",minDiversity:4,minLength:8},{id:3,value:"Strong",minDiversity:4,minLength:10}],Wh=(t,e=wl,n="!\"#$%&'()*+,-./:;<=>?@[\\\\\\]^_`{|}~")=>{let i=t||"";e[0].minDiversity=0,e[0].minLength=0;const r=[{regex:"[a-z]",message:"lowercase"},{regex:"[A-Z]",message:"uppercase"},{regex:"[0-9]",message:"number"}];n&&r.push({regex:`[${n}]`,message:"symbol"});let s={};s.contains=r.filter(c=>new RegExp(`${c.regex}`).test(i)).map(c=>c.message),s.length=i.length;let o=e.filter(c=>s.contains.length>=c.minDiversity).filter(c=>s.length>=c.minLength).sort((c,l)=>l.id-c.id).map(c=>({id:c.id,value:c.value}));return Object.assign(s,o[0]),s};vl.exports={passwordStrength:Wh,defaultOptions:wl};var uw=vl.exports.passwordStrength=Wh;vl.exports.defaultOptions=wl;function dw(t){return uw(t).id<2?!1:t.length>=8&&/[a-z]/.test(t)&&/[A-Z]/.test(t)&&/[0-9]/.test(t)&&/[^A-Za-z0-9]/.test(t)}async function _o(t,e){var r;const n=await t.env.data.emailProviders.get(t.var.tenant_id)||(t.env.DEFAULT_TENANT_ID?await t.env.data.emailProviders.get(t.env.DEFAULT_TENANT_ID):null);if(!n)throw new j(500,{message:"Email provider not found"});const i=(r=t.env.emailProviders)==null?void 0:r[n.name];if(!i)throw new j(500,{message:"Email provider not found"});await i({emailProvider:n,...e,from:n.default_from_address||`login@${t.env.ISSUER}`})}async function pw(t,e,n,i){const r=await t.env.data.tenants.get(t.var.tenant_id);if(!r)throw new j(500,{message:"Tenant not found"});const s=`${kt(t.env)}reset-password?state=${i}&code=${n}`,o={vendorName:r.name,lng:r.language||"en"};await _o(t,{to:e,subject:"Reset your password",html:`Click here to reset your password: ${kt(t.env)}reset-password?state=${i}&code=${n}`,template:"auth-password-reset",data:{vendorName:r.name,logo:r.logo||"",passwordResetUrl:s,supportUrl:r.support_url||"https://support.sesamy.com",buttonColor:r.primary_color||"#7d68f4",passwordResetTitle:pe("password_reset_title",o),resetPasswordEmailClickToReset:pe("reset_password_email_click_to_reset",o),resetPasswordEmailReset:pe("reset_password_email_reset",o),supportInfo:pe("support_info",o),contactUs:pe("contact_us",o),copyright:pe("copyright",o)}})}async function Gh(t,e,n){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new j(500,{message:"Tenant not found"});const r={vendorName:i.name,code:n,lng:i.language||"en"};await _o(t,{to:e,subject:pe("code_email_subject",r),html:`Click here to validate your email: ${kt(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:i.name,logo:i.logo||"",supportUrl:i.support_url||"",magicLink:`${Ce(t.env)}passwordless/verify_redirect?ticket=${n}`,buttonColor:i.primary_color||"",welcomeToYourAccount:pe("welcome_to_your_account",r),linkEmailClickToLogin:pe("link_email_click_to_login",r),linkEmailLogin:pe("link_email_login",r),linkEmailOrEnterCode:pe("link_email_or_enter_code",r),codeValid30Mins:pe("code_valid_30_minutes",r),supportInfo:pe("support_info",r),contactUs:pe("contact_us",r),copyright:pe("copyright",r)}});const s=be(t,{type:_e.CODE_LINK_SENT,description:e});Ye(t,t.env.data.logs.create(i.id,s))}async function bl(t,e,n){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new j(500,{message:"Tenant not found"});const r={vendorName:i.name,code:n,lng:i.language||"en"};await _o(t,{to:e,subject:pe("code_email_subject",r),html:`Click here to validate your email: ${kt(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:i.name,logo:i.logo||"",supportUrl:i.support_url||"",magicLink:`${Ce(t.env)}passwordless/verify_redirect?ticket=${n}`,buttonColor:i.primary_color||"",welcomeToYourAccount:pe("welcome_to_your_account",r),linkEmailClickToLogin:pe("link_email_click_to_login",r),linkEmailLogin:pe("link_email_login",r),linkEmailOrEnterCode:pe("link_email_or_enter_code",r),codeValid30Mins:pe("code_valid_30_minutes",r),supportInfo:pe("support_info",r),contactUs:pe("contact_us",r),copyright:pe("copyright",r)}});const s=be(t,{type:_e.CODE_LINK_SENT,description:e});Ye(t,t.env.data.logs.create(i.id,s))}async function Jh(t,e){const n=await t.env.data.tenants.get(t.var.tenant_id);if(!n)throw new j(500,{message:"Tenant not found"});const i={vendorName:n.name,lng:n.language||"en"};await _o(t,{to:e.email,subject:"Validate your email address",html:`Click here to validate your email: ${kt(t.env)}validate-email`,template:"auth-verify-email",data:{vendorName:n.name,logo:n.logo||"",emailValidationUrl:`${kt(t.env)}validate-email`,supportUrl:n.support_url||"https://support.sesamy.com",buttonColor:n.primary_color||"#7d68f4",welcomeToYourAccount:pe("welcome_to_your_account",i),verifyEmailVerify:pe("verify_email_verify",i),supportInfo:pe("support_info",i),contactUs:pe("contact_us",i),copyright:pe("copyright",i)}})}const fw=new a.OpenAPIHono().openapi(a.createRoute({tags:["dbconnections"],method:"post",path:"/signup",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.literal("Username-Password-Authentication"),email:a.z.string().transform(t=>t.toLowerCase()),password:a.z.string()})}}}},responses:{200:{content:{"application/json":{schema:a.z.object({_id:a.z.string(),email:a.z.string(),email_verified:a.z.boolean(),app_metadata:a.z.object({}),user_metadata:a.z.object({})})}},description:"Created user"}}}),async t=>{const{email:e,password:n,client_id:i}=t.req.valid("json"),r=await t.env.data.clients.get(i);if(!r)throw new j(400,{message:"Client not found"});if(t.set("client_id",r.id),t.set("tenant_id",r.tenant.id),!dw(n))throw new j(400,{message:"Password does not meet the requirements"});if(await ws({userAdapter:t.env.data.users,tenant_id:r.tenant.id,email:e,provider:"auth2"}))throw new j(400,{message:"Invalid sign up"});const o=await t.env.data.users.create(r.tenant.id,{user_id:`auth2|${wc()}`,email:e,email_verified:!1,provider:"auth2",connection:"Username-Password-Authentication",is_social:!1});t.set("user_id",o.user_id),t.set("username",o.email),t.set("connection",o.connection);const c=await vc.hash(n,10);await t.env.data.passwords.create(r.tenant.id,{user_id:o.user_id,password:c,algorithm:"bcrypt"}),await Jh(t,o);const l=be(t,{type:_e.SUCCESS_SIGNUP,description:"Successful signup"});return await t.env.data.logs.create(r.tenant.id,l),t.json({_id:o.user_id,email:o.email,email_verified:!1,app_metadata:{},user_metadata:{}})}).openapi(a.createRoute({tags:["dbconnections"],method:"post",path:"/change_password",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.literal("Username-Password-Authentication"),email:a.z.string().transform(t=>t.toLowerCase())})}}}},responses:{200:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{email:e,client_id:n}=t.req.valid("json"),i=await t.env.data.clients.get(n);if(!i)throw new j(400,{message:"Client not found"});if(t.set("client_id",i.id),t.set("tenant_id",i.tenant.id),!await bc({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:e,provider:"auth2"}))return t.html("If an account with that email exists, we've sent instructions to reset your password.");const s={client_id:n,username:e},o=await t.env.data.logins.create(i.tenant.id,{expires_at:new Date(Date.now()+us*1e3).toISOString(),authParams:s,...Gn(t.req)});return await pw(t,e,o.login_id,o.authParams.state),t.html("If an account with that email exists, we've sent instructions to reset your password.")});function fs(){const t="1234567890";let e="";for(let n=0;n<6;n+=1)e+=t[Math.floor(Math.random()*10)];return e.toString()}const hw=new a.OpenAPIHono().openapi(a.createRoute({tags:["passwordless"],method:"post",path:"/start",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.string(),email:a.z.string().transform(t=>t.toLowerCase()),send:a.z.enum(["link","code"]),authParams:_c.omit({client_id:!0})})}}}},responses:{200:{description:"Status"}}}),async t=>{const e=t.req.valid("json"),{env:n}=t,{client_id:i,email:r,send:s,authParams:o}=e,c=await t.env.data.clients.get(i);if(!c)throw new j(400,{message:"Client not found"});t.set("client_id",c.id),t.set("tenant_id",c.tenant.id);const l=await n.data.logins.create(c.tenant.id,{authParams:{...o,client_id:i,username:r},expires_at:new Date(Date.now()+lc).toISOString(),...Gn(t.req)}),u=await n.data.codes.create(c.tenant.id,{code_id:fs(),code_type:"otp",login_id:l.login_id,expires_at:new Date(Date.now()+lc).toISOString()});return s==="link"?await bl(t,r,u.code_id):await Gh(t,r,u.code_id),t.html("OK")}).openapi(a.createRoute({tags:["passwordless"],method:"get",path:"/verify_redirect",request:{query:a.z.object({scope:a.z.string(),response_type:a.z.nativeEnum(un),redirect_uri:a.z.string(),state:a.z.string(),nonce:a.z.string().optional(),verification_code:a.z.string(),connection:a.z.string(),client_id:a.z.string(),email:a.z.string().transform(t=>t.toLowerCase()),audience:a.z.string().optional()})},responses:{302:{description:"Status"}}}),async t=>{const{env:e}=t,{client_id:n,email:i,verification_code:r,redirect_uri:s,state:o,scope:c,audience:l,response_type:u,nonce:p}=t.req.valid("query"),g=await fo(e,n);t.set("client_id",g.id),t.set("tenant_id",g.tenant.id),t.set("connection","email");const _=await e.data.codes.get(g.tenant.id,r,"otp");if(!_)throw new j(400,{message:"Code not found or expired"});if(_.expires_at<new Date().toISOString())throw new j(400,{message:"Code expired"});const k=await e.data.logins.get(g.tenant.id,_.login_id);if(!k||k.authParams.username!==i)throw new j(400,{message:"Code not found or expired"});const h=Gn(t.req);if(k.ip!==h.ip)return t.redirect(`${kt(t.env)}invalid-session?state=${k.login_id}`);if(!ho(s,g.callbacks,{allowPathWildcards:!0}))throw new j(400,{message:`Invalid redirect URI - ${s}`});const m={client_id:n,redirect_uri:s,state:o,nonce:p,scope:c,audience:l,response_type:u},b=await ws({userAdapter:e.data.users,tenant_id:g.tenant.id,email:i,provider:"email"});if(!b)throw new j(400,{message:"User not found"});return oi(t,{user:b,client:g,loginSession:k,authParams:m})});class pi extends j{constructor(n,i){super(n,i);Q(this,"_code");this._code=i==null?void 0:i.code}get code(){return this._code}}async function gw(t,e,n){const{env:i}=t,r=n.username;if(t.set("username",r),!r)throw new j(400,{message:"Username is required"});const s=await bc({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:r,provider:"auth2"});if(!s){const _=be(t,{type:_e.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid user"});throw Ye(t,t.env.data.logs.create(e.tenant.id,_)),new pi(403,{message:"User not found",code:"USER_NOT_FOUND"})}const o=s.linked_to?await i.data.users.get(e.tenant.id,s.linked_to):s;if(!o)throw new pi(403,{message:"User not found",code:"USER_NOT_FOUND"});t.set("connection",s.connection),t.set("user_id",o.user_id);const{password:c}=await i.data.passwords.get(e.tenant.id,s.user_id);if(!await vc.compare(n.password,c)){const _=be(t,{type:_e.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});throw Ye(t,t.env.data.logs.create(e.tenant.id,_)),new pi(403,{message:"Invalid password",code:"INVALID_PASSWORD"})}if((await i.data.logs.list(e.tenant.id,{page:0,per_page:10,include_totals:!1,q:`user_id:${o.user_id}`})).logs.filter(_=>_.type===_e.FAILED_LOGIN_INCORRECT_PASSWORD&&new Date(_.date)>new Date(Date.now()-1e3*60*5)).length>=3){const _=be(t,{type:_e.FAILED_LOGIN,description:"Too many failed login attempts"});throw Ye(t,t.env.data.logs.create(e.tenant.id,_)),new pi(403,{message:"Too many failed login attempts",code:"TOO_MANY_FAILED_LOGINS"})}if(!s.email_verified&&e.email_validation==="enforced"){await Jh(t,s);const _=be(t,{type:_e.FAILED_LOGIN,description:"Email not verified"});throw await t.env.data.logs.create(e.tenant.id,_),new pi(403,{message:"Email not verified",code:"EMAIL_NOT_VERIFIED"})}const g=be(t,{type:_e.SUCCESS_LOGIN,description:"Successful login",strategy_type:"Username-Password-Authentication",strategy:"Username-Password-Authentication"});return Ye(t,t.env.data.logs.create(e.tenant.id,g)),o}function _w(){const t=new Uint8Array(32);return crypto.getRandomValues(t),ln.encode(t,{includePadding:!1})}function Fd(){return new j(403,{res:new Response(JSON.stringify({error:"access_denied",error_description:"Wrong email or verification code."}),{status:403,headers:{"Content-Type":"application/json"}}),message:"Wrong email or verification code."})}const Hd=30*60*1e3,mw=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.union([a.z.object({credential_type:a.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),otp:a.z.string(),client_id:a.z.string(),username:a.z.string().transform(t=>t.toLowerCase()),realm:a.z.enum(["email"]),scope:a.z.string().optional()}),a.z.object({credential_type:a.z.literal("http://auth0.com/oauth/grant-type/password-realm"),client_id:a.z.string(),username:a.z.string().transform(t=>t.toLowerCase()),password:a.z.string(),realm:a.z.enum(["Username-Password-Authentication"]),scope:a.z.string().optional()})])}}}},responses:{200:{description:"List of tenants"}}}),async t=>{const e=t.req.valid("json"),{client_id:n,username:i}=e;t.set("username",i);const r=await t.env.data.clients.get(n);if(!r)throw new j(400,{message:"Client not found"});t.set("client_id",n),t.set("tenant_id",r.tenant.id);const s=i.toLocaleLowerCase();let o;if("otp"in e){const p=await t.env.data.codes.get(r.tenant.id,e.otp,"otp");if(!p)throw Fd();const g=await t.env.data.logins.get(r.tenant.id,p.login_id);if(!g||g.authParams.username!==s)throw Fd();o=g}else if("password"in e)await gw(t,r,{username:i,password:e.password,client_id:n}),o=await t.env.data.logins.create(r.tenant.id,{expires_at:new Date(Date.now()+Hd).toISOString(),authParams:{client_id:r.id,username:s},...Gn(t.req)});else throw new j(400,{message:"Code or password required"});const c=_w(),l=De(12),u=await t.env.data.codes.create(r.tenant.id,{code_id:De(),code_type:"ticket",login_id:o.login_id,expires_at:new Date(Date.now()+Hd).toISOString(),code_verifier:[l,c].join("|")});return t.json({login_ticket:u.code_id,co_verifier:c,co_id:l})});function yw(t,e){var i,r,s;if(!t||e.length===0)return!1;const n=((i=Ro(t))==null?void 0:i.host)??null;if(!n)return!1;for(const o of e){let c;if(o.startsWith("http://")||o.startsWith("https://")?c=((r=Ro(o))==null?void 0:r.host)??null:c=((s=Ro("https://"+o))==null?void 0:s.host)??null,n===c)return!0}return!1}function Ro(t){try{return new URL(t)}catch{return null}}async function vw({ctx:t,session:e,client:n,authParams:i,connection:r,login_hint:s}){const o=await t.env.data.logins.create(n.tenant.id,{expires_at:new Date(Date.now()+us*1e3).toISOString(),authParams:i,...Gn(t.req)});if(e&&s){const c=await t.env.data.users.get(n.tenant.id,e.user_id);if((c==null?void 0:c.email)===s)return oi(t,{client:n,loginSession:o,authParams:i,user:c,sessionId:e.id})}if(r==="email"&&s){const c=fs();return await t.env.data.codes.create(n.tenant.id,{code_id:c,code_type:"otp",login_id:o.login_id,expires_at:new Date(Date.now()+us*1e3).toISOString()}),await bl(t,s,c),t.redirect(`/u/enter-code?state=${o.login_id}`)}return e?t.redirect(`/u/check-account?state=${o.login_id}`):t.redirect(`/u/enter-email?state=${o.login_id}`)}function ww(t){if(t==="Username-Password-Authentication")return"auth2";if(t==="email")return"email";throw new j(403,{message:"Invalid realm"})}async function bw(t,e,n,i,r){var _;const{env:s}=t;t.set("connection",r);const o=await s.data.codes.get(e,n,"ticket");if(!o||o.used_at)throw new j(403,{message:"Ticket not found"});const c=await s.data.logins.get(e,o.login_id);if(!c||!c.authParams.username)throw new j(403,{message:"Session not found"});const l=await s.data.clients.get(c.authParams.client_id);if(!l)throw new j(403,{message:"Client not found"});t.set("client_id",c.authParams.client_id),await s.data.codes.used(e,n);const u=ww(r);let p=await ws({userAdapter:s.data.users,tenant_id:e,email:c.authParams.username,provider:u});p||(p=await s.data.users.create(e,{user_id:`email|${wc()}`,email:c.authParams.username,name:c.authParams.username,provider:"email",connection:"email",email_verified:!0,is_social:!1,last_ip:"",last_login:new Date().toISOString()})),t.set("username",p.email),t.set("user_id",p.user_id);const g=await Fh(t,{user:p,client:l,scope:i.scope,audience:i.audience});return oi(t,{authParams:{scope:(_=c.authParams)==null?void 0:_.scope,...i},loginSession:c,sessionId:g.id,user:p,client:l})}async function qd(t,e){return`<!DOCTYPE html>
|
|
149
|
+
</html>`;return new Response(r,{headers:{"Content-Type":"text/html"}})}async function Lw(t,e,n,i,r){var m,v,h;if(!n.redirect_uri)throw new O(400,{message:"Missing redirect_uri in authParams"});const[s]=await t.env.data.keys.list();if(!s)throw new O(500,{message:"No signing key found"});if(!((m=e.addons)!=null&&m.samlp))throw new O(400,{message:`SAML Addon is not enabled for client ${e.id}`});const{recipient:o,audience:c}=e.addons.samlp,l=n.state||"";if(!o||!l||!i||!n.state)throw new O(400,{message:"Missing recipient or inResponseTo"});const u=JSON.parse(n.state),p=new URL(n.redirect_uri),f=await Uw(t,{issuer:t.env.ISSUER,audience:c||n.client_id,destination:p.toString(),inResponseTo:u.requestId,userId:((h=(v=i.app_metadata)==null?void 0:v.vimeo)==null?void 0:h.user_id)||i.user_id,email:i.email,sessionIndex:r,signature:{privateKeyPem:s.pkcs7,cert:s.cert,kid:s.kid}});return Rw(p.toString(),f,u.relayState)}async function Uw(t,e){const n=e.notBefore||new Date().toISOString(),i=e.notAfter||new Date(new Date(n).getTime()+10*60*1e3).toISOString(),r=e.issueInstant||n,s=e.sessionNotOnOrAfter||i,o=e.responseId||`_${He()}`,c=e.assertionId||`_${He()}`,l=[{"samlp:Response":[{"saml:Issuer":[{"#text":e.issuer}]},{"samlp:Status":[{"samlp:StatusCode":[],":@":{"@_Value":"urn:oasis:names:tc:SAML:2.0:status:Success"}}]},{"saml:Assertion":[{"saml:Issuer":[{"#text":e.issuer}]},{"saml:Subject":[{"saml:NameID":[{"#text":e.email}],":@":{"@_Format":"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"}},{"saml:SubjectConfirmation":[{"saml:SubjectConfirmationData":[],":@":{"@_InResponseTo":e.inResponseTo,"@_NotOnOrAfter":i,"@_Recipient":e.destination}}],":@":{"@_Method":"urn:oasis:names:tc:SAML:2.0:cm:bearer"}}]},{"saml:Conditions":[{"saml:AudienceRestriction":[{"saml:Audience":[{"#text":e.audience}]}]}],":@":{"@_NotBefore":n,"@_NotOnOrAfter":i}},{"saml:AuthnStatement":[{"saml:AuthnContext":[{"saml:AuthnContextClassRef":[{"#text":"urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified"}]}]}],":@":{"@_AuthnInstant":r,"@_SessionIndex":e.sessionIndex,"@_SessionNotOnOrAfter":s}},{"saml:AttributeStatement":[{"saml:Attribute":[{"saml:AttributeValue":[{"#text":e.userId}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_FriendlyName":"persistent","@_Name":"id","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":e.email}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"email","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"manage-account"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"default-roles-master"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"offline_access"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"view-profile"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"uma_authorization"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}},{"saml:Attribute":[{"saml:AttributeValue":[{"#text":"manage-account-links"}],":@":{"@_xmlns:xs":"http://www.w3.org/2001/XMLSchema","@_xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","@_xsi:type":"xs:string"}}],":@":{"@_Name":"Role","@_NameFormat":"urn:oasis:names:tc:SAML:2.0:attrname-format:basic"}}]}],":@":{"@_xmlns":"urn:oasis:names:tc:SAML:2.0:assertion","@_ID":c,"@_IssueInstant":r,"@_Version":"2.0"}}],":@":{"@_xmlns:samlp":"urn:oasis:names:tc:SAML:2.0:protocol","@_xmlns:saml":"urn:oasis:names:tc:SAML:2.0:assertion","@_Destination":e.destination,"@_ID":o,"@_InResponseTo":e.inResponseTo,"@_IssueInstant":r,"@_Version":"2.0"}}];let p=new Pw.XMLBuilder({ignoreAttributes:!1,suppressEmptyNode:!0,preserveOrder:!0}).build(l);if(e.signature){const m=await fetch(t.env.SAML_SIGN_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({xmlContent:p,privateKey:e.signature.privateKeyPem,publicCert:e.signature.cert})});if(!m.ok)throw new Error(`Failed to sign SAML response: ${m.status}`);p=await m.text()}return e.encode===!1?p:btoa(p)}const pp=["sub","iss","aud","exp","nbf","iat","jti"];async function Dl(t,e){var _,y;const{authParams:n,user:i,client:r,session_id:s}=e,c=(await t.env.data.keys.list()).filter(x=>!x.revoked_at||new Date(x.revoked_at)>new Date),l=c[c.length-1];if(!(l!=null&&l.pkcs7))throw new O(500,{message:"No signing key available"});const u=gv(l.pkcs7),p={aud:n.audience||"default",scope:n.scope||"",sub:(i==null?void 0:i.user_id)||n.client_id,iss:t.env.ISSUER,tenant_id:t.var.tenant_id,sid:s},f=i&&((_=n.scope)!=null&&_.split(" ").includes("openid"))?{aud:n.client_id,sub:i.user_id,iss:t.env.ISSUER,sid:s,nonce:n.nonce,given_name:i.given_name,family_name:i.family_name,nickname:i.nickname,picture:i.picture,locale:i.locale,name:i.name,email:i.email,email_verified:i.email_verified}:void 0;(y=t.env.hooks)!=null&&y.onExecuteCredentialsExchange&&await t.env.hooks.onExecuteCredentialsExchange({client:r,user:i,scope:n.scope||"",grant_type:""},{accessToken:{setCustomClaim:(x,C)=>{if(pp.includes(x))throw new Error(`Cannot overwrite reserved claim '${x}'`);p[x]=C}},idToken:{setCustomClaim:(x,C)=>{if(pp.includes(x))throw new Error(`Cannot overwrite reserved claim '${x}'`);f&&(f[x]=C)}},access:{deny:x=>{throw new O(400,{message:`Access denied: ${x}`})}}});const m={includeIssuedTimestamp:!0,expiresIn:new Pl(1,"d"),headers:{kid:l.kid}},v=await op("RS256",u,p,m),h=f?await op("RS256",u,f,m):void 0;return{access_token:v,refresh_token:e.refresh_token,id_token:h,token_type:"Bearer",expires_in:86400}}async function Vw(t,e){const{client:n,scope:i,audience:r=n.tenant.audience,session_id:s}=e;return await t.env.data.refreshTokens.create(n.tenant.id,{id:He(),session_id:s,client_id:n.id,expires_at:new Date(Date.now()+No*1e3).toISOString(),user_id:e.user.user_id,device:{last_ip:"",initial_ip:"",last_user_agent:"",initial_user_agent:"",initial_asn:"",last_asn:""},resource_servers:[{audience:r,scopes:i}],rotating:!1})}async function xg(t,e){const{user:n,client:i,scope:r,audience:s}=e,o=await t.env.data.sessions.create(i.tenant.id,{id:He(),user_id:n.user_id,expires_at:new Date(Date.now()+No*1e3).toISOString(),used_at:new Date().toISOString(),device:{last_ip:t.req.header("x-real-ip")||"",initial_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||"",initial_user_agent:t.req.header("user-agent")||"",initial_asn:"",last_asn:""},clients:[i.id]}),c=r!=null&&r.split(" ").includes("offline_access")?await Vw(t,{...e,session_id:o.id,scope:r,audience:s}):void 0;return{...o,refresh_token:c}}async function di(t,e){var f;const{authParams:n,user:i,client:r}=e,s=be(t,{type:me.SUCCESS_LOGIN,description:`Successful login for ${i.user_id}`,userId:i.user_id});Xe(t,t.env.data.logs.create(r.tenant.id,s)),Xe(t,t.env.data.users.update(r.tenant.id,i.user_id,{last_login:new Date().toISOString(),last_ip:t.req.header("x-real-ip")||"",login_count:i.login_count+1}));let o=e.refreshToken,c=e.sessionId;if(!c){const m=await xg(t,{user:i,client:r,scope:n.scope,audience:n.audience});c=m.id,o=(f=m.refresh_token)==null?void 0:f.id}if(e.authParams.response_mode===Wt.SAML_POST)return Lw(t,e.client,e.authParams,i,c);const l=await Dl(t,{authParams:n,user:i,client:r,session_id:c,refresh_token:o}),u=new Headers({"set-cookie":gg(r.tenant.id,c)});if(n.response_mode===Wt.WEB_MESSAGE)return t.json(l,{headers:u});if((n.response_type||fn.CODE)===fn.CODE){if(!e.loginSession)throw new O(500,{message:"Login session not found"});const m=await t.env.data.codes.create(r.tenant.id,{code_id:He(),user_id:i.user_id,code_type:"authorization_code",login_id:e.loginSession.login_id,expires_at:new Date(Date.now()+Iy*1e3).toISOString()});u.set("location",`${n.redirect_uri}?state=${e.authParams.state}&code=${m.code_id}`)}return new Response("Redirecting",{status:302,headers:u})}function Mw(t){return async(e,n)=>{if(!n.email||!n.email_verified)return t.users.create(e,n);const i=await Vs({userAdapter:t.users,tenant_id:e,email:n.email});return i?(await t.users.create(e,{...n,linked_to:i.user_id}),i):t.users.create(e,n)}}async function Sg(t,e,n){for await(const i of e)if(!(await fetch(i.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})).ok){const s=be(t,{type:me.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});await n.logs.create(t.var.tenant_id,s)}}function Dw(t,e){return async(n,i)=>{const{hooks:r}=await e.hooks.list(n);return await Sg(t,r,{tenant_id:n,user:i,trigger_id:"post-user-registration"}),i}}function Hw(t,e){return async(n,i)=>{const{hooks:r}=await e.hooks.list(n,{q:"trigger_id:pre-user-signup",page:0,per_page:100,include_totals:!1});await Sg(t,r,{tenant_id:n,email:i,trigger_id:"pre-user-signup"})}}function Fw(t,e){return async(n,i)=>{let r=await Mw(e)(n,i);return await Dw(t,e)(n,r),r}}async function Ag(t,e,n,i){if(e.disable_sign_ups&&!await Vs({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:i})){const s=be(t,{type:me.FAILED_SIGNUP,description:"Public signup is disabled"});throw await t.env.data.logs.create(e.tenant.id,s),new O(400,{message:"Signups are disabled for this client"})}await Hw(t,n)(t.var.tenant_id||"",i)}function qw(t,e){return{...e,users:{...e.users,create:Fw(t,e)}}}async function Kw(t,e,n,i){if(!i.state)throw new O(400,{message:"State not found"});const r=e.connections.find(l=>l.name===n);if(!r){t.set("client_id",e.id);const l=be(t,{type:me.FAILED_LOGIN,description:"Connection not found"});throw await t.env.data.logs.create(e.tenant.id,l),new O(403,{message:"Connection Not Found"})}let s=await t.env.data.logins.get(e.tenant.id,i.state);s||(s=await t.env.data.logins.create(e.tenant.id,{expires_at:new Date(Date.now()+Cs*1e3).toISOString(),authParams:i,...ui(t.req)}));const c=await pg(t,r.strategy).getRedirect(t,r);return await t.env.data.codes.create(e.tenant.id,{login_id:s.login_id,code_id:c.code,code_type:"oauth2_state",connection_id:r.id,code_verifier:c.codeVerifier,expires_at:new Date(Date.now()+Cy*1e3).toISOString()}),t.redirect(c.redirectUrl)}async function fp(t,{code:e,state:n}){var h;const{env:i}=t,r=await i.data.codes.get(t.var.tenant_id||"",n,"oauth2_state");if(!r||!r.connection_id)throw new O(403,{message:"State not found"});const s=await i.data.logins.get(t.var.tenant_id||"",r.login_id);if(!s)throw new O(403,{message:"Session not found"});const o=await Oo(i,s.authParams.client_id);t.set("client_id",o.id),t.set("tenant_id",o.tenant.id);const c=o.connections.find(_=>_.id===r.connection_id);if(!c){const _=be(t,{type:me.FAILED_LOGIN,description:"Connection not found"});throw await i.data.logs.create(o.tenant.id,_),new O(403,{message:"Connection not found"})}if(t.set("connection",c.name),!s.authParams.redirect_uri){const _=be(t,{type:me.FAILED_LOGIN,description:"Redirect URI not defined"});throw await i.data.logs.create(o.tenant.id,_),new O(403,{message:"Redirect URI not defined"})}if(!Bo(s.authParams.redirect_uri,o.callbacks||[],{allowPathWildcards:!0})){const _=`Invalid redirect URI - ${s.authParams.redirect_uri}`,y=be(t,{type:me.FAILED_LOGIN,description:_});throw await i.data.logs.create(o.tenant.id,y),new O(403,{message:_})}const u=await pg(t,c.strategy).validateAuthorizationCodeAndGetUser(t,c,e,r.code_verifier),{sub:p,...f}=u;t.set("user_id",p);const m=((h=u.email)==null?void 0:h.toLocaleLowerCase())||`${c.name}.${p}@${new URL(t.env.ISSUER).hostname}`;t.set("username",m);let v=await Ki({userAdapter:i.data.users,tenant_id:o.tenant.id,email:m,provider:c.name});if(!v){try{await Ag(t,o,t.env.data,m)}catch(_){const y=_;throw new O(500,{message:`Failed to run preUserSignupHook: ${y.message}`})}v=await i.data.users.create(o.tenant.id,{user_id:`${c.name}|${p}`,email:m,name:m,provider:c.name,connection:c.name,email_verified:!0,last_ip:"",is_social:!0,last_login:new Date().toISOString(),profileData:JSON.stringify(f)}),t.set("user_id",v.user_id)}return di(t,{client:o,authParams:s.authParams,loginSession:s,user:v})}async function hp(t,e,n,i,r,s){const o=await t.env.data.codes.get(t.var.tenant_id||"",e,"oauth2_state");if(!o)throw new O(400,{message:"State not found"});const c=await t.env.data.logins.get(t.var.tenant_id,o.login_id);if(!c)throw new O(400,{message:"Login not found"});const{redirect_uri:l}=c.authParams;if(!l)throw new O(400,{message:"Redirect uri not found"});const u=be(t,{type:me.FAILED_LOGIN,description:`Failed connection login: ${r} ${n}, ${i}`});Xe(t,t.env.data.logs.create(t.var.tenant_id,u));const p=new URL(l);return Ay(p,{error:n,error_description:i,error_reason:s,error_code:r,state:c.authParams.state}),t.redirect(`${xt(t.env)}enter-email?state=${c.login_id}&error=${n}`)}const Ww=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string(),code:a.z.string().optional(),scope:a.z.string().optional(),hd:a.z.string().optional(),error:a.z.string().optional(),error_description:a.z.string().optional(),error_code:a.z.string().optional(),error_reason:a.z.string().optional()})},responses:{302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{state:e,code:n,error:i,error_description:r,error_code:s,error_reason:o}=t.req.valid("query");if(i)return hp(t,e,i,r,s,o);if(!n)throw new O(400,{message:"Code is required"});return fp(t,{code:n,state:e})}).openapi(a.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({state:a.z.string(),code:a.z.string().optional(),scope:a.z.string().optional(),hd:a.z.string().optional(),error:a.z.string().optional(),error_description:a.z.string().optional(),error_code:a.z.string().optional(),error_reason:a.z.string().optional()})}}}},responses:{302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{state:e,code:n,error:i,error_description:r,error_code:s,error_reason:o}=t.req.valid("form");if(i)return hp(t,e,i,r,s,o);if(!n)throw new O(400,{message:"Code is required"});return fp(t,{code:n,state:e})}),Gw=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:a.z.object({client_id:a.z.string(),returnTo:a.z.string().optional()}),header:a.z.object({cookie:a.z.string().optional()})},responses:{302:{description:"Log the user out"}}}),async t=>{const{client_id:e,returnTo:n}=t.req.valid("query"),i=await t.env.data.clients.get(e);if(!i)return t.text("OK");const r=await t.env.data.clients.get("DEFAULT_CLIENT");t.set("client_id",e),t.set("tenant_id",i.tenant.id);const s=n||t.req.header("referer");if(!s)return t.text("OK");if(!Bo(s,[...i.allowed_logout_urls||[],...(r==null?void 0:r.allowed_logout_urls)||[]],{allowPathWildcards:!0}))throw new O(400,{message:"Invalid redirect uri"});const o=t.req.header("cookie");if(o){const l=hg(i.tenant.id,o);if(l){const u=await t.env.data.sessions.get(i.tenant.id,l);if(u){const p=await t.env.data.users.get(i.tenant.id,u.user_id);p&&(t.set("user_id",p.user_id),t.set("connection",p.connection))}await t.env.data.sessions.remove(i.tenant.id,l)}}const c=be(t,{type:me.SUCCESS_LOGOUT,description:"User successfully logged out"});return await t.env.data.logs.create(i.tenant.id,c),new Response("Redirecting",{status:302,headers:{"set-cookie":yv(i.tenant.id),location:s}})}),gp=a.z.object({sub:a.z.string(),email:a.z.string().optional(),family_name:a.z.string().optional(),given_name:a.z.string().optional(),email_verified:a.z.boolean()}),Jw=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"get",path:"/",request:{},security:[{Bearer:["openid"]}],responses:{200:{content:{"application/json":{schema:gp}},description:"Userinfo"}}}),async t=>{if(!t.var.user)throw new O(404,{message:"User not found"});const e=await t.env.data.users.get(t.var.user.tenant_id,t.var.user.sub);if(!e)throw new O(404,{message:"User not found"});return t.json(gp.parse({...e,sub:e.user_id}))}),Zw=new a.OpenAPIHono().openapi(a.createRoute({tags:["well known"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:Kp}},description:"List of tenants"}}}),async t=>{const e=await t.env.data.keys.list(),n=await Promise.all(e.map(async i=>{const s=await new Bl(i.cert).publicKey.export(),o=await crypto.subtle.exportKey("jwk",s);return Mc.parse({...o,kid:i.kid})}));return t.json({keys:n},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${br}, stale-while-revalidate=${br*2}, stale-if-error=86400`}})}).openapi(a.createRoute({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:ua}},description:"List of tenants"}}}),async t=>{const e=ua.parse({issuer:tv(t.env),authorization_endpoint:`${$e(t.env)}authorize`,token_endpoint:`${$e(t.env)}oauth/token`,device_authorization_endpoint:`${$e(t.env)}oauth/device/code`,userinfo_endpoint:`${$e(t.env)}userinfo`,mfa_challenge_endpoint:`${$e(t.env)}mfa/challenge`,jwks_uri:`${$e(t.env)}.well-known/jwks.json`,registration_endpoint:`${$e(t.env)}oidc/register`,revocation_endpoint:`${$e(t.env)}oauth/revoke`,scopes_supported:["openid","profile","offline_access","name","given_name","family_name","nickname","email","email_verified","picture","created_at","identities","phone","address"],response_types_supported:["code","token","id_token","code token","code id_token","token id_token","code token id_token"],code_challenge_methods_supported:["S256","plain"],response_modes_supported:["query","fragment","form_post"],subject_types_supported:["public"],id_token_signing_alg_values_supported:["RS256"],token_endpoint_auth_methods_supported:["client_secret_basic","client_secret_post"],claims_supported:["aud","auth_time","created_at","email","email_verified","exp","family_name","given_name","iat","identities","iss","name","nickname","phone_number","picture","sub"],request_uri_parameter_supported:!1,request_parameter_supported:!1,token_endpoint_auth_signing_alg_values_supported:["RS256","RS384","PS256"]});return t.json(e,{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${br}, stale-while-revalidate=${br*2}, stale-if-error=86400`}})});function Nr(t,e){if(!t||!e||t.length!==e.length)return!1;let n=0;for(let i=0;i<t.length;i++)n|=t.charCodeAt(i)^e.charCodeAt(i);return n===0}const Eg=a.z.object({grant_type:a.z.literal("client_credentials"),scope:a.z.string().optional(),client_secret:a.z.string(),client_id:a.z.string(),audience:a.z.string().optional()});async function Yw(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new O(403,{message:"Invalid client credentials"});if(n.client_secret&&!Nr(n.client_secret,e.client_secret))throw new O(403,{message:"Invalid client credentials"});const i={client_id:n.id,scope:e.scope,audience:e.audience},r=await Dl(t,{authParams:i,client:n});return t.json(r)}const Xw=a.z.object({grant_type:a.z.literal("authorization_code"),client_id:a.z.string(),code:a.z.string(),redirect_uri:a.z.string().optional(),client_secret:a.z.string().optional(),code_verifier:a.z.string().optional()}).refine(t=>"client_secret"in t&&!("code_verifier"in t)||!("client_secret"in t)&&"code_verifier"in t,{message:"Must provide either client_secret (standard flow) or code_verifier/code_verifier_mode (PKCE flow), but not both"});async function Qw(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new O(403,{message:"Client not found"});const i=await t.env.data.codes.get(n.tenant.id,e.code,"authorization_code");if(!i||!i.user_id)throw new O(403,{message:"Invalid client credentials"});if(new Date(i.expires_at)<new Date)throw new O(403,{message:"Code expired"});if(i.used_at)throw new O(403,{message:"Code already used"});const r=await t.env.data.logins.get(n.tenant.id,i.login_id);if(!r)throw new O(403,{message:"Invalid login"});if("client_secret"in e){const o=await t.env.data.clients.get("DEFAULT_CLIENT");if(!Nr(n.client_secret,e.client_secret)&&!Nr(o==null?void 0:o.client_secret,e.client_secret))throw new O(403,{message:"Invalid client credentials"})}else if("code_verifier"in e&&typeof e.code_verifier=="string"&&"code_challenge_method"in r.authParams&&typeof r.authParams.code_challenge_method=="string"){const o=await mv(e.code_verifier,r.authParams.code_challenge_method);if(!Nr(o,r.authParams.code_challenge||""))throw new O(403,{message:"Invalid client credentials"})}if(r.authParams.redirect_uri&&r.authParams.redirect_uri!==e.redirect_uri)throw new O(403,{message:"Invalid redirect uri"});const s=await t.env.data.users.get(n.tenant.id,i.user_id);if(!s)throw new O(403,{message:"User not found"});return await t.env.data.codes.used(n.tenant.id,e.code),di(t,{user:s,client:n,loginSession:r,authParams:{...r.authParams,response_mode:Wt.WEB_MESSAGE}})}const eb=a.z.object({grant_type:a.z.literal("refresh_token"),client_id:a.z.string(),redirect_uri:a.z.string().optional(),refresh_token:a.z.string()});async function tb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new O(403,{message:"Client not found"});const i=await t.env.data.refreshTokens.get(n.tenant.id,e.refresh_token);if(i){if(i.expires_at&&new Date(i.expires_at)<new Date||i.idle_expires_at&&new Date(i.idle_expires_at)<new Date)throw new O(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Refresh token has expired"})})}else throw new O(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Invalid refresh token"})});const r=await t.env.data.users.get(n.tenant.id,i.user_id);if(!r)throw new O(403,{message:"User not found"});const s=i.resource_servers[0];if(i.idle_expires_at){const o=new Date(Date.now()+2592e6);await t.env.data.refreshTokens.update(n.tenant.id,i.id,{idle_expires_at:o.toISOString(),last_exchanged_at:new Date().toISOString(),device:{...i.device,last_ip:t.req.header["x-real-ip"]||"",last_user_agent:t.req.header["user-agent"]||""}})}return di(t,{user:r,client:n,refreshToken:i.id,sessionId:i.session_id,authParams:{client_id:n.id,audience:s==null?void 0:s.audience,scope:s==null?void 0:s.scopes,response_mode:Wt.WEB_MESSAGE}})}const mp=a.z.object({client_id:a.z.string().optional(),client_secret:a.z.string().optional()}),nb=a.z.union([Eg.extend(mp.shape),a.z.object({grant_type:a.z.literal("authorization_code"),client_id:a.z.string(),code:a.z.string(),redirect_uri:a.z.string(),code_verifier:a.z.string().min(43).max(128)}),a.z.object({grant_type:a.z.literal("authorization_code"),code:a.z.string(),redirect_uri:a.z.string().optional(),...mp.shape}),a.z.object({grant_type:a.z.literal("refresh_token"),client_id:a.z.string(),refresh_token:a.z.string(),redirect_uri:a.z.string().optional()})]);function ib(t){if(!t)return{};const[e,n]=t.split(" ");if((e==null?void 0:e.toLowerCase())==="basic"&&n){const[i,r]=atob(n).split(":");return{client_id:i,client_secret:r}}return{}}const rb=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:nb}}}},responses:{200:{content:{"application/json":{schema:Xp}},description:"Tokens"}}}),async t=>{const e=t.req.valid("form"),n=ib(t.req.header("Authorization")),i={...e,...n};if(!i.client_id)throw new O(400,{message:"client_id is required"});switch(e.grant_type){case bi.AuthorizationCode:return Qw(t,Xw.parse(i));case bi.ClientCredential:return Yw(t,Eg.parse(i));case bi.RefreshToken:return tb(t,eb.parse(i));default:throw new O(400,{message:"Not implemented"})}});var Hl={exports:{}};const Fl=[{id:0,value:"Too weak",minDiversity:0,minLength:0},{id:1,value:"Weak",minDiversity:2,minLength:6},{id:2,value:"Medium",minDiversity:4,minLength:8},{id:3,value:"Strong",minDiversity:4,minLength:10}],Ig=(t,e=Fl,n="!\"#$%&'()*+,-./:;<=>?@[\\\\\\]^_`{|}~")=>{let i=t||"";e[0].minDiversity=0,e[0].minLength=0;const r=[{regex:"[a-z]",message:"lowercase"},{regex:"[A-Z]",message:"uppercase"},{regex:"[0-9]",message:"number"}];n&&r.push({regex:`[${n}]`,message:"symbol"});let s={};s.contains=r.filter(c=>new RegExp(`${c.regex}`).test(i)).map(c=>c.message),s.length=i.length;let o=e.filter(c=>s.contains.length>=c.minDiversity).filter(c=>s.length>=c.minLength).sort((c,l)=>l.id-c.id).map(c=>({id:c.id,value:c.value}));return Object.assign(s,o[0]),s};Hl.exports={passwordStrength:Ig,defaultOptions:Fl};var sb=Hl.exports.passwordStrength=Ig;Hl.exports.defaultOptions=Fl;function ob(t){return sb(t).id<2?!1:t.length>=8&&/[a-z]/.test(t)&&/[A-Z]/.test(t)&&/[0-9]/.test(t)&&/[^A-Za-z0-9]/.test(t)}async function Po(t,e){var r;const n=await t.env.data.emailProviders.get(t.var.tenant_id)||(t.env.DEFAULT_TENANT_ID?await t.env.data.emailProviders.get(t.env.DEFAULT_TENANT_ID):null);if(!n)throw new O(500,{message:"Email provider not found"});const i=(r=t.env.emailProviders)==null?void 0:r[n.name];if(!i)throw new O(500,{message:"Email provider not found"});await i({emailProvider:n,...e,from:n.default_from_address||`login@${t.env.ISSUER}`})}async function ab(t,e,n,i){const r=await t.env.data.tenants.get(t.var.tenant_id);if(!r)throw new O(500,{message:"Tenant not found"});const s=`${xt(t.env)}reset-password?state=${i}&code=${n}`,o={vendorName:r.name,lng:r.language||"en"};await Po(t,{to:e,subject:"Reset your password",html:`Click here to reset your password: ${xt(t.env)}reset-password?state=${i}&code=${n}`,template:"auth-password-reset",data:{vendorName:r.name,logo:r.logo||"",passwordResetUrl:s,supportUrl:r.support_url||"https://support.sesamy.com",buttonColor:r.primary_color||"#7d68f4",passwordResetTitle:fe("password_reset_title",o),resetPasswordEmailClickToReset:fe("reset_password_email_click_to_reset",o),resetPasswordEmailReset:fe("reset_password_email_reset",o),supportInfo:fe("support_info",o),contactUs:fe("contact_us",o),copyright:fe("copyright",o)}})}async function Cg(t,e,n){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new O(500,{message:"Tenant not found"});const r={vendorName:i.name,code:n,lng:i.language||"en"};await Po(t,{to:e,subject:fe("code_email_subject",r),html:`Click here to validate your email: ${xt(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:i.name,logo:i.logo||"",supportUrl:i.support_url||"",magicLink:`${$e(t.env)}passwordless/verify_redirect?ticket=${n}`,buttonColor:i.primary_color||"",welcomeToYourAccount:fe("welcome_to_your_account",r),linkEmailClickToLogin:fe("link_email_click_to_login",r),linkEmailLogin:fe("link_email_login",r),linkEmailOrEnterCode:fe("link_email_or_enter_code",r),codeValid30Mins:fe("code_valid_30_minutes",r),supportInfo:fe("support_info",r),contactUs:fe("contact_us",r),copyright:fe("copyright",r)}});const s=be(t,{type:me.CODE_LINK_SENT,description:e});Xe(t,t.env.data.logs.create(i.id,s))}async function ql(t,e,n){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new O(500,{message:"Tenant not found"});const r={vendorName:i.name,code:n,lng:i.language||"en"};await Po(t,{to:e,subject:fe("code_email_subject",r),html:`Click here to validate your email: ${xt(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:i.name,logo:i.logo||"",supportUrl:i.support_url||"",magicLink:`${$e(t.env)}passwordless/verify_redirect?ticket=${n}`,buttonColor:i.primary_color||"",welcomeToYourAccount:fe("welcome_to_your_account",r),linkEmailClickToLogin:fe("link_email_click_to_login",r),linkEmailLogin:fe("link_email_login",r),linkEmailOrEnterCode:fe("link_email_or_enter_code",r),codeValid30Mins:fe("code_valid_30_minutes",r),supportInfo:fe("support_info",r),contactUs:fe("contact_us",r),copyright:fe("copyright",r)}});const s=be(t,{type:me.CODE_LINK_SENT,description:e});Xe(t,t.env.data.logs.create(i.id,s))}async function $g(t,e){const n=await t.env.data.tenants.get(t.var.tenant_id);if(!n)throw new O(500,{message:"Tenant not found"});const i={vendorName:n.name,lng:n.language||"en"};await Po(t,{to:e.email,subject:"Validate your email address",html:`Click here to validate your email: ${xt(t.env)}validate-email`,template:"auth-verify-email",data:{vendorName:n.name,logo:n.logo||"",emailValidationUrl:`${xt(t.env)}validate-email`,supportUrl:n.support_url||"https://support.sesamy.com",buttonColor:n.primary_color||"#7d68f4",welcomeToYourAccount:fe("welcome_to_your_account",i),verifyEmailVerify:fe("verify_email_verify",i),supportInfo:fe("support_info",i),contactUs:fe("contact_us",i),copyright:fe("copyright",i)}})}const cb=new a.OpenAPIHono().openapi(a.createRoute({tags:["dbconnections"],method:"post",path:"/signup",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.literal("Username-Password-Authentication"),email:a.z.string().transform(t=>t.toLowerCase()),password:a.z.string()})}}}},responses:{200:{content:{"application/json":{schema:a.z.object({_id:a.z.string(),email:a.z.string(),email_verified:a.z.boolean(),app_metadata:a.z.object({}),user_metadata:a.z.object({})})}},description:"Created user"}}}),async t=>{const{email:e,password:n,client_id:i}=t.req.valid("json"),r=await t.env.data.clients.get(i);if(!r)throw new O(400,{message:"Client not found"});if(t.set("client_id",r.id),t.set("tenant_id",r.tenant.id),!ob(n))throw new O(400,{message:"Password does not meet the requirements"});if(await Ki({userAdapter:t.env.data.users,tenant_id:r.tenant.id,email:e,provider:"auth2"}))throw new O(400,{message:"Invalid sign up"});const o=await t.env.data.users.create(r.tenant.id,{user_id:`auth2|${Fc()}`,email:e,email_verified:!1,provider:"auth2",connection:"Username-Password-Authentication",is_social:!1});t.set("user_id",o.user_id),t.set("username",o.email),t.set("connection",o.connection);const c=await Hc.hash(n,10);await t.env.data.passwords.create(r.tenant.id,{user_id:o.user_id,password:c,algorithm:"bcrypt"}),await $g(t,o);const l=be(t,{type:me.SUCCESS_SIGNUP,description:"Successful signup"});return await t.env.data.logs.create(r.tenant.id,l),t.json({_id:o.user_id,email:o.email,email_verified:!1,app_metadata:{},user_metadata:{}})}).openapi(a.createRoute({tags:["dbconnections"],method:"post",path:"/change_password",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.literal("Username-Password-Authentication"),email:a.z.string().transform(t=>t.toLowerCase())})}}}},responses:{200:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{email:e,client_id:n}=t.req.valid("json"),i=await t.env.data.clients.get(n);if(!i)throw new O(400,{message:"Client not found"});if(t.set("client_id",i.id),t.set("tenant_id",i.tenant.id),!await qc({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:e,provider:"auth2"}))return t.html("If an account with that email exists, we've sent instructions to reset your password.");const s={client_id:n,username:e},o=await t.env.data.logins.create(i.tenant.id,{expires_at:new Date(Date.now()+Cs*1e3).toISOString(),authParams:s,...ui(t.req)});return await ab(t,e,o.login_id,o.authParams.state),t.html("If an account with that email exists, we've sent instructions to reset your password.")});function Ns(){const t="1234567890";let e="";for(let n=0;n<6;n+=1)e+=t[Math.floor(Math.random()*10)];return e.toString()}async function zg(t,e,n,i,r){const{env:s}=t,o=await s.data.codes.get(e.tenant.id,r,"otp");if(!o)throw new O(400,{message:"Code not found or expired"});if(o.expires_at<new Date().toISOString())throw new O(400,{message:"Code expired"});const c=await s.data.logins.get(e.tenant.id,o.login_id);if(!c||c.authParams.username!==i)throw new O(400,{message:"Code not found or expired"});const l=ui(t.req);if(c.ip!==l.ip)return t.redirect(`${xt(t.env)}invalid-session?state=${c.login_id}`);if(n.redirect_uri&&!Bo(n.redirect_uri,e.callbacks,{allowPathWildcards:!0}))throw new O(400,{message:`Invalid redirect URI - ${n.redirect_uri}`});const u=await Ki({userAdapter:s.data.users,tenant_id:e.tenant.id,email:i,provider:"email"});if(!u)throw new O(400,{message:"User not found"});return di(t,{user:u,client:e,loginSession:c,authParams:n})}const lb=new a.OpenAPIHono().openapi(a.createRoute({tags:["passwordless"],method:"post",path:"/start",request:{body:{content:{"application/json":{schema:a.z.object({client_id:a.z.string(),connection:a.z.string(),email:a.z.string().transform(t=>t.toLowerCase()),send:a.z.enum(["link","code"]),authParams:Vc.omit({client_id:!0})})}}}},responses:{200:{description:"Status"}}}),async t=>{const e=t.req.valid("json"),{env:n}=t,{client_id:i,email:r,send:s,authParams:o}=e,c=await t.env.data.clients.get(i);if(!c)throw new O(400,{message:"Client not found"});t.set("client_id",c.id),t.set("tenant_id",c.tenant.id);const l=await n.data.logins.create(c.tenant.id,{authParams:{...o,client_id:i,username:r},expires_at:new Date(Date.now()+Nc).toISOString(),...ui(t.req)}),u=await n.data.codes.create(c.tenant.id,{code_id:Ns(),code_type:"otp",login_id:l.login_id,expires_at:new Date(Date.now()+Nc).toISOString()});return s==="link"?await ql(t,r,u.code_id):await Cg(t,r,u.code_id),t.html("OK")}).openapi(a.createRoute({tags:["passwordless"],method:"get",path:"/verify_redirect",request:{query:a.z.object({scope:a.z.string(),response_type:a.z.nativeEnum(fn),redirect_uri:a.z.string(),state:a.z.string(),nonce:a.z.string().optional(),verification_code:a.z.string(),connection:a.z.string(),client_id:a.z.string(),email:a.z.string().transform(t=>t.toLowerCase()),audience:a.z.string().optional()})},responses:{302:{description:"Status"}}}),async t=>{const{env:e}=t,{client_id:n,email:i,verification_code:r,redirect_uri:s,state:o,scope:c,audience:l,response_type:u,nonce:p}=t.req.valid("query"),f=await Oo(e,n);return t.set("client_id",f.id),t.set("tenant_id",f.tenant.id),t.set("connection","email"),zg(t,f,{client_id:n,redirect_uri:s,state:o,nonce:p,scope:c,audience:l,response_type:u},i,r)});class yi extends O{constructor(n,i){super(n,i);Q(this,"_code");this._code=i==null?void 0:i.code}get code(){return this._code}}async function ub(t,e,n){const{env:i}=t,r=n.username;if(t.set("username",r),!r)throw new O(400,{message:"Username is required"});const s=await qc({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:r,provider:"auth2"});if(!s){const m=be(t,{type:me.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid user"});throw Xe(t,t.env.data.logs.create(e.tenant.id,m)),new yi(403,{message:"User not found",code:"USER_NOT_FOUND"})}const o=s.linked_to?await i.data.users.get(e.tenant.id,s.linked_to):s;if(!o)throw new yi(403,{message:"User not found",code:"USER_NOT_FOUND"});t.set("connection",s.connection),t.set("user_id",o.user_id);const{password:c}=await i.data.passwords.get(e.tenant.id,s.user_id);if(!await Hc.compare(n.password,c)){const m=be(t,{type:me.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});throw Xe(t,t.env.data.logs.create(e.tenant.id,m)),new yi(403,{message:"Invalid password",code:"INVALID_PASSWORD"})}if((await i.data.logs.list(e.tenant.id,{page:0,per_page:10,include_totals:!1,q:`user_id:${o.user_id}`})).logs.filter(m=>m.type===me.FAILED_LOGIN_INCORRECT_PASSWORD&&new Date(m.date)>new Date(Date.now()-1e3*60*5)).length>=3){const m=be(t,{type:me.FAILED_LOGIN,description:"Too many failed login attempts"});throw Xe(t,t.env.data.logs.create(e.tenant.id,m)),new yi(403,{message:"Too many failed login attempts",code:"TOO_MANY_FAILED_LOGINS"})}if(!s.email_verified&&e.email_validation==="enforced"){await $g(t,s);const m=be(t,{type:me.FAILED_LOGIN,description:"Email not verified"});throw await t.env.data.logs.create(e.tenant.id,m),new yi(403,{message:"Email not verified",code:"EMAIL_NOT_VERIFIED"})}const f=be(t,{type:me.SUCCESS_LOGIN,description:"Successful login",strategy_type:"Username-Password-Authentication",strategy:"Username-Password-Authentication"});return Xe(t,t.env.data.logs.create(e.tenant.id,f)),o}function db(){const t=new Uint8Array(32);return crypto.getRandomValues(t),pn.encode(t,{includePadding:!1})}function _p(){return new O(403,{res:new Response(JSON.stringify({error:"access_denied",error_description:"Wrong email or verification code."}),{status:403,headers:{"Content-Type":"application/json"}}),message:"Wrong email or verification code."})}const yp=30*60*1e3,pb=new a.OpenAPIHono().openapi(a.createRoute({tags:["oauth"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:a.z.union([a.z.object({credential_type:a.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),otp:a.z.string(),client_id:a.z.string(),username:a.z.string().transform(t=>t.toLowerCase()),realm:a.z.enum(["email"]),scope:a.z.string().optional()}),a.z.object({credential_type:a.z.literal("http://auth0.com/oauth/grant-type/password-realm"),client_id:a.z.string(),username:a.z.string().transform(t=>t.toLowerCase()),password:a.z.string(),realm:a.z.enum(["Username-Password-Authentication"]),scope:a.z.string().optional()})])}}}},responses:{200:{description:"List of tenants"}}}),async t=>{const e=t.req.valid("json"),{client_id:n,username:i}=e;t.set("username",i);const r=await t.env.data.clients.get(n);if(!r)throw new O(400,{message:"Client not found"});t.set("client_id",n),t.set("tenant_id",r.tenant.id);const s=i.toLocaleLowerCase();let o;if("otp"in e){const p=await t.env.data.codes.get(r.tenant.id,e.otp,"otp");if(!p)throw _p();const f=await t.env.data.logins.get(r.tenant.id,p.login_id);if(!f||f.authParams.username!==s)throw _p();o=f}else if("password"in e)await ub(t,r,{username:i,password:e.password,client_id:n}),o=await t.env.data.logins.create(r.tenant.id,{expires_at:new Date(Date.now()+yp).toISOString(),authParams:{client_id:r.id,username:s},...ui(t.req)});else throw new O(400,{message:"Code or password required"});const c=db(),l=He(12),u=await t.env.data.codes.create(r.tenant.id,{code_id:He(),code_type:"ticket",login_id:o.login_id,expires_at:new Date(Date.now()+yp).toISOString(),code_verifier:[l,c].join("|")});return t.json({login_ticket:u.code_id,co_verifier:c,co_id:l})});function fb(t,e){var i,r,s;if(!t||e.length===0)return!1;const n=((i=ea(t))==null?void 0:i.host)??null;if(!n)return!1;for(const o of e){let c;if(o.startsWith("http://")||o.startsWith("https://")?c=((r=ea(o))==null?void 0:r.host)??null:c=((s=ea("https://"+o))==null?void 0:s.host)??null,n===c)return!0}return!1}function ea(t){try{return new URL(t)}catch{return null}}async function hb({ctx:t,session:e,client:n,authParams:i,connection:r,login_hint:s}){const o=await t.env.data.logins.create(n.tenant.id,{expires_at:new Date(Date.now()+Cs*1e3).toISOString(),authParams:i,...ui(t.req)});if(e&&s){const c=await t.env.data.users.get(n.tenant.id,e.user_id);if((c==null?void 0:c.email)===s)return di(t,{client:n,loginSession:o,authParams:i,user:c,sessionId:e.id})}if(r==="email"&&s){const c=Ns();return await t.env.data.codes.create(n.tenant.id,{code_id:c,code_type:"otp",login_id:o.login_id,expires_at:new Date(Date.now()+Cs*1e3).toISOString()}),await ql(t,s,c),t.redirect(`/u/enter-code?state=${o.login_id}`)}return e?t.redirect(`/u/check-account?state=${o.login_id}`):t.redirect(`/u/enter-email?state=${o.login_id}`)}function gb(t){if(t==="Username-Password-Authentication")return"auth2";if(t==="email")return"email";throw new O(403,{message:"Invalid realm"})}async function mb(t,e,n,i,r){var m;const{env:s}=t;t.set("connection",r);const o=await s.data.codes.get(e,n,"ticket");if(!o||o.used_at)throw new O(403,{message:"Ticket not found"});const c=await s.data.logins.get(e,o.login_id);if(!c||!c.authParams.username)throw new O(403,{message:"Session not found"});const l=await s.data.clients.get(c.authParams.client_id);if(!l)throw new O(403,{message:"Client not found"});t.set("client_id",c.authParams.client_id),await s.data.codes.used(e,n);const u=gb(r);let p=await Ki({userAdapter:s.data.users,tenant_id:e,email:c.authParams.username,provider:u});p||(p=await s.data.users.create(e,{user_id:`email|${Fc()}`,email:c.authParams.username,name:c.authParams.username,provider:"email",connection:"email",email_verified:!0,is_social:!1,last_ip:"",last_login:new Date().toISOString()})),t.set("username",p.email),t.set("user_id",p.user_id);const f=await xg(t,{user:p,client:l,scope:i.scope,audience:i.audience});return di(t,{authParams:{scope:(m=c.authParams)==null?void 0:m.scope,...i},loginSession:c,sessionId:f.id,user:p,client:l})}async function vp(t,e){return`<!DOCTYPE html>
|
|
150
150
|
<html>
|
|
151
151
|
|
|
152
152
|
<head>
|
|
@@ -189,17 +189,17 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
189
189
|
<\/script>
|
|
190
190
|
</body>
|
|
191
191
|
|
|
192
|
-
</html>`}async function kw({ctx:t,client:e,session:n,redirect_uri:i,state:r,nonce:s,code_challenge_method:o,code_challenge:c,audience:l,scope:u,response_type:p}){const{env:g}=t,_=new URL(i);if(n!=null&&n.expires_at&&new Date(n.expires_at)>new Date){t.set("user_id",n.user_id);const h=new Headers,m=Th(e.tenant.id,n.id);h.set("set-cookie",m);const b=await g.data.users.get(e.tenant.id,n.user_id);if(b){t.set("username",b.email),t.set("connection",b.connection);const S=await yl(t,{client:e,authParams:{client_id:e.id,audience:l,code_challenge_method:o,code_challenge:c,scope:u,state:r,nonce:s,response_type:p},user:b,session_id:n.id});await g.data.sessions.update(e.tenant.id,n.id,{used_at:new Date().toISOString(),expires_at:new Date(Date.now()+uo*1e3).toISOString()});const O=be(t,{type:_e.SUCCESS_SILENT_AUTH,description:"Successful silent authentication"});return await t.env.data.logs.create(e.tenant.id,O),t.html(qd(`${_.protocol}//${_.host}`,JSON.stringify(S)),{headers:h})}}const k=be(t,{type:_e.FAILED_SILENT_AUTH,description:"Login required"});return await t.env.data.logs.create(e.tenant.id,k),t.html(qd(`${_.protocol}//${_.host}`,JSON.stringify({error:"login_required",error_description:"Login required",state:r})))}const xw=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(Ht).optional(),response_type:a.z.nativeEnum(un).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(ms).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 t=>{const{env:e}=t,{client_id:n,vendor_id:i,redirect_uri:r,scope:s,state:o,audience:c,nonce:l,connection:u,response_type:p,response_mode:g,code_challenge:_,code_challenge_method:k,prompt:h,login_ticket:m,realm:b,auth0Client:S,login_hint:O,ui_locales:T}=t.req.valid("query");t.set("log","authorize");const K=await fo(e,n);t.set("client_id",K.id),t.set("tenant_id",K.tenant.id);const ce={redirect_uri:r,scope:s,state:o,client_id:n,vendor_id:i,audience:c,nonce:l,prompt:h,response_type:p,response_mode:g,code_challenge:_,code_challenge_method:k,username:O,ui_locales:T},he=t.req.header("origin");if(he&&!yw(he,K.web_origins||[]))throw new j(403,{message:`Origin ${he} not allowed`});if(ce.redirect_uri&&!ho(ce.redirect_uri,K.callbacks||[],{allowPathWildcards:!0}))throw new j(400,{message:`Invalid redirect URI - ${ce.redirect_uri}`});const ue=Bh(K.tenant.id,t.req.header("cookie")),Le=ue?await e.data.sessions.get(K.tenant.id,ue):void 0;if(h=="none"){if(!p)throw new j(400,{message:"Missing response_type"});return kw({ctx:t,session:Le||void 0,redirect_uri:r,state:o,response_type:p,client:K,nonce:l,code_challenge_method:k,code_challenge:_,audience:c,scope:s})}return u&&u!=="email"?Yv(t,K,u,ce):m?bw(t,K.tenant.id,m,ce,b):vw({ctx:t,client:K,auth0Client:S,authParams:ce,session:Le||void 0,connection:u,login_hint:O})});function Sw(){const t=new a.OpenAPIHono;t.use(xh(t));const e=t.route("/v2/logout",Qv).route("/userinfo",ew).route("/.well-known",tw).route("/oauth/token",lw).route("/dbconnections",fw).route("/passwordless",hw).route("/co/authenticate",mw).route("/authorize",xw).route("/callback",Xv);return e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth API"}}),kh(e),e}var Aw={Stringify:1,BeforeStream:2,Stream:3},dt=(t,e)=>{const n=new String(t);return n.isEscaped=!0,n.callbacks=e,n},Iw=/[&<>'"]/,Zh=async(t,e)=>{let n="";e||(e=[]);const i=await Promise.all(t);for(let r=i.length-1;n+=i[r],r--,!(r<0);r--){let s=i[r];typeof s=="object"&&e.push(...s.callbacks||[]);const o=s.isEscaped;if(s=await(typeof s=="object"?s.toString():s),typeof s=="object"&&e.push(...s.callbacks||[]),s.isEscaped??o)n+=s;else{const c=[n];Ft(s,c),n=c[0]}}return dt(n,e)},Ft=(t,e)=>{const n=t.search(Iw);if(n===-1){e[0]+=t;return}let i,r,s=0;for(r=n;r<t.length;r++){switch(t.charCodeAt(r)){case 34:i=""";break;case 39:i="'";break;case 38:i="&";break;case 60:i="<";break;case 62:i=">";break;default:continue}e[0]+=t.substring(s,r)+i,s=r+1}e[0]+=t.substring(s,r)},Yh=t=>{const e=t.callbacks;if(!(e!=null&&e.length))return t;const n=[t],i={};return e.forEach(r=>r({phase:Aw.Stringify,buffer:n,context:i})),n[0]},Ew=(t,...e)=>{const n=[""];for(let i=0,r=t.length-1;i<r;i++){n[0]+=t[i];const s=Array.isArray(e[i])?e[i].flat(1/0):[e[i]];for(let o=0,c=s.length;o<c;o++){const l=s[o];if(typeof l=="string")Ft(l,n);else if(typeof l=="number")n[0]+=l;else{if(typeof l=="boolean"||l===null||l===void 0)continue;if(typeof l=="object"&&l.isEscaped)if(l.callbacks)n.unshift("",l);else{const u=l.toString();u instanceof Promise?n.unshift("",u):n[0]+=u}else l instanceof Promise?n.unshift("",l):Ft(l.toString(),n)}}}return n[0]+=t[t.length-1],n.length===1?"callbacks"in n?dt(Yh(dt(n[0],n.callbacks))):dt(n[0]):Zh(n,n.callbacks)},Xh=Symbol("RENDERER"),Cw=Symbol("ERROR_HANDLER"),zw=Symbol("INTERNAL"),hs=Symbol("PERMALINK"),Kd=t=>(t[zw]=!0,t),$w=t=>({value:e,children:n})=>{if(!n)return;const i={children:[{tag:Kd(()=>{t.push(e)}),props:{}}]};Array.isArray(n)?i.children.push(...n.flat()):i.children.push(n),i.children.push({tag:Kd(()=>{t.pop()}),props:{}});const r={tag:"",props:i,type:""};return r[Cw]=s=>{throw t.pop(),s},r},pc=[],jw=t=>{const e=[t],n=i=>{e.push(i.value);let r;try{r=i.children?(Array.isArray(i.children)?new tg("",{},i.children):i.children).toString():""}finally{e.pop()}return r instanceof Promise?r.then(s=>dt(s,s.callbacks)):dt(r)};return n.values=e,n.Provider=n,n[Xh]=$w(e),pc.push(n),n},mo=t=>t.values.at(-1),Nw={title:[],script:["src"],style:["data-href"],link:["href"],meta:["name","httpEquiv","charset","itemProp"]},Wd={},Ow="data-precedence",yo=t=>Array.isArray(t)?t:[t],Gd=new WeakMap,Jd=(t,e,n,i)=>({buffer:r,context:s})=>{if(!r)return;const o=Gd.get(s)||{};Gd.set(s,o);const c=o[t]||(o[t]=[]);let l=!1;const u=Nw[t];if(u.length>0){e:for(const[,p]of c)for(const g of u)if(((p==null?void 0:p[g])??null)===(n==null?void 0:n[g])){l=!0;break e}}if(l?r[0]=r[0].replaceAll(e,""):u.length>0?c.push([e,n,i]):c.unshift([e,n,i]),r[0].indexOf("</head>")!==-1){let p;if(i===void 0)p=c.map(([g])=>g);else{const g=[];p=c.map(([_,,k])=>{let h=g.indexOf(k);return h===-1&&(g.push(k),h=g.length-1),[_,h]}).sort((_,k)=>_[1]-k[1]).map(([_])=>_)}p.forEach(g=>{r[0]=r[0].replaceAll(g,"")}),r[0]=r[0].replace(/(?=<\/head>)/,p.join(""))}},tr=(t,e,n)=>dt(new pt(t,n,yo(e??[])).toString()),nr=(t,e,n,i)=>{if("itemProp"in n)return tr(t,e,n);let{precedence:r,blocking:s,...o}=n;r=i?r??"":void 0,i&&(o[Ow]=r);const c=new pt(t,o,yo(e||[])).toString();return c instanceof Promise?c.then(l=>dt(c,[...l.callbacks||[],Jd(t,l,o,r)])):dt(c,[Jd(t,c,o,r)])},Bw=({children:t,...e})=>{const n=kl();if(n){const i=mo(n);if(i==="svg"||i==="head")return new pt("title",e,yo(t??[]))}return nr("title",t,e,!1)},Tw=({children:t,...e})=>{const n=kl();return["src","async"].some(i=>!e[i])||n&&mo(n)==="head"?tr("script",t,e):nr("script",t,e,!1)},Rw=({children:t,...e})=>["href","precedence"].every(n=>n in e)?(e["data-href"]=e.href,delete e.href,nr("style",t,e,!0)):tr("style",t,e),Pw=({children:t,...e})=>["onLoad","onError"].some(n=>n in e)||e.rel==="stylesheet"&&(!("precedence"in e)||"disabled"in e)?tr("link",t,e):nr("link",t,e,"precedence"in e),Lw=({children:t,...e})=>{const n=kl();return n&&mo(n)==="head"?tr("meta",t,e):nr("meta",t,e,!1)},Qh=(t,{children:e,...n})=>new pt(t,n,yo(e??[])),Uw=t=>(typeof t.action=="function"&&(t.action=hs in t.action?t.action[hs]:void 0),Qh("form",t)),eg=(t,e)=>(typeof e.formAction=="function"&&(e.formAction=hs in e.formAction?e.formAction[hs]:void 0),Qh(t,e)),Vw=t=>eg("input",t),Mw=t=>eg("button",t);const Po=Object.freeze(Object.defineProperty({__proto__:null,button:Mw,form:Uw,input:Vw,link:Pw,meta:Lw,script:Tw,style:Rw,title:Bw},Symbol.toStringTag,{value:"Module"}));var Dw=new Map([["className","class"],["htmlFor","for"],["crossOrigin","crossorigin"],["httpEquiv","http-equiv"],["itemProp","itemprop"],["fetchPriority","fetchpriority"],["noModule","nomodule"],["formAction","formaction"]]),Zd=t=>Dw.get(t)||t,Fw=(t,e)=>{for(const[n,i]of Object.entries(t)){const r=n[0]==="-"||!/[A-Z]/.test(n)?n:n.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);e(r,i==null?null:typeof i=="number"?r.match(/^(?:a|border-im|column(?:-c|s)|flex(?:$|-[^b])|grid-(?:ar|[^a])|font-w|li|or|sca|st|ta|wido|z)|ty$/)?`${i}`:`${i}px`:i)}},Ri=void 0,kl=()=>Ri,Hw=t=>/[A-Z]/.test(t)&&t.match(/^(?:al|basel|clip(?:Path|Rule)$|co|do|fill|fl|fo|gl|let|lig|i|marker[EMS]|o|pai|pointe|sh|st[or]|text[^L]|tr|u|ve|w)/)?t.replace(/([A-Z])/g,"-$1").toLowerCase():t,qw=["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],Kw=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","download","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"],xl=(t,e)=>{for(let n=0,i=t.length;n<i;n++){const r=t[n];if(typeof r=="string")Ft(r,e);else{if(typeof r=="boolean"||r===null||r===void 0)continue;r instanceof pt?r.toStringToBuffer(e):typeof r=="number"||r.isEscaped?e[0]+=r:r instanceof Promise?e.unshift("",r):xl(r,e)}}},pt=class{constructor(t,e,n){Q(this,"tag");Q(this,"props");Q(this,"key");Q(this,"children");Q(this,"isEscaped",!0);Q(this,"localContexts");this.tag=t,this.props=e,this.children=n}get type(){return this.tag}get ref(){return this.props.ref||null}toString(){var e,n;const t=[""];(e=this.localContexts)==null||e.forEach(([i,r])=>{i.values.push(r)});try{this.toStringToBuffer(t)}finally{(n=this.localContexts)==null||n.forEach(([i])=>{i.values.pop()})}return t.length===1?"callbacks"in t?Yh(dt(t[0],t.callbacks)).toString():t[0]:Zh(t,t.callbacks)}toStringToBuffer(t){const e=this.tag,n=this.props;let{children:i}=this;t[0]+=`<${e}`;const r=Ri&&mo(Ri)==="svg"?s=>Hw(Zd(s)):s=>Zd(s);for(let[s,o]of Object.entries(n))if(s=r(s),s!=="children"){if(s==="style"&&typeof o=="object"){let c="";Fw(o,(l,u)=>{u!=null&&(c+=`${c?";":""}${l}:${u}`)}),t[0]+=' style="',Ft(c,t),t[0]+='"'}else if(typeof o=="string")t[0]+=` ${s}="`,Ft(o,t),t[0]+='"';else if(o!=null)if(typeof o=="number"||o.isEscaped)t[0]+=` ${s}="${o}"`;else if(typeof o=="boolean"&&Kw.includes(s))o&&(t[0]+=` ${s}=""`);else if(s==="dangerouslySetInnerHTML"){if(i.length>0)throw"Can only set one of `children` or `props.dangerouslySetInnerHTML`.";i=[dt(o.__html)]}else if(o instanceof Promise)t[0]+=` ${s}="`,t.unshift('"',o);else if(typeof o=="function"){if(!s.startsWith("on"))throw`Invalid prop '${s}' of type 'function' supplied to '${e}'.`}else t[0]+=` ${s}="`,Ft(o.toString(),t),t[0]+='"'}if(qw.includes(e)&&i.length===0){t[0]+="/>";return}t[0]+=">",xl(i,t),t[0]+=`</${e}>`}},Lo=class extends pt{toStringToBuffer(t){const{children:e}=this,n=this.tag.call(null,{...this.props,children:e.length<=1?e[0]:e});if(!(typeof n=="boolean"||n==null))if(n instanceof Promise)if(pc.length===0)t.unshift("",n);else{const i=pc.map(r=>[r,r.values.at(-1)]);t.unshift("",n.then(r=>(r instanceof pt&&(r.localContexts=i),r)))}else n instanceof pt?n.toStringToBuffer(t):typeof n=="number"||n.isEscaped?(t[0]+=n,n.callbacks&&(t.callbacks||(t.callbacks=[]),t.callbacks.push(...n.callbacks))):Ft(n,t)}},tg=class extends pt{toStringToBuffer(t){xl(this.children,t)}},Yd=!1,Uo=(t,e,n)=>{if(!Yd){for(const i in Wd)Po[i][Xh]=Wd[i];Yd=!0}return typeof t=="function"?new Lo(t,e,n):Po[t]?new Lo(Po[t],e,n):t==="svg"||t==="head"?(Ri||(Ri=jw("")),new pt(t,e,[new Lo(Ri,{value:t},n)])):new pt(t,e,n)},ng=({children:t})=>new tg("",{children:t},Array.isArray(t)?t:t?[t]:[]);function P(t,e,n){let i;if(!e||!("children"in e))i=Uo(t,e,[]);else{const r=e.children;i=Array.isArray(r)?Uo(t,e,r):Uo(t,e,[r])}return i.key=n,i}const Ww=({vendorSettings:t})=>t!=null&&t.logoUrl?P("div",{className:"flex h-9 items-center",children:P("img",{src:t.logoUrl,className:"max-h-full",alt:"Vendor logo"})}):P(ng,{}),Gw=({vendorSettings:t})=>{const{termsAndConditionsUrl:e}=t;return P("div",{className:"mt-8",children:e&&P("div",{className:"text-xs text-gray-300",children:[se.t("agree_to")," ",P("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noreferrer",children:se.t("terms")})]})})};var ig={exports:{}};/*!
|
|
192
|
+
</html>`}async function _b({ctx:t,client:e,session:n,redirect_uri:i,state:r,nonce:s,code_challenge_method:o,code_challenge:c,audience:l,scope:u,response_type:p}){const{env:f}=t,m=new URL(i);if(n!=null&&n.expires_at&&new Date(n.expires_at)>new Date){t.set("user_id",n.user_id);const h=new Headers,_=gg(e.tenant.id,n.id);h.set("set-cookie",_);const y=await f.data.users.get(e.tenant.id,n.user_id);if(y){t.set("username",y.email),t.set("connection",y.connection);const x=await Dl(t,{client:e,authParams:{client_id:e.id,audience:l,code_challenge_method:o,code_challenge:c,scope:u,state:r,nonce:s,response_type:p},user:y,session_id:n.id});await f.data.sessions.update(e.tenant.id,n.id,{used_at:new Date().toISOString(),expires_at:new Date(Date.now()+No*1e3).toISOString()});const C=be(t,{type:me.SUCCESS_SILENT_AUTH,description:"Successful silent authentication"});return await t.env.data.logs.create(e.tenant.id,C),t.html(vp(`${m.protocol}//${m.host}`,JSON.stringify(x)),{headers:h})}}const v=be(t,{type:me.FAILED_SILENT_AUTH,description:"Login required"});return await t.env.data.logs.create(e.tenant.id,v),t.html(vp(`${m.protocol}//${m.host}`,JSON.stringify({error:"login_required",error_description:"Login required",state:r})))}const yb=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(Wt).optional(),response_type:a.z.nativeEnum(fn).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(Ls).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 t=>{const{env:e}=t,{client_id:n,vendor_id:i,redirect_uri:r,scope:s,state:o,audience:c,nonce:l,connection:u,response_type:p,response_mode:f,code_challenge:m,code_challenge_method:v,prompt:h,login_ticket:_,realm:y,auth0Client:x,login_hint:C,ui_locales:j}=t.req.valid("query");t.set("log","authorize");const R=await Oo(e,n);t.set("client_id",R.id),t.set("tenant_id",R.tenant.id);const ee={redirect_uri:r,scope:s,state:o,client_id:n,vendor_id:i,audience:c,nonce:l,prompt:h,response_type:p,response_mode:f,code_challenge:m,code_challenge_method:v,username:C,ui_locales:j},pe=t.req.header("origin");if(pe&&!fb(pe,R.web_origins||[]))throw new O(403,{message:`Origin ${pe} not allowed`});if(ee.redirect_uri&&!Bo(ee.redirect_uri,R.callbacks||[],{allowPathWildcards:!0}))throw new O(400,{message:`Invalid redirect URI - ${ee.redirect_uri}`});const le=hg(R.tenant.id,t.req.header("cookie")),Ue=le?await e.data.sessions.get(R.tenant.id,le):void 0;if(h=="none"){if(!p)throw new O(400,{message:"Missing response_type"});return _b({ctx:t,session:Ue||void 0,redirect_uri:r,state:o,response_type:p,client:R,nonce:l,code_challenge_method:v,code_challenge:m,audience:c,scope:s})}return u&&u!=="email"?Kw(t,R,u,ee):_?mb(t,R.tenant.id,_,ee,y):hb({ctx:t,client:R,auth0Client:x,authParams:ee,session:Ue||void 0,connection:u,login_hint:C})});function vb(){const t=new a.OpenAPIHono;t.use(ig(t));const e=t.route("/v2/logout",Gw).route("/userinfo",Jw).route("/.well-known",Zw).route("/oauth/token",rb).route("/dbconnections",cb).route("/passwordless",lb).route("/co/authenticate",pb).route("/authorize",yb).route("/callback",Ww);return e.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth API"}}),ng(e),e}var wb={Stringify:1,BeforeStream:2,Stream:3},pt=(t,e)=>{const n=new String(t);return n.isEscaped=!0,n.callbacks=e,n},bb=/[&<>'"]/,Ng=async(t,e)=>{let n="";e||(e=[]);const i=await Promise.all(t);for(let r=i.length-1;n+=i[r],r--,!(r<0);r--){let s=i[r];typeof s=="object"&&e.push(...s.callbacks||[]);const o=s.isEscaped;if(s=await(typeof s=="object"?s.toString():s),typeof s=="object"&&e.push(...s.callbacks||[]),s.isEscaped??o)n+=s;else{const c=[n];qt(s,c),n=c[0]}}return pt(n,e)},qt=(t,e)=>{const n=t.search(bb);if(n===-1){e[0]+=t;return}let i,r,s=0;for(r=n;r<t.length;r++){switch(t.charCodeAt(r)){case 34:i=""";break;case 39:i="'";break;case 38:i="&";break;case 60:i="<";break;case 62:i=">";break;default:continue}e[0]+=t.substring(s,r)+i,s=r+1}e[0]+=t.substring(s,r)},jg=t=>{const e=t.callbacks;if(!(e!=null&&e.length))return t;const n=[t],i={};return e.forEach(r=>r({phase:wb.Stringify,buffer:n,context:i})),n[0]},kb=(t,...e)=>{const n=[""];for(let i=0,r=t.length-1;i<r;i++){n[0]+=t[i];const s=Array.isArray(e[i])?e[i].flat(1/0):[e[i]];for(let o=0,c=s.length;o<c;o++){const l=s[o];if(typeof l=="string")qt(l,n);else if(typeof l=="number")n[0]+=l;else{if(typeof l=="boolean"||l===null||l===void 0)continue;if(typeof l=="object"&&l.isEscaped)if(l.callbacks)n.unshift("",l);else{const u=l.toString();u instanceof Promise?n.unshift("",u):n[0]+=u}else l instanceof Promise?n.unshift("",l):qt(l.toString(),n)}}}return n[0]+=t[t.length-1],n.length===1?"callbacks"in n?pt(jg(pt(n[0],n.callbacks))):pt(n[0]):Ng(n,n.callbacks)},Kl=Symbol("RENDERER"),Bc=Symbol("ERROR_HANDLER"),Se=Symbol("STASH"),Og=Symbol("INTERNAL"),xb=Symbol("MEMO"),js=Symbol("PERMALINK"),wp=t=>(t[Og]=!0,t),Bg=t=>({value:e,children:n})=>{if(!n)return;const i={children:[{tag:wp(()=>{t.push(e)}),props:{}}]};Array.isArray(n)?i.children.push(...n.flat()):i.children.push(n),i.children.push({tag:wp(()=>{t.pop()}),props:{}});const r={tag:"",props:i,type:""};return r[Bc]=s=>{throw t.pop(),s},r},Tg=t=>{const e=[t],n=Bg(e);return n.values=e,n.Provider=n,Yn.push(n),n},Yn=[],Sb=t=>{const e=[t],n=i=>{e.push(i.value);let r;try{r=i.children?(Array.isArray(i.children)?new Ug("",{},i.children):i.children).toString():""}finally{e.pop()}return r instanceof Promise?r.then(s=>pt(s,s.callbacks)):pt(r)};return n.values=e,n.Provider=n,n[Kl]=Bg(e),Yn.push(n),n},pi=t=>t.values.at(-1),jr={title:[],script:["src"],style:["data-href"],link:["href"],meta:["name","httpEquiv","charset","itemProp"]},Tc={},Or="data-precedence",dr=t=>Array.isArray(t)?t:[t],bp=new WeakMap,kp=(t,e,n,i)=>({buffer:r,context:s})=>{if(!r)return;const o=bp.get(s)||{};bp.set(s,o);const c=o[t]||(o[t]=[]);let l=!1;const u=jr[t];if(u.length>0){e:for(const[,p]of c)for(const f of u)if(((p==null?void 0:p[f])??null)===(n==null?void 0:n[f])){l=!0;break e}}if(l?r[0]=r[0].replaceAll(e,""):u.length>0?c.push([e,n,i]):c.unshift([e,n,i]),r[0].indexOf("</head>")!==-1){let p;if(i===void 0)p=c.map(([f])=>f);else{const f=[];p=c.map(([m,,v])=>{let h=f.indexOf(v);return h===-1&&(f.push(v),h=f.length-1),[m,h]}).sort((m,v)=>m[1]-v[1]).map(([m])=>m)}p.forEach(f=>{r[0]=r[0].replaceAll(f,"")}),r[0]=r[0].replace(/(?=<\/head>)/,p.join(""))}},pr=(t,e,n)=>pt(new ft(t,n,dr(e??[])).toString()),fr=(t,e,n,i)=>{if("itemProp"in n)return pr(t,e,n);let{precedence:r,blocking:s,...o}=n;r=i?r??"":void 0,i&&(o[Or]=r);const c=new ft(t,o,dr(e||[])).toString();return c instanceof Promise?c.then(l=>pt(c,[...l.callbacks||[],kp(t,l,o,r)])):pt(c,[kp(t,c,o,r)])},Ab=({children:t,...e})=>{const n=Wl();if(n){const i=pi(n);if(i==="svg"||i==="head")return new ft("title",e,dr(t??[]))}return fr("title",t,e,!1)},Eb=({children:t,...e})=>{const n=Wl();return["src","async"].some(i=>!e[i])||n&&pi(n)==="head"?pr("script",t,e):fr("script",t,e,!1)},Ib=({children:t,...e})=>["href","precedence"].every(n=>n in e)?(e["data-href"]=e.href,delete e.href,fr("style",t,e,!0)):pr("style",t,e),Cb=({children:t,...e})=>["onLoad","onError"].some(n=>n in e)||e.rel==="stylesheet"&&(!("precedence"in e)||"disabled"in e)?pr("link",t,e):fr("link",t,e,"precedence"in e),$b=({children:t,...e})=>{const n=Wl();return n&&pi(n)==="head"?pr("meta",t,e):fr("meta",t,e,!1)},Pg=(t,{children:e,...n})=>new ft(t,n,dr(e??[])),zb=t=>(typeof t.action=="function"&&(t.action=js in t.action?t.action[js]:void 0),Pg("form",t)),Rg=(t,e)=>(typeof e.formAction=="function"&&(e.formAction=js in e.formAction?e.formAction[js]:void 0),Pg(t,e)),Nb=t=>Rg("input",t),jb=t=>Rg("button",t);const ta=Object.freeze(Object.defineProperty({__proto__:null,button:jb,form:zb,input:Nb,link:Cb,meta:$b,script:Eb,style:Ib,title:Ab},Symbol.toStringTag,{value:"Module"}));var Ob=new Map([["className","class"],["htmlFor","for"],["crossOrigin","crossorigin"],["httpEquiv","http-equiv"],["itemProp","itemprop"],["fetchPriority","fetchpriority"],["noModule","nomodule"],["formAction","formaction"]]),Os=t=>Ob.get(t)||t,Lg=(t,e)=>{for(const[n,i]of Object.entries(t)){const r=n[0]==="-"||!/[A-Z]/.test(n)?n:n.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);e(r,i==null?null:typeof i=="number"?r.match(/^(?:a|border-im|column(?:-c|s)|flex(?:$|-[^b])|grid-(?:ar|[^a])|font-w|li|or|sca|st|ta|wido|z)|ty$/)?`${i}`:`${i}px`:i)}},Hi=void 0,Wl=()=>Hi,Bb=t=>/[A-Z]/.test(t)&&t.match(/^(?:al|basel|clip(?:Path|Rule)$|co|do|fill|fl|fo|gl|let|lig|i|marker[EMS]|o|pai|pointe|sh|st[or]|text[^L]|tr|u|ve|w)/)?t.replace(/([A-Z])/g,"-$1").toLowerCase():t,Tb=["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],Pb=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","download","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"],Gl=(t,e)=>{for(let n=0,i=t.length;n<i;n++){const r=t[n];if(typeof r=="string")qt(r,e);else{if(typeof r=="boolean"||r===null||r===void 0)continue;r instanceof ft?r.toStringToBuffer(e):typeof r=="number"||r.isEscaped?e[0]+=r:r instanceof Promise?e.unshift("",r):Gl(r,e)}}},ft=class{constructor(t,e,n){Q(this,"tag");Q(this,"props");Q(this,"key");Q(this,"children");Q(this,"isEscaped",!0);Q(this,"localContexts");this.tag=t,this.props=e,this.children=n}get type(){return this.tag}get ref(){return this.props.ref||null}toString(){var e,n;const t=[""];(e=this.localContexts)==null||e.forEach(([i,r])=>{i.values.push(r)});try{this.toStringToBuffer(t)}finally{(n=this.localContexts)==null||n.forEach(([i])=>{i.values.pop()})}return t.length===1?"callbacks"in t?jg(pt(t[0],t.callbacks)).toString():t[0]:Ng(t,t.callbacks)}toStringToBuffer(t){const e=this.tag,n=this.props;let{children:i}=this;t[0]+=`<${e}`;const r=Hi&&pi(Hi)==="svg"?s=>Bb(Os(s)):s=>Os(s);for(let[s,o]of Object.entries(n))if(s=r(s),s!=="children"){if(s==="style"&&typeof o=="object"){let c="";Lg(o,(l,u)=>{u!=null&&(c+=`${c?";":""}${l}:${u}`)}),t[0]+=' style="',qt(c,t),t[0]+='"'}else if(typeof o=="string")t[0]+=` ${s}="`,qt(o,t),t[0]+='"';else if(o!=null)if(typeof o=="number"||o.isEscaped)t[0]+=` ${s}="${o}"`;else if(typeof o=="boolean"&&Pb.includes(s))o&&(t[0]+=` ${s}=""`);else if(s==="dangerouslySetInnerHTML"){if(i.length>0)throw"Can only set one of `children` or `props.dangerouslySetInnerHTML`.";i=[pt(o.__html)]}else if(o instanceof Promise)t[0]+=` ${s}="`,t.unshift('"',o);else if(typeof o=="function"){if(!s.startsWith("on"))throw`Invalid prop '${s}' of type 'function' supplied to '${e}'.`}else t[0]+=` ${s}="`,qt(o.toString(),t),t[0]+='"'}if(Tb.includes(e)&&i.length===0){t[0]+="/>";return}t[0]+=">",Gl(i,t),t[0]+=`</${e}>`}},na=class extends ft{toStringToBuffer(t){const{children:e}=this,n=this.tag.call(null,{...this.props,children:e.length<=1?e[0]:e});if(!(typeof n=="boolean"||n==null))if(n instanceof Promise)if(Yn.length===0)t.unshift("",n);else{const i=Yn.map(r=>[r,r.values.at(-1)]);t.unshift("",n.then(r=>(r instanceof ft&&(r.localContexts=i),r)))}else n instanceof ft?n.toStringToBuffer(t):typeof n=="number"||n.isEscaped?(t[0]+=n,n.callbacks&&(t.callbacks||(t.callbacks=[]),t.callbacks.push(...n.callbacks))):qt(n,t)}},Ug=class extends ft{toStringToBuffer(t){Gl(this.children,t)}},Rb=(t,e,...n)=>{e??(e={}),n.length&&(e.children=n.length===1?n[0]:n);const i=e.key;delete e.key;const r=Br(t,e,n);return r.key=i,r},xp=!1,Br=(t,e,n)=>{if(!xp){for(const i in Tc)ta[i][Kl]=Tc[i];xp=!0}return typeof t=="function"?new na(t,e,n):ta[t]?new na(ta[t],e,n):t==="svg"||t==="head"?(Hi||(Hi=Sb("")),new ft(t,e,[new na(Hi,{value:t},n)])):new ft(t,e,n)},Jl=({children:t})=>new Ug("",{children:t},Array.isArray(t)?t:t?[t]:[]),Lb=(t,e,...n)=>Rb(t.tag,{...t.props,...e},...n);function B(t,e,n){let i;if(!e||!("children"in e))i=Br(t,e,[]);else{const r=e.children;i=Array.isArray(r)?Br(t,e,r):Br(t,e,[r])}return i.key=n,i}const Ub=({vendorSettings:t})=>t!=null&&t.logoUrl?B("div",{className:"flex h-9 items-center",children:B("img",{src:t.logoUrl,className:"max-h-full",alt:"Vendor logo"})}):B(Jl,{}),Vb=({vendorSettings:t})=>{const{termsAndConditionsUrl:e}=t;return B("div",{className:"mt-8",children:e&&B("div",{className:"text-xs text-gray-300",children:[re.t("agree_to")," ",B("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noreferrer",children:re.t("terms")})]})})};var Vg={exports:{}};/*!
|
|
193
193
|
Copyright (c) 2018 Jed Watson.
|
|
194
194
|
Licensed under the MIT License (MIT), see
|
|
195
195
|
http://jedwatson.github.io/classnames
|
|
196
|
-
*/(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",o=0;o<arguments.length;o++){var c=arguments[o];c&&(s=r(s,i(c)))}return s}function i(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return n.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var o="";for(var c in s)e.call(s,c)&&s[c]&&(o=r(o,c));return o}function r(s,o){return o?s?s+" "+o:s+o:s}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(
|
|
196
|
+
*/(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",o=0;o<arguments.length;o++){var c=arguments[o];c&&(s=r(s,i(c)))}return s}function i(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return n.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var o="";for(var c in s)e.call(s,c)&&s[c]&&(o=r(o,c));return o}function r(s,o){return o?s?s+" "+o:s+o:s}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(Vg);var Mb=Vg.exports;const St=of(Mb),Db=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",Kt=({name:t,size:e,className:n=""})=>{const i=Db(e);return B("span",{className:St(`uicon-${t}`,n,i)})};var Sp=Object.freeze,Hb=Object.defineProperty,Fb=(t,e)=>Sp(Hb(t,"raw",{value:Sp(t.slice())})),Ap;const qb=t=>{const{style:e}=t;return`
|
|
197
197
|
body {
|
|
198
198
|
--primary-color: ${e.primaryColor};
|
|
199
199
|
--primary-hover: ${e.primaryHoverColor};
|
|
200
200
|
--text-on-primary: ${e.buttonTextColor};
|
|
201
201
|
}
|
|
202
|
-
`},
|
|
202
|
+
`},Kb="https://assets.sesamy.com/images/login-bg.jpg",Mg=({title:t,children:e,vendorSettings:n})=>{const i={backgroundImage:`url(${(n==null?void 0:n.loginBackgroundImage)||Kb})`};return B("html",{lang:"en",children:[B("head",{children:[B("title",{children:t}),B("meta",{charset:"UTF-8"}),B("meta",{name:"robots",content:"noindex, follow"}),B("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Regular.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),B("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Medium.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),B("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Bold.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),B("link",{rel:"stylesheet",href:"/css/tailwind.css"}),B("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"}),B("style",{children:qb(n)}),B("meta",{name:"theme-color",content:"#000000"})]}),B("body",{children:B("div",{className:"row min-h-full w-full overflow-hidden bg-cover bg-center text-sm sm:bg-fixed sm:bg-left-top sm:pt-16 py-2",style:i,children:B("div",{className:"row-up-left w-[calc(100%-theme(space.2)-theme(space.2))] max-w-[1295px] !flex-nowrap sm:w-[calc(100%-theme(space.16)-theme(space.16))]",children:B("div",{className:"column-left w-full sm:w-auto",children:[B("div",{className:"relative flex w-full flex-col rounded-2xl bg-white px-5 py-10 dark:bg-gray-800 dark:text-white sm:min-h-[700px] sm:max-w-md sm:px-14 sm:py-14 md:min-w-[448px] short:min-h-[558px] min-h-[calc(100vh-83px)]",children:[B("div",{className:"mb-16",children:B(Ub,{vendorSettings:n})}),B("div",{className:"flex flex-1 flex-col",children:[e,B(Vb,{vendorSettings:n})]})]}),B("div",{className:"flex w-full items-center px-6 pb-8 pt-4 justify-between",children:[B("div",{className:"flex justify-center leading-[0]",children:B("a",{href:"https://sesamy.com",target:"_blank",rel:"noreferrer",children:B(Kt,{name:"sesamy",className:"text-xl text-white"})})}),B("div",{className:"flex justify-center space-x-2 text-xs text-white sm:justify-normal md:text-xs",children:[n.supportUrl&&B("a",{className:"text-xs text-white hover:underline md:text-xs",href:n.supportUrl,target:"_blank",rel:"noopener noreferrer",children:re.t("contact_support")}),B("span",{className:"text-gray-300",children:"|"})," ",B("span",{children:re.t("copyright_sesamy")})]})]})]})})})}),kb(Ap||(Ap=Fb([`
|
|
203
203
|
<script>
|
|
204
204
|
function swapButtons() {
|
|
205
205
|
document.getElementById("initial-btn").classList.add("hidden");
|
|
@@ -214,37 +214,37 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
214
214
|
};
|
|
215
215
|
}
|
|
216
216
|
<\/script>
|
|
217
|
-
`])))]})},
|
|
217
|
+
`])))]})},Wb=t=>B("a",{className:"block text-primary hover:text-primaryHover text-center",href:`/u/enter-email?state=${t.state}`,children:re.t("go_back")}),Ep={name:"sesamy",logoUrl:"https://assets.sesamy.com/static/images/email/sesamy-logo.png",style:{primaryColor:"#7D68F4",buttonTextColor:"#FFFFFF",primaryHoverColor:"#A091F2"},loginBackgroundImage:"",checkoutHideSocial:!1,supportEmail:"support@sesamy.com",supportUrl:"https://support.sesamy.com",siteUrl:"https://sesamy.com",termsAndConditionsUrl:"https://store.sesamy.com/pages/terms-of-service",manageSubscriptionsUrl:"https://account.sesamy.com/manage-subscriptions"};async function Gb(t,e,n){if(!n&&!e)return Ep;const i=n||e;try{const r=await fetch(`${t.API_URL}/profile/vendors/${i}/style`);if(!r.ok)throw new Error("Failed to fetch vendor settings");const s=await r.json();return Dp.parse(s)}catch(r){return console.error(r),Ep}}async function Bs(t,e){var l;const{env:n}=t,i=await n.data.logins.get(t.var.tenant_id||"",e);if(!i)throw new O(400,{message:"Session not found"});t.set("login",i);const r=await Oo(n,i.authParams.client_id);t.set("client_id",r.id),t.set("tenant_id",r.tenant.id);const s=await n.data.tenants.get(r.tenant.id);if(!s)throw new O(400,{message:"Tenant not found"});const o=await Gb(n,r.id,i.authParams.vendor_id),c=(l=i.authParams.ui_locales)==null?void 0:l.split(" ").map(u=>u.split("-")[0]).find(u=>{if(Array.isArray(re.options.supportedLngs))return re.options.supportedLngs.includes(u)});return await re.changeLanguage(c||s.language||"sv"),{vendorSettings:{...o,termsAndConditionsUrl:r.id==="fokus-app"?"https://www.fokus.se/kopvillkor-app/":o.termsAndConditionsUrl},client:r,tenant:s,session:i}}async function Jb(t,e,n,i){if(i!==void 0)return i==="password";const r=await Vs({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:n});if(r){const o=await t.env.data.logs.list(e.tenant.id,{page:0,per_page:10,include_totals:!1,sort:{sort_by:"date",sort_order:"desc"},q:`type:${me.SUCCESS_LOGIN} user_id:${r.user_id}`}),[c]=o.logs.filter(l=>l.strategy&&["Username-Password-Authentication","passwordless","email"].includes(l.strategy));if(c)return c.strategy==="Username-Password-Authentication"}return(await t.env.data.promptSettings.get(e.tenant.id)).password_first}const Dg=({children:t})=>B("div",{className:"mb-2 text-sm text-red",children:t}),Zb=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",Yb=({size:t})=>{const e=Zb(t);return B("div",{className:"relative inline-block leading-[0]",children:[B(Kt,{className:St("text-gray-200 dark:text-[#201a41]",{[e]:e}),name:"spinner-circle"}),B(Kt,{className:St("absolute inset-0 animate-spin text-primary",{[e]:e}),name:"spinner-inner"})]})},Ts=({children:t,className:e,Component:n="button",variant:i="primary",href:r,disabled:s,isLoading:o,id:c})=>{const l=n==="a"?{href:r}:{};return B(n,{class:St("relative w-full rounded-lg text-center",e,{"px-4 py-5":i!=="custom","bg-primary text-textOnPrimary hover:bg-primaryHover":i==="primary","border border-gray-300 bg-white text-black":i==="secondary","pointer-events-none cursor-not-allowed opacity-40":s},"focus:outline-none focus:ring"),type:"submit",disabled:s,id:c,...l,children:[B("span",{className:`
|
|
218
218
|
flex items-center justify-center space-x-2
|
|
219
219
|
${o?"invisible h-0":"visible h-auto"}
|
|
220
|
-
`,children:t}),o&&
|
|
220
|
+
`,children:t}),o&&B("div",{className:"absolute left-0 top-0 flex h-full w-full items-center justify-center",children:B(Yb,{size:"medium"})})]})},kr=({connection:t,text:e,icon:n=null,canResize:i=!1,session:r})=>{const s=new URLSearchParams({client_id:r.authParams.client_id,connection:t});r.authParams.response_type&&s.set("response_type",r.authParams.response_type),r.authParams.redirect_uri&&s.set("redirect_uri",r.authParams.redirect_uri),r.authParams.scope&&s.set("scope",r.authParams.scope),r.authParams.nonce&&s.set("nonce",r.authParams.nonce),r.authParams.response_type&&s.set("response_type",r.authParams.response_type),r.authParams.state&&s.set("state",r.login_id);const o=`/authorize?${s.toString()}`;return B(Ts,{className:St("border border-gray-200 bg-white hover:bg-gray-100 dark:border-gray-400 dark:bg-black dark:hover:bg-black/90",{"px-0 py-3 sm:px-10 sm:py-4 short:px-0 short:py-3":i,"px-10 py-3":!i}),variant:"custom","aria-label":e,Component:"a",href:o,children:[n||"",B("div",{className:St("text-left text-black dark:text-white sm:text-base",{"hidden sm:inline short:hidden":i}),children:e})]})},Xb=({...t})=>B("svg",{width:"45",height:"45",viewBox:"0 0 45 45",xmlns:"http://www.w3.org/2000/svg",...t,children:[B("path",{d:"M44.1035 23.0123C44.1054 21.4791 43.9758 19.9486 43.716 18.4375H22.498V27.1028H34.6507C34.4021 28.4868 33.8757 29.8061 33.1034 30.9812C32.3311 32.1562 31.3289 33.1628 30.1571 33.9401V39.5649H37.41C41.6567 35.6494 44.1035 29.859 44.1035 23.0123Z",fill:"#4285F4"}),B("path",{d:"M22.4982 44.9997C28.5698 44.9997 33.6821 43.0061 37.4101 39.5687L30.1573 33.9439C28.1386 35.3126 25.5387 36.0938 22.4982 36.0938C16.6296 36.0938 11.6485 32.1377 9.86736 26.8066H2.39575V32.6033C4.26839 36.3297 7.13989 39.4622 10.6896 41.6512C14.2394 43.8402 18.3277 44.9995 22.4982 44.9997Z",fill:"#34A853"}),B("path",{d:"M9.86737 26.8073C8.92572 24.0138 8.92572 20.9886 9.86737 18.1951V12.3984H2.39576C0.820432 15.5332 0 18.9929 0 22.5012C0 26.0095 0.820432 29.4692 2.39576 32.604L9.86737 26.8073Z",fill:"#FBBC04"}),B("path",{d:"M22.4982 8.90741C25.7068 8.85499 28.8071 10.0673 31.1291 12.2823L37.5507 5.86064C33.4788 2.03602 28.0843 -0.0637686 22.4982 0.00147616C18.3277 0.00166623 14.2394 1.16098 10.6896 3.34999C7.13989 5.539 4.26839 8.67155 2.39575 12.3979L9.86736 18.1946C11.6485 12.8635 16.6296 8.90741 22.4982 8.90741Z",fill:"#EA4335"})]}),Hg=({children:t,className:e})=>B(Jl,{children:[B(Ts,{className:e,id:"initial-btn",children:t}),B(Ts,{className:St(e,"hidden"),isLoading:!0,id:"loading-btn",disabled:!0,children:" "})]}),Fg=({children:t,className:e})=>B("form",{id:"form",method:"post",className:e,children:t}),Qb=({...t})=>B("svg",{version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 48 48",enableBackground:"new 0 0 48 48",width:"45",height:"45",...t,children:[B("path",{fill:"#FF5B24",d:"M3.5,8h41c1.9,0,3.5,1.6,3.5,3.5v25c0,1.9-1.6,3.5-3.5,3.5h-41C1.6,40,0,38.4,0,36.5v-25C0,9.6,1.6,8,3.5,8z"}),B("path",{fillRule:"evenodd",clipRule:"evenodd",fill:"#FFFFFF",d:`M27.9,20.3c1.4,0,2.6-1,2.6-2.5h0c0-1.5-1.2-2.5-2.6-2.5c-1.4,0-2.6,1-2.6,2.5C25.3,19.2,26.5,20.3,27.9,20.3z
|
|
221
221
|
M31.2,24.4c-1.7,2.2-3.5,3.8-6.7,3.8h0c-3.2,0-5.8-2-7.7-4.8c-0.8-1.2-2-1.4-2.9-0.8c-0.8,0.6-1,1.8-0.3,2.9
|
|
222
|
-
c2.7,4.1,6.5,6.6,10.9,6.6c4,0,7.2-2,9.6-5.2c0.9-1.2,0.9-2.5,0-3.1C33.3,22.9,32.1,23.2,31.2,24.4z`})]}),np=({error:t,vendorSettings:e,session:n,email:i,client:r,impersonation:s})=>{const o=r.connections.map(({name:_})=>_),c=o.includes("facebook"),l=o.includes("google-oauth2"),u=o.includes("apple"),p=o.includes("vipps"),g=c||l||u||p;return P(tb,{title:se.t("welcome"),vendorSettings:e,children:[P("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:se.t("welcome")}),P("div",{className:"mb-8 text-gray-300",children:se.t("login_description")}),P("div",{className:"flex flex-1 flex-col justify-center",children:[P(lb,{className:"mb-7",children:[P("input",{type:"email",name:"username",placeholder:se.t("email_placeholder"),className:Bt("mb-2 w-full rounded-lg border bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),required:!0,value:i||""}),s&&P("input",{type:"email",name:"act_as",placeholder:"Impersonate as",className:Bt("mb-2 w-full rounded-lg border bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),required:!0,value:""}),t&&P(rb,{children:t}),P(cb,{className:"text-base sm:mt-4 md:text-base",children:P("div",{className:"flex items-center space-x-2",children:[P("span",{children:se.t("continue")}),P(Rn,{className:"text-xs",name:"arrow-right"})]})})]}),g&&P("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[P("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),P("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:se.t("continue_social_login")})]}),P("div",{className:"flex space-x-4 sm:flex-col sm:space-x-0 sm:space-y-4 short:flex-row short:space-x-4 short:space-y-0",children:[c&&P(ur,{connection:"facebook",text:se.t("continue_with",{provider:"Facebook"}),canResize:!0,icon:P(Rn,{className:"text-xl text-[#1196F5] sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"facebook"}),session:n}),l&&P(ur,{connection:"google-oauth2",text:se.t("continue_with",{provider:"Google"}),canResize:!0,icon:P(ab,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),session:n}),u&&P(ur,{connection:"apple",text:se.t("continue_with",{provider:"Apple"}),canResize:!0,icon:P(Rn,{className:"text-xl text-black dark:text-white sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"apple"}),session:n}),p&&P(ur,{connection:"vipps",text:se.t("continue_with",{provider:"Vipps"}),canResize:!0,icon:P(ub,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),session:n})]})]})]})},db=["Auth0.swift"];function pb(t){if(!t)return"link";const e=atob(t),n=JSON.parse(e);return db.includes(n.name)?"code":"link"}const fb=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/enter-email",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),impersonation:a.z.string().optional()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e,impersonation:n}=t.req.valid("query"),{vendorSettings:i,session:r,client:s}=await tp(t,e);return t.html(P(np,{vendorSettings:i,session:r,client:s,email:r.authParams.username,impersonation:n==="true"}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/enter-email",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({username:a.z.string().transform(t=>t.toLowerCase()),act_as:a.z.string().transform(t=>t.toLowerCase()).optional(),login_selection:a.z.enum(["code","password"]).optional()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),i=t.req.valid("form");t.set("body",i),t.set("username",i.username);const{client:r,session:s,vendorSettings:o}=await tp(t,n);t.set("client_id",r.id);const c=i.username,l=await vs({userAdapter:e.data.users,tenant_id:r.tenant.id,email:c});if(l&&t.set("user_id",l.user_id),!l)try{await qh(t,r,t.env.data,i.username)}catch{const k=be(t,{type:_e.FAILED_SIGNUP,description:"Public signup is disabled"});return await t.env.data.logs.create(r.tenant.id,k),t.html(P(np,{vendorSettings:o,session:s,error:se.t("user_account_does_not_exist"),email:i.username,client:r}),400)}if(s.authParams.username=i.username,s.authParams.act_as=i.act_as,await e.data.logins.update(r.tenant.id,s.login_id,s),await ib(t,r,i.username,i.login_selection))return t.redirect(`/u/enter-password?state=${n}`);let u=fs(),p=await e.data.codes.get(r.tenant.id,u,"otp");for(;p;)u=fs(),p=await e.data.codes.get(r.tenant.id,u,"otp");const g=await t.env.data.codes.create(r.tenant.id,{code_id:u,code_type:"otp",login_id:s.login_id,expires_at:new Date(Date.now()+lc).toISOString()});return pb(s.auth0Client)==="link"&&!i.username.includes("online.no")?Ye(t,bl(t,i.username,g.code_id)):Ye(t,Gh(t,i.username,g.code_id)),t.redirect(`/u/enter-code?state=${n}`)});function hb(){const e=new a.OpenAPIHono().route("/enter-email",fb);return e.doc("/u/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Universal login"}}),e}const gb="Account detected",_b="We have detected that you have already created an account through",mb="By signing in, you agree to our",yb="and",vb="Callback URL mismatch",wb="The provided redirect_uri is not in the list of allowed callback URLs.",bb="continue with user",kb="Please click the button to create a new password account.",xb="Enter the code at {{vendorName}} to complete the login",Sb="Welcome to {{vendorName}}! {{code}} is the login code",Ab="Welcome to {{vendorName}}! {{code}} is the login code",Ib="The code is valid for 30 minutes",Eb="Confirm password",Cb="Need Help?",zb="Contact us",$b="or continue with social account",jb="Continue with {{provider}}",Nb="Would you like to continue with your existing account?",Ob="Copyright © 2023 SESAMY. All rights reserved.",Bb="©2023 Sesamy",Tb="Choose a password with a mix of uppercase and lowercase letters, numbers, and symbols.",Rb="Please enter a valid email address.",Pb="The passwords didn't match. Try again.",Lb="Choose password",Ub="Password must be at least 8 characters long and contain at least one lowercase letter, one uppercase letter, one number and one symbol.",Vb="Create new account",Mb="Sign up with password",Db="You are currently logged in as <0>{{email}}</0>",Fb="Email",Hb="Email address",qb="Your email address has been validated",Kb="Now enter your password to login again",Wb="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.",Gb="Email verification sent",Jb="Enter a code",Zb="We'll send you a verification link to ensure you own this email address.",Yb="Enter new password",Xb="Enter password",Qb="Enter your email address and password to login.",e1="Enter your password",t1="The magic link has expired. Please click on the button below to receive a new link in your inbox.",n1="Hey! We updated our login experience. <0>Click here to learn more about it.</0>",i1="Send password reset email",r1="Click the button below and we’ll send instructions on how to reset your password.",s1="Password reset email sent",o1="Forgot password?",a1="Forgot password?",c1="Go back",l1="Invalid password",u1=`The link is no longer valid.
|
|
222
|
+
c2.7,4.1,6.5,6.6,10.9,6.6c4,0,7.2-2,9.6-5.2c0.9-1.2,0.9-2.5,0-3.1C33.3,22.9,32.1,23.2,31.2,24.4z`})]}),Ip=({error:t,vendorSettings:e,session:n,email:i,client:r,impersonation:s})=>{const o=r.connections.map(({name:m})=>m),c=o.includes("facebook"),l=o.includes("google-oauth2"),u=o.includes("apple"),p=o.includes("vipps"),f=c||l||u||p;return B(Mg,{title:re.t("welcome"),vendorSettings:e,children:[B("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:re.t("welcome")}),B("div",{className:"mb-8 text-gray-300",children:re.t("login_description")}),B("div",{className:"flex flex-1 flex-col justify-center",children:[B(Fg,{className:"mb-7",children:[B("input",{type:"email",name:"username",placeholder:re.t("email_placeholder"),className:St("mb-2 w-full rounded-lg border bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),required:!0,value:i||""}),s&&B("input",{type:"email",name:"act_as",placeholder:"Impersonate as",className:St("mb-2 w-full rounded-lg border bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),required:!0,value:""}),t&&B(Dg,{children:t}),B(Hg,{className:"text-base sm:mt-4 md:text-base",children:B("div",{className:"flex items-center space-x-2",children:[B("span",{children:re.t("continue")}),B(Kt,{className:"text-xs",name:"arrow-right"})]})})]}),f&&B("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[B("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),B("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:re.t("continue_social_login")})]}),B("div",{className:"flex space-x-4 sm:flex-col sm:space-x-0 sm:space-y-4 short:flex-row short:space-x-4 short:space-y-0",children:[c&&B(kr,{connection:"facebook",text:re.t("continue_with",{provider:"Facebook"}),canResize:!0,icon:B(Kt,{className:"text-xl text-[#1196F5] sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"facebook"}),session:n}),l&&B(kr,{connection:"google-oauth2",text:re.t("continue_with",{provider:"Google"}),canResize:!0,icon:B(Xb,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),session:n}),u&&B(kr,{connection:"apple",text:re.t("continue_with",{provider:"Apple"}),canResize:!0,icon:B(Kt,{className:"text-xl text-black dark:text-white sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"apple"}),session:n}),p&&B(kr,{connection:"vipps",text:re.t("continue_with",{provider:"Vipps"}),canResize:!0,icon:B(Qb,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),session:n})]})]})]})},e1=["Auth0.swift"];function t1(t){if(!t)return"link";const e=atob(t),n=JSON.parse(e);return e1.includes(n.name)?"code":"link"}const n1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),impersonation:a.z.string().optional()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e,impersonation:n}=t.req.valid("query"),{vendorSettings:i,session:r,client:s}=await Bs(t,e);return t.html(B(Ip,{vendorSettings:i,session:r,client:s,email:r.authParams.username,impersonation:n==="true"}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({username:a.z.string().transform(t=>t.toLowerCase()),act_as:a.z.string().transform(t=>t.toLowerCase()).optional(),login_selection:a.z.enum(["code","password"]).optional()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),i=t.req.valid("form");t.set("body",i),t.set("username",i.username);const{client:r,session:s,vendorSettings:o}=await Bs(t,n);t.set("client_id",r.id);const c=i.username,l=await Vs({userAdapter:e.data.users,tenant_id:r.tenant.id,email:c});if(l&&t.set("user_id",l.user_id),!l)try{await Ag(t,r,t.env.data,i.username)}catch{const v=be(t,{type:me.FAILED_SIGNUP,description:"Public signup is disabled"});return await t.env.data.logs.create(r.tenant.id,v),t.html(B(Ip,{vendorSettings:o,session:s,error:re.t("user_account_does_not_exist"),email:i.username,client:r}),400)}if(s.authParams.username=i.username,s.authParams.act_as=i.act_as,await e.data.logins.update(r.tenant.id,s.login_id,s),await Jb(t,r,i.username,i.login_selection))return t.redirect(`/u/enter-password?state=${n}`);let u=Ns(),p=await e.data.codes.get(r.tenant.id,u,"otp");for(;p;)u=Ns(),p=await e.data.codes.get(r.tenant.id,u,"otp");const f=await t.env.data.codes.create(r.tenant.id,{code_id:u,code_type:"otp",login_id:s.login_id,expires_at:new Date(Date.now()+Nc).toISOString()});return t1(s.auth0Client)==="link"&&!i.username.includes("online.no")?Xe(t,ql(t,i.username,f.code_id)):Xe(t,Cg(t,i.username,f.code_id)),t.redirect(`/u/enter-code?state=${n}`)});var Fi="_hp",i1={Change:"Input",DoubleClick:"DblClick"},r1={svg:"2000/svg",math:"1998/Math/MathML"},qi=[],Pc=new WeakMap,Xn=void 0,s1=()=>Xn,Ct=t=>"t"in t,ia={onClick:["click",!1]},Cp=t=>{if(!t.startsWith("on"))return;if(ia[t])return ia[t];const e=t.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);if(e){const[,n,i]=e;return ia[t]=[(i1[n]||n).toLowerCase(),!!i]}},$p=(t,e)=>Xn&&t instanceof SVGElement&&/[A-Z]/.test(e)&&(e in t.style||e.match(/^(?:o|pai|str|u|ve)/))?e.replace(/([A-Z])/g,"-$1").toLowerCase():e,o1=(t,e,n)=>{var i;e||(e={});for(let r in e){const s=e[r];if(r!=="children"&&(!n||n[r]!==s)){r=Os(r);const o=Cp(r);if(o){if((n==null?void 0:n[r])!==s&&(n&&t.removeEventListener(o[0],n[r],o[1]),s!=null)){if(typeof s!="function")throw new Error(`Event handler for "${r}" is not a function`);t.addEventListener(o[0],s,o[1])}}else if(r==="dangerouslySetInnerHTML"&&s)t.innerHTML=s.__html;else if(r==="ref"){let c;typeof s=="function"?c=s(t)||(()=>s(null)):s&&"current"in s&&(s.current=t,c=()=>s.current=null),Pc.set(t,c)}else if(r==="style"){const c=t.style;typeof s=="string"?c.cssText=s:(c.cssText="",s!=null&&Lg(s,c.setProperty.bind(c)))}else{if(r==="value"){const l=t.nodeName;if(l==="INPUT"||l==="TEXTAREA"||l==="SELECT"){if(t.value=s==null||s===!1?null:s,l==="TEXTAREA"){t.textContent=s;continue}else if(l==="SELECT"){t.selectedIndex===-1&&(t.selectedIndex=0);continue}}}else(r==="checked"&&t.nodeName==="INPUT"||r==="selected"&&t.nodeName==="OPTION")&&(t[r]=s);const c=$p(t,r);s==null||s===!1?t.removeAttribute(c):s===!0?t.setAttribute(c,""):typeof s=="string"||typeof s=="number"?t.setAttribute(c,s):t.setAttribute(c,s.toString())}}}if(n)for(let r in n){const s=n[r];if(r!=="children"&&!(r in e)){r=Os(r);const o=Cp(r);o?t.removeEventListener(o[0],s,o[1]):r==="ref"?(i=Pc.get(t))==null||i():t.removeAttribute($p(t,r))}}},a1=(t,e)=>{e[Se][0]=0,qi.push([t,e]);const n=e.tag[Kl]||e.tag,i=n.defaultProps?{...n.defaultProps,...e.props}:e.props;try{return[n.call(null,i)]}finally{qi.pop()}},qg=(t,e,n,i,r)=>{var s,o;(s=t.vR)!=null&&s.length&&(i.push(...t.vR),delete t.vR),typeof t.tag=="function"&&((o=t[Se][1][Jg])==null||o.forEach(c=>r.push(c))),t.vC.forEach(c=>{var l;if(Ct(c))n.push(c);else if(typeof c.tag=="function"||c.tag===""){c.c=e;const u=n.length;if(qg(c,e,n,i,r),c.s){for(let p=u;p<n.length;p++)n[p].s=!0;c.s=!1}}else n.push(c),(l=c.vR)!=null&&l.length&&(i.push(...c.vR),delete c.vR)})},c1=t=>{for(;;t=t.tag===Fi||!t.vC||!t.pP?t.nN:t.vC[0]){if(!t)return null;if(t.tag!==Fi&&t.e)return t.e}},Kg=t=>{var e,n,i,r,s,o;Ct(t)||((n=(e=t[Se])==null?void 0:e[1][Jg])==null||n.forEach(c=>{var l;return(l=c[2])==null?void 0:l.call(c)}),(i=Pc.get(t.e))==null||i(),t.p===2&&((r=t.vC)==null||r.forEach(c=>c.p=2)),(s=t.vC)==null||s.forEach(Kg)),t.p||((o=t.e)==null||o.remove(),delete t.e),typeof t.tag=="function"&&(vi.delete(t),Tr.delete(t),delete t[Se][3],t.a=!0)},Wg=(t,e,n)=>{t.c=e,Gg(t,e,n)},zp=(t,e)=>{if(e){for(let n=0,i=t.length;n<i;n++)if(t[n]===e)return n}},Np=Symbol(),Gg=(t,e,n)=>{var u;const i=[],r=[],s=[];qg(t,e,i,r,s),r.forEach(Kg);const o=n?void 0:e.childNodes;let c,l=null;if(n)c=-1;else if(!o.length)c=0;else{const p=zp(o,c1(t.nN));p!==void 0?(l=o[p],c=p):c=zp(o,(u=i.find(f=>f.tag!==Fi&&f.e))==null?void 0:u.e)??-1,c===-1&&(n=!0)}for(let p=0,f=i.length;p<f;p++,c++){const m=i[p];let v;if(m.s&&m.e)v=m.e,m.s=!1;else{const h=n||!m.e;Ct(m)?(m.e&&m.d&&(m.e.textContent=m.t),m.d=!1,v=m.e||(m.e=document.createTextNode(m.t))):(v=m.e||(m.e=m.n?document.createElementNS(m.n,m.tag):document.createElement(m.tag)),o1(v,m.props,m.pP),Gg(m,v,h))}m.tag===Fi?c--:n?v.parentNode||e.appendChild(v):o[c]!==v&&o[c-1]!==v&&(o[c+1]===v?e.appendChild(o[c]):e.insertBefore(v,l||o[c]||null))}if(t.pP&&delete t.pP,s.length){const p=[],f=[];s.forEach(([,m,,v,h])=>{m&&p.push(m),v&&f.push(v),h==null||h()}),p.forEach(m=>m()),f.length&&requestAnimationFrame(()=>{f.forEach(m=>m())})}},Tr=new WeakMap,Rc=(t,e,n)=>{var s,o,c,l,u,p;const i=!n&&e.pC;n&&(e.pC||(e.pC=e.vC));let r;try{n||(n=typeof e.tag=="function"?a1(t,e):dr(e.props.children)),((s=n[0])==null?void 0:s.tag)===""&&n[0][Bc]&&(r=n[0][Bc],t[5].push([t,r,e]));const f=i?[...e.pC]:e.vC?[...e.vC]:void 0,m=[];let v;for(let h=0;h<n.length;h++){Array.isArray(n[h])&&n.splice(h,1,...n[h].flat());let _=l1(n[h]);if(_){typeof _.tag=="function"&&!_.tag[Og]&&(Yn.length>0&&(_[Se][2]=Yn.map(x=>[x,x.values.at(-1)])),(o=t[5])!=null&&o.length&&(_[Se][3]=t[5].at(-1)));let y;if(f&&f.length){const x=f.findIndex(Ct(_)?C=>Ct(C):_.key!==void 0?C=>C.key===_.key&&C.tag===_.tag:C=>C.tag===_.tag);x!==-1&&(y=f[x],f.splice(x,1))}if(y)if(Ct(_))y.t!==_.t&&(y.t=_.t,y.d=!0),_=y;else{const x=y.pP=y.props;y.props=_.props,y.f||(y.f=_.f||e.f),typeof _.tag=="function"&&(y[Se][2]=_[Se][2]||[],y[Se][3]=_[Se][3],!y.f&&((y.o||y)===_.o||(l=(c=y.tag)[xb])!=null&&l.call(c,x,y.props))&&(y.s=!0)),_=y}else if(!Ct(_)&&Xn){const x=pi(Xn);x&&(_.n=x)}if(!Ct(_)&&!_.s&&(Rc(t,_),delete _.f),m.push(_),v&&!v.s&&!_.s)for(let x=v;x&&!Ct(x);x=(u=x.vC)==null?void 0:u.at(-1))x.nN=_;v=_}}e.vR=i?[...e.vC,...f||[]]:f||[],e.vC=m,i&&delete e.pC}catch(f){if(e.f=!0,f===Np){if(r)return;throw f}const[m,v,h]=((p=e[Se])==null?void 0:p[3])||[];if(v){const _=()=>Pr([0,!1,t[2]],h),y=Tr.get(h)||[];y.push(_),Tr.set(h,y);const x=v(f,()=>{const C=Tr.get(h);if(C){const j=C.indexOf(_);if(j!==-1)return C.splice(j,1),_()}});if(x){if(t[0]===1)t[1]=!0;else if(Rc(t,h,[x]),(v.length===1||t!==m)&&h.c){Wg(h,h.c,!1);return}throw Np}}throw f}finally{r&&t[5].pop()}},l1=t=>{if(!(t==null||typeof t=="boolean")){if(typeof t=="string"||typeof t=="number")return{t:t.toString(),d:!0};if("vR"in t&&(t={tag:t.tag,props:t.props,key:t.key,f:t.f,type:t.tag,ref:t.props.ref,o:t.o||t}),typeof t.tag=="function")t[Se]=[0,[]];else{const e=r1[t.tag];e&&(Xn||(Xn=Tg("")),t.props.children=[{tag:Xn,props:{value:t.n=`http://www.w3.org/${e}`,children:t.props.children}}])}return t}},jp=(t,e)=>{var n,i;(n=e[Se][2])==null||n.forEach(([r,s])=>{r.values.push(s)});try{Rc(t,e,void 0)}catch{return}if(e.a){delete e.a;return}(i=e[Se][2])==null||i.forEach(([r])=>{r.values.pop()}),(t[0]!==1||!t[1])&&Wg(e,e.c,!1)},vi=new WeakMap,Op=[],Pr=async(t,e)=>{t[5]||(t[5]=[]);const n=vi.get(e);n&&n[0](void 0);let i;const r=new Promise(s=>i=s);if(vi.set(e,[i,()=>{t[2]?t[2](t,e,s=>{jp(s,e)}).then(()=>i(e)):(jp(t,e),i(e))}]),Op.length)Op.at(-1).add(e);else{await Promise.resolve();const s=vi.get(e);s&&(vi.delete(e),s[1]())}return r},u1=(t,e,n)=>({tag:Fi,props:{children:t},key:n,e,p:1}),ra=0,Jg=1,sa=2,oa=3,aa=new WeakMap,Zg=(t,e)=>!t||!e||t.length!==e.length||e.some((n,i)=>n!==t[i]),d1=void 0,Bp=[],p1=t=>{var o;const e=()=>typeof t=="function"?t():t,n=qi.at(-1);if(!n)return[e(),()=>{}];const[,i]=n,r=(o=i[Se][1])[ra]||(o[ra]=[]),s=i[Se][0]++;return r[s]||(r[s]=[e(),c=>{const l=d1,u=r[s];if(typeof c=="function"&&(c=c(u[0])),!Object.is(c,u[0]))if(u[0]=c,Bp.length){const[p,f]=Bp.at(-1);Promise.all([p===3?i:Pr([p,!1,l],i),f]).then(([m])=>{if(!m||!(p===2||p===3))return;const v=m.vC;requestAnimationFrame(()=>{setTimeout(()=>{v===m.vC&&Pr([p===3?1:0,!1,l],m)})})})}else Pr([0,!1,l],i)}])},Zl=(t,e)=>{var c;const n=qi.at(-1);if(!n)return t;const[,i]=n,r=(c=i[Se][1])[sa]||(c[sa]=[]),s=i[Se][0]++,o=r[s];return Zg(o==null?void 0:o[1],e)?r[s]=[t,e]:t=r[s][0],t},f1=t=>{const e=aa.get(t);if(e){if(e.length===2)throw e[1];return e[0]}throw t.then(n=>aa.set(t,[n]),n=>aa.set(t,[void 0,n])),t},h1=(t,e)=>{var c;const n=qi.at(-1);if(!n)return t();const[,i]=n,r=(c=i[Se][1])[oa]||(c[oa]=[]),s=i[Se][0]++,o=r[s];return Zg(o==null?void 0:o[1],e)&&(r[s]=[t(),e]),r[s][0]},g1=Tg({pending:!1,data:null,method:null,action:null}),Tp=new Set,m1=t=>{Tp.add(t),t.finally(()=>Tp.delete(t))},Yl=(t,e)=>h1(()=>n=>{let i;t&&(typeof t=="function"?i=t(n)||(()=>{t(null)}):t&&"current"in t&&(t.current=n,i=()=>{t.current=null}));const r=e(n);return()=>{r==null||r(),i==null||i()}},[t]),On=Object.create(null),xr=Object.create(null),hr=(t,e,n,i,r)=>{if(e!=null&&e.itemProp)return{tag:t,props:e,type:t,ref:e.ref};const s=document.head;let{onLoad:o,onError:c,precedence:l,blocking:u,...p}=e,f=null,m=!1;const v=jr[t];let h;if(v.length>0){const C=s.querySelectorAll(t);e:for(const j of C)for(const R of jr[t])if(j.getAttribute(R)===e[R]){f=j;break e}if(!f){const j=v.reduce((R,ee)=>e[ee]===void 0?R:`${R}-${ee}-${e[ee]}`,t);m=!xr[j],f=xr[j]||(xr[j]=(()=>{const R=document.createElement(t);for(const ee of v)e[ee]!==void 0&&R.setAttribute(ee,e[ee]),e.rel&&R.setAttribute("rel",e.rel);return R})())}}else h=s.querySelectorAll(t);l=i?l??"":void 0,i&&(p[Or]=l);const _=Zl(C=>{if(v.length>0){let j=!1;for(const R of s.querySelectorAll(t)){if(j&&R.getAttribute(Or)!==l){s.insertBefore(C,R);return}R.getAttribute(Or)===l&&(j=!0)}s.appendChild(C)}else if(h){let j=!1;for(const R of h)if(R===C){j=!0;break}j||s.insertBefore(C,s.contains(h[0])?h[0]:s.querySelector(t)),h=void 0}},[l]),y=Yl(e.ref,C=>{var ee;const j=v[0];if(n===2&&(C.innerHTML=""),(m||h)&&_(C),!c&&!o)return;let R=On[ee=C.getAttribute(j)]||(On[ee]=new Promise((pe,le)=>{C.addEventListener("load",pe),C.addEventListener("error",le)}));o&&(R=R.then(o)),c&&(R=R.catch(c)),R.catch(()=>{})});if(r&&u==="render"){const C=jr[t][0];if(e[C]){const j=e[C],R=On[j]||(On[j]=new Promise((ee,pe)=>{_(f),f.addEventListener("load",ee),f.addEventListener("error",pe)}));f1(R)}}const x={tag:t,type:t,props:{...p,ref:y},ref:y};return x.p=n,f&&(x.e=f),u1(x,s)},_1=t=>{const e=s1(),n=e&&pi(e);return n!=null&&n.endsWith("svg")?{tag:"title",props:t,type:"title",ref:t.ref}:hr("title",t,void 0,!1,!1)},y1=t=>!t||["src","async"].some(e=>!t[e])?{tag:"script",props:t,type:"script",ref:t.ref}:hr("script",t,1,!1,!0),v1=t=>!t||!["href","precedence"].every(e=>e in t)?{tag:"style",props:t,type:"style",ref:t.ref}:(t["data-href"]=t.href,delete t.href,hr("style",t,2,!0,!0)),w1=t=>!t||["onLoad","onError"].some(e=>e in t)||t.rel==="stylesheet"&&(!("precedence"in t)||"disabled"in t)?{tag:"link",props:t,type:"link",ref:t.ref}:hr("link",t,1,"precedence"in t,!0),b1=t=>hr("meta",t,void 0,!1,!1),Yg=Symbol(),k1=t=>{const{action:e,...n}=t;typeof e!="function"&&(n.action=e);const[i,r]=p1([null,!1]),s=Zl(async u=>{const p=u.isTrusted?e:u.detail[Yg];if(typeof p!="function")return;u.preventDefault();const f=new FormData(u.target);r([f,!0]);const m=p(f);m instanceof Promise&&(m1(m),await m),r([null,!0])},[]),o=Yl(t.ref,u=>(u.addEventListener("submit",s),()=>{u.removeEventListener("submit",s)})),[c,l]=i;return i[1]=!1,{tag:g1,props:{value:{pending:c!==null,data:c,method:c?"post":null,action:c?e:null},children:{tag:"form",props:{...n,ref:o},type:"form",ref:o}},f:l}},Xg=(t,{formAction:e,...n})=>{if(typeof e=="function"){const i=Zl(r=>{r.preventDefault(),r.currentTarget.form.dispatchEvent(new CustomEvent("submit",{detail:{[Yg]:e}}))},[]);n.ref=Yl(n.ref,r=>(r.addEventListener("click",i),()=>{r.removeEventListener("click",i)}))}return{tag:t,props:n,type:t,ref:n.ref}},x1=t=>Xg("input",t),S1=t=>Xg("button",t);Object.assign(Tc,{title:_1,script:y1,style:v1,link:w1,meta:b1,form:k1,input:x1,button:S1});new TextEncoder;const A1=t=>{const{i18nKey:e,values:n,components:i}=t,r=re.t(e,n),s=/<(\d+)>(.*?)<\/\d+>/g,o=[];let c=0,l;for(;(l=s.exec(r))!==null;){const[,u,p]=l,f=r.substring(c,l.index);f&&o.push(f);const m=parseInt(u,10);o.push(Lb(i[m],{},p)),c=s.lastIndex}return c<r.length&&o.push(r.substring(c)),B(Jl,{children:o})},Pp=6,E1=({error:t,vendorSettings:e,email:n,state:i,client:r,hasPasswordLogin:s})=>{const o=new URLSearchParams({state:i}),l=r.connections.map(({name:u})=>u).includes("auth2");return B(Mg,{title:re.t("verify_your_email"),vendorSettings:e,children:[B("div",{className:"mb-4 text-2xl font-medium",children:re.t("verify_your_email")}),B("div",{className:"mb-8 text-gray-300",children:B(A1,{i18nKey:"we_sent_a_code_to",components:[B("span",{className:"text-black dark:text-white"},"span")],values:{email:n}})}),B("div",{className:"flex flex-1 flex-col justify-center",children:[B(Fg,{className:"pt-2",children:[B("input",{autoFocus:!0,type:"text",pattern:"[0-9]*",maxLength:Pp,inputMode:"numeric",name:"code",placeholder:"******",className:St("mb-2 w-full rounded-lg border bg-gray-100 px-4 pb-2 pt-2.5 text-center indent-[5px] font-mono text-3xl placeholder:text-gray-300 dark:bg-gray-600 md:text-3xl",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),minLength:Pp,required:!0,id:"code-input"}),t&&B(Dg,{children:t}),B("div",{className:"text-center sm:mt-2",children:B(Hg,{className:"text-base sm:mt-4 md:text-base",children:B("div",{className:"flex items-center space-x-2",children:[B("span",{children:re.t("login")}),B(Kt,{className:"text-xs",name:"arrow-right"})]})})}),B("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[B(Kt,{className:"text-base",name:"info-bubble"}),B("div",{className:"text-sm text-gray-300 md:text-sm",children:re.t("sent_code_spam")})]}),l&&B("div",{className:"text-center mb-12",children:[B("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[B("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),B("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:re.t("or")})]}),B(Ts,{Component:"a",href:`/u/${s?"enter-password":"pre-signup"}?${o.toString()}`,variant:"secondary",className:"block",children:re.t("enter_your_password_btn")})]})]}),B(Wb,{state:i})]})]})},I1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,session:i,client:r}=await Bs(t,e);if(!i.authParams.username)throw new O(400,{message:"Username not found in state"});const s=await Ki({userAdapter:t.env.data.users,tenant_id:r.tenant.id,email:i.authParams.username,provider:"auth2"});return t.html(B(E1,{vendorSettings:n,email:i.authParams.username,state:e,client:r,hasPasswordLogin:!!s}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({code:a.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{code:n}=t.req.valid("form"),{session:i,client:r}=await Bs(t,e);if(t.set("client_id",r.id),!i.authParams.username)throw new O(400,{message:"Username not found in state"});return zg(t,r,i.authParams,i.authParams.username,n)});function C1(){const e=new a.OpenAPIHono().route("/enter-email",n1).route("/enter-code",I1);return e.doc("/u/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Universal login"}}),e}const $1="Account detected",z1="We have detected that you have already created an account through",N1="By signing in, you agree to our",j1="and",O1="Callback URL mismatch",B1="The provided redirect_uri is not in the list of allowed callback URLs.",T1="continue with user",P1="Please click the button to create a new password account.",R1="Enter the code at {{vendorName}} to complete the login",L1="Welcome to {{vendorName}}! {{code}} is the login code",U1="Welcome to {{vendorName}}! {{code}} is the login code",V1="The code is valid for 30 minutes",M1="Confirm password",D1="Need Help?",H1="Contact us",F1="or continue with social account",q1="Continue with {{provider}}",K1="Would you like to continue with your existing account?",W1="Copyright © 2023 SESAMY. All rights reserved.",G1="©2023 Sesamy",J1="Choose a password with a mix of uppercase and lowercase letters, numbers, and symbols.",Z1="Please enter a valid email address.",Y1="The passwords didn't match. Try again.",X1="Choose password",Q1="Password must be at least 8 characters long and contain at least one lowercase letter, one uppercase letter, one number and one symbol.",ek="Create new account",tk="Sign up with password",nk="You are currently logged in as <0>{{email}}</0>",ik="Email",rk="Email address",sk="Your email address has been validated",ok="Now enter your password to login again",ak="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.",ck="Email verification sent",lk="Enter a code",uk="We'll send you a verification link to ensure you own this email address.",dk="Enter new password",pk="Enter password",fk="Enter your email address and password to login.",hk="Enter your password",gk="The magic link has expired. Please click on the button below to receive a new link in your inbox.",mk="Hey! We updated our login experience. <0>Click here to learn more about it.</0>",_k="Send password reset email",yk="Click the button below and we’ll send instructions on how to reset your password.",vk="Password reset email sent",wk="Forgot password?",bk="Forgot password?",kk="Go back",xk="Invalid password",Sk=`The link is no longer valid.
|
|
223
223
|
|
|
224
224
|
Please make sure to open the login link in the same browser you started the login with.
|
|
225
225
|
|
|
226
|
-
You can click the link below to start a new login.`,
|
|
226
|
+
You can click the link below to start a new login.`,Ak="Invalid link",Ek="Click the button to log in",Ik="Login",Ck="Or enter the code at {{vendorName}} to complete the login.",$k="Enter your email address to unlock this show on {{service}}",zk="Link your account with {{service}}",Nk="You are logged in as",jk="Login",Ok="Enter your email address to sign in.",Bk="Enter your email address and we will send you a login code.",Tk="Enter your email address and we will send you a login link.",Pk="Log out",Rk="No, I want to use another account",Lk="or",Uk="Password",Vk="The password has been reset",Mk="Success",Dk="Change password for your {{vendorName}} account",Hk="Change password for your {{vendorName}} account",Fk="Privacy Policy",qk="Redirecting",Kk="Confirm password",Wk="Register a new password",Gk="Resend code",Jk="Change password",Zk="Enter your new password below for the email account: ",Yk="Click the button to reset your password",Xk="Click the button to reset your password",Qk="Reset your password",ex="Change password for your {{vendorName}} account",tx="Reset password",nx="Send",ix="Send me a new magic link",rx="Remember to check your spam folder if the email did not arrive.",sx="Set password",ox="Sign in",ax="Signup",cx="Sign up successful",lx="It appears that your Spotify account is currently linked to another Sesamy account. But fear not, we're here to guide you through the process to get this fixed.",ux="Go to Spotify's Content Access page",dx=`Let's start by unlinking your Spotify account. Click the button below to go to Spotify's Content Access page. After you've logged in to your Spotify account, find Sesamy on the list of connected platforms. Click "Unlink" next to the Sesamy logo.`,px="Step 1: Unlink Your Spotify Account",fx="Once you've successfully unlinked your Spotify account, you can relink it to Sesamy. Simply repeat the steps you previously took that led you to this page.",hx="Step 2: Relink Your Spotify Account to Sesamy",gx="Oops! Your Spotify Account Is Already Linked",mx="If you have questions or need assistance, you can contact our support team",_x="Terms and Conditions",yx="Your email address needs validating. We have sent a new email to your inbox",vx="User account does not exist",wx="User account does not exist",bx="We could not find a user with the provided email address. Please, try again.",kx="Try again.",xx="Validate code",Sx="Check your inbox for email validation instructions.",Ax="Signed up",Ex="Click the button to verify your email address",Ix="Validate your email address",Cx="Validate your email address",$x="Verify account",zx="Verify your email",Nx="Please check your email at <0>{{email}}</0> and enter the six-digit code that we've sent you.",jx="Welcome",Ox="Welcome to your {{vendorName}} account!",Bx="Continue with this account",Tx="Yes, continue with {{text}}",Px="Yes, continue with existing account",Rx={"Server error: Invalid code":"Invalid code","Wrong email or verification code":{"":"Wrong email or verification code."},account_detected:$1,account_with_sso_provider:z1,agree_to:N1,and:j1,callback_url_mismatch:O1,callback_url_not_allowed:B1,check_email_title:T1,click_to_sign_up_description:P1,code_email_enter_code:R1,code_email_subject:L1,code_email_title:U1,code_valid_30_minutes:V1,confirm_password:M1,contact_support:D1,contact_us:H1,continue:"Continue",continue_social_login:F1,continue_with:q1,continue_with_sso_provider_headline:K1,copyright:W1,copyright_sesamy:G1,create_account_description:J1,create_account_email_invalid:Z1,create_account_passwords_didnt_match:Y1,create_account_title:X1,create_account_weak_password:Q1,create_new_account_link:ek,create_password_account_title:tk,currently_logged_in_as:nk,email:ik,email_placeholder:rk,email_validated:sk,email_validated_cta:ok,email_verification_for_signup_sent_description:ak,email_verification_for_signup_sent_title:ck,enter_a_code_btn:lk,enter_email_for_verification_description:uk,enter_new_password_placeholder:dk,enter_password:pk,enter_password_description:fk,enter_your_password_btn:hk,expired_code:gk,fokus_info_message:mk,forgot_password_cta:_k,forgot_password_description:yk,forgot_password_email_sent:vk,forgot_password_link:wk,forgot_password_title:bk,go_back:kk,"invalid-email":"Invalid email",invalid_password:xk,invalid_session_body:Sk,invalid_session_title:Ak,link_email_click_to_login:Ek,link_email_login:Ik,link_email_or_enter_code:Ck,link_page_body:$k,link_page_headline:zk,logged_in_as:Nk,login:jk,login_description:Ok,login_description_code:Bk,login_description_link:Tk,logout:Pk,no_use_another:Rk,or:Lk,password:Uk,password_has_been_reset:Vk,password_has_been_reset_title:Mk,password_reset_subject:Dk,password_reset_title:Hk,privacy_policy:Fk,redirecting:qk,reenter_new_password_placeholder:Kk,register_password_account:Wk,resend_code:Gk,reset_password_cta:Jk,reset_password_description:Zk,reset_password_email_click_to_reset:Yk,reset_password_email_cta:Xk,reset_password_email_reset:Qk,reset_password_subject:ex,reset_password_title:tx,send:nx,send_me_a_new_magic_link:ix,sent_code_spam:rx,set_password:sx,sign_in:ox,signup:ax,signup_success:cx,spotify_already_linked_body:lx,spotify_already_linked_cta:ux,spotify_already_linked_step1_body:dx,spotify_already_linked_step1_title:px,spotify_already_linked_step2_body:fx,spotify_already_linked_step2_title:hx,spotify_already_linked_title:gx,support_info:mx,terms:_x,unverified_email:yx,user_account_does_not_exist:vx,user_not_found:wx,user_not_found_body:bx,user_not_found_cta:kx,validate_code:xx,validate_email_body:Sx,validate_email_title:Ax,verify_email_click_to_verify:Ex,verify_email_subject:Ix,verify_email_title:Cx,verify_email_verify:$x,verify_your_email:zx,we_sent_a_code_to:Nx,welcome:jx,welcome_to_your_account:Ox,yes_continue:Bx,yes_continue_with:Tx,yes_continue_with_existing_account:Px},Lx="Account rilevato",Ux="Abbiamo rilevato che l'utente ha già creato un account tramite",Vx="Effettuando l'accesso, l'utente accetta la nostra",Mx="e",Dx="Mancata corrispondenza dell'URL di callback",Hx="Il redirect_uri fornito non è nell'elenco degli URL di callback consentiti.",Fx="continuare con l'utente",qx="Fare clic sul pulsante per creare un nuovo account con password.",Kx="Inserite il codice all'indirizzo {{vendorName}} per completare il login.",Wx="Benvenuti su {{vendorName}}! {{code}} è il codice di accesso",Gx="Benvenuti su {{vendorName}}! {{code}} è il codice di accesso",Jx="Il codice è valido per 30 minuti",Zx="Confermare la password",Yx="Avete bisogno di aiuto?",Xx="Contattateci",Qx="o continuare con il conto sociale",eS="Continua con {{provider}}",tS="Desidera continuare a utilizzare l'account esistente?",nS="Copyright © 2023 SESAMY. Tutti i diritti riservati.",iS="©2023 Sesamy",rS="Scegliete una password con un mix di lettere maiuscole e minuscole, numeri e simboli.",sS="Inserire un indirizzo e-mail valido.",oS="Le password non corrispondono. Riprovare.",aS="Scegliere la password",cS="La password deve essere lunga almeno 8 caratteri e contenere almeno una lettera minuscola, una lettera maiuscola, un numero e un simbolo.",lS="Creare un nuovo account",uS="Iscriviti con la password",dS="Attualmente si è connessi come <0>{{email}}</0>",pS="Email",fS="Indirizzo e-mail",hS="Il tuo indirizzo e-mail è stato convalidato",gS="Ora inserire la password per accedere nuovamente",mS="È stata inviata un'e-mail a <0>{{email}}</0> con un link di verifica. Fare clic sul link per verificare l'indirizzo e-mail e impostare una password.",_S="Email di verifica inviata",yS="Inserire un codice",vS="Vi invieremo un link di verifica per assicurarvi di possedere questo indirizzo e-mail.",wS="Inserire la nuova password",bS="Inserire la password",kS="Inserire l'indirizzo e-mail e la password per accedere.",xS="Inserire la password",SS="Il link magico è scaduto. Cliccate sul pulsante sottostante per ricevere un nuovo link nella vostra casella di posta elettronica.",AS="Abbiamo aggiornato la nostra esperienza di accesso. <0>Clicca qui per saperne di più.</0>",ES="Inviare l'e-mail di reimpostazione della password",IS="Fare clic sul pulsante sottostante per ricevere le istruzioni su come reimpostare la password.",CS="Email di reimpostazione della password inviata",$S="Hai dimenticato la password?",zS="Hai dimenticato la password?",NS="Torna indietro",jS="Password non valida",OS=`Il link non è più valido.
|
|
227
227
|
|
|
228
228
|
Assicuratevi di aprire il link di accesso con lo stesso browser con cui avete iniziato l'accesso.
|
|
229
229
|
|
|
230
|
-
Potete fare clic sul link sottostante per iniziare un nuovo accesso.`,
|
|
230
|
+
Potete fare clic sul link sottostante per iniziare un nuovo accesso.`,BS="Collegamento non valido",TS="Fare clic sul pulsante per accedere",PS="Accedi",RS="Oppure inserire il codice all'indirizzo {{vendorName}} per completare il login.",LS="Inserisci il tuo indirizzo e-mail per sbloccare questo spettacolo su {{service}}",US="Collegate il vostro account con {{service}}",VS="L'utente ha effettuato l'accesso come",MS="Accesso",DS="Inserire l'indirizzo e-mail per accedere.",HS="Inserite il vostro indirizzo e-mail e vi invieremo un codice di accesso.",FS="Inserite il vostro indirizzo e-mail e vi invieremo un link di accesso.",qS="Disconnettersi",KS="No, voglio usare un altro account",WS="o",GS="Password",JS="La password è stata reimpostata",ZS="Il successo",YS="Modifica della password dell'account {{vendorName}}",XS="Modifica della password dell'account {{vendorName}} ",QS="Informativa sulla privacy",e2="Reindirizzamento",t2="Confermare la password",n2="Registrazione di una nuova password",i2="Reinvio del codice",r2="Modifica della password",s2="Immettere di seguito la nuova password per l'account e-mail: ",o2="Fare clic sul pulsante per reimpostare la password",a2="Fare clic sul pulsante per reimpostare la password",c2="Reimpostare la password",l2="Modifica della password dell'account {{vendorName}} ",u2="Reimpostare la password",d2="Inviare",p2="Inviami un nuovo link magico",f2="Ricordate di controllare la cartella spam se l'e-mail non è arrivata.",h2="Impostare la password",g2="Accedi",m2="Iscriviti",_2="Iscriviti con successo",y2="Sembra che il vostro account Spotify sia attualmente collegato a un altro account Sesamy. Ma non temete, siamo qui per guidarvi attraverso la procedura per risolvere il problema.",v2="Vai alla pagina di accesso ai contenuti di Spotify",w2=`Cominciamo con lo scollegare il vostro account Spotify. Fare clic sul pulsante sottostante per accedere alla pagina di accesso ai contenuti di Spotify. Dopo aver effettuato l'accesso al vostro account Spotify, trovate Sesamy nell'elenco delle piattaforme collegate. Fate clic su "Unlink" accanto al logo di Sesamy.`,b2="Passo 1: Disconnettere l'account Spotify",k2="Dopo aver scollegato con successo il proprio account Spotify, è possibile ricollegarlo a Sesamy. È sufficiente ripetere i passaggi precedenti che vi hanno portato a questa pagina.",x2="Passo 2: ricollegare l'account Spotify a Sesamy",S2="Ops! Il tuo account Spotify è già collegato",A2="Se avete domande o bisogno di assistenza, potete contattare il nostro team di supporto",E2="Termini e condizioni",I2="Il tuo indirizzo e-mail deve essere convalidato. Abbiamo inviato una nuova e-mail alla tua casella di posta.",C2="L'account utente non esiste",$2="L'account utente non esiste",z2="Non è stato possibile trovare un utente con l'indirizzo e-mail fornito. Si prega di riprovare.",N2="Riprova.",j2="Convalida del codice",O2="Controllate la vostra casella di posta per le istruzioni di convalida dell'e-mail.",B2="Iscritta",T2="Fare clic sul pulsante per verificare l'indirizzo e-mail",P2="Convalidare l'indirizzo e-mail",R2="Convalidare l'indirizzo e-mail",L2="Verifica dell'account",U2="Verificare l'e-mail",V2="Controllate la vostra e-mail all'indirizzo <0>{{email}}</0> e inserisca il codice a sei cifre che le abbiamo inviato.",M2="Benvenuti",D2="Benvenuto nel tuo account {{vendorName}}!",H2="Continuare con questo account",F2="Sì, continuare con {{text}}",q2="Sì, continuare con l'account esistente",K2={"Server error: Invalid code":"Codice non valido","Wrong email or verification code":{"":"Email o codice di verifica errati."},account_detected:Lx,account_with_sso_provider:Ux,agree_to:Vx,and:Mx,callback_url_mismatch:Dx,callback_url_not_allowed:Hx,check_email_title:Fx,click_to_sign_up_description:qx,code_email_enter_code:Kx,code_email_subject:Wx,code_email_title:Gx,code_valid_30_minutes:Jx,confirm_password:Zx,contact_support:Yx,contact_us:Xx,continue:"Continua",continue_social_login:Qx,continue_with:eS,continue_with_sso_provider_headline:tS,copyright:nS,copyright_sesamy:iS,create_account_description:rS,create_account_email_invalid:sS,create_account_passwords_didnt_match:oS,create_account_title:aS,create_account_weak_password:cS,create_new_account_link:lS,create_password_account_title:uS,currently_logged_in_as:dS,email:pS,email_placeholder:fS,email_validated:hS,email_validated_cta:gS,email_verification_for_signup_sent_description:mS,email_verification_for_signup_sent_title:_S,enter_a_code_btn:yS,enter_email_for_verification_description:vS,enter_new_password_placeholder:wS,enter_password:bS,enter_password_description:kS,enter_your_password_btn:xS,expired_code:SS,fokus_info_message:AS,forgot_password_cta:ES,forgot_password_description:IS,forgot_password_email_sent:CS,forgot_password_link:$S,forgot_password_title:zS,go_back:NS,"invalid-email":"Email non valida",invalid_password:jS,invalid_session_body:OS,invalid_session_title:BS,link_email_click_to_login:TS,link_email_login:PS,link_email_or_enter_code:RS,link_page_body:LS,link_page_headline:US,logged_in_as:VS,login:MS,login_description:DS,login_description_code:HS,login_description_link:FS,logout:qS,no_use_another:KS,or:WS,password:GS,password_has_been_reset:JS,password_has_been_reset_title:ZS,password_reset_subject:YS,password_reset_title:XS,privacy_policy:QS,redirecting:e2,reenter_new_password_placeholder:t2,register_password_account:n2,resend_code:i2,reset_password_cta:r2,reset_password_description:s2,reset_password_email_click_to_reset:o2,reset_password_email_cta:a2,reset_password_email_reset:c2,reset_password_subject:l2,reset_password_title:u2,send:d2,send_me_a_new_magic_link:p2,sent_code_spam:f2,set_password:h2,sign_in:g2,signup:m2,signup_success:_2,spotify_already_linked_body:y2,spotify_already_linked_cta:v2,spotify_already_linked_step1_body:w2,spotify_already_linked_step1_title:b2,spotify_already_linked_step2_body:k2,spotify_already_linked_step2_title:x2,spotify_already_linked_title:S2,support_info:A2,terms:E2,unverified_email:I2,user_account_does_not_exist:C2,user_not_found:$2,user_not_found_body:z2,user_not_found_cta:N2,validate_code:j2,validate_email_body:O2,validate_email_title:B2,verify_email_click_to_verify:T2,verify_email_subject:P2,verify_email_title:R2,verify_email_verify:L2,verify_your_email:U2,we_sent_a_code_to:V2,welcome:M2,welcome_to_your_account:D2,yes_continue:H2,yes_continue_with:F2,yes_continue_with_existing_account:q2},W2="Konto oppdaget",G2="Vi har oppdaget at du allerede har opprettet en konto gjennom",J2="Ved å logge på godtar du vår",Z2="og",Y2="Callback-URLen samsvarer ikke",X2="Den oppgitte redirect_uri er ikke på listen over tillatte tilbakeringings-URLer.",Q2="fortsett med bruker",eA="Klikk på knappen for å opprette en ny passordkonto.",tA="Skriv inn koden på {{vendorName}} for å fullføre påloggingen",nA="Velkommen til {{vendorName}} ! {{code}} er påloggingskoden",iA="Velkommen til {{vendorName}}! {{code}} er påloggingskoden",rA="Koden er gyldig i 30 minutter",sA="Bekreft passord",oA="Trenger hjelp?",aA="Kontakt oss",cA="eller fortsett med sosial konto",lA="Fortsett med {{provider}}",uA="Vil du fortsette med din eksisterende konto?",dA="Opphavsrett © 2023 SESAMY. Alle rettigheter forbeholdt.",pA="©2023 Sesamy",fA="Velg et passord med en blanding av store og små bokstaver, tall og symboler.",hA="Vennligst skriv inn en gyldig e-postadresse.",gA="Passordene stemte ikke overens. Prøv igjen.",mA="Velg passord",_A="Passordet må være på minst 8 tegn og inneholde minst én liten bokstav, én stor bokstav, ett tall og ett symbol.",yA="Opprett ny konto",vA="Registrer deg med passord",wA="Du er logget på som <0> {{email}}</0>",bA="E-post",kA="E-postadresse",xA="E-postadressen din har blitt validert",SA="Skriv nå inn passordet ditt for å logge inn igjen",AA="En e-post har blitt sendt til <0>{{email}}</0> med en bekreftelseslenke. Klikk på lenken for å bekrefte e-postadressen din og angi et passord.",EA="E-postbekreftelse sendt",IA="Angi en kode",CA="Vi sender deg en bekreftelseskobling for å sikre at du eier denne e-postadressen.",$A="Skriv inn nytt passord",zA="Oppgi passord",NA="Skriv inn e-postadressen og passordet ditt for å logge inn.",jA="Skriv inn passordet ditt",OA="Den magiske lenken er utløpt. Vennligst klikk på knappen nedenfor for å motta en ny lenke i innboksen din.",BA="Hei! Vi oppdaterte påloggingsopplevelsen vår. <0>Klikk her for å lære mer om det.</0>",TA="Send e-post om tilbakestilling av passord",PA="Klikk på knappen nedenfor, så sender vi deg instruksjoner om hvordan du tilbakestiller passordet ditt.",RA="E-post om tilbakestilling av passord sendt",LA="Har du glemt passordet?",UA="Har du glemt passordet?",VA="Gå tilbake",MA="Ugyldig passord",DA=`Lenken er ikke lenger gyldig.
|
|
231
231
|
|
|
232
232
|
Sørg for å åpne påloggingslenken i samme nettleser som du startet påloggingen med.
|
|
233
233
|
|
|
234
|
-
Du kan klikke på lenken nedenfor for å starte en ny pålogging.`,
|
|
234
|
+
Du kan klikke på lenken nedenfor for å starte en ny pålogging.`,HA="Ugyldig lenke",FA="Klikk på knappen for å logge inn",qA="Logg inn",KA="Eller skriv inn koden på {{vendorName}} for å fullføre påloggingen.",WA="Skriv inn e-postadressen din for å låse opp dette programmet på {{service}}",GA="Koble kontoen din til {{service}}",JA="Du er innlogget som",ZA="Logg inn",YA="Skriv inn e-postadressen din for å logge på.",XA="Skriv inn e-postadressen din og vi sender deg en påloggingskode.",QA="Skriv inn e-postadressen din og vi sender deg en påloggingslenke.",e4="Logg ut",t4="Nei, jeg vil bruke en annen konto",n4="eller",i4="Passord",r4="Passordet har blitt tilbakestilt",s4="Suksess",o4="Endre passord for {{vendorName}} kontoen din",a4="Endre passord for {{vendorName}} kontoen din",c4="Personvernerklæring",l4="Omdirigerer",u4="Bekreft passord",d4="Registrer et nytt passord",p4="Send kode på nytt",f4="Endre passord",h4="Skriv inn det nye passordet for e-postkontoen nedenfor: ",g4="Klikk på knappen for å tilbakestille passordet ditt",m4="Klikk på knappen for å tilbakestille passordet ditt",_4="Tilbakestill passordet ditt",y4="Endre passord for {{vendorName}} -kontoen din",v4="Tilbakestill passord",w4="Send",b4="Send meg en ny magisk lenke",k4="Husk å sjekke søppelpostmappen din hvis e-posten ikke kom.",x4="Angi passord",S4="Logg inn",A4="Påmelding",E4="Vellykket registrering",I4="Det ser ut til at Spotify-kontoen din for øyeblikket er koblet til en annen Sesamy-konto. Men ikke vær redd, vi er her for å veilede deg gjennom prosessen for å få dette fikset.",C4="Gå til Spotifys innholdstilgangsside",$4='La oss starte med å koble fra Spotify-kontoen din. Klikk på knappen nedenfor for å gå til Spotifys innholdstilgang-side. Etter at du har logget på Spotify-kontoen din, finner du Sesamy på listen over tilkoblede plattformer. Klikk "Fjern kobling" ved siden av Sesamy-logoen.',z4="Trinn 1: Koble fra Spotify-kontoen din",N4="Når du har koblet fra Spotify-kontoen din, kan du koble den til Sesamy på nytt. Bare gjenta trinnene du tidligere tok som førte deg til denne siden.",j4="Trinn 2: Koble Spotify-kontoen din til Sesamy på nytt",O4="Oops! Spotify-kontoen din er allerede koblet",B4="Hvis du har spørsmål eller trenger hjelp, kan du kontakte supportteamet vårt",T4="vilkår",P4="E-postadressen din må bekreftes. Vi har sendt en ny e-post til innboksen din.",R4="Brukerkonto eksisterer ikke",L4="Brukerkonto eksisterer ikke",U4="Vi kunne ikke finne en bruker med den oppgitte e-postadressen. Vær så snill, prøv på nytt.",V4="Prøv igjen.",M4="Bekreft koden",D4="Sjekk innboksen din for instruksjoner om e-postvalidering.",H4="Registrerte seg",F4="Klikk på knappen for å bekrefte e-postadressen din",q4="Bekreft e-postadressen din",K4="Bekreft e-postadressen din",W4="Bekreft konto",G4="Bekreft e-posten din",J4="Vennligst sjekk e-posten din på <0>{{email}}</0> og skriv inn den sekssifrede koden som vi har sendt deg.",Z4="Velkommen",Y4="Velkommen til din brukerkonto hos {{vendorName}} !",X4="Fortsett med denne kontoen",Q4="Ja, fortsett med {{text}}",eE="Ja, fortsett med eksisterende konto",tE={"Server error: Invalid code":"Ugyldig kode","Wrong email or verification code":{"":"Feil e-post eller bekreftelseskode."},account_detected:W2,account_with_sso_provider:G2,agree_to:J2,and:Z2,callback_url_mismatch:Y2,callback_url_not_allowed:X2,check_email_title:Q2,click_to_sign_up_description:eA,code_email_enter_code:tA,code_email_subject:nA,code_email_title:iA,code_valid_30_minutes:rA,confirm_password:sA,contact_support:oA,contact_us:aA,continue:"Fortsette",continue_social_login:cA,continue_with:lA,continue_with_sso_provider_headline:uA,copyright:dA,copyright_sesamy:pA,create_account_description:fA,create_account_email_invalid:hA,create_account_passwords_didnt_match:gA,create_account_title:mA,create_account_weak_password:_A,create_new_account_link:yA,create_password_account_title:vA,currently_logged_in_as:wA,email:bA,email_placeholder:kA,email_validated:xA,email_validated_cta:SA,email_verification_for_signup_sent_description:AA,email_verification_for_signup_sent_title:EA,enter_a_code_btn:IA,enter_email_for_verification_description:CA,enter_new_password_placeholder:$A,enter_password:zA,enter_password_description:NA,enter_your_password_btn:jA,expired_code:OA,fokus_info_message:BA,forgot_password_cta:TA,forgot_password_description:PA,forgot_password_email_sent:RA,forgot_password_link:LA,forgot_password_title:UA,go_back:VA,"invalid-email":"Ugyldig epost",invalid_password:MA,invalid_session_body:DA,invalid_session_title:HA,link_email_click_to_login:FA,link_email_login:qA,link_email_or_enter_code:KA,link_page_body:WA,link_page_headline:GA,logged_in_as:JA,login:ZA,login_description:YA,login_description_code:XA,login_description_link:QA,logout:e4,no_use_another:t4,or:n4,password:i4,password_has_been_reset:r4,password_has_been_reset_title:s4,password_reset_subject:o4,password_reset_title:a4,privacy_policy:c4,redirecting:l4,reenter_new_password_placeholder:u4,register_password_account:d4,resend_code:p4,reset_password_cta:f4,reset_password_description:h4,reset_password_email_click_to_reset:g4,reset_password_email_cta:m4,reset_password_email_reset:_4,reset_password_subject:y4,reset_password_title:v4,send:w4,send_me_a_new_magic_link:b4,sent_code_spam:k4,set_password:x4,sign_in:S4,signup:A4,signup_success:E4,spotify_already_linked_body:I4,spotify_already_linked_cta:C4,spotify_already_linked_step1_body:$4,spotify_already_linked_step1_title:z4,spotify_already_linked_step2_body:N4,spotify_already_linked_step2_title:j4,spotify_already_linked_title:O4,support_info:B4,terms:T4,unverified_email:P4,user_account_does_not_exist:R4,user_not_found:L4,user_not_found_body:U4,user_not_found_cta:V4,validate_code:M4,validate_email_body:D4,validate_email_title:H4,verify_email_click_to_verify:F4,verify_email_subject:q4,verify_email_title:K4,verify_email_verify:W4,verify_your_email:G4,we_sent_a_code_to:J4,welcome:Z4,welcome_to_your_account:Y4,yes_continue:X4,yes_continue_with:Q4,yes_continue_with_existing_account:eE},nE="Fortsätt med existerande konto",iE="Det verkar som att du redan har skapat ett konto genom",rE="Genom att logga in godkänner du våra",sE="och",oE="Callback URL mismatch",aE="The provided redirect_uri is not in the list of allowed callback URLs.",cE="fortsätt med användaren",lE="Klicka på knappen för att skapa ett nytt lösenordskonto.",uE="Skriv in koden på {{vendorName}} för att slutföra inloggningen",dE="Välkommen till {{vendorName}}! {{code}} är koden för att logga in",pE="Välkommen till {{vendorName}}! {{code}} är koden för att logga in",fE="Koden är giltig i 30 minuter",hE="Bekräfta lösenord",gE="Behöver du hjälp?",mE="Kontakta oss",_E="eller via sociala medier",yE="Fortsätt med {{provider}}",vE="Vill du fortsätta med det här kontot?",wE="Copyright © 2023 SESAMY. Alla rättigheter förbehållna.",bE="©2023 Sesamy",kE="Välj ett lösenord med en blandning av stora och små bokstäver, siffror och symboler.",xE="Ange en giltig e-postadress.",SE="Lösenorden stämde inte överens. Försök igen.",AE="Välj lösenord",EE="Lösenordet måste vara minst 8 tecken långt och innehålla minst en gemen bokstav, en versal bokstav, en siffra och en symbol.",IE="Skapa nytt konto",CE="Registrera dig med lösenord",$E="Du är inloggad som <0>{{email}}</0>",zE="E-postadress",NE="E-postadress",jE="Din e-postadress har validerats",OE="Ange nu ditt lösenord för att logga in igen",BE="Ett e-postmeddelande har skickats till <0>{{email}}</0> med en verifieringslänk. Vänligen klicka på länken för att verifiera din e-postadress och välja ett lösenord.",TE="E-postverifiering skickad",PE="Logga in med kod",RE="Vi skickar dig en verifieringslänk för att säkerställa att du äger den här e-postadressen.",LE="Ange nytt lösenord",UE="Ange lösenord",VE="Ange din e-postadress och ditt lösenord för att logga in.",ME="Logga in med lösenord",DE="Länken är inte längre giltig. Klicka på knappen för att skicka en ny länk till din epost.",HE="Vi har bytt inloggningssystem, <0>här kan du läsa mer om vad det innebär</0>",FE="Skicka",qE="Klicka på knappen nedan så skickar vi instruktioner om hur du återställer ditt lösenord.",KE="Vi har skickat ett e-postmeddelande med instruktioner om hur du återställer ditt lösenord till den e-postadress du angav.",WE="Har du glömt lösenordet?",GE="Har du glömt lösenordet?",JE="Gå tillbaka",ZE="Ogiltigt lösenord",YE=`Länken är inte längre giltig.
|
|
235
235
|
|
|
236
236
|
Vänligen se till att öppna inloggningslänken i samma webbläsare som du startade inloggningen med.
|
|
237
237
|
|
|
238
|
-
Du kan klicka på länken nedan för att starta en ny inloggning.`,
|
|
238
|
+
Du kan klicka på länken nedan för att starta en ny inloggning.`,XE="Ogiltig länk",QE="Klicka på knappen för att logga in",eI="Logga in",tI="Eller skriv in koden på {{vendorName}} för att slutföra inloggningen.",nI="Ange din epost för att låsa upp den här showen på {{service}}",iI="Koppla ditt konto till {{service}}",rI="Du är inloggad som",sI="Logga in",oI="Ange din e-postadress för att logga in.",aI="Ange din mejladress, så skickar vi en kod till dig som du kan logga in med.",cI="Ange din mejladress, så skickar vi en länk till dig som du kan logga in med.",lI="Logga ut",uI="Nej, jag vill använda ett annat konto",dI="eller",pI="Lösenord",fI="Lösenordet har återställts",hI="Framgång",gI="Byt lösenord för ditt {{vendorName}} konto",mI="Byt lösenord för ditt {{vendorName}} konto",_I="Integritetspolicy",yI="Du skickas vidare",vI="Bekräfta lösenord",wI="Registrera ett nytt lösenord",bI="Skicka koden igen",kI="Ändra lösenord",xI="Ange ditt nya lösenord nedan för e-postkontot: ",SI="Klicka på knappen för att återställa ditt lösenord",AI="Klicka på knappen för att återställa ditt lösenord",EI="Återställ ditt lösenord",II="Byt lösenord för ditt {{vendorName}} konto",CI="Återställ lösenord",$I="Skicka",zI="Skicka en ny inloggninglänk",NI="Kom ihåg att kontrollera din skräppost om du inte kan hitta mailet vi har skickat.",jI="Välj lösenord",OI="Logga in",BI="Registrera dig",TI="Registrera dig framgångsrik",PI="Det verkar som att ditt Spotify-konto för närvarande är kopplat till ett annat Sesamy-konto. Ingen fara, vi är här för att guida dig genom processen för att lösa detta.",RI="Gå till Spotify's Content Access sida",LI=`Vi börjar med att avlänka ditt Spotify-konto. Klicka på knappen nedan för att komma till Spotify's Content Access sida. När du har loggat in på ditt Spotify-konto, leta upp Sesamy i listan över anslutna plattformar. Klicka på "Unlink" bredvid Sesamys logotyp.`,UI="Steg 1: Avlänka ditt Spotify-konto",VI="När du har avlänkat ditt Spotify-konto kan du koppla det till Sesamy igen. Upprepa helt enkelt de steg du tog som ledde dig till den här sidan.",MI="Steg 2: Koppla ditt Spotify-konto till Sesamy igen",DI="Oj! Ditt Spotify-konto är redan kopplat",HI="Om du har frågor eller behöver hjälp kan du kontakta vårt supportteam",FI="Villkor",qI="Din e-postadress behöver valideras. Vi har skickat ett nytt e-postmeddelande till din inkorg",KI="Kontot existerar inte",WI="Kontot extisterar inte",GI="Vi kan inte hitta en användare med denna eposten. Vänligen försök igen.",JI="Försök igen.",ZI="Validera kod",YI="Kontrollera din inkorg för instruktioner om validering av e-post.",XI="Registrerad",QI="Klicka på knappen för att verifiera din e-postadress",e3="Bekräfta din e-postadress",t3="Bekräfta din e-postadress",n3="Verifiera konto",i3="Ange engångskod",r3="Vänligen kontrollera din e-post för <0>{{email}}</0> och ange den sexsiffriga koden som vi har skickat till dig.",s3="Välkommen",o3="Välkommen till ditt {{vendorName}}-konto!",a3="Fortsätt med konto",c3="Ja, fortsätt med {{text}}",l3="Ja, fortsätt med detta kontot",u3={"Server error: Invalid code":"Koden är inte giltig","Wrong email or verification code":{"":"Fel e-post eller verifieringskod."},account_detected:nE,account_with_sso_provider:iE,agree_to:rE,and:sE,callback_url_mismatch:oE,callback_url_not_allowed:aE,check_email_title:cE,click_to_sign_up_description:lE,code_email_enter_code:uE,code_email_subject:dE,code_email_title:pE,code_valid_30_minutes:fE,confirm_password:hE,contact_support:gE,contact_us:mE,continue:"Fortsätt",continue_social_login:_E,continue_with:yE,continue_with_sso_provider_headline:vE,copyright:wE,copyright_sesamy:bE,create_account_description:kE,create_account_email_invalid:xE,create_account_passwords_didnt_match:SE,create_account_title:AE,create_account_weak_password:EE,create_new_account_link:IE,create_password_account_title:CE,currently_logged_in_as:$E,email:zE,email_placeholder:NE,email_validated:jE,email_validated_cta:OE,email_verification_for_signup_sent_description:BE,email_verification_for_signup_sent_title:TE,enter_a_code_btn:PE,enter_email_for_verification_description:RE,enter_new_password_placeholder:LE,enter_password:UE,enter_password_description:VE,enter_your_password_btn:ME,expired_code:DE,fokus_info_message:HE,forgot_password_cta:FE,forgot_password_description:qE,forgot_password_email_sent:KE,forgot_password_link:WE,forgot_password_title:GE,go_back:JE,"invalid-email":"Ogiltig e-postadress",invalid_password:ZE,invalid_session_body:YE,invalid_session_title:XE,link_email_click_to_login:QE,link_email_login:eI,link_email_or_enter_code:tI,link_page_body:nI,link_page_headline:iI,logged_in_as:rI,login:sI,login_description:oI,login_description_code:aI,login_description_link:cI,logout:lI,no_use_another:uI,or:dI,password:pI,password_has_been_reset:fI,password_has_been_reset_title:hI,password_reset_subject:gI,password_reset_title:mI,privacy_policy:_I,redirecting:yI,reenter_new_password_placeholder:vI,register_password_account:wI,resend_code:bI,reset_password_cta:kI,reset_password_description:xI,reset_password_email_click_to_reset:SI,reset_password_email_cta:AI,reset_password_email_reset:EI,reset_password_subject:II,reset_password_title:CI,send:$I,send_me_a_new_magic_link:zI,sent_code_spam:NI,set_password:jI,sign_in:OI,signup:BI,signup_success:TI,spotify_already_linked_body:PI,spotify_already_linked_cta:RI,spotify_already_linked_step1_body:LI,spotify_already_linked_step1_title:UI,spotify_already_linked_step2_body:VI,spotify_already_linked_step2_title:MI,spotify_already_linked_title:DI,support_info:HI,terms:FI,unverified_email:qI,user_account_does_not_exist:KI,user_not_found:WI,user_not_found_body:GI,user_not_found_cta:JI,validate_code:ZI,validate_email_body:YI,validate_email_title:XI,verify_email_click_to_verify:QI,verify_email_subject:e3,verify_email_title:t3,verify_email_verify:n3,verify_your_email:i3,we_sent_a_code_to:r3,welcome:s3,welcome_to_your_account:o3,yes_continue:a3,yes_continue_with:c3,yes_continue_with_existing_account:l3},d3="Wykryto konto",p3="Wykryliśmy, że użytkownik utworzył już konto za pośrednictwem",f3="Logując się, wyrażasz zgodę na nasze",h3="i",g3="Niezgodność adresu URL wywołania zwrotnego",m3="Podany adres redirect_uri nie znajduje się na liście dozwolonych adresów URL wywołania zwrotnego.",_3="kontynuować z użytkownikiem",y3="Kliknij przycisk, aby utworzyć nowe konto z hasłem.",v3="Wpisz kod na stronie {{vendorName}}, aby się zalogować.",w3="Witamy na {{vendorName}}! {{code}} to kod logowania do Twojego konta.",b3="Witamy na {{vendorName}}! {{code}} to kod logowania.",k3="Kod jest ważny przez 30 minut",x3="Potwierdź hasło",S3="Potrzebujesz pomocy?",A3="Skontaktuj się z nami",E3="lub kontynuować korzystanie z konta społecznościowego",I3="Kontynuuj {{provider}}",C3="Czy chcesz kontynuować korzystanie z istniejącego konta?",$3="Copyright © 2023 SESAMY. Wszelkie prawa zastrzeżone.",z3="©2023 Sesamy",N3="Wybierz hasło składające się z małych i wielkich liter, cyfr i symboli.",j3="Wprowadź prawidłowy adres e-mail.",O3="Hasła nie są zgodne. Spróbuj ponownie.",B3="Wybierz hasło",T3="Hasło musi mieć co najmniej 8 znaków i zawierać co najmniej jedną małą literę, jedną wielką literę, jedną cyfrę i jeden symbol.",P3="Utwórz nowe konto",R3="Zarejestruj się przy użyciu hasła",L3="Jesteś obecnie zalogowany jako <0>{{email}}</0>",U3="E-mail",V3="Adres e-mail",M3="Twój adres e-mail został zweryfikowany",D3="Teraz wprowadź hasło, aby zalogować się ponownie",H3="Wiadomość e-mail została wysłana do <0>{{email}}</0> z linkiem weryfikacyjnym. Kliknij łącze, aby zweryfikować swój adres e-mail i ustawić hasło.",F3="Wysłano weryfikację e-mail",q3="Wprowadź kod",K3="Wyślemy Ci link weryfikacyjny, aby upewnić się, że posiadasz ten adres e-mail.",W3="Wprowadź nowe hasło",G3="Wprowadź hasło",J3="Wprowadź swój adres e-mail i hasło, aby się zalogować.",Z3="Wprowadź hasło",Y3="Magiczny link wygasł. Kliknij poniższy przycisk, aby otrzymać nowy link w skrzynce odbiorczej.",X3="Zaktualizowaliśmy sposób logowania. <0>Kliknij tutaj, aby dowiedzieć się więcej.</0>",Q3="Wyślij wiadomość e-mail z resetem hasła",e6="Kliknij poniższy przycisk, a my wyślemy Ci instrukcje, jak zresetować hasło.",t6="Wysłano wiadomość e-mail z resetem hasła",n6="Zapomniałeś hasła?",i6="Zapomniałeś hasła?",r6="Wróć",s6="Nieprawidłowe hasło",o6=`Link jest już nieaktualny.
|
|
239
239
|
|
|
240
240
|
Upewnij się, że otworzyłeś link logowania w tej samej przeglądarce, w której rozpocząłeś logowanie.
|
|
241
241
|
|
|
242
|
-
Możesz kliknąć poniższy link, aby rozpocząć nowe logowanie.`,
|
|
242
|
+
Możesz kliknąć poniższy link, aby rozpocząć nowe logowanie.`,a6="Nieprawidłowy link",c6="Kliknij przycisk, aby się zalogować",l6="Zaloguj się",u6="Lub wprowadź kod na stronie {{vendorName}}, aby dokończyć logowanie.",d6="Wprowadź swój adres e-mail, aby odblokować ten program na {{service}}",p6="Połącz swoje konto z {{service}}",f6="Jesteś zalogowany jako",h6="Logowanie",g6="Wprowadź swój adres e-mail, aby się zalogować.",m6="Wprowadź swój adres e-mail, a my wyślemy Ci kod logowania.",_6="Wprowadź swój adres e-mail, a my wyślemy Ci link do logowania.",y6="Wylogowanie",v6="Nie, chcę użyć innego konta",w6="lub",b6="Hasło",k6="Hasło zostało zresetowane",x6="Sukces",S6="Zmień hasło do konta {{vendorName}} ",A6="Zmiana hasła do konta {{vendorName}} ",E6="Polityka prywatności",I6="Przekierowanie",C6="Potwierdź hasło",$6="Zarejestruj nowe hasło",z6="Wyślij ponownie kod",N6="Zmiana hasła",j6="Wprowadź poniżej nowe hasło do konta e-mail: ",O6="Kliknij przycisk, aby zresetować hasło",B6="Kliknij przycisk, aby zresetować hasło",T6="Zmień hasło",P6="Zmiana hasła do konta {{vendorName}} ",R6="Resetowanie hasła",L6="Wyślij",U6="Wyślij mi nowy magiczny link",V6="Pamiętaj, aby sprawdzić folder spamu, jeśli wiadomość e-mail nie dotarła.",M6="Ustaw hasło",D6="Zaloguj się",H6="Rejestracja",F6="Rejestracja zakończona sukcesem",q6="Wygląda na to, że Twoje konto Spotify jest obecnie połączone z innym kontem Sesamy. Ale nie martw się, jesteśmy tutaj, aby poprowadzić Cię przez proces, aby to naprawić.",K6="Przejdź do strony dostępu do treści Spotify",W6='Zacznijmy od odłączenia konta Spotify. Kliknij poniższy przycisk, aby przejść do strony dostępu do treści Spotify. Po zalogowaniu się na swoje konto Spotify, znajdź Sesamy na liście połączonych platform. Kliknij "Odłącz" obok logo Sesamy.',G6="Krok 1: Odłącz swoje konto Spotify",J6="Po pomyślnym odłączeniu konta Spotify możesz ponownie połączyć je z Sesamy. Wystarczy powtórzyć poprzednie kroki, które doprowadziły Cię do tej strony.",Z6="Krok 2: Połącz ponownie swoje konto Spotify z Sesamy",Y6="Ups! Twoje konto Spotify jest już połączone",X6="Jeśli masz pytania lub potrzebujesz pomocy, skontaktuj się z nami",Q6="Zasady i warunki",eC="Twój adres e-mail wymaga weryfikacji. Wysłaliśmy nową wiadomość e-mail na Twoją skrzynkę odbiorczą",tC="Konto użytkownika nie istnieje",nC="Konto użytkownika nie istnieje",iC="Nie mogliśmy znaleźć użytkownika o podanym adresie e-mail. Spróbuj ponownie.",rC="Spróbuj ponownie.",sC="Sprawdź poprawność kodu",oC="Sprawdź swoją skrzynkę odbiorczą, aby uzyskać instrukcje dotyczące weryfikacji wiadomości e-mail.",aC="Zarejestrowany",cC="Kliknij przycisk, aby zweryfikować swój adres e-mail",lC="Potwierdź swój adres e-mail",uC="Potwierdź swój adres e-mail",dC="Zweryfikuj konto",pC="Zweryfikuj swój adres e-mail",fC="Sprawdź swoją skrzynkę e-mail pod adresem <0>{{email}}</0> i wprowadź sześciocyfrowy kod, który wysłaliśmy.",hC="Witamy",gC="Witamy na koncie {{vendorName}}!",mC="Kontynuuj korzystanie z tego konta",_C="Tak, kontynuuj {{text}}",yC="Tak, kontynuuj korzystanie z istniejącego konta",vC={"Server error: Invalid code":"Nieprawidłowy kod","Wrong email or verification code":{"":"Nieprawidłowy adres e-mail lub kod weryfikacyjny."},account_detected:d3,account_with_sso_provider:p3,agree_to:f3,and:h3,callback_url_mismatch:g3,callback_url_not_allowed:m3,check_email_title:_3,click_to_sign_up_description:y3,code_email_enter_code:v3,code_email_subject:w3,code_email_title:b3,code_valid_30_minutes:k3,confirm_password:x3,contact_support:S3,contact_us:A3,continue:"Kontynuuj",continue_social_login:E3,continue_with:I3,continue_with_sso_provider_headline:C3,copyright:$3,copyright_sesamy:z3,create_account_description:N3,create_account_email_invalid:j3,create_account_passwords_didnt_match:O3,create_account_title:B3,create_account_weak_password:T3,create_new_account_link:P3,create_password_account_title:R3,currently_logged_in_as:L3,email:U3,email_placeholder:V3,email_validated:M3,email_validated_cta:D3,email_verification_for_signup_sent_description:H3,email_verification_for_signup_sent_title:F3,enter_a_code_btn:q3,enter_email_for_verification_description:K3,enter_new_password_placeholder:W3,enter_password:G3,enter_password_description:J3,enter_your_password_btn:Z3,expired_code:Y3,fokus_info_message:X3,forgot_password_cta:Q3,forgot_password_description:e6,forgot_password_email_sent:t6,forgot_password_link:n6,forgot_password_title:i6,go_back:r6,"invalid-email":"Nieprawidłowy adres e-mail",invalid_password:s6,invalid_session_body:o6,invalid_session_title:a6,link_email_click_to_login:c6,link_email_login:l6,link_email_or_enter_code:u6,link_page_body:d6,link_page_headline:p6,logged_in_as:f6,login:h6,login_description:g6,login_description_code:m6,login_description_link:_6,logout:y6,no_use_another:v6,or:w6,password:b6,password_has_been_reset:k6,password_has_been_reset_title:x6,password_reset_subject:S6,password_reset_title:A6,privacy_policy:E6,redirecting:I6,reenter_new_password_placeholder:C6,register_password_account:$6,resend_code:z6,reset_password_cta:N6,reset_password_description:j6,reset_password_email_click_to_reset:O6,reset_password_email_cta:B6,reset_password_email_reset:T6,reset_password_subject:P6,reset_password_title:R6,send:L6,send_me_a_new_magic_link:U6,sent_code_spam:V6,set_password:M6,sign_in:D6,signup:H6,signup_success:F6,spotify_already_linked_body:q6,spotify_already_linked_cta:K6,spotify_already_linked_step1_body:W6,spotify_already_linked_step1_title:G6,spotify_already_linked_step2_body:J6,spotify_already_linked_step2_title:Z6,spotify_already_linked_title:Y6,support_info:X6,terms:Q6,unverified_email:eC,user_account_does_not_exist:tC,user_not_found:nC,user_not_found_body:iC,user_not_found_cta:rC,validate_code:sC,validate_email_body:oC,validate_email_title:aC,verify_email_click_to_verify:cC,verify_email_subject:lC,verify_email_title:uC,verify_email_verify:dC,verify_your_email:pC,we_sent_a_code_to:fC,welcome:hC,welcome_to_your_account:gC,yes_continue:mC,yes_continue_with:_C,yes_continue_with_existing_account:yC},wC="Zjištěný účet",bC="Zjistili jsme, že jste si již vytvořili účet prostřednictvím",kC="Přihlášením souhlasíte s našimi",xC="a",SC="Neshoda adresy URL zpětného volání",AC="Zadané redirect_uri není v seznamu povolených zpětných adres URL.",EC="pokračovat s uživatelem",IC="Klikněte na tlačítko pro vytvoření nového účtu s heslem.",CC="Pro dokončení přihlášení zadejte kód na adrese {{vendorName}}.",$C="Vítejte na {{vendorName}}! {{code}} je přihlašovací kód.",zC="Vítejte na {{vendorName}}! {{code}} je přihlašovací kód.",NC="Kód je platný po dobu 30 minut",jC="Potvrzení hesla",OC="Potřebujete pomoc?",BC="Kontaktujte nás",TC="nebo pokračovat v sociálním účtu",PC="Pokračovat s {{provider}}",RC="Chcete pokračovat ve svém stávajícím účtu?",LC="Copyright © 2023 SESAMY. Všechna práva vyhrazena.",UC="©2023 Sesamy",VC="Zvolte heslo složené z velkých a malých písmen, číslic a symbolů.",MC="Zadejte prosím platnou e-mailovou adresu.",DC="Hesla se neshodovala. Zkuste to znovu.",HC="Zvolte heslo",FC="Heslo musí mít alespoň 8 znaků a obsahovat alespoň jedno malé písmeno, jedno velké písmeno, jednu číslici a jeden symbol.",qC="Vytvořit nový účet",KC="Zaregistrujte se pomocí hesla",WC="V současné době jste přihlášeni jako <0>{{email}}</0>",GC="E-mail",JC="E-mailová adresa",ZC="Vaše e-mailová adresa byla ověřena",YC="Nyní zadejte své heslo a znovu se přihlaste",XC="E-mail byl odeslán na adresu <0>{{email}}</0> s ověřovacím odkazem. Kliknutím na odkaz ověřte svou e-mailovou adresu a nastavte heslo.",QC="Ověření e-mailem odesláno",e$="Zadejte kód",t$="Pošleme vám ověřovací odkaz, abychom se ujistili, že tuto e-mailovou adresu vlastníte.",n$="Zadejte nové heslo",i$="Zadejte heslo",r$="Pro přihlášení zadejte svou e-mailovou adresu a heslo.",s$="Zadejte své heslo",o$="Platnost kouzelného odkazu vypršela. Klikněte na tlačítko níže, abyste obdrželi nový odkaz do své e-mailové schránky.",a$="Ahoj! Aktualizovali jsme naše přihlašovací prostředí. <0>Klikněte sem a dozvíte se o něm více.</0>",c$="Odeslání e-mailu pro obnovení hesla",l$="Klikněte na tlačítko níže a my vám zašleme pokyny k obnovení hesla.",u$="Odeslání e-mailu s žádostí o obnovení hesla",d$="Zapomněli jste heslo?",p$="Zapomněli jste heslo?",f$="Vrátit se zpět",h$="Neplatné heslo",g$=`Odkaz již není platný.
|
|
243
243
|
|
|
244
244
|
Ujistěte se, že jste odkaz na přihlášení otevřeli ve stejném prohlížeči, ve kterém jste přihlášení zahájili.
|
|
245
245
|
|
|
246
|
-
Kliknutím na odkaz níže můžete zahájit nové přihlášení.`,
|
|
246
|
+
Kliknutím na odkaz níže můžete zahájit nové přihlášení.`,m$="Neplatný odkaz",_$="Kliknutím na tlačítko se přihlásíte",y$="Přihlášení",v$="Nebo zadejte kód na adrese {{vendorName}} a dokončete přihlášení.",w$="Zadejte svou e-mailovou adresu pro odemknutí tohoto pořadu na {{service}}",b$="Propojte svůj účet s {{service}}",k$="Jste přihlášeni jako",x$="Přihlášení",S$="Pro přihlášení zadejte svou e-mailovou adresu.",A$="Zadejte svou e-mailovou adresu a my vám zašleme přihlašovací kód.",E$="Zadejte svou e-mailovou adresu a my vám zašleme odkaz pro přihlášení.",I$="Odhlášení",C$="Ne, chci použít jiný účet",$$="nebo",z$="Heslo",N$="Heslo bylo resetováno",j$="Úspěch",O$="Změna hesla k účtu {{vendorName}} ",B$="Změna hesla k účtu {{vendorName}} ",T$="Zásady ochrany osobních údajů",P$="Přesměrování",R$="Potvrzení hesla",L$="Registrace nového hesla",U$="Opětovné odeslání kódu",V$="Změna hesla",M$="Níže zadejte nové heslo k e-mailovému účtu: ",D$="Kliknutím na tlačítko obnovíte své heslo",H$="Kliknutím na tlačítko obnovíte své heslo",F$="Obnovení hesla",q$="Změna hesla k účtu {{vendorName}} ",K$="Obnovení hesla",W$="Odeslat",G$="Pošlete mi nový kouzelný odkaz",J$="Pokud e-mail nedorazil, nezapomeňte zkontrolovat složku nevyžádané pošty.",Z$="Nastavení hesla",Y$="Přihlásit se",X$="Registrace",Q$="Úspěšná registrace",ez="Zdá se, že váš účet Spotify je v současné době propojen s jiným účtem Sesamy. Ale nebojte se, jsme tu, abychom vás provedli procesem, jak to napravit.",tz="Přejděte na stránku Spotify pro přístup k obsahu",nz='Začněme odpojením účtu Spotify. Kliknutím na tlačítko níže přejděte na stránku přístupu k obsahu služby Spotify. Po přihlášení k účtu Spotify najděte v seznamu připojených platforem položku Sesamy. Klikněte na tlačítko "Unlink" vedle loga Sesamy.',iz="Krok 1: Odpojení účtu Spotify",rz="Po úspěšném odpojení účtu Spotify jej můžete znovu propojit se službou Sesamy. Stačí zopakovat předchozí kroky, které vás přivedly na tuto stránku.",sz="Krok 2: Propojení účtu Spotify s aplikací Sesamy",oz="Ups! Váš účet Spotify je již propojen",az="Pokud máte dotazy nebo potřebujete pomoc, můžete se obrátit na náš tým podpory.",cz="Podmínky a pravidla",lz="Vaši e-mailovou adresu je třeba ověřit. Do vaší e-mailové schránky jsme odeslali nový e-mail.",uz="Uživatelský účet neexistuje",dz="Uživatelský účet neexistuje",pz="Nepodařilo se nám najít uživatele se zadanou e-mailovou adresou. Zkuste to prosím znovu.",fz="Zkuste to znovu.",hz="Ověření kódu",gz="Pokyny k ověření e-mailu najdete ve své e-mailové schránce.",mz="Zaregistrovali jste se",_z="Klikněte na tlačítko pro ověření e-mailové adresy",yz="Ověřte svou e-mailovou adresu",vz="Ověřte svou e-mailovou adresu",wz="Ověření účtu",bz="Ověření e-mailu",kz="Zkontrolujte si prosím svůj e-mail na adrese <0>{{email}}</0> a zadejte šestimístný kód, který jsme vám zaslali.",xz="Vítejte na",Sz="Vítejte na svém účtu {{vendorName}}!",Az="Pokračujte s tímto účtem",Ez="Ano, pokračujte {{text}}",Iz="Ano, pokračujte ve stávajícím účtu",Cz={"Server error: Invalid code":"Neplatný kód","Wrong email or verification code":{"":"Špatný e-mail nebo ověřovací kód."},account_detected:wC,account_with_sso_provider:bC,agree_to:kC,and:xC,callback_url_mismatch:SC,callback_url_not_allowed:AC,check_email_title:EC,click_to_sign_up_description:IC,code_email_enter_code:CC,code_email_subject:$C,code_email_title:zC,code_valid_30_minutes:NC,confirm_password:jC,contact_support:OC,contact_us:BC,continue:"Pokračovat",continue_social_login:TC,continue_with:PC,continue_with_sso_provider_headline:RC,copyright:LC,copyright_sesamy:UC,create_account_description:VC,create_account_email_invalid:MC,create_account_passwords_didnt_match:DC,create_account_title:HC,create_account_weak_password:FC,create_new_account_link:qC,create_password_account_title:KC,currently_logged_in_as:WC,email:GC,email_placeholder:JC,email_validated:ZC,email_validated_cta:YC,email_verification_for_signup_sent_description:XC,email_verification_for_signup_sent_title:QC,enter_a_code_btn:e$,enter_email_for_verification_description:t$,enter_new_password_placeholder:n$,enter_password:i$,enter_password_description:r$,enter_your_password_btn:s$,expired_code:o$,fokus_info_message:a$,forgot_password_cta:c$,forgot_password_description:l$,forgot_password_email_sent:u$,forgot_password_link:d$,forgot_password_title:p$,go_back:f$,"invalid-email":"Neplatný e-mail",invalid_password:h$,invalid_session_body:g$,invalid_session_title:m$,link_email_click_to_login:_$,link_email_login:y$,link_email_or_enter_code:v$,link_page_body:w$,link_page_headline:b$,logged_in_as:k$,login:x$,login_description:S$,login_description_code:A$,login_description_link:E$,logout:I$,no_use_another:C$,or:$$,password:z$,password_has_been_reset:N$,password_has_been_reset_title:j$,password_reset_subject:O$,password_reset_title:B$,privacy_policy:T$,redirecting:P$,reenter_new_password_placeholder:R$,register_password_account:L$,resend_code:U$,reset_password_cta:V$,reset_password_description:M$,reset_password_email_click_to_reset:D$,reset_password_email_cta:H$,reset_password_email_reset:F$,reset_password_subject:q$,reset_password_title:K$,send:W$,send_me_a_new_magic_link:G$,sent_code_spam:J$,set_password:Z$,sign_in:Y$,signup:X$,signup_success:Q$,spotify_already_linked_body:ez,spotify_already_linked_cta:tz,spotify_already_linked_step1_body:nz,spotify_already_linked_step1_title:iz,spotify_already_linked_step2_body:rz,spotify_already_linked_step2_title:sz,spotify_already_linked_title:oz,support_info:az,terms:cz,unverified_email:lz,user_account_does_not_exist:uz,user_not_found:dz,user_not_found_body:pz,user_not_found_cta:fz,validate_code:hz,validate_email_body:gz,validate_email_title:mz,verify_email_click_to_verify:_z,verify_email_subject:yz,verify_email_title:vz,verify_email_verify:wz,verify_your_email:bz,we_sent_a_code_to:kz,welcome:xz,welcome_to_your_account:Sz,yes_continue:Az,yes_continue_with:Ez,yes_continue_with_existing_account:Iz},$z="Tili havaittu",zz="Olemme havainneet, että olet jo luonut tilin kautta",Nz="Kirjautumalla sisään hyväksyt",jz="ja",Oz="Takaisinkutsun URL-osoite ei vastaa toisiaan",Bz="Annettu redirect_uri ei ole sallittujen takaisinsoitto-URL-osoitteiden luettelossa.",Tz="jatka käyttäjän kanssa",Pz="Klikkaa painiketta luodaksesi uuden salasanatilin.",Rz="Kirjoita koodi osoitteessa {{vendorName}} kirjautumisen loppuun saattamiseksi.",Lz="Tervetuloa osoitteeseen {{vendorName}}! {{code}} on kirjautumiskoodi.",Uz="Tervetuloa osoitteeseen {{vendorName}}! {{code}} on kirjautumiskoodi.",Vz="Koodi on voimassa 30 minuuttia",Mz="Vahvista salasana",Dz="Tarvitsetko apua?",Hz="Ota yhteyttä",Fz="tai jatka sosiaalisella tilillä",qz="Jatka {{provider}}",Kz="Haluatko jatkaa olemassa olevalla tililläsi?",Wz="Copyright © 2023 SESAMY. Kaikki oikeudet pidätetään.",Gz="©2023 Sesamy",Jz="Valitse salasana, jossa on isoja ja pieniä kirjaimia, numeroita ja symboleja.",Zz="Kirjoita voimassa oleva sähköpostiosoite.",Yz="Salasanat eivät vastanneet toisiaan. Yritä uudelleen.",Xz="Valitse salasana",Qz="Salasanan on oltava vähintään 8 merkkiä pitkä ja sisällettävä vähintään yksi pieni kirjain, yksi iso kirjain, yksi numero ja yksi symboli.",eN="Luo uusi tili",tN="Rekisteröidy salasanalla",nN="Olet tällä hetkellä kirjautuneena sisään nimellä <0>{{email}}</0>",iN="Sähköposti",rN="Sähköpostiosoite",sN="Sähköpostiosoitteesi on vahvistettu",oN="Kirjoita nyt salasanasi kirjautuaksesi uudelleen",aN="Sähköposti on lähetetty osoitteeseen <0>{{email}}</0> jossa on vahvistuslinkki. Klikkaa linkkiä vahvistaaksesi sähköpostiosoitteesi ja asettaaksesi salasanan.",cN="Sähköpostivarmennus lähetetty",lN="Syötä koodi",uN="Lähetämme sinulle vahvistuslinkin varmistaaksemme, että omistat tämän sähköpostiosoitteen.",dN="Anna uusi salasana",pN="Anna salasana",fN="Anna sähköpostiosoitteesi ja salasanasi kirjautuaksesi sisään.",hN="Syötä salasanasi",gN="Taikalinkki on vanhentunut. Klikkaa alla olevaa painiketta saadaksesi uuden linkin sähköpostiisi.",mN="Hei! Päivitimme kirjautumiskokemuksemme. <0>Klikkaa tästä saadaksesi lisätietoja siitä.</0>",_N="Lähetä salasanan palautussähköposti",yN="Napsauta alla olevaa painiketta, niin lähetämme ohjeet salasanasi palauttamiseen.",vN="Salasanan palautussähköposti lähetetty",wN="Unohditko salasanan?",bN="Unohditko salasanan?",kN="Palaa takaisin",xN="Virheellinen salasana",SN=`Linkki ei ole enää voimassa.
|
|
247
247
|
|
|
248
248
|
Varmista, että avaat kirjautumislinkin samalla selaimella, jolla aloitit kirjautumisen.
|
|
249
249
|
|
|
250
|
-
Voit aloittaa uuden kirjautumisen klikkaamalla alla olevaa linkkiä.`,
|
|
250
|
+
Voit aloittaa uuden kirjautumisen klikkaamalla alla olevaa linkkiä.`,AN="Virheellinen linkki",EN="Kirjaudu sisään napsauttamalla painiketta",IN="Kirjaudu sisään",CN="Tai kirjoita koodi osoitteessa {{vendorName}} kirjautumisen loppuun saattamiseksi.",$N="Kirjoita sähköpostiosoitteesi avataksesi tämän ohjelman osoitteessa {{service}}",zN="Yhdistä tilisi {{service}}",NN="Olet kirjautunut sisään nimellä",jN="Kirjaudu sisään",ON="Kirjoita sähköpostiosoitteesi kirjautuaksesi sisään.",BN="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumiskoodin.",TN="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumislinkin.",PN="Kirjaudu ulos",RN="Ei, haluan käyttää toista tiliä",LN="tai",UN="Salasana",VN="Salasana on nollattu",MN="Menestys",DN="Vaihda salasana tilillesi {{vendorName}} ",HN="Vaihda salasana tilillesi {{vendorName}} ",FN="Tietosuojakäytäntö",qN="Uudelleenohjaus",KN="Vahvista salasana",WN="Rekisteröi uusi salasana",GN="Lähetä koodi uudelleen",JN="Vaihda salasana",ZN="Kirjoita alla oleva uusi salasanasi sähköpostitiliä varten: ",YN="Napsauta painiketta salasanasi palauttamiseksi",XN="Napsauta painiketta salasanasi palauttamiseksi",QN="Nollaa salasanasi",ej="Vaihda salasana tilillesi {{vendorName}} ",tj="Nollaa salasana",nj="Lähetä",ij="Lähetä minulle uusi maaginen linkki",rj="Muista tarkistaa roskapostikansiosi, jos sähköposti ei ole saapunut.",sj="Aseta salasana",oj="Kirjaudu sisään",aj="Rekisteröityminen",cj="Rekisteröidy onnistuneesti",lj="Näyttää siltä, että Spotify-tilisi on tällä hetkellä yhdistetty toiseen Sesamy-tiliin. Mutta älä pelkää, me opastamme sinua prosessin läpi, jotta saat tämän korjattua.",uj="Siirry Spotifyn Content Access -sivulle",dj='Aloitetaan poistamalla Spotify-tilisi linkitys. Klikkaa alla olevaa painiketta siirtyäksesi Spotifyn Content Access -sivulle. Kun olet kirjautunut sisään Spotify-tilillesi, etsi Sesamy yhdistettyjen alustojen luettelosta. Napsauta "Unlink" Sesamyn logon vieressä.',pj="Vaihe 1: Poista Spotify-tilisi linkitys",fj="Kun olet onnistuneesti irrottanut Spotify-tilisi, voit yhdistää sen uudelleen Sesamyn kanssa. Toista vain aiemmin tekemäsi vaiheet, jotka johtivat sinut tälle sivulle.",hj="Vaihe 2: Yhdistä Spotify-tilisi uudelleen Sesamyn kanssa",gj="Hups! Spotify-tilisi on jo linkitetty",mj="Jos sinulla on kysyttävää tai tarvitset apua, voit ottaa yhteyttä tukitiimiimme.",_j="Ehdot ja edellytykset",yj="Sähköpostiosoitteesi on vahvistettava. Olemme lähettäneet uuden sähköpostiviestin sähköpostiisi.",vj="Käyttäjätiliä ei ole olemassa",wj="Käyttäjätiliä ei ole olemassa",bj="Emme löytäneet käyttäjää, jolla on annettu sähköpostiosoite. Yritä uudelleen.",kj="Yritä uudelleen.",xj="Validoi koodi",Sj="Tarkista sähköpostin vahvistusohjeet postilaatikostasi.",Aj="Rekisteröitynyt",Ej="Vahvista sähköpostiosoitteesi napsauttamalla painiketta",Ij="Vahvista sähköpostiosoitteesi",Cj="Vahvista sähköpostiosoitteesi",$j="Vahvista tili",zj="Vahvista sähköpostiosoitteesi",Nj="Tarkista sähköpostisi osoitteesta <0>{{email}}</0> ja syötä lähettämämme kuusinumeroinen koodi.",jj="Tervetuloa",Oj="Tervetuloa tilillesi {{vendorName}}!",Bj="Jatka tällä tilillä",Tj="Kyllä, jatka {{text}}",Pj="Kyllä, jatka olemassa olevalla tilillä",Rj={"Server error: Invalid code":"Virheellinen koodi","Wrong email or verification code":{"":"Väärä sähköpostiosoite tai vahvistuskoodi."},account_detected:$z,account_with_sso_provider:zz,agree_to:Nz,and:jz,callback_url_mismatch:Oz,callback_url_not_allowed:Bz,check_email_title:Tz,click_to_sign_up_description:Pz,code_email_enter_code:Rz,code_email_subject:Lz,code_email_title:Uz,code_valid_30_minutes:Vz,confirm_password:Mz,contact_support:Dz,contact_us:Hz,continue:"Jatka",continue_social_login:Fz,continue_with:qz,continue_with_sso_provider_headline:Kz,copyright:Wz,copyright_sesamy:Gz,create_account_description:Jz,create_account_email_invalid:Zz,create_account_passwords_didnt_match:Yz,create_account_title:Xz,create_account_weak_password:Qz,create_new_account_link:eN,create_password_account_title:tN,currently_logged_in_as:nN,email:iN,email_placeholder:rN,email_validated:sN,email_validated_cta:oN,email_verification_for_signup_sent_description:aN,email_verification_for_signup_sent_title:cN,enter_a_code_btn:lN,enter_email_for_verification_description:uN,enter_new_password_placeholder:dN,enter_password:pN,enter_password_description:fN,enter_your_password_btn:hN,expired_code:gN,fokus_info_message:mN,forgot_password_cta:_N,forgot_password_description:yN,forgot_password_email_sent:vN,forgot_password_link:wN,forgot_password_title:bN,go_back:kN,"invalid-email":"Virheellinen sähköpostiosoite",invalid_password:xN,invalid_session_body:SN,invalid_session_title:AN,link_email_click_to_login:EN,link_email_login:IN,link_email_or_enter_code:CN,link_page_body:$N,link_page_headline:zN,logged_in_as:NN,login:jN,login_description:ON,login_description_code:BN,login_description_link:TN,logout:PN,no_use_another:RN,or:LN,password:UN,password_has_been_reset:VN,password_has_been_reset_title:MN,password_reset_subject:DN,password_reset_title:HN,privacy_policy:FN,redirecting:qN,reenter_new_password_placeholder:KN,register_password_account:WN,resend_code:GN,reset_password_cta:JN,reset_password_description:ZN,reset_password_email_click_to_reset:YN,reset_password_email_cta:XN,reset_password_email_reset:QN,reset_password_subject:ej,reset_password_title:tj,send:nj,send_me_a_new_magic_link:ij,sent_code_spam:rj,set_password:sj,sign_in:oj,signup:aj,signup_success:cj,spotify_already_linked_body:lj,spotify_already_linked_cta:uj,spotify_already_linked_step1_body:dj,spotify_already_linked_step1_title:pj,spotify_already_linked_step2_body:fj,spotify_already_linked_step2_title:hj,spotify_already_linked_title:gj,support_info:mj,terms:_j,unverified_email:yj,user_account_does_not_exist:vj,user_not_found:wj,user_not_found_body:bj,user_not_found_cta:kj,validate_code:xj,validate_email_body:Sj,validate_email_title:Aj,verify_email_click_to_verify:Ej,verify_email_subject:Ij,verify_email_title:Cj,verify_email_verify:$j,verify_your_email:zj,we_sent_a_code_to:Nj,welcome:jj,welcome_to_your_account:Oj,yes_continue:Bj,yes_continue_with:Tj,yes_continue_with_existing_account:Pj};re.init({supportedLngs:["en","it","nb","sv","pl","cs","fi"],fallbackLng:"en",resources:{en:{translation:Rx},it:{translation:K2},nb:{translation:tE},sv:{translation:u3},pl:{translation:vC},cs:{translation:Cz},fi:{translation:Rj}}});function Lj(t){const e=new a.OpenAPIHono;e.use(async(s,o)=>(s.env.data=qw(s,t.dataAdapter),o())),e.get("/",s=>s.json({name:"authhero"}));const n=Sy();e.route("/api/v2",n);const i=vb();e.route("/",i);const r=C1();return e.route("/u",r),{app:e,managementApp:n,oauthApp:i,universalApp:r,createX509Certificate:zc}}exports.Auth0Client=Gp;exports.AuthorizationResponseMode=Wt;exports.AuthorizationResponseType=fn;exports.CodeChallengeMethod=Ls;exports.GrantType=bi;exports.LogTypes=me;exports.applicationInsertSchema=Dr;exports.applicationSchema=on;exports.auth0UserResponseSchema=vt;exports.authParamsSchema=Vc;exports.baseUserSchema=Rs;exports.bordersSchema=Qp;exports.brandingSchema=la;exports.codeInsertSchema=Fp;exports.codeSchema=Tm;exports.codeTypeSchema=Hp;exports.colorsSchema=ef;exports.connectionInsertSchema=Hr;exports.connectionSchema=Vt;exports.domainInsertSchema=qp;exports.domainSchema=Pm;exports.emailProviderSchema=Ar;exports.fontDetailsSchema=rn;exports.fontsSchema=tf;exports.hookInsertSchema=qr;exports.hookSchema=Bn;exports.identitySchema=Vp;exports.init=Lj;exports.jwksKeySchema=Kp;exports.jwksSchema=Mc;exports.logSchema=Kr;exports.loginInsertSchema=Wp;exports.loginSchema=Rm;exports.openIDConfigurationSchema=ua;exports.pageBackgroundSchema=nf;exports.parseUserId=Dm;exports.passwordInsertSchema=Jp;exports.passwordSchema=Um;exports.profileDataSchema=Up;exports.promptSettingSchema=Sr;exports.refreshTokenInsertSchema=Dc;exports.refreshTokenSchema=Mm;exports.samlpAddon=Mp;exports.sessionInsertSchema=Yp;exports.sessionSchema=Us;exports.signingKeySchema=da;exports.tenantInsertSchema=Fr;exports.tenantSchema=Pn;exports.themeInsertSchema=sf;exports.themeSchema=Vm;exports.tokenResponseSchema=Xp;exports.totalsSchema=Yt;exports.userInsertSchema=Mr;exports.userResponseSchema=Nm;exports.userSchema=Uc;exports.vendorSettingsSchema=Dp;exports.widgetSchema=rf;
|