authhero 0.117.0 → 0.119.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/authhero.cjs CHANGED
@@ -1,14 +1,14 @@
1
- "use strict";var Fm=Object.defineProperty;var Km=(t,e,n)=>e in t?Fm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var te=(t,e,n)=>Km(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@hono/zod-openapi"),ne=t=>typeof t=="string",Er=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},$d=t=>t==null?"":""+t,Wm=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Gm=/###/g,Od=t=>t&&t.indexOf("###")>-1?t.replace(Gm,"."):t,Pd=t=>!t||ne(t),Pr=(t,e,n)=>{const r=ne(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(Pd(t))return{};const s=Od(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return Pd(t)?{}:{obj:t,k:Od(r[i])}},Td=(t,e,n)=>{const{obj:r,k:i}=Pr(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],a=e.slice(0,e.length-1),c=Pr(t,a,Object);for(;c.obj===void 0&&a.length;)s=`${a[a.length-1]}.${s}`,a=a.slice(0,a.length-1),c=Pr(t,a,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${s}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${s}`]=n},Jm=(t,e,n,r)=>{const{obj:i,k:s}=Pr(t,e,Object);i[s]=i[s]||[],i[s].push(n)},Qi=(t,e)=>{const{obj:n,k:r}=Pr(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Zm=(t,e,n)=>{const r=Qi(t,n);return r!==void 0?r:Qi(e,n)},of=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?ne(t[r])||t[r]instanceof String||ne(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):of(t[r],e[r],n):t[r]=e[r]);return t},Vn=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Ym={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const Xm=t=>ne(t)?t.replace(/[&<>"'\/]/g,e=>Ym[e]):t;class Qm{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 r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}const e0=[" ",",","?","!",";"],t0=new Qm(20),n0=(t,e,n)=>{e=e||"",n=n||"";const r=e0.filter(a=>e.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const i=t0.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let s=!i.test(t);if(!s){const a=t.indexOf(n);a>0&&!i.test(t.substring(0,a))&&(s=!0)}return s},Aa=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 r=e.split(n);let i=t;for(let s=0;s<r.length;){if(!i||typeof i!="object")return;let a,c="";for(let l=s;l<r.length;++l)if(l!==s&&(c+=n),c+=r[l],a=i[c],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&l<r.length-1)continue;s+=l-s+1;break}i=a}return i},es=t=>t==null?void 0:t.replace("_","-"),r0={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,r;(r=(n=console==null?void 0:console[t])==null?void 0:n.apply)==null||r.call(n,console,e)}};class ts{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||r0,this.options=n,this.debug=n.debug}log(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"log","",!0)}warn(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"warn","",!0)}error(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"error","")}deprecate(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,i){return i&&!this.debug?null:(ne(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new ts(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new ts(this.logger,e)}}var At=new ts;class Zs{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+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,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];this.observers[e]&&Array.from(this.observers[e].entries()).forEach(a=>{let[c,l]=a;for(let d=0;d<l;d++)c(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[c,l]=a;for(let d=0;d<l;d++)c.apply(c,[e,...r])})}}class Bd extends Zs{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,r){var d,p;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,a=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let c;e.indexOf(".")>-1?c=e.split("."):(c=[e,n],r&&(Array.isArray(r)?c.push(...r):ne(r)&&s?c.push(...r.split(s)):c.push(r)));const l=Qi(this.data,c);return!l&&!n&&!r&&e.indexOf(".")>-1&&(e=c[0],n=c[1],r=c.slice(2).join(".")),l||!a||!ne(r)?l:Aa((p=(d=this.data)==null?void 0:d[e])==null?void 0:p[n],r,s)}addResource(e,n,r,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let c=[e,n];r&&(c=c.concat(a?r.split(a):r)),e.indexOf(".")>-1&&(c=e.split("."),i=n,n=c[1]),this.addNamespaces(n),Td(this.data,c,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const s in r)(ne(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},c=[e,n];e.indexOf(".")>-1&&(c=e.split("."),i=r,r=n,n=c[1]),this.addNamespaces(n);let l=Qi(this.data,c)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?of(l,r,s):l={...l,...r},Td(this.data,c,l),a.silent||this.emit("added",e,n,r)}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(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var af={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{var a;e=((a=this.processors[s])==null?void 0:a.process(e,n,r,i))??e}),e}};const Rd={};class ns extends Zs{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Wm(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=At.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 r=this.resolve(e,n);return(r==null?void 0:r.res)!==void 0}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const a=r&&e.indexOf(r)>-1,c=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!n0(e,r,i);if(a&&!c){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:ne(s)?[s]:s};const d=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(d[0])>-1)&&(s=d.shift()),e=d.join(i)}return{key:e,namespaces:ne(s)?[s]:s}}translate(e,n,r){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 i=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,namespaces:c}=this.extractFromKey(e[e.length-1],n),l=c[c.length-1],d=n.lng||this.language,p=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((d==null?void 0:d.toLowerCase())==="cimode"){if(p){const L=n.nsSeparator||this.options.nsSeparator;return i?{res:`${l}${L}${a}`,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${L}${a}`}return i?{res:a,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:a}const f=this.resolve(e,n);let m=f==null?void 0:f.res;const w=(f==null?void 0:f.usedKey)||a,h=(f==null?void 0:f.exactUsedKey)||a,_=Object.prototype.toString.apply(m),v=["[object Number]","[object Function]","[object RegExp]"],S=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,C=!this.i18nFormat||this.i18nFormat.handleAsObject,O=!ne(m)&&typeof m!="boolean"&&typeof m!="number";if(C&&m&&O&&v.indexOf(_)<0&&!(ne(S)&&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 L=this.options.returnedObjectHandler?this.options.returnedObjectHandler(w,m,{...n,ns:c}):`key '${a} (${this.language})' returned an object instead of string.`;return i?(f.res=L,f.usedParams=this.getUsedParamsDetails(n),f):L}if(s){const L=Array.isArray(m),Q=L?[]:{},ce=L?h:w;for(const le in m)if(Object.prototype.hasOwnProperty.call(m,le)){const De=`${ce}${s}${le}`;Q[le]=this.translate(De,{...n,joinArrays:!1,ns:c}),Q[le]===De&&(Q[le]=m[le])}m=Q}}else if(C&&ne(S)&&Array.isArray(m))m=m.join(S),m&&(m=this.extendTranslation(m,e,n,r));else{let L=!1,Q=!1;const ce=n.count!==void 0&&!ne(n.count),le=ns.hasDefaultValue(n),De=ce?this.pluralResolver.getSuffix(d,n.count,n):"",Ve=n.ordinal&&ce?this.pluralResolver.getSuffix(d,n.count,{ordinal:!1}):"",Re=ce&&!n.ordinal&&n.count===0,j=Re&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${De}`]||n[`defaultValue${Ve}`]||n.defaultValue;!this.isValidLookup(m)&&le&&(L=!0,m=j),this.isValidLookup(m)||(Q=!0,m=a);const z=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&Q?void 0:m,k=le&&j!==m&&this.options.updateMissing;if(Q||L||k){if(this.logger.log(k?"updateKey":"missingKey",d,l,a,k?j:m),s){const X=this.resolve(a,{...n,keySeparator:!1});X&&X.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 x=[];const $=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&$&&$[0])for(let X=0;X<$.length;X++)x.push($[X]);else this.options.saveMissingTo==="all"?x=this.languageUtils.toResolveHierarchy(n.lng||this.language):x.push(n.lng||this.language);const U=(X,G,se)=>{var D;const ue=le&&se!==m?se:z;this.options.missingKeyHandler?this.options.missingKeyHandler(X,l,G,ue,k,n):(D=this.backendConnector)!=null&&D.saveMissing&&this.backendConnector.saveMissing(X,l,G,ue,k,n),this.emit("missingKey",X,l,G,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&ce?x.forEach(X=>{const G=this.pluralResolver.getSuffixes(X,n);Re&&n[`defaultValue${this.options.pluralSeparator}zero`]&&G.indexOf(`${this.options.pluralSeparator}zero`)<0&&G.push(`${this.options.pluralSeparator}zero`),G.forEach(se=>{U([X],a+se,n[`defaultValue${se}`]||j)})}):U(x,a,j))}m=this.extendTranslation(m,e,n,f,r),Q&&m===a&&this.options.appendNamespaceToMissingKey&&(m=`${l}:${a}`),(Q||L)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${a}`:a,L?m:void 0))}return i?(f.res=m,f.usedParams=this.getUsedParamsDetails(n),f):m}extendTranslation(e,n,r,i,s){var d,p;var a=this;if((d=this.i18nFormat)!=null&&d.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const f=ne(e)&&(((p=r==null?void 0:r.interpolation)==null?void 0:p.skipOnVariables)!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let m;if(f){const h=e.match(this.interpolator.nestingRegexp);m=h&&h.length}let w=r.replace&&!ne(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(w={...this.options.interpolation.defaultVariables,...w}),e=this.interpolator.interpolate(e,w,r.lng||this.language||i.usedLng,r),f){const h=e.match(this.interpolator.nestingRegexp),_=h&&h.length;m<_&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,function(){for(var h=arguments.length,_=new Array(h),v=0;v<h;v++)_[v]=arguments[v];return(s==null?void 0:s[0])===_[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${_[0]} in key: ${n[0]}`),null):a.translate(..._,n)},r)),r.interpolation&&this.interpolator.reset()}const c=r.postProcess||this.options.postProcess,l=ne(c)?[c]:c;return e!=null&&(l!=null&&l.length)&&r.applyPostProcessor!==!1&&(e=af.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,i,s,a,c;return ne(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(r))return;const d=this.extractFromKey(l,n),p=d.key;i=p;let f=d.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const m=n.count!==void 0&&!ne(n.count),w=m&&!n.ordinal&&n.count===0,h=n.context!==void 0&&(ne(n.context)||typeof n.context=="number")&&n.context!=="",_=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(v=>{var S,C;this.isValidLookup(r)||(c=v,!Rd[`${_[0]}-${v}`]&&((S=this.utils)!=null&&S.hasLoadedNamespace)&&!((C=this.utils)!=null&&C.hasLoadedNamespace(c))&&(Rd[`${_[0]}-${v}`]=!0,this.logger.warn(`key "${i}" 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(O=>{var ce;if(this.isValidLookup(r))return;a=O;const L=[p];if((ce=this.i18nFormat)!=null&&ce.addLookupKeys)this.i18nFormat.addLookupKeys(L,p,O,v,n);else{let le;m&&(le=this.pluralResolver.getSuffix(O,n.count,n));const De=`${this.options.pluralSeparator}zero`,Ve=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(L.push(p+le),n.ordinal&&le.indexOf(Ve)===0&&L.push(p+le.replace(Ve,this.options.pluralSeparator)),w&&L.push(p+De)),h){const Re=`${p}${this.options.contextSeparator}${n.context}`;L.push(Re),m&&(L.push(Re+le),n.ordinal&&le.indexOf(Ve)===0&&L.push(Re+le.replace(Ve,this.options.pluralSeparator)),w&&L.push(Re+De))}}let Q;for(;Q=L.pop();)this.isValidLookup(r)||(s=Q,r=this.getResource(O,v,Q,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:a,usedNS:c}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r){var s;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return(s=this.i18nFormat)!=null&&s.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}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"],r=e.replace&&!ne(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const s of n)delete i[s]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class Ld{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=At.create("languageUtils")}getScriptPartFromCode(e){if(e=es(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=es(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(ne(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(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getLanguagePartFromCode(r);if(this.isSupportedCode(i))return n=i;n=this.options.supportedLngs.find(s=>{if(s===i)return s;if(!(s.indexOf("-")<0&&i.indexOf("-")<0)&&(s.indexOf("-")>0&&i.indexOf("-")<0&&s.substring(0,s.indexOf("-"))===i||s.indexOf(i)===0&&i.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)),ne(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],e),i=[],s=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return ne(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))):ne(e)&&s(this.formatLanguageCode(e)),r.forEach(a=>{i.indexOf(a)<0&&s(this.formatLanguageCode(a))}),i}}const Ud={zero:0,one:1,two:2,few:3,many:4,other:5},Vd={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class i0{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=At.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 r=es(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let a;try{a=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),Vd;if(!e.match(/-|_/))return Vd;const l=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(l,n)}return this.pluralRulesCache[s]=a,a}needsPlural(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),(r==null?void 0:r.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,s)=>Ud[i]-Ud[s]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const qd=function(t,e,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=Zm(t,e,n);return!s&&i&&ne(n)&&(s=Aa(t,n,r),s===void 0&&(s=Aa(e,n,r))),s},ra=t=>t.replace(/\$/g,"$$$$");class s0{constructor(){var n;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=At.create("interpolator"),this.options=e,this.format=((n=e==null?void 0:e.interpolation)==null?void 0:n.format)||(r=>r),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:r,useRawValueToEscape:i,prefix:s,prefixEscaped:a,suffix:c,suffixEscaped:l,formatSeparator:d,unescapeSuffix:p,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:w,nestingSuffix:h,nestingSuffixEscaped:_,nestingOptionsSeparator:v,maxReplaces:S,alwaysFormat:C}=e.interpolation;this.escape=n!==void 0?n:Xm,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Vn(s):a||"{{",this.suffix=c?Vn(c):l||"}}",this.formatSeparator=d||",",this.unescapePrefix=p?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=m?Vn(m):w||Vn("$t("),this.nestingSuffix=h?Vn(h):_||Vn(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=S||1e3,this.alwaysFormat=C!==void 0?C:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>(n==null?void 0:n.source)===r?(n.lastIndex=0,n):new RegExp(r,"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,r,i){var w;let s,a,c;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=h=>{if(h.indexOf(this.formatSeparator)<0){const C=qd(n,l,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(C,void 0,r,{...i,...n,interpolationkey:h}):C}const _=h.split(this.formatSeparator),v=_.shift().trim(),S=_.join(this.formatSeparator).trim();return this.format(qd(n,l,v,this.options.keySeparator,this.options.ignoreJSONStructure),S,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const p=(i==null?void 0:i.missingInterpolationHandler)||this.options.missingInterpolationHandler,f=((w=i==null?void 0:i.interpolation)==null?void 0:w.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>ra(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?ra(this.escape(h)):ra(h)}].forEach(h=>{for(c=0;s=h.regex.exec(e);){const _=s[1].trim();if(a=d(_),a===void 0)if(typeof p=="function"){const S=p(e,s,i);a=ne(S)?S:""}else if(i&&Object.prototype.hasOwnProperty.call(i,_))a="";else if(f){a=s[0];continue}else this.logger.warn(`missed to pass in variable ${_} for interpolating ${e}`),a="";else!ne(a)&&!this.useRawValueToEscape&&(a=$d(a));const v=h.safeValue(a);if(e=e.replace(s[0],v),f?(h.regex.lastIndex+=a.length,h.regex.lastIndex-=s[0].length):h.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),e}nest(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i,s,a;const c=(l,d)=>{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,a);const w=m.match(/'/g),h=m.match(/"/g);(((w==null?void 0:w.length)??0)%2===0&&!h||h.length%2!==0)&&(m=m.replace(/'/g,'"'));try{a=JSON.parse(m),d&&(a={...d,...a})}catch(_){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,_),`${l}${p}${m}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];a={...r},a=a.replace&&!ne(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let d=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const p=i[1].split(this.formatSeparator).map(f=>f.trim());i[1]=p.shift(),l=p,d=!0}if(s=n(c.call(this,i[1].trim(),a),a),s&&i[0]===e&&!ne(s))return s;ne(s)||(s=$d(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),d&&(s=l.reduce((p,f)=>this.format(p,f,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const o0=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(a=>{if(a){const[c,...l]=a.split(":"),d=l.join(":").trim().replace(/^'+|'+$/g,""),p=c.trim();n[p]||(n[p]=d),d==="false"&&(n[p]=!1),d==="true"&&(n[p]=!0),isNaN(d)||(n[p]=parseInt(d,10))}})}return{formatName:e,formatOptions:n}},qn=t=>{const e={};return(n,r,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});const a=r+JSON.stringify(s);let c=e[a];return c||(c=t(es(r),i),e[a]=c),c(n)}};class a0{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=At.create("formatter"),this.options=e,this.formats={number:qn((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return s=>i.format(s)}),currency:qn((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return s=>i.format(s)}),datetime:qn((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return s=>i.format(s)}),relativetime:qn((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return s=>i.format(s,r.range||"day")}),list:qn((n,r)=>{const i=new Intl.ListFormat(n,{...r});return s=>i.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()]=qn(n)}format(e,n,r){let i=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:d,formatOptions:p}=o0(l);if(this.formats[d]){let m=c;try{const w=((f=i==null?void 0:i.formatParams)==null?void 0:f[i.interpolationkey])||{},h=w.locale||w.lng||i.locale||i.lng||r;m=this.formats[d](c,h,{...p,...i,...w})}catch(w){this.logger.warn(w)}return m}else this.logger.warn(`there was no format function for ${d}`);return c},e)}}const c0=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class l0 extends Zs{constructor(e,n,r){var s,a;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=At.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],(a=(s=this.backend)==null?void 0:s.init)==null||a.call(s,r,i.backend,i)}queueLoad(e,n,r,i){const s={},a={},c={},l={};return e.forEach(d=>{let p=!0;n.forEach(f=>{const m=`${d}|${f}`;!r.reload&&this.store.hasResourceBundle(d,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?a[m]===void 0&&(a[m]=!0):(this.state[m]=1,p=!1,a[m]===void 0&&(a[m]=!0),s[m]===void 0&&(s[m]=!0),l[f]===void 0&&(l[f]=!0)))}),p||(c[d]=!0)}),(Object.keys(s).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(a),toLoadLanguages:Object.keys(c),toLoadNamespaces:Object.keys(l)}}loaded(e,n,r){const i=e.split("|"),s=i[0],a=i[1];n&&this.emit("failedLoading",s,a,n),!n&&r&&this.store.addResourceBundle(s,a,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const c={};this.queue.forEach(l=>{Jm(l.loaded,[s],a),c0(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(d=>{c[d]||(c[d]={});const p=l.loaded[d];p.length&&p.forEach(f=>{c[d][f]===void 0&&(c[d][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,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:a});return}this.readingCalls++;const c=(d,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(d&&p&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,s*2,a)},s);return}a(d,p)},l=this.backend[r].bind(this.backend);if(l.length===2){try{const d=l(e,n);d&&typeof d.then=="function"?d.then(p=>c(null,p)).catch(c):c(null,d)}catch(d){c(d)}return}return l(e,n,c)}prepareLoading(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=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."),i&&i();ne(e)&&(e=this.languageUtils.toResolveHierarchy(e)),ne(n)&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(a=>{this.loadOne(a)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=e.split("|"),i=r[0],s=r[1];this.read(i,s,"read",void 0,void 0,(a,c)=>{a&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,a),!a&&c&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,c),this.loaded(e,a,c)})}saveMissing(e,n,r,i,s){var l,d,p,f,m;let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if((d=(l=this.services)==null?void 0:l.utils)!=null&&d.hasLoadedNamespace&&!((f=(p=this.services)==null?void 0:p.utils)!=null&&f.hasLoadedNamespace(n))){this.logger.warn(`did not save key "${r}" 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(!(r==null||r==="")){if((m=this.backend)!=null&&m.create){const w={...a,isUpdate:s},h=this.backend.create.bind(this.backend);if(h.length<6)try{let _;h.length===5?_=h(e,n,r,i,w):_=h(e,n,r,i),_&&typeof _.then=="function"?_.then(v=>c(null,v)).catch(c):c(null,_)}catch(_){c(_)}else h(e,n,r,i,c,w)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const Md=()=>({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]),ne(t[1])&&(e.defaultValue=t[1]),ne(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),Hd=t=>{var e,n;return ne(t.ns)&&(t.ns=[t.ns]),ne(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),ne(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},$i=()=>{},d0=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class qr extends Zs{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Hd(e),this.services={},this.logger=At,this.modules={external:[]},d0(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]:{},r=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(ne(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const i=Md();this.options={...i,...this.options,...Hd(n)},this.options.interpolation={...i.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?At.init(s(this.modules.logger),this.options):At.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:p=a0;const f=new Ld(this.options);this.store=new Bd(this.options.resources,this.options);const m=this.services;m.logger=At,m.resourceStore=this.store,m.languageUtils=f,m.pluralResolver=new i0(f,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),p&&(!this.options.interpolation.format||this.options.interpolation.format===i.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 s0(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new l0(s(this.modules.backend),m.resourceStore,m,this.options),m.backendConnector.on("*",function(w){for(var h=arguments.length,_=new Array(h>1?h-1:0),v=1;v<h;v++)_[v-1]=arguments[v];e.emit(w,..._)}),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 ns(this.services,this.options),this.translator.on("*",function(w){for(var h=arguments.length,_=new Array(h>1?h-1:0),v=1;v<h;v++)_[v-1]=arguments[v];e.emit(w,..._)}),this.modules.external.forEach(w=>{w.init&&w.init(this)})}if(this.format=this.options.interpolation.format,r||(r=$i),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=Er(),d=()=>{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),r(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?d():setTimeout(d,0),l}loadResources(e){var s,a;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:$i;const i=ne(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if((i==null?void 0:i.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const c=[],l=d=>{if(!d||d==="cimode")return;this.services.languageUtils.toResolveHierarchy(d).forEach(f=>{f!=="cimode"&&c.indexOf(f)<0&&c.push(f)})};i?l(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(p=>l(p)),(a=(s=this.options.preload)==null?void 0:s.forEach)==null||a.call(s,d=>l(d)),this.services.backendConnector.load(c,this.options.ns,d=>{!d&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(d)})}else r(null)}reloadResources(e,n,r){const i=Er();return typeof e=="function"&&(r=e,e=void 0),typeof n=="function"&&(r=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),r||(r=$i),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),i}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"&&af.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 r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}changeLanguage(e,n){var r=this;this.isLanguageChangingTo=e;const i=Er();this.emit("languageChanging",e);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},a=(l,d)=>{d?(s(d),this.translator.changeLanguage(d),this.isLanguageChangingTo=void 0,this.emit("languageChanged",d),this.logger.log("languageChanged",d)):this.isLanguageChangingTo=void 0,i.resolve(function(){return r.t(...arguments)}),n&&n(l,function(){return r.t(...arguments)})},c=l=>{var p,f;!e&&!l&&this.services.languageDetector&&(l=[]);const d=ne(l)?l:this.services.languageUtils.getBestMatchFromCodes(l);d&&(this.language||s(d),this.translator.language||this.translator.changeLanguage(d),(f=(p=this.services.languageDetector)==null?void 0:p.cacheUserLanguage)==null||f.call(p,d)),this.loadResources(d,m=>{a(m,d)})};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),i}getFixedT(e,n,r){var i=this;const s=function(a,c){let l;if(typeof c!="object"){for(var d=arguments.length,p=new Array(d>2?d-2:0),f=2;f<d;f++)p[f-2]=arguments[f];l=i.options.overloadTranslationOptionHandler([a,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||r||s.keyPrefix);const m=i.options.keySeparator||".";let w;return l.keyPrefix&&Array.isArray(a)?w=a.map(h=>`${l.keyPrefix}${m}${h}`):w=l.keyPrefix?`${l.keyPrefix}${m}${a}`:a,i.t(w,l)};return ne(e)?s.lng=e:s.lngs=e,s.ns=n,s.keyPrefix=r,s}t(){var i;for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(i=this.translator)==null?void 0:i.translate(...n)}exists(){var i;for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(i=this.translator)==null?void 0:i.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 r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(c,l)=>{const d=this.services.backendConnector.state[`${c}|${l}`];return d===-1||d===0||d===2};if(n.precheck){const c=n.precheck(this,a);if(c!==void 0)return c}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,e)&&(!i||a(s,e)))}loadNamespaces(e,n){const r=Er();return this.options.ns?(ne(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=Er();ne(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(a=>i.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return s.length?(this.options.preload=i.concat(s),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(e){var i,s;if(e||(e=this.resolvedLanguage||(((i=this.languages)==null?void 0:i.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"],r=((s=this.services)==null?void 0:s.languageUtils)||new Ld(Md());return n.indexOf(r.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 qr(e,n)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:$i;const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new qr(i);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)},r){const c=Object.keys(this.store.data).reduce((l,d)=>(l[d]={...this.store.data[d]},Object.keys(l[d]).reduce((p,f)=>(p[f]={...l[d][f]},p),{})),{});s.store=new Bd(c,i),s.services.resourceStore=s.store}return s.translator=new ns(s.services,i),s.translator.on("*",function(c){for(var l=arguments.length,d=new Array(l>1?l-1:0),p=1;p<l;p++)d[p-1]=arguments[p];s.emit(c,...d)}),s.init(i,n),s.translator.options=i,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 T=qr.createInstance();T.createInstance=qr.createInstance;T.createInstance;T.dir;T.init;T.loadResources;T.reloadResources;T.use;T.changeLanguage;T.getFixedT;const re=T.t;T.exists;T.setDefaultNamespace;T.hasLoadedNamespace;T.loadNamespaces;T.loadLanguages;var cf=t=>{const n={...{origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[]},...t},r=(i=>typeof i=="string"?i==="*"?()=>i:s=>i===s?s:null:typeof i=="function"?i:s=>i.includes(s)?s:null)(n.origin);return async function(s,a){var d,p;function c(f,m){s.res.headers.set(f,m)}const l=r(s.req.header("origin")||"",s);if(l&&c("Access-Control-Allow-Origin",l),n.origin!=="*"){const f=s.req.header("Vary");f?c("Vary",f):c("Vary","Origin")}if(n.credentials&&c("Access-Control-Allow-Credentials","true"),(d=n.exposeHeaders)!=null&&d.length&&c("Access-Control-Expose-Headers",n.exposeHeaders.join(",")),s.req.method==="OPTIONS"){n.maxAge!=null&&c("Access-Control-Max-Age",n.maxAge.toString()),(p=n.allowMethods)!=null&&p.length&&c("Access-Control-Allow-Methods",n.allowMethods.join(","));let f=n.allowHeaders;if(!(f!=null&&f.length)){const m=s.req.header("Access-Control-Request-Headers");m&&(f=m.split(/\s*,\s*/))}return f!=null&&f.length&&(c("Access-Control-Allow-Headers",f.join(",")),s.res.headers.append("Vary","Access-Control-Request-Headers")),s.res.headers.delete("Content-Length"),s.res.headers.delete("Content-Type"),new Response(null,{headers:s.res.headers,status:204,statusText:s.res.statusText})}await a()}};const an=o.z.object({start:o.z.number(),limit:o.z.number(),length:o.z.number()}),lf=o.z.object({created_at:o.z.string(),updated_at:o.z.string()}),df=o.z.object({email:o.z.string().optional(),email_verified:o.z.boolean().optional(),name:o.z.string().optional(),username:o.z.string().optional(),given_name:o.z.string().optional(),phone_number:o.z.string().optional(),phone_verified:o.z.boolean().optional(),family_name:o.z.string().optional()}).catchall(o.z.any()),uf=o.z.object({connection:o.z.string(),user_id:o.z.string(),provider:o.z.string(),isSocial:o.z.boolean(),access_token:o.z.string().optional(),access_token_secret:o.z.string().optional(),refresh_token:o.z.string().optional(),profileData:df.optional()}),Ys=o.z.object({email:o.z.string().optional(),username:o.z.string().optional(),phone_number:o.z.string().optional(),given_name:o.z.string().optional(),family_name:o.z.string().optional(),nickname:o.z.string().optional(),name:o.z.string().optional(),picture:o.z.string().optional(),locale:o.z.string().optional(),linked_to:o.z.string().optional(),profileData:o.z.string().optional(),user_id:o.z.string().optional(),app_metadata:o.z.any().default({}).optional(),user_metadata:o.z.any().default({}).optional()}),rs=Ys.extend({email_verified:o.z.boolean().default(!1),verify_email:o.z.boolean().optional(),last_ip:o.z.string().optional(),last_login:o.z.string().optional(),user_id:o.z.string().optional(),provider:o.z.string().default("email"),connection:o.z.string().default("email"),is_social:o.z.boolean().optional()}),il=o.z.object({...rs.shape,...lf.shape,user_id:o.z.string(),is_social:o.z.boolean(),email:o.z.string().optional(),login_count:o.z.number(),identities:o.z.array(uf).optional()}),St=il,u0=Ys.extend({email:o.z.string(),login_count:o.z.number(),multifactor:o.z.array(o.z.string()).optional(),last_ip:o.z.string().optional(),last_login:o.z.string().optional(),user_id:o.z.string()}).catchall(o.z.any()),p0="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let f0=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=p0[n[t]&63];return e};const pf=o.z.object({audience:o.z.string().optional(),recipient:o.z.string().optional(),createUpnClaim:o.z.boolean().optional(),mapUnknownClaimsAsIs:o.z.boolean().optional(),passthroughClaimsWithNoMapping:o.z.boolean().optional(),mapIdentities:o.z.boolean().optional(),signatureAlgorithm:o.z.string().optional(),digestAlgorithm:o.z.string().optional(),issuer:o.z.string().optional(),destination:o.z.string().optional(),lifetimeInSeconds:o.z.number().optional(),signResponse:o.z.boolean().optional(),nameIdentifierFormat:o.z.string().optional(),nameIdentifierProbes:o.z.array(o.z.string()).optional(),authnContextClassRef:o.z.string().optional(),mappings:o.z.record(o.z.string()).optional()}),is=o.z.object({id:o.z.string(),name:o.z.string(),callbacks:o.z.array(o.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:o.z.array(o.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:o.z.array(o.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:o.z.array(o.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:o.z.array(o.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:o.z.object({samlp:pf.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:o.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:o.z.string().default(()=>f0()).optional(),disable_sign_ups:o.z.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),mn=o.z.object({created_at:o.z.string().transform(t=>t===null?"":t),updated_at:o.z.string().transform(t=>t===null?"":t),...is.shape});var It=(t=>(t.TOKEN="token",t.TOKEN_ID_TOKEN="token id_token",t.CODE="code",t))(It||{}),Rt=(t=>(t.QUERY="query",t.FRAGMENT="fragment",t.FORM_POST="form_post",t.WEB_MESSAGE="web_message",t.SAML_POST="saml_post",t))(Rt||{}),Xs=(t=>(t.S256="S256",t.Plain="plain",t))(Xs||{});const Mr=o.z.object({client_id:o.z.string(),act_as:o.z.string().optional(),response_type:o.z.nativeEnum(It).optional(),response_mode:o.z.nativeEnum(Rt).optional(),redirect_uri:o.z.string().optional(),audience:o.z.string().optional(),organization:o.z.string().optional(),state:o.z.string().optional(),nonce:o.z.string().optional(),scope:o.z.string().optional(),prompt:o.z.string().optional(),code_challenge_method:o.z.nativeEnum(Xs).optional(),code_challenge:o.z.string().optional(),username:o.z.string().optional(),ui_locales:o.z.string().optional(),vendor_id:o.z.string().optional()}),za=o.z.object({colors:o.z.object({primary:o.z.string(),page_background:o.z.object({type:o.z.string().optional(),start:o.z.string().optional(),end:o.z.string().optional(),angle_deg:o.z.number().optional()}).optional()}).optional(),logo_url:o.z.string().optional(),favicon_url:o.z.string().optional(),font:o.z.object({url:o.z.string()}).optional()}),sl=o.z.object({kid:o.z.string().optional(),team_id:o.z.string().optional(),realms:o.z.string().optional(),client_id:o.z.string().optional(),client_secret:o.z.string().optional(),app_secret:o.z.string().optional(),scope:o.z.string().optional(),authorization_endpoint:o.z.string().optional(),token_endpoint:o.z.string().optional(),userinfo_endpoint:o.z.string().optional(),jwks_uri:o.z.string().optional(),discovery_url:o.z.string().optional(),issuer:o.z.string().optional(),provider:o.z.string().optional(),from:o.z.string().optional(),twilio_sid:o.z.string().optional(),twilio_token:o.z.string().optional()}),ss=o.z.object({id:o.z.string().optional(),name:o.z.string(),strategy:o.z.string(),options:sl.default({}),enabled_clients:o.z.array(o.z.string()).default([]).optional(),response_type:o.z.custom().optional(),response_mode:o.z.custom().optional()}),Jt=o.z.object({id:o.z.string(),created_at:o.z.string().transform(t=>t===null?"":t),updated_at:o.z.string().transform(t=>t===null?"":t)}).extend(ss.shape),os=o.z.object({name:o.z.string(),audience:o.z.string(),sender_email:o.z.string().email(),sender_name:o.z.string(),support_url:o.z.string().url().optional(),logo:o.z.string().url().optional(),primary_color:o.z.string().optional(),secondary_color:o.z.string().optional(),language:o.z.string().optional(),id:o.z.string().optional()}),Jn=o.z.object({created_at:o.z.string().transform(t=>t===null?"":t),updated_at:o.z.string().transform(t=>t===null?"":t),...os.shape,id:o.z.string()}),ff=o.z.object({logoUrl:o.z.string(),loginBackgroundImage:o.z.string().nullish(),style:o.z.object({primaryColor:o.z.string(),buttonTextColor:o.z.string(),primaryHoverColor:o.z.string()}),supportEmail:o.z.string().nullable(),supportUrl:o.z.string().nullable(),name:o.z.string(),showGreyishBackground:o.z.boolean().optional(),termsAndConditionsUrl:o.z.string().nullable(),companyName:o.z.string().optional(),checkoutHideSocial:o.z.boolean().optional(),siteUrl:o.z.string().nullable(),manageSubscriptionsUrl:o.z.string().optional()});o.z.object({...mn.shape,tenant:Jn,connections:o.z.array(Jt)});const hf=o.z.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),gf=o.z.object({code_id:o.z.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:o.z.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:o.z.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:hf,code_verifier:o.z.string().optional().openapi({description:"The code verifier used in PKCE in outbound flows"}),expires_at:o.z.string(),used_at:o.z.string().optional(),user_id:o.z.string().optional()}),h0=o.z.object({...gf.shape,created_at:o.z.string()}),ol=o.z.object({domain:o.z.string(),custom_domain_id:o.z.string().optional(),type:o.z.enum(["auth0_managed_certs","self_managed_certs"]),verification_method:o.z.enum(["txt"]).optional(),tls_policy:o.z.enum(["recommended"]).optional(),custom_client_ip_header:o.z.enum(["true-client-ip","cf-connecting-ip","x-forwarded-for","x-azure-clientip","null"]).optional(),domain_metadata:o.z.record(o.z.string().max(255)).optional()}),mf=o.z.object({name:o.z.literal("txt"),record:o.z.string(),domain:o.z.string()}),Gt=o.z.object({...ol.shape,custom_domain_id:o.z.string(),primary:o.z.boolean(),status:o.z.enum(["disabled","pending","pending_verification","ready"]),origin_domain_name:o.z.string().optional(),verification:o.z.object({methods:o.z.array(mf)}).optional(),tls_policy:o.z.string().optional()}),g0=Gt.extend({tenant_id:o.z.string()}),as=o.z.object({trigger_id:o.z.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:o.z.boolean().default(!1),url:o.z.string(),hook_id:o.z.string().optional(),synchronous:o.z.boolean().default(!1),priority:o.z.number().optional()}),Kn=as.extend({...lf.shape,hook_id:o.z.string()}),al=o.z.object({alg:o.z.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:o.z.string(),kid:o.z.string(),kty:o.z.enum(["RSA","EC","oct"]),n:o.z.string(),x5t:o.z.string().optional(),x5c:o.z.array(o.z.string()).optional(),use:o.z.enum(["sig","enc"]).optional()}),_f=o.z.object({keys:o.z.array(al)}),Ea=o.z.object({issuer:o.z.string(),authorization_endpoint:o.z.string(),token_endpoint:o.z.string(),device_authorization_endpoint:o.z.string(),userinfo_endpoint:o.z.string(),mfa_challenge_endpoint:o.z.string(),jwks_uri:o.z.string(),registration_endpoint:o.z.string(),revocation_endpoint:o.z.string(),scopes_supported:o.z.array(o.z.string()),response_types_supported:o.z.array(o.z.string()),code_challenge_methods_supported:o.z.array(o.z.string()),response_modes_supported:o.z.array(o.z.string()),subject_types_supported:o.z.array(o.z.string()),id_token_signing_alg_values_supported:o.z.array(o.z.string()),token_endpoint_auth_methods_supported:o.z.array(o.z.string()),claims_supported:o.z.array(o.z.string()),request_uri_parameter_supported:o.z.boolean(),request_parameter_supported:o.z.boolean(),token_endpoint_auth_signing_alg_values_supported:o.z.array(o.z.string())}),yf=o.z.object({csrf_token:o.z.string(),auth0Client:o.z.string().optional(),authParams:Mr,expires_at:o.z.string(),deleted_at:o.z.string().optional(),ip:o.z.string().optional(),useragent:o.z.string().optional(),session_id:o.z.string().optional(),authorization_url:o.z.string().optional()}).openapi({description:"This represents a login sesion"}),m0=o.z.object({...yf.shape,id:o.z.string().openapi({description:"This is is used as the state in the universal login"}),created_at:o.z.string(),updated_at:o.z.string()});var ge=(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))(ge||{});const _0=o.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"]),wf=o.z.object({name:o.z.string(),version:o.z.string(),env:o.z.object({node:o.z.string().optional()}).optional()}),cs=o.z.object({type:_0,date:o.z.string(),description:o.z.string().optional(),log_id:o.z.string().optional(),_id:o.z.string().optional(),ip:o.z.string(),user_agent:o.z.string(),details:o.z.any().optional(),isMobile:o.z.boolean(),user_id:o.z.string().optional(),user_name:o.z.string().optional(),connection:o.z.string().optional(),connection_id:o.z.string().optional(),client_id:o.z.string().optional(),client_name:o.z.string().optional(),audience:o.z.string().optional(),scope:o.z.array(o.z.string()).optional(),strategy:o.z.string().optional(),strategy_type:o.z.string().optional(),hostname:o.z.string().optional(),auth0_client:wf.optional()}),vf=o.z.object({user_id:o.z.string(),password:o.z.string(),algorithm:o.z.enum(["bcrypt","argon2id"]).default("argon2id")}),y0=o.z.object({...vf.shape,created_at:o.z.string(),updated_at:o.z.string()}),bf=o.z.object({initial_user_agent:o.z.string().describe("First user agent of the device from which this user logged in"),initial_ip:o.z.string().describe("First IP address associated with this session"),initial_asn:o.z.string().describe("First autonomous system number associated with this session"),last_user_agent:o.z.string().describe("Last user agent of the device from which this user logged in"),last_ip:o.z.string().describe("Last IP address from which this user logged in"),last_asn:o.z.string().describe("Last autonomous system number from which this user logged in")}),xf=o.z.object({id:o.z.string(),revoked_at:o.z.string().optional(),used_at:o.z.string().optional(),user_id:o.z.string().describe("The user ID associated with the session"),expires_at:o.z.string().optional(),idle_expires_at:o.z.string().optional(),device:bf.describe("Metadata related to the device used in the session"),clients:o.z.array(o.z.string()).describe("List of client details for the session")}),Qs=o.z.object({created_at:o.z.string(),updated_at:o.z.string(),authenticated_at:o.z.string(),last_interaction_at:o.z.string(),...xf.shape}),Ia=o.z.object({kid:o.z.string().openapi({description:"The key id of the signing key"}),cert:o.z.string().openapi({description:"The public certificate of the signing key"}),fingerprint:o.z.string().openapi({description:"The cert fingerprint"}),thumbprint:o.z.string().openapi({description:"The cert thumbprint"}),pkcs7:o.z.string().optional().openapi({description:"The private key in pkcs7 format"}),current:o.z.boolean().optional().openapi({description:"True if the key is the current key"}),next:o.z.boolean().optional().openapi({description:"True if the key is the next key"}),previous:o.z.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:o.z.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:o.z.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:o.z.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:o.z.string().optional().openapi({description:"The date and time when the key was revoked"})});var Wn=(t=>(t.RefreshToken="refresh_token",t.AuthorizationCode="authorization_code",t.ClientCredential="client_credentials",t.Passwordless="passwordless",t.Password="password",t.OTP="http://auth0.com/oauth/grant-type/passwordless/otp",t))(Wn||{});const kf=o.z.object({access_token:o.z.string(),id_token:o.z.string().optional(),scope:o.z.string().optional(),state:o.z.string().optional(),refresh_token:o.z.string().optional(),token_type:o.z.string(),expires_in:o.z.number()});o.z.object({code:o.z.string(),state:o.z.string().optional()});const Sf=o.z.object({button_border_radius:o.z.number(),button_border_weight:o.z.number(),buttons_style:o.z.enum(["pill"]),input_border_radius:o.z.number(),input_border_weight:o.z.number(),inputs_style:o.z.enum(["pill"]),show_widget_shadow:o.z.boolean(),widget_border_weight:o.z.number(),widget_corner_radius:o.z.number()}),Af=o.z.object({base_focus_color:o.z.string(),base_hover_color:o.z.string(),body_text:o.z.string(),captcha_widget_theme:o.z.enum(["auto"]),error:o.z.string(),header:o.z.string(),icons:o.z.string(),input_background:o.z.string(),input_border:o.z.string(),input_filled_text:o.z.string(),input_labels_placeholders:o.z.string(),links_focused_components:o.z.string(),primary_button:o.z.string(),primary_button_label:o.z.string(),secondary_button_border:o.z.string(),secondary_button_label:o.z.string(),success:o.z.string(),widget_background:o.z.string(),widget_border:o.z.string()}),hn=o.z.object({bold:o.z.boolean(),size:o.z.number()}),zf=o.z.object({body_text:hn,buttons_text:hn,font_url:o.z.string(),input_labels:hn,links:hn,links_style:o.z.enum(["normal"]),reference_text_size:o.z.number(),subtitle:hn,title:hn}),Ef=o.z.object({background_color:o.z.string(),background_image_url:o.z.string(),page_layout:o.z.enum(["center"])}),If=o.z.object({header_text_alignment:o.z.enum(["center"]),logo_height:o.z.number(),logo_position:o.z.enum(["center"]),logo_url:o.z.string(),social_buttons_layout:o.z.enum(["bottom"])}),Cf=o.z.object({borders:Sf,colors:Af,displayName:o.z.string(),fonts:zf,page_background:Ef,widget:If}),w0=Cf.extend({themeId:o.z.string()}),Ui=o.z.object({universal_login_experience:o.z.enum(["new","classic"]).default("new"),identifier_first:o.z.boolean().default(!0),password_first:o.z.boolean().default(!1),webauthn_platform_first_factor:o.z.boolean()}),Vi=o.z.object({name:o.z.string(),enabled:o.z.boolean().optional().default(!0),default_from_address:o.z.string().optional(),credentials:o.z.union([o.z.object({accessKeyId:o.z.string(),secretAccessKey:o.z.string(),region:o.z.string()}),o.z.object({smtp_host:o.z.array(o.z.string()),smtp_port:o.z.number(),smtp_user:o.z.string(),smtp_pass:o.z.string()}),o.z.object({api_key:o.z.string(),domain:o.z.string().optional()}),o.z.object({connectionString:o.z.string()}),o.z.object({tenantId:o.z.string(),clientId:o.z.string(),clientSecret:o.z.string()})]),settings:o.z.object({}).optional()}),cl=o.z.object({id:o.z.string(),session_id:o.z.string(),user_id:o.z.string(),client_id:o.z.string(),expires_at:o.z.string().optional(),idle_expires_at:o.z.string().optional(),last_exchanged_at:o.z.string().optional(),device:bf,resource_servers:o.z.array(o.z.object({audience:o.z.string(),scopes:o.z.string()})),rotating:o.z.boolean()}),v0=o.z.object({created_at:o.z.string(),...cl.shape}),b0=o.z.object({to:o.z.string(),message:o.z.string()}),x0=o.z.object({name:o.z.string(),options:o.z.object({})});function k0(t){const[e,n]=t.split("|");if(!e||!n)throw new Error(`Invalid user_id: ${t}`);return{connection:e,id:n}}const S0=new o.OpenAPIHono().openapi(o.createRoute({tags:["branding"],method:"get",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:za}},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(o.createRoute({tags:["branding"],method:"patch",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(za.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 I=class extends Error{constructor(e=500,n){super(n==null?void 0:n.message,{cause:n==null?void 0:n.cause});te(this,"res");te(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})}},ls=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Nf(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function A0(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?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(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}function z0(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 jf={exports:{}};const E0={},I0=Object.freeze(Object.defineProperty({__proto__:null,default:E0},Symbol.toStringTag,{value:"Module"})),C0=A0(I0);(function(t){/**
1
+ "use strict";var Gm=Object.defineProperty;var Jm=(t,e,n)=>e in t?Gm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var te=(t,e,n)=>Jm(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@hono/zod-openapi"),ne=t=>typeof t=="string",Er=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},$d=t=>t==null?"":""+t,Zm=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Ym=/###/g,Od=t=>t&&t.indexOf("###")>-1?t.replace(Ym,"."):t,Pd=t=>!t||ne(t),Pr=(t,e,n)=>{const r=ne(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(Pd(t))return{};const s=Od(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return Pd(t)?{}:{obj:t,k:Od(r[i])}},Td=(t,e,n)=>{const{obj:r,k:i}=Pr(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let s=e[e.length-1],a=e.slice(0,e.length-1),c=Pr(t,a,Object);for(;c.obj===void 0&&a.length;)s=`${a[a.length-1]}.${s}`,a=a.slice(0,a.length-1),c=Pr(t,a,Object),c!=null&&c.obj&&typeof c.obj[`${c.k}.${s}`]<"u"&&(c.obj=void 0);c.obj[`${c.k}.${s}`]=n},Xm=(t,e,n,r)=>{const{obj:i,k:s}=Pr(t,e,Object);i[s]=i[s]||[],i[s].push(n)},Qi=(t,e)=>{const{obj:n,k:r}=Pr(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Qm=(t,e,n)=>{const r=Qi(t,n);return r!==void 0?r:Qi(e,n)},cf=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?ne(t[r])||t[r]instanceof String||ne(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):cf(t[r],e[r],n):t[r]=e[r]);return t},Vn=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var e0={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const t0=t=>ne(t)?t.replace(/[&<>"'\/]/g,e=>e0[e]):t;class n0{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 r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}const r0=[" ",",","?","!",";"],i0=new n0(20),s0=(t,e,n)=>{e=e||"",n=n||"";const r=r0.filter(a=>e.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const i=i0.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let s=!i.test(t);if(!s){const a=t.indexOf(n);a>0&&!i.test(t.substring(0,a))&&(s=!0)}return s},Aa=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 r=e.split(n);let i=t;for(let s=0;s<r.length;){if(!i||typeof i!="object")return;let a,c="";for(let l=s;l<r.length;++l)if(l!==s&&(c+=n),c+=r[l],a=i[c],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&l<r.length-1)continue;s+=l-s+1;break}i=a}return i},es=t=>t==null?void 0:t.replace("_","-"),o0={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,r;(r=(n=console==null?void 0:console[t])==null?void 0:n.apply)==null||r.call(n,console,e)}};class ts{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||o0,this.options=n,this.debug=n.debug}log(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"log","",!0)}warn(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"warn","",!0)}error(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"error","")}deprecate(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,r,i){return i&&!this.debug?null:(ne(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new ts(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new ts(this.logger,e)}}var At=new ts;class Zs{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+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,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];this.observers[e]&&Array.from(this.observers[e].entries()).forEach(a=>{let[c,l]=a;for(let d=0;d<l;d++)c(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[c,l]=a;for(let d=0;d<l;d++)c.apply(c,[e,...r])})}}class Bd extends Zs{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,r){var d,p;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const s=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,a=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let c;e.indexOf(".")>-1?c=e.split("."):(c=[e,n],r&&(Array.isArray(r)?c.push(...r):ne(r)&&s?c.push(...r.split(s)):c.push(r)));const l=Qi(this.data,c);return!l&&!n&&!r&&e.indexOf(".")>-1&&(e=c[0],n=c[1],r=c.slice(2).join(".")),l||!a||!ne(r)?l:Aa((p=(d=this.data)==null?void 0:d[e])==null?void 0:p[n],r,s)}addResource(e,n,r,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator;let c=[e,n];r&&(c=c.concat(a?r.split(a):r)),e.indexOf(".")>-1&&(c=e.split("."),i=n,n=c[1]),this.addNamespaces(n),Td(this.data,c,i),s.silent||this.emit("added",e,n,r,i)}addResources(e,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const s in r)(ne(r[s])||Array.isArray(r[s]))&&this.addResource(e,n,s,r[s],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,s){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},c=[e,n];e.indexOf(".")>-1&&(c=e.split("."),i=r,r=n,n=c[1]),this.addNamespaces(n);let l=Qi(this.data,c)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?cf(l,r,s):l={...l,...r},Td(this.data,c,l),a.silent||this.emit("added",e,n,r)}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(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var lf={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(s=>{var a;e=((a=this.processors[s])==null?void 0:a.process(e,n,r,i))??e}),e}};const Rd={};class ns extends Zs{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Zm(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=At.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 r=this.resolve(e,n);return(r==null?void 0:r.res)!==void 0}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let s=n.ns||this.options.defaultNS||[];const a=r&&e.indexOf(r)>-1,c=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!s0(e,r,i);if(a&&!c){const l=e.match(this.interpolator.nestingRegexp);if(l&&l.length>0)return{key:e,namespaces:ne(s)?[s]:s};const d=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(d[0])>-1)&&(s=d.shift()),e=d.join(i)}return{key:e,namespaces:ne(s)?[s]:s}}translate(e,n,r){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 i=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,s=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,namespaces:c}=this.extractFromKey(e[e.length-1],n),l=c[c.length-1],d=n.lng||this.language,p=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((d==null?void 0:d.toLowerCase())==="cimode"){if(p){const L=n.nsSeparator||this.options.nsSeparator;return i?{res:`${l}${L}${a}`,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${L}${a}`}return i?{res:a,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:a}const f=this.resolve(e,n);let m=f==null?void 0:f.res;const w=(f==null?void 0:f.usedKey)||a,h=(f==null?void 0:f.exactUsedKey)||a,_=Object.prototype.toString.apply(m),v=["[object Number]","[object Function]","[object RegExp]"],S=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,C=!this.i18nFormat||this.i18nFormat.handleAsObject,O=!ne(m)&&typeof m!="boolean"&&typeof m!="number";if(C&&m&&O&&v.indexOf(_)<0&&!(ne(S)&&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 L=this.options.returnedObjectHandler?this.options.returnedObjectHandler(w,m,{...n,ns:c}):`key '${a} (${this.language})' returned an object instead of string.`;return i?(f.res=L,f.usedParams=this.getUsedParamsDetails(n),f):L}if(s){const L=Array.isArray(m),Q=L?[]:{},ce=L?h:w;for(const le in m)if(Object.prototype.hasOwnProperty.call(m,le)){const De=`${ce}${s}${le}`;Q[le]=this.translate(De,{...n,joinArrays:!1,ns:c}),Q[le]===De&&(Q[le]=m[le])}m=Q}}else if(C&&ne(S)&&Array.isArray(m))m=m.join(S),m&&(m=this.extendTranslation(m,e,n,r));else{let L=!1,Q=!1;const ce=n.count!==void 0&&!ne(n.count),le=ns.hasDefaultValue(n),De=ce?this.pluralResolver.getSuffix(d,n.count,n):"",Ve=n.ordinal&&ce?this.pluralResolver.getSuffix(d,n.count,{ordinal:!1}):"",Re=ce&&!n.ordinal&&n.count===0,j=Re&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${De}`]||n[`defaultValue${Ve}`]||n.defaultValue;!this.isValidLookup(m)&&le&&(L=!0,m=j),this.isValidLookup(m)||(Q=!0,m=a);const z=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&Q?void 0:m,k=le&&j!==m&&this.options.updateMissing;if(Q||L||k){if(this.logger.log(k?"updateKey":"missingKey",d,l,a,k?j:m),s){const X=this.resolve(a,{...n,keySeparator:!1});X&&X.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 x=[];const $=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&$&&$[0])for(let X=0;X<$.length;X++)x.push($[X]);else this.options.saveMissingTo==="all"?x=this.languageUtils.toResolveHierarchy(n.lng||this.language):x.push(n.lng||this.language);const U=(X,G,se)=>{var D;const ue=le&&se!==m?se:z;this.options.missingKeyHandler?this.options.missingKeyHandler(X,l,G,ue,k,n):(D=this.backendConnector)!=null&&D.saveMissing&&this.backendConnector.saveMissing(X,l,G,ue,k,n),this.emit("missingKey",X,l,G,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&ce?x.forEach(X=>{const G=this.pluralResolver.getSuffixes(X,n);Re&&n[`defaultValue${this.options.pluralSeparator}zero`]&&G.indexOf(`${this.options.pluralSeparator}zero`)<0&&G.push(`${this.options.pluralSeparator}zero`),G.forEach(se=>{U([X],a+se,n[`defaultValue${se}`]||j)})}):U(x,a,j))}m=this.extendTranslation(m,e,n,f,r),Q&&m===a&&this.options.appendNamespaceToMissingKey&&(m=`${l}:${a}`),(Q||L)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}:${a}`:a,L?m:void 0))}return i?(f.res=m,f.usedParams=this.getUsedParamsDetails(n),f):m}extendTranslation(e,n,r,i,s){var d,p;var a=this;if((d=this.i18nFormat)!=null&&d.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const f=ne(e)&&(((p=r==null?void 0:r.interpolation)==null?void 0:p.skipOnVariables)!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let m;if(f){const h=e.match(this.interpolator.nestingRegexp);m=h&&h.length}let w=r.replace&&!ne(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(w={...this.options.interpolation.defaultVariables,...w}),e=this.interpolator.interpolate(e,w,r.lng||this.language||i.usedLng,r),f){const h=e.match(this.interpolator.nestingRegexp),_=h&&h.length;m<_&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,function(){for(var h=arguments.length,_=new Array(h),v=0;v<h;v++)_[v]=arguments[v];return(s==null?void 0:s[0])===_[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${_[0]} in key: ${n[0]}`),null):a.translate(..._,n)},r)),r.interpolation&&this.interpolator.reset()}const c=r.postProcess||this.options.postProcess,l=ne(c)?[c]:c;return e!=null&&(l!=null&&l.length)&&r.applyPostProcessor!==!1&&(e=lf.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,i,s,a,c;return ne(e)&&(e=[e]),e.forEach(l=>{if(this.isValidLookup(r))return;const d=this.extractFromKey(l,n),p=d.key;i=p;let f=d.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const m=n.count!==void 0&&!ne(n.count),w=m&&!n.ordinal&&n.count===0,h=n.context!==void 0&&(ne(n.context)||typeof n.context=="number")&&n.context!=="",_=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(v=>{var S,C;this.isValidLookup(r)||(c=v,!Rd[`${_[0]}-${v}`]&&((S=this.utils)!=null&&S.hasLoadedNamespace)&&!((C=this.utils)!=null&&C.hasLoadedNamespace(c))&&(Rd[`${_[0]}-${v}`]=!0,this.logger.warn(`key "${i}" 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(O=>{var ce;if(this.isValidLookup(r))return;a=O;const L=[p];if((ce=this.i18nFormat)!=null&&ce.addLookupKeys)this.i18nFormat.addLookupKeys(L,p,O,v,n);else{let le;m&&(le=this.pluralResolver.getSuffix(O,n.count,n));const De=`${this.options.pluralSeparator}zero`,Ve=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(L.push(p+le),n.ordinal&&le.indexOf(Ve)===0&&L.push(p+le.replace(Ve,this.options.pluralSeparator)),w&&L.push(p+De)),h){const Re=`${p}${this.options.contextSeparator}${n.context}`;L.push(Re),m&&(L.push(Re+le),n.ordinal&&le.indexOf(Ve)===0&&L.push(Re+le.replace(Ve,this.options.pluralSeparator)),w&&L.push(Re+De))}}let Q;for(;Q=L.pop();)this.isValidLookup(r)||(s=Q,r=this.getResource(O,v,Q,n))}))})}),{res:r,usedKey:i,exactUsedKey:s,usedLng:a,usedNS:c}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,n,r){var s;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return(s=this.i18nFormat)!=null&&s.getResource?this.i18nFormat.getResource(e,n,r,i):this.resourceStore.getResource(e,n,r,i)}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"],r=e.replace&&!ne(e.replace);let i=r?e.replace:e;if(r&&typeof e.count<"u"&&(i.count=e.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const s of n)delete i[s]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class Ld{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=At.create("languageUtils")}getScriptPartFromCode(e){if(e=es(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=es(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(ne(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(r=>{if(n)return;const i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&e.forEach(r=>{if(n)return;const i=this.getLanguagePartFromCode(r);if(this.isSupportedCode(i))return n=i;n=this.options.supportedLngs.find(s=>{if(s===i)return s;if(!(s.indexOf("-")<0&&i.indexOf("-")<0)&&(s.indexOf("-")>0&&i.indexOf("-")<0&&s.substring(0,s.indexOf("-"))===i||s.indexOf(i)===0&&i.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)),ne(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let r=e[n];return r||(r=e[this.getScriptPartFromCode(n)]),r||(r=e[this.formatLanguageCode(n)]),r||(r=e[this.getLanguagePartFromCode(n)]),r||(r=e.default),r||[]}toResolveHierarchy(e,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],e),i=[],s=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return ne(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))):ne(e)&&s(this.formatLanguageCode(e)),r.forEach(a=>{i.indexOf(a)<0&&s(this.formatLanguageCode(a))}),i}}const Ud={zero:0,one:1,two:2,few:3,many:4,other:5},Vd={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class a0{constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=n,this.logger=At.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 r=es(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",s=JSON.stringify({cleanedCode:r,type:i});if(s in this.pluralRulesCache)return this.pluralRulesCache[s];let a;try{a=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),Vd;if(!e.match(/-|_/))return Vd;const l=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(l,n)}return this.pluralRulesCache[s]=a,a}needsPlural(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),(r==null?void 0:r.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,r).map(i=>`${n}${i}`)}getSuffixes(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(e,n);return r||(r=this.getRule("dev",n)),r?r.resolvedOptions().pluralCategories.sort((i,s)=>Ud[i]-Ud[s]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const qd=function(t,e,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=Qm(t,e,n);return!s&&i&&ne(n)&&(s=Aa(t,n,r),s===void 0&&(s=Aa(e,n,r))),s},ra=t=>t.replace(/\$/g,"$$$$");class c0{constructor(){var n;let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=At.create("interpolator"),this.options=e,this.format=((n=e==null?void 0:e.interpolation)==null?void 0:n.format)||(r=>r),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:r,useRawValueToEscape:i,prefix:s,prefixEscaped:a,suffix:c,suffixEscaped:l,formatSeparator:d,unescapeSuffix:p,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:w,nestingSuffix:h,nestingSuffixEscaped:_,nestingOptionsSeparator:v,maxReplaces:S,alwaysFormat:C}=e.interpolation;this.escape=n!==void 0?n:t0,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?Vn(s):a||"{{",this.suffix=c?Vn(c):l||"}}",this.formatSeparator=d||",",this.unescapePrefix=p?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":p||"",this.nestingPrefix=m?Vn(m):w||Vn("$t("),this.nestingSuffix=h?Vn(h):_||Vn(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=S||1e3,this.alwaysFormat=C!==void 0?C:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(n,r)=>(n==null?void 0:n.source)===r?(n.lastIndex=0,n):new RegExp(r,"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,r,i){var w;let s,a,c;const l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=h=>{if(h.indexOf(this.formatSeparator)<0){const C=qd(n,l,h,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(C,void 0,r,{...i,...n,interpolationkey:h}):C}const _=h.split(this.formatSeparator),v=_.shift().trim(),S=_.join(this.formatSeparator).trim();return this.format(qd(n,l,v,this.options.keySeparator,this.options.ignoreJSONStructure),S,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const p=(i==null?void 0:i.missingInterpolationHandler)||this.options.missingInterpolationHandler,f=((w=i==null?void 0:i.interpolation)==null?void 0:w.skipOnVariables)!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:h=>ra(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?ra(this.escape(h)):ra(h)}].forEach(h=>{for(c=0;s=h.regex.exec(e);){const _=s[1].trim();if(a=d(_),a===void 0)if(typeof p=="function"){const S=p(e,s,i);a=ne(S)?S:""}else if(i&&Object.prototype.hasOwnProperty.call(i,_))a="";else if(f){a=s[0];continue}else this.logger.warn(`missed to pass in variable ${_} for interpolating ${e}`),a="";else!ne(a)&&!this.useRawValueToEscape&&(a=$d(a));const v=h.safeValue(a);if(e=e.replace(s[0],v),f?(h.regex.lastIndex+=a.length,h.regex.lastIndex-=s[0].length):h.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),e}nest(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i,s,a;const c=(l,d)=>{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,a);const w=m.match(/'/g),h=m.match(/"/g);(((w==null?void 0:w.length)??0)%2===0&&!h||h.length%2!==0)&&(m=m.replace(/'/g,'"'));try{a=JSON.parse(m),d&&(a={...d,...a})}catch(_){return this.logger.warn(`failed parsing options string in nesting for key ${l}`,_),`${l}${p}${m}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,l};for(;i=this.nestingRegexp.exec(e);){let l=[];a={...r},a=a.replace&&!ne(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let d=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const p=i[1].split(this.formatSeparator).map(f=>f.trim());i[1]=p.shift(),l=p,d=!0}if(s=n(c.call(this,i[1].trim(),a),a),s&&i[0]===e&&!ne(s))return s;ne(s)||(s=$d(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),d&&(s=l.reduce((p,f)=>this.format(p,f,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const l0=t=>{let e=t.toLowerCase().trim();const n={};if(t.indexOf("(")>-1){const r=t.split("(");e=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);e==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):e==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(a=>{if(a){const[c,...l]=a.split(":"),d=l.join(":").trim().replace(/^'+|'+$/g,""),p=c.trim();n[p]||(n[p]=d),d==="false"&&(n[p]=!1),d==="true"&&(n[p]=!0),isNaN(d)||(n[p]=parseInt(d,10))}})}return{formatName:e,formatOptions:n}},qn=t=>{const e={};return(n,r,i)=>{let s=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(s={...s,[i.interpolationkey]:void 0});const a=r+JSON.stringify(s);let c=e[a];return c||(c=t(es(r),i),e[a]=c),c(n)}};class d0{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=At.create("formatter"),this.options=e,this.formats={number:qn((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return s=>i.format(s)}),currency:qn((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return s=>i.format(s)}),datetime:qn((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return s=>i.format(s)}),relativetime:qn((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return s=>i.format(s,r.range||"day")}),list:qn((n,r)=>{const i=new Intl.ListFormat(n,{...r});return s=>i.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()]=qn(n)}format(e,n,r){let i=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:d,formatOptions:p}=l0(l);if(this.formats[d]){let m=c;try{const w=((f=i==null?void 0:i.formatParams)==null?void 0:f[i.interpolationkey])||{},h=w.locale||w.lng||i.locale||i.lng||r;m=this.formats[d](c,h,{...p,...i,...w})}catch(w){this.logger.warn(w)}return m}else this.logger.warn(`there was no format function for ${d}`);return c},e)}}const u0=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class p0 extends Zs{constructor(e,n,r){var s,a;let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=At.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],(a=(s=this.backend)==null?void 0:s.init)==null||a.call(s,r,i.backend,i)}queueLoad(e,n,r,i){const s={},a={},c={},l={};return e.forEach(d=>{let p=!0;n.forEach(f=>{const m=`${d}|${f}`;!r.reload&&this.store.hasResourceBundle(d,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?a[m]===void 0&&(a[m]=!0):(this.state[m]=1,p=!1,a[m]===void 0&&(a[m]=!0),s[m]===void 0&&(s[m]=!0),l[f]===void 0&&(l[f]=!0)))}),p||(c[d]=!0)}),(Object.keys(s).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(s),pending:Object.keys(a),toLoadLanguages:Object.keys(c),toLoadNamespaces:Object.keys(l)}}loaded(e,n,r){const i=e.split("|"),s=i[0],a=i[1];n&&this.emit("failedLoading",s,a,n),!n&&r&&this.store.addResourceBundle(s,a,r,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&r&&(this.state[e]=0);const c={};this.queue.forEach(l=>{Xm(l.loaded,[s],a),u0(l,e),n&&l.errors.push(n),l.pendingCount===0&&!l.done&&(Object.keys(l.loaded).forEach(d=>{c[d]||(c[d]={});const p=l.loaded[d];p.length&&p.forEach(f=>{c[d][f]===void 0&&(c[d][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,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:s,callback:a});return}this.readingCalls++;const c=(d,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(d&&p&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,s*2,a)},s);return}a(d,p)},l=this.backend[r].bind(this.backend);if(l.length===2){try{const d=l(e,n);d&&typeof d.then=="function"?d.then(p=>c(null,p)).catch(c):c(null,d)}catch(d){c(d)}return}return l(e,n,c)}prepareLoading(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=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."),i&&i();ne(e)&&(e=this.languageUtils.toResolveHierarchy(e)),ne(n)&&(n=[n]);const s=this.queueLoad(e,n,r,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach(a=>{this.loadOne(a)})}load(e,n,r){this.prepareLoading(e,n,{},r)}reload(e,n,r){this.prepareLoading(e,n,{reload:!0},r)}loadOne(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=e.split("|"),i=r[0],s=r[1];this.read(i,s,"read",void 0,void 0,(a,c)=>{a&&this.logger.warn(`${n}loading namespace ${s} for language ${i} failed`,a),!a&&c&&this.logger.log(`${n}loaded namespace ${s} for language ${i}`,c),this.loaded(e,a,c)})}saveMissing(e,n,r,i,s){var l,d,p,f,m;let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if((d=(l=this.services)==null?void 0:l.utils)!=null&&d.hasLoadedNamespace&&!((f=(p=this.services)==null?void 0:p.utils)!=null&&f.hasLoadedNamespace(n))){this.logger.warn(`did not save key "${r}" 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(!(r==null||r==="")){if((m=this.backend)!=null&&m.create){const w={...a,isUpdate:s},h=this.backend.create.bind(this.backend);if(h.length<6)try{let _;h.length===5?_=h(e,n,r,i,w):_=h(e,n,r,i),_&&typeof _.then=="function"?_.then(v=>c(null,v)).catch(c):c(null,_)}catch(_){c(_)}else h(e,n,r,i,c,w)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const Md=()=>({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]),ne(t[1])&&(e.defaultValue=t[1]),ne(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const n=t[3]||t[2];Object.keys(n).forEach(r=>{e[r]=n[r]})}return e},interpolation:{escapeValue:!0,format:t=>t,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),Hd=t=>{var e,n;return ne(t.ns)&&(t.ns=[t.ns]),ne(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),ne(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},$i=()=>{},f0=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class qr extends Zs{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Hd(e),this.services={},this.logger=At,this.modules={external:[]},f0(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]:{},r=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(ne(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const i=Md();this.options={...i,...this.options,...Hd(n)},this.options.interpolation={...i.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?At.init(s(this.modules.logger),this.options):At.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:p=d0;const f=new Ld(this.options);this.store=new Bd(this.options.resources,this.options);const m=this.services;m.logger=At,m.resourceStore=this.store,m.languageUtils=f,m.pluralResolver=new a0(f,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),p&&(!this.options.interpolation.format||this.options.interpolation.format===i.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 c0(this.options),m.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},m.backendConnector=new p0(s(this.modules.backend),m.resourceStore,m,this.options),m.backendConnector.on("*",function(w){for(var h=arguments.length,_=new Array(h>1?h-1:0),v=1;v<h;v++)_[v-1]=arguments[v];e.emit(w,..._)}),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 ns(this.services,this.options),this.translator.on("*",function(w){for(var h=arguments.length,_=new Array(h>1?h-1:0),v=1;v<h;v++)_[v-1]=arguments[v];e.emit(w,..._)}),this.modules.external.forEach(w=>{w.init&&w.init(this)})}if(this.format=this.options.interpolation.format,r||(r=$i),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=Er(),d=()=>{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),r(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?d():setTimeout(d,0),l}loadResources(e){var s,a;let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:$i;const i=ne(e)?e:this.language;if(typeof e=="function"&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if((i==null?void 0:i.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const c=[],l=d=>{if(!d||d==="cimode")return;this.services.languageUtils.toResolveHierarchy(d).forEach(f=>{f!=="cimode"&&c.indexOf(f)<0&&c.push(f)})};i?l(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(p=>l(p)),(a=(s=this.options.preload)==null?void 0:s.forEach)==null||a.call(s,d=>l(d)),this.services.backendConnector.load(c,this.options.ns,d=>{!d&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(d)})}else r(null)}reloadResources(e,n,r){const i=Er();return typeof e=="function"&&(r=e,e=void 0),typeof n=="function"&&(r=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),r||(r=$i),this.services.backendConnector.reload(e,n,s=>{i.resolve(),r(s)}),i}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"&&lf.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 r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}changeLanguage(e,n){var r=this;this.isLanguageChangingTo=e;const i=Er();this.emit("languageChanging",e);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},a=(l,d)=>{d?(s(d),this.translator.changeLanguage(d),this.isLanguageChangingTo=void 0,this.emit("languageChanged",d),this.logger.log("languageChanged",d)):this.isLanguageChangingTo=void 0,i.resolve(function(){return r.t(...arguments)}),n&&n(l,function(){return r.t(...arguments)})},c=l=>{var p,f;!e&&!l&&this.services.languageDetector&&(l=[]);const d=ne(l)?l:this.services.languageUtils.getBestMatchFromCodes(l);d&&(this.language||s(d),this.translator.language||this.translator.changeLanguage(d),(f=(p=this.services.languageDetector)==null?void 0:p.cacheUserLanguage)==null||f.call(p,d)),this.loadResources(d,m=>{a(m,d)})};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),i}getFixedT(e,n,r){var i=this;const s=function(a,c){let l;if(typeof c!="object"){for(var d=arguments.length,p=new Array(d>2?d-2:0),f=2;f<d;f++)p[f-2]=arguments[f];l=i.options.overloadTranslationOptionHandler([a,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||r||s.keyPrefix);const m=i.options.keySeparator||".";let w;return l.keyPrefix&&Array.isArray(a)?w=a.map(h=>`${l.keyPrefix}${m}${h}`):w=l.keyPrefix?`${l.keyPrefix}${m}${a}`:a,i.t(w,l)};return ne(e)?s.lng=e:s.lngs=e,s.ns=n,s.keyPrefix=r,s}t(){var i;for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(i=this.translator)==null?void 0:i.translate(...n)}exists(){var i;for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return(i=this.translator)==null?void 0:i.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 r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,s=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(c,l)=>{const d=this.services.backendConnector.state[`${c}|${l}`];return d===-1||d===0||d===2};if(n.precheck){const c=n.precheck(this,a);if(c!==void 0)return c}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,e)&&(!i||a(s,e)))}loadNamespaces(e,n){const r=Er();return this.options.ns?(ne(e)&&(e=[e]),e.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(e,n){const r=Er();ne(e)&&(e=[e]);const i=this.options.preload||[],s=e.filter(a=>i.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return s.length?(this.options.preload=i.concat(s),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(e){var i,s;if(e||(e=this.resolvedLanguage||(((i=this.languages)==null?void 0:i.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"],r=((s=this.services)==null?void 0:s.languageUtils)||new Ld(Md());return n.indexOf(r.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 qr(e,n)}cloneInstance(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:$i;const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new qr(i);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)},r){const c=Object.keys(this.store.data).reduce((l,d)=>(l[d]={...this.store.data[d]},Object.keys(l[d]).reduce((p,f)=>(p[f]={...l[d][f]},p),{})),{});s.store=new Bd(c,i),s.services.resourceStore=s.store}return s.translator=new ns(s.services,i),s.translator.on("*",function(c){for(var l=arguments.length,d=new Array(l>1?l-1:0),p=1;p<l;p++)d[p-1]=arguments[p];s.emit(c,...d)}),s.init(i,n),s.translator.options=i,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 T=qr.createInstance();T.createInstance=qr.createInstance;T.createInstance;T.dir;T.init;T.loadResources;T.reloadResources;T.use;T.changeLanguage;T.getFixedT;const re=T.t;T.exists;T.setDefaultNamespace;T.hasLoadedNamespace;T.loadNamespaces;T.loadLanguages;var df=t=>{const n={...{origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[]},...t},r=(i=>typeof i=="string"?i==="*"?()=>i:s=>i===s?s:null:typeof i=="function"?i:s=>i.includes(s)?s:null)(n.origin);return async function(s,a){var d,p;function c(f,m){s.res.headers.set(f,m)}const l=r(s.req.header("origin")||"",s);if(l&&c("Access-Control-Allow-Origin",l),n.origin!=="*"){const f=s.req.header("Vary");f?c("Vary",f):c("Vary","Origin")}if(n.credentials&&c("Access-Control-Allow-Credentials","true"),(d=n.exposeHeaders)!=null&&d.length&&c("Access-Control-Expose-Headers",n.exposeHeaders.join(",")),s.req.method==="OPTIONS"){n.maxAge!=null&&c("Access-Control-Max-Age",n.maxAge.toString()),(p=n.allowMethods)!=null&&p.length&&c("Access-Control-Allow-Methods",n.allowMethods.join(","));let f=n.allowHeaders;if(!(f!=null&&f.length)){const m=s.req.header("Access-Control-Request-Headers");m&&(f=m.split(/\s*,\s*/))}return f!=null&&f.length&&(c("Access-Control-Allow-Headers",f.join(",")),s.res.headers.append("Vary","Access-Control-Request-Headers")),s.res.headers.delete("Content-Length"),s.res.headers.delete("Content-Type"),new Response(null,{headers:s.res.headers,status:204,statusText:s.res.statusText})}await a()}};const an=o.z.object({start:o.z.number(),limit:o.z.number(),length:o.z.number()}),uf=o.z.object({created_at:o.z.string(),updated_at:o.z.string()}),pf=o.z.object({email:o.z.string().optional(),email_verified:o.z.boolean().optional(),name:o.z.string().optional(),username:o.z.string().optional(),given_name:o.z.string().optional(),phone_number:o.z.string().optional(),phone_verified:o.z.boolean().optional(),family_name:o.z.string().optional()}).catchall(o.z.any()),ff=o.z.object({connection:o.z.string(),user_id:o.z.string(),provider:o.z.string(),isSocial:o.z.boolean(),access_token:o.z.string().optional(),access_token_secret:o.z.string().optional(),refresh_token:o.z.string().optional(),profileData:pf.optional()}),Ys=o.z.object({email:o.z.string().optional(),username:o.z.string().optional(),phone_number:o.z.string().optional(),given_name:o.z.string().optional(),family_name:o.z.string().optional(),nickname:o.z.string().optional(),name:o.z.string().optional(),picture:o.z.string().optional(),locale:o.z.string().optional(),linked_to:o.z.string().optional(),profileData:o.z.string().optional(),user_id:o.z.string().optional(),app_metadata:o.z.any().default({}).optional(),user_metadata:o.z.any().default({}).optional()}),rs=Ys.extend({email_verified:o.z.boolean().default(!1),verify_email:o.z.boolean().optional(),last_ip:o.z.string().optional(),last_login:o.z.string().optional(),user_id:o.z.string().optional(),provider:o.z.string().default("email"),connection:o.z.string().default("email"),is_social:o.z.boolean().optional()}),il=o.z.object({...rs.shape,...uf.shape,user_id:o.z.string(),is_social:o.z.boolean(),email:o.z.string().optional(),login_count:o.z.number(),identities:o.z.array(ff).optional()}),St=il,h0=Ys.extend({email:o.z.string(),login_count:o.z.number(),multifactor:o.z.array(o.z.string()).optional(),last_ip:o.z.string().optional(),last_login:o.z.string().optional(),user_id:o.z.string()}).catchall(o.z.any()),g0="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let m0=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=g0[n[t]&63];return e};const hf=o.z.object({audience:o.z.string().optional(),recipient:o.z.string().optional(),createUpnClaim:o.z.boolean().optional(),mapUnknownClaimsAsIs:o.z.boolean().optional(),passthroughClaimsWithNoMapping:o.z.boolean().optional(),mapIdentities:o.z.boolean().optional(),signatureAlgorithm:o.z.string().optional(),digestAlgorithm:o.z.string().optional(),issuer:o.z.string().optional(),destination:o.z.string().optional(),lifetimeInSeconds:o.z.number().optional(),signResponse:o.z.boolean().optional(),nameIdentifierFormat:o.z.string().optional(),nameIdentifierProbes:o.z.array(o.z.string()).optional(),authnContextClassRef:o.z.string().optional(),mappings:o.z.record(o.z.string()).optional()}),is=o.z.object({id:o.z.string(),name:o.z.string(),callbacks:o.z.array(o.z.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:o.z.array(o.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:o.z.array(o.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:o.z.array(o.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:o.z.array(o.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:o.z.object({samlp:hf.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:o.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:o.z.string().default(()=>m0()).optional(),disable_sign_ups:o.z.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),mn=o.z.object({created_at:o.z.string().transform(t=>t===null?"":t),updated_at:o.z.string().transform(t=>t===null?"":t),...is.shape});var It=(t=>(t.TOKEN="token",t.TOKEN_ID_TOKEN="token id_token",t.CODE="code",t))(It||{}),Rt=(t=>(t.QUERY="query",t.FRAGMENT="fragment",t.FORM_POST="form_post",t.WEB_MESSAGE="web_message",t.SAML_POST="saml_post",t))(Rt||{}),Xs=(t=>(t.S256="S256",t.Plain="plain",t))(Xs||{});const Mr=o.z.object({client_id:o.z.string(),act_as:o.z.string().optional(),response_type:o.z.nativeEnum(It).optional(),response_mode:o.z.nativeEnum(Rt).optional(),redirect_uri:o.z.string().optional(),audience:o.z.string().optional(),organization:o.z.string().optional(),state:o.z.string().optional(),nonce:o.z.string().optional(),scope:o.z.string().optional(),prompt:o.z.string().optional(),code_challenge_method:o.z.nativeEnum(Xs).optional(),code_challenge:o.z.string().optional(),username:o.z.string().optional(),ui_locales:o.z.string().optional(),vendor_id:o.z.string().optional()}),za=o.z.object({colors:o.z.object({primary:o.z.string(),page_background:o.z.object({type:o.z.string().optional(),start:o.z.string().optional(),end:o.z.string().optional(),angle_deg:o.z.number().optional()}).optional()}).optional(),logo_url:o.z.string().optional(),favicon_url:o.z.string().optional(),font:o.z.object({url:o.z.string()}).optional()}),sl=o.z.object({kid:o.z.string().optional(),team_id:o.z.string().optional(),realms:o.z.string().optional(),client_id:o.z.string().optional(),client_secret:o.z.string().optional(),app_secret:o.z.string().optional(),scope:o.z.string().optional(),authorization_endpoint:o.z.string().optional(),token_endpoint:o.z.string().optional(),userinfo_endpoint:o.z.string().optional(),jwks_uri:o.z.string().optional(),discovery_url:o.z.string().optional(),issuer:o.z.string().optional(),provider:o.z.string().optional(),from:o.z.string().optional(),twilio_sid:o.z.string().optional(),twilio_token:o.z.string().optional()}),ss=o.z.object({id:o.z.string().optional(),name:o.z.string(),strategy:o.z.string(),options:sl.default({}),enabled_clients:o.z.array(o.z.string()).default([]).optional(),response_type:o.z.custom().optional(),response_mode:o.z.custom().optional()}),Jt=o.z.object({id:o.z.string(),created_at:o.z.string().transform(t=>t===null?"":t),updated_at:o.z.string().transform(t=>t===null?"":t)}).extend(ss.shape),os=o.z.object({name:o.z.string(),audience:o.z.string(),sender_email:o.z.string().email(),sender_name:o.z.string(),support_url:o.z.string().url().optional(),logo:o.z.string().url().optional(),primary_color:o.z.string().optional(),secondary_color:o.z.string().optional(),language:o.z.string().optional(),id:o.z.string().optional()}),Jn=o.z.object({created_at:o.z.string().transform(t=>t===null?"":t),updated_at:o.z.string().transform(t=>t===null?"":t),...os.shape,id:o.z.string()}),gf=o.z.object({logoUrl:o.z.string(),loginBackgroundImage:o.z.string().nullish(),style:o.z.object({primaryColor:o.z.string(),buttonTextColor:o.z.string(),primaryHoverColor:o.z.string()}),supportEmail:o.z.string().nullable(),supportUrl:o.z.string().nullable(),name:o.z.string(),showGreyishBackground:o.z.boolean().optional(),termsAndConditionsUrl:o.z.string().nullable(),companyName:o.z.string().optional(),checkoutHideSocial:o.z.boolean().optional(),siteUrl:o.z.string().nullable(),manageSubscriptionsUrl:o.z.string().optional()});o.z.object({...mn.shape,tenant:Jn,connections:o.z.array(Jt)});const mf=o.z.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),_f=o.z.object({code_id:o.z.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:o.z.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:o.z.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:mf,code_verifier:o.z.string().optional().openapi({description:"The code verifier used in PKCE in outbound flows"}),expires_at:o.z.string(),used_at:o.z.string().optional(),user_id:o.z.string().optional()}),_0=o.z.object({..._f.shape,created_at:o.z.string()}),ol=o.z.object({domain:o.z.string(),custom_domain_id:o.z.string().optional(),type:o.z.enum(["auth0_managed_certs","self_managed_certs"]),verification_method:o.z.enum(["txt"]).optional(),tls_policy:o.z.enum(["recommended"]).optional(),custom_client_ip_header:o.z.enum(["true-client-ip","cf-connecting-ip","x-forwarded-for","x-azure-clientip","null"]).optional(),domain_metadata:o.z.record(o.z.string().max(255)).optional()}),yf=o.z.object({name:o.z.literal("txt"),record:o.z.string(),domain:o.z.string()}),Gt=o.z.object({...ol.shape,custom_domain_id:o.z.string(),primary:o.z.boolean(),status:o.z.enum(["disabled","pending","pending_verification","ready"]),origin_domain_name:o.z.string().optional(),verification:o.z.object({methods:o.z.array(yf)}).optional(),tls_policy:o.z.string().optional()}),y0=Gt.extend({tenant_id:o.z.string()}),as=o.z.object({trigger_id:o.z.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:o.z.boolean().default(!1),url:o.z.string(),hook_id:o.z.string().optional(),synchronous:o.z.boolean().default(!1),priority:o.z.number().optional()}),Kn=as.extend({...uf.shape,hook_id:o.z.string()}),al=o.z.object({alg:o.z.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:o.z.string(),kid:o.z.string(),kty:o.z.enum(["RSA","EC","oct"]),n:o.z.string(),x5t:o.z.string().optional(),x5c:o.z.array(o.z.string()).optional(),use:o.z.enum(["sig","enc"]).optional()}),wf=o.z.object({keys:o.z.array(al)}),Ea=o.z.object({issuer:o.z.string(),authorization_endpoint:o.z.string(),token_endpoint:o.z.string(),device_authorization_endpoint:o.z.string(),userinfo_endpoint:o.z.string(),mfa_challenge_endpoint:o.z.string(),jwks_uri:o.z.string(),registration_endpoint:o.z.string(),revocation_endpoint:o.z.string(),scopes_supported:o.z.array(o.z.string()),response_types_supported:o.z.array(o.z.string()),code_challenge_methods_supported:o.z.array(o.z.string()),response_modes_supported:o.z.array(o.z.string()),subject_types_supported:o.z.array(o.z.string()),id_token_signing_alg_values_supported:o.z.array(o.z.string()),token_endpoint_auth_methods_supported:o.z.array(o.z.string()),claims_supported:o.z.array(o.z.string()),request_uri_parameter_supported:o.z.boolean(),request_parameter_supported:o.z.boolean(),token_endpoint_auth_signing_alg_values_supported:o.z.array(o.z.string())}),vf=o.z.object({csrf_token:o.z.string(),auth0Client:o.z.string().optional(),authParams:Mr,expires_at:o.z.string(),deleted_at:o.z.string().optional(),ip:o.z.string().optional(),useragent:o.z.string().optional(),session_id:o.z.string().optional(),authorization_url:o.z.string().optional()}).openapi({description:"This represents a login sesion"}),w0=o.z.object({...vf.shape,id:o.z.string().openapi({description:"This is is used as the state in the universal login"}),created_at:o.z.string(),updated_at:o.z.string()});var ge=(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))(ge||{});const v0=o.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"]),bf=o.z.object({name:o.z.string(),version:o.z.string(),env:o.z.object({node:o.z.string().optional()}).optional()}),cs=o.z.object({type:v0,date:o.z.string(),description:o.z.string().optional(),log_id:o.z.string().optional(),_id:o.z.string().optional(),ip:o.z.string(),user_agent:o.z.string(),details:o.z.any().optional(),isMobile:o.z.boolean(),user_id:o.z.string().optional(),user_name:o.z.string().optional(),connection:o.z.string().optional(),connection_id:o.z.string().optional(),client_id:o.z.string().optional(),client_name:o.z.string().optional(),audience:o.z.string().optional(),scope:o.z.array(o.z.string()).optional(),strategy:o.z.string().optional(),strategy_type:o.z.string().optional(),hostname:o.z.string().optional(),auth0_client:bf.optional()}),xf=o.z.object({user_id:o.z.string(),password:o.z.string(),algorithm:o.z.enum(["bcrypt","argon2id"]).default("argon2id")}),b0=o.z.object({...xf.shape,created_at:o.z.string(),updated_at:o.z.string()}),kf=o.z.object({initial_user_agent:o.z.string().describe("First user agent of the device from which this user logged in"),initial_ip:o.z.string().describe("First IP address associated with this session"),initial_asn:o.z.string().describe("First autonomous system number associated with this session"),last_user_agent:o.z.string().describe("Last user agent of the device from which this user logged in"),last_ip:o.z.string().describe("Last IP address from which this user logged in"),last_asn:o.z.string().describe("Last autonomous system number from which this user logged in")}),Sf=o.z.object({id:o.z.string(),revoked_at:o.z.string().optional(),used_at:o.z.string().optional(),user_id:o.z.string().describe("The user ID associated with the session"),expires_at:o.z.string().optional(),idle_expires_at:o.z.string().optional(),device:kf.describe("Metadata related to the device used in the session"),clients:o.z.array(o.z.string()).describe("List of client details for the session")}),Qs=o.z.object({created_at:o.z.string(),updated_at:o.z.string(),authenticated_at:o.z.string(),last_interaction_at:o.z.string(),...Sf.shape}),Ia=o.z.object({kid:o.z.string().openapi({description:"The key id of the signing key"}),cert:o.z.string().openapi({description:"The public certificate of the signing key"}),fingerprint:o.z.string().openapi({description:"The cert fingerprint"}),thumbprint:o.z.string().openapi({description:"The cert thumbprint"}),pkcs7:o.z.string().optional().openapi({description:"The private key in pkcs7 format"}),current:o.z.boolean().optional().openapi({description:"True if the key is the current key"}),next:o.z.boolean().optional().openapi({description:"True if the key is the next key"}),previous:o.z.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:o.z.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:o.z.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:o.z.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:o.z.string().optional().openapi({description:"The date and time when the key was revoked"})});var Wn=(t=>(t.RefreshToken="refresh_token",t.AuthorizationCode="authorization_code",t.ClientCredential="client_credentials",t.Passwordless="passwordless",t.Password="password",t.OTP="http://auth0.com/oauth/grant-type/passwordless/otp",t))(Wn||{});const Af=o.z.object({access_token:o.z.string(),id_token:o.z.string().optional(),scope:o.z.string().optional(),state:o.z.string().optional(),refresh_token:o.z.string().optional(),token_type:o.z.string(),expires_in:o.z.number()});o.z.object({code:o.z.string(),state:o.z.string().optional()});const zf=o.z.object({button_border_radius:o.z.number(),button_border_weight:o.z.number(),buttons_style:o.z.enum(["pill"]),input_border_radius:o.z.number(),input_border_weight:o.z.number(),inputs_style:o.z.enum(["pill"]),show_widget_shadow:o.z.boolean(),widget_border_weight:o.z.number(),widget_corner_radius:o.z.number()}),Ef=o.z.object({base_focus_color:o.z.string(),base_hover_color:o.z.string(),body_text:o.z.string(),captcha_widget_theme:o.z.enum(["auto"]),error:o.z.string(),header:o.z.string(),icons:o.z.string(),input_background:o.z.string(),input_border:o.z.string(),input_filled_text:o.z.string(),input_labels_placeholders:o.z.string(),links_focused_components:o.z.string(),primary_button:o.z.string(),primary_button_label:o.z.string(),secondary_button_border:o.z.string(),secondary_button_label:o.z.string(),success:o.z.string(),widget_background:o.z.string(),widget_border:o.z.string()}),hn=o.z.object({bold:o.z.boolean(),size:o.z.number()}),If=o.z.object({body_text:hn,buttons_text:hn,font_url:o.z.string(),input_labels:hn,links:hn,links_style:o.z.enum(["normal"]),reference_text_size:o.z.number(),subtitle:hn,title:hn}),Cf=o.z.object({background_color:o.z.string(),background_image_url:o.z.string(),page_layout:o.z.enum(["center"])}),Nf=o.z.object({header_text_alignment:o.z.enum(["center"]),logo_height:o.z.number(),logo_position:o.z.enum(["center"]),logo_url:o.z.string(),social_buttons_layout:o.z.enum(["bottom"])}),jf=o.z.object({borders:zf,colors:Ef,displayName:o.z.string(),fonts:If,page_background:Cf,widget:Nf}),x0=jf.extend({themeId:o.z.string()}),Ui=o.z.object({universal_login_experience:o.z.enum(["new","classic"]).default("new"),identifier_first:o.z.boolean().default(!0),password_first:o.z.boolean().default(!1),webauthn_platform_first_factor:o.z.boolean()}),Vi=o.z.object({name:o.z.string(),enabled:o.z.boolean().optional().default(!0),default_from_address:o.z.string().optional(),credentials:o.z.union([o.z.object({accessKeyId:o.z.string(),secretAccessKey:o.z.string(),region:o.z.string()}),o.z.object({smtp_host:o.z.array(o.z.string()),smtp_port:o.z.number(),smtp_user:o.z.string(),smtp_pass:o.z.string()}),o.z.object({api_key:o.z.string(),domain:o.z.string().optional()}),o.z.object({connectionString:o.z.string()}),o.z.object({tenantId:o.z.string(),clientId:o.z.string(),clientSecret:o.z.string()})]),settings:o.z.object({}).optional()}),cl=o.z.object({id:o.z.string(),session_id:o.z.string(),user_id:o.z.string(),client_id:o.z.string(),expires_at:o.z.string().optional(),idle_expires_at:o.z.string().optional(),last_exchanged_at:o.z.string().optional(),device:kf,resource_servers:o.z.array(o.z.object({audience:o.z.string(),scopes:o.z.string()})),rotating:o.z.boolean()}),k0=o.z.object({created_at:o.z.string(),...cl.shape}),S0=o.z.object({to:o.z.string(),message:o.z.string()}),A0=o.z.object({name:o.z.string(),options:o.z.object({})});function z0(t){const[e,n]=t.split("|");if(!e||!n)throw new Error(`Invalid user_id: ${t}`);return{connection:e,id:n}}const E0=new o.OpenAPIHono().openapi(o.createRoute({tags:["branding"],method:"get",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:za}},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(o.createRoute({tags:["branding"],method:"patch",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(za.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 I=class extends Error{constructor(e=500,n){super(n==null?void 0:n.message,{cause:n==null?void 0:n.cause});te(this,"res");te(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})}},ls=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $f(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function I0(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var n=function r(){return this instanceof r?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(r){var i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}),n}function C0(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 Of={exports:{}};const N0={},j0=Object.freeze(Object.defineProperty({__proto__:null,default:N0},Symbol.toStringTag,{value:"Module"})),$0=I0(j0);(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 z0=="function"&&t&&t.exports?t.exports=n():(e.dcodeIO=e.dcodeIO||{}).bcrypt=n()})(ls,function(){var e={},n=null;function r(j){if(t&&t.exports)try{return C0.randomBytes(j)}catch{}try{var N;return(self.crypto||self.msCrypto).getRandomValues(N=new Uint32Array(j)),Array.prototype.slice.call(N)}catch{}if(!n)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return n(j)}var i=!1;try{r(1),i=!0}catch{}n=null,e.setRandomFallback=function(j){n=j},e.genSaltSync=function(j,N){if(j=j||_,typeof j!="number")throw Error("Illegal arguments: "+typeof j+", "+typeof N);j<4?j=4:j>31&&(j=31);var z=[];return z.push("$2a$"),j<10&&z.push("0"),z.push(j.toString()),z.push("$"),z.push(f(r(h),h)),z.join("")},e.genSalt=function(j,N,z){if(typeof N=="function"&&(z=N,N=void 0),typeof j=="function"&&(z=j,j=void 0),typeof j>"u")j=_;else if(typeof j!="number")throw Error("illegal arguments: "+typeof j);function k(x){a(function(){try{x(null,e.genSaltSync(j))}catch($){x($)}})}if(z){if(typeof z!="function")throw Error("Illegal callback: "+typeof z);k(z)}else return new Promise(function(x,$){k(function(U,X){if(U){$(U);return}x(X)})})},e.hashSync=function(j,N){if(typeof N>"u"&&(N=_),typeof N=="number"&&(N=e.genSaltSync(N)),typeof j!="string"||typeof N!="string")throw Error("Illegal arguments: "+typeof j+", "+typeof N);return Re(j,N)},e.hash=function(j,N,z,k){function x($){typeof j=="string"&&typeof N=="number"?e.genSalt(N,function(U,X){Re(j,X,$,k)}):typeof j=="string"&&typeof N=="string"?Re(j,N,$,k):a($.bind(this,Error("Illegal arguments: "+typeof j+", "+typeof N)))}if(z){if(typeof z!="function")throw Error("Illegal callback: "+typeof z);x(z)}else return new Promise(function($,U){x(function(X,G){if(X){U(X);return}$(G)})})};function s(j,N){for(var z=0,k=0,x=0,$=j.length;x<$;++x)j.charCodeAt(x)===N.charCodeAt(x)?++z:++k;return z<0?!1:k===0}e.compareSync=function(j,N){if(typeof j!="string"||typeof N!="string")throw Error("Illegal arguments: "+typeof j+", "+typeof N);return N.length!==60?!1:s(e.hashSync(j,N.substr(0,N.length-31)),N)},e.compare=function(j,N,z,k){function x($){if(typeof j!="string"||typeof N!="string"){a($.bind(this,Error("Illegal arguments: "+typeof j+", "+typeof N)));return}if(N.length!==60){a($.bind(this,null,!1));return}e.hash(j,N.substr(0,29),function(U,X){U?$(U):$(null,s(X,N))},k)}if(z){if(typeof z!="function")throw Error("Illegal callback: "+typeof z);x(z)}else return new Promise(function($,U){x(function(X,G){if(X){U(X);return}$(G)})})},e.getRounds=function(j){if(typeof j!="string")throw Error("Illegal arguments: "+typeof j);return parseInt(j.split("$")[2],10)},e.getSalt=function(j){if(typeof j!="string")throw Error("Illegal arguments: "+typeof j);if(j.length!==60)throw Error("Illegal hash length: "+j.length+" != 60");return j.substring(0,29)};var a=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function c(j){var N=[],z=0;return w.encodeUTF16toUTF8(function(){return z>=j.length?null:j.charCodeAt(z++)},function(k){N.push(k)}),N}var l="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),d=[-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(j,N){var z=0,k=[],x,$;if(N<=0||N>j.length)throw Error("Illegal len: "+N);for(;z<N;){if(x=j[z++]&255,k.push(l[x>>2&63]),x=(x&3)<<4,z>=N){k.push(l[x&63]);break}if($=j[z++]&255,x|=$>>4&15,k.push(l[x&63]),x=($&15)<<2,z>=N){k.push(l[x&63]);break}$=j[z++]&255,x|=$>>6&3,k.push(l[x&63]),k.push(l[$&63])}return k.join("")}function m(j,N){var z=0,k=j.length,x=0,$=[],U,X,G,se,ue,D;if(N<=0)throw Error("Illegal len: "+N);for(;z<k-1&&x<N&&(D=j.charCodeAt(z++),U=D<d.length?d[D]:-1,D=j.charCodeAt(z++),X=D<d.length?d[D]:-1,!(U==-1||X==-1||(ue=U<<2>>>0,ue|=(X&48)>>4,$.push(p(ue)),++x>=N||z>=k)||(D=j.charCodeAt(z++),G=D<d.length?d[D]:-1,G==-1)||(ue=(X&15)<<4>>>0,ue|=(G&60)>>2,$.push(p(ue)),++x>=N||z>=k)));)D=j.charCodeAt(z++),se=D<d.length?d[D]:-1,ue=(G&3)<<6>>>0,ue|=se,$.push(p(ue)),++x;var Ce=[];for(z=0;z<x;z++)Ce.push($[z].charCodeAt(0));return Ce}var w=function(){var j={};return j.MAX_CODEPOINT=1114111,j.encodeUTF8=function(N,z){var k=null;for(typeof N=="number"&&(k=N,N=function(){return null});k!==null||(k=N())!==null;)k<128?z(k&127):k<2048?(z(k>>6&31|192),z(k&63|128)):k<65536?(z(k>>12&15|224),z(k>>6&63|128),z(k&63|128)):(z(k>>18&7|240),z(k>>12&63|128),z(k>>6&63|128),z(k&63|128)),k=null},j.decodeUTF8=function(N,z){for(var k,x,$,U,X=function(G){G=G.slice(0,G.indexOf(null));var se=Error(G.toString());throw se.name="TruncatedError",se.bytes=G,se};(k=N())!==null;)if(!(k&128))z(k);else if((k&224)===192)(x=N())===null&&X([k,x]),z((k&31)<<6|x&63);else if((k&240)===224)((x=N())===null||($=N())===null)&&X([k,x,$]),z((k&15)<<12|(x&63)<<6|$&63);else if((k&248)===240)((x=N())===null||($=N())===null||(U=N())===null)&&X([k,x,$,U]),z((k&7)<<18|(x&63)<<12|($&63)<<6|U&63);else throw RangeError("Illegal starting byte: "+k)},j.UTF16toUTF8=function(N,z){for(var k,x=null;(k=x!==null?x:N())!==null;){if(k>=55296&&k<=57343&&(x=N())!==null&&x>=56320&&x<=57343){z((k-55296)*1024+x-56320+65536),x=null;continue}z(k)}x!==null&&z(x)},j.UTF8toUTF16=function(N,z){var k=null;for(typeof N=="number"&&(k=N,N=function(){return null});k!==null||(k=N())!==null;)k<=65535?z(k):(k-=65536,z((k>>10)+55296),z(k%1024+56320)),k=null},j.encodeUTF16toUTF8=function(N,z){j.UTF16toUTF8(N,function(k){j.encodeUTF8(k,z)})},j.decodeUTF8toUTF16=function(N,z){j.decodeUTF8(N,function(k){j.UTF8toUTF16(k,z)})},j.calculateCodePoint=function(N){return N<128?1:N<2048?2:N<65536?3:4},j.calculateUTF8=function(N){for(var z,k=0;(z=N())!==null;)k+=j.calculateCodePoint(z);return k},j.calculateUTF16asUTF8=function(N){var z=0,k=0;return j.UTF16toUTF8(N,function(x){++z,k+=j.calculateCodePoint(x)}),[z,k]},j}();Date.now=Date.now||function(){return+new Date};var h=16,_=10,v=16,S=100,C=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],O=[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],L=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function Q(j,N,z,k){var x,$=j[N],U=j[N+1];return $^=z[0],x=k[$>>>24],x+=k[256|$>>16&255],x^=k[512|$>>8&255],x+=k[768|$&255],U^=x^z[1],x=k[U>>>24],x+=k[256|U>>16&255],x^=k[512|U>>8&255],x+=k[768|U&255],$^=x^z[2],x=k[$>>>24],x+=k[256|$>>16&255],x^=k[512|$>>8&255],x+=k[768|$&255],U^=x^z[3],x=k[U>>>24],x+=k[256|U>>16&255],x^=k[512|U>>8&255],x+=k[768|U&255],$^=x^z[4],x=k[$>>>24],x+=k[256|$>>16&255],x^=k[512|$>>8&255],x+=k[768|$&255],U^=x^z[5],x=k[U>>>24],x+=k[256|U>>16&255],x^=k[512|U>>8&255],x+=k[768|U&255],$^=x^z[6],x=k[$>>>24],x+=k[256|$>>16&255],x^=k[512|$>>8&255],x+=k[768|$&255],U^=x^z[7],x=k[U>>>24],x+=k[256|U>>16&255],x^=k[512|U>>8&255],x+=k[768|U&255],$^=x^z[8],x=k[$>>>24],x+=k[256|$>>16&255],x^=k[512|$>>8&255],x+=k[768|$&255],U^=x^z[9],x=k[U>>>24],x+=k[256|U>>16&255],x^=k[512|U>>8&255],x+=k[768|U&255],$^=x^z[10],x=k[$>>>24],x+=k[256|$>>16&255],x^=k[512|$>>8&255],x+=k[768|$&255],U^=x^z[11],x=k[U>>>24],x+=k[256|U>>16&255],x^=k[512|U>>8&255],x+=k[768|U&255],$^=x^z[12],x=k[$>>>24],x+=k[256|$>>16&255],x^=k[512|$>>8&255],x+=k[768|$&255],U^=x^z[13],x=k[U>>>24],x+=k[256|U>>16&255],x^=k[512|U>>8&255],x+=k[768|U&255],$^=x^z[14],x=k[$>>>24],x+=k[256|$>>16&255],x^=k[512|$>>8&255],x+=k[768|$&255],U^=x^z[15],x=k[U>>>24],x+=k[256|U>>16&255],x^=k[512|U>>8&255],x+=k[768|U&255],$^=x^z[16],j[N]=U^z[v+1],j[N+1]=$,j}function ce(j,N){for(var z=0,k=0;z<4;++z)k=k<<8|j[N]&255,N=(N+1)%j.length;return{key:k,offp:N}}function le(j,N,z){for(var k=0,x=[0,0],$=N.length,U=z.length,X,G=0;G<$;G++)X=ce(j,k),k=X.offp,N[G]=N[G]^X.key;for(G=0;G<$;G+=2)x=Q(x,0,N,z),N[G]=x[0],N[G+1]=x[1];for(G=0;G<U;G+=2)x=Q(x,0,N,z),z[G]=x[0],z[G+1]=x[1]}function De(j,N,z,k){for(var x=0,$=[0,0],U=z.length,X=k.length,G,se=0;se<U;se++)G=ce(N,x),x=G.offp,z[se]=z[se]^G.key;for(x=0,se=0;se<U;se+=2)G=ce(j,x),x=G.offp,$[0]^=G.key,G=ce(j,x),x=G.offp,$[1]^=G.key,$=Q($,0,z,k),z[se]=$[0],z[se+1]=$[1];for(se=0;se<X;se+=2)G=ce(j,x),x=G.offp,$[0]^=G.key,G=ce(j,x),x=G.offp,$[1]^=G.key,$=Q($,0,z,k),k[se]=$[0],k[se+1]=$[1]}function Ve(j,N,z,k,x){var $=L.slice(),U=$.length,X;if(z<4||z>31)if(X=Error("Illegal number of rounds (4-31): "+z),k){a(k.bind(this,X));return}else throw X;if(N.length!==h)if(X=Error("Illegal salt length: "+N.length+" != "+h),k){a(k.bind(this,X));return}else throw X;z=1<<z>>>0;var G,se,ue=0,D;Int32Array?(G=new Int32Array(C),se=new Int32Array(O)):(G=C.slice(),se=O.slice()),De(N,j,G,se);function Ce(){if(x&&x(ue/z),ue<z)for(var he=Date.now();ue<z&&(ue=ue+1,le(j,G,se),le(N,G,se),!(Date.now()-he>S)););else{for(ue=0;ue<64;ue++)for(D=0;D<U>>1;D++)Q($,D<<1,G,se);var Se=[];for(ue=0;ue<U;ue++)Se.push(($[ue]>>24&255)>>>0),Se.push(($[ue]>>16&255)>>>0),Se.push(($[ue]>>8&255)>>>0),Se.push(($[ue]&255)>>>0);if(k){k(null,Se);return}else return Se}k&&a(Ce)}if(typeof k<"u")Ce();else for(var fn;;)if(typeof(fn=Ce())<"u")return fn||[]}function Re(j,N,z,k){var x;if(typeof j!="string"||typeof N!="string")if(x=Error("Invalid string / salt: Not a string"),z){a(z.bind(this,x));return}else throw x;var $,U;if(N.charAt(0)!=="$"||N.charAt(1)!=="2")if(x=Error("Invalid salt version: "+N.substring(0,2)),z){a(z.bind(this,x));return}else throw x;if(N.charAt(2)==="$")$="\0",U=3;else{if($=N.charAt(2),$!=="a"&&$!=="b"&&$!=="y"||N.charAt(3)!=="$")if(x=Error("Invalid salt revision: "+N.substring(2,4)),z){a(z.bind(this,x));return}else throw x;U=4}if(N.charAt(U+2)>"$")if(x=Error("Missing salt rounds"),z){a(z.bind(this,x));return}else throw x;var X=parseInt(N.substring(U,U+1),10)*10,G=parseInt(N.substring(U+1,U+2),10),se=X+G,ue=N.substring(U+3,U+25);j+=$>="a"?"\0":"";var D=c(j),Ce=m(ue,h);function fn(he){var Se=[];return Se.push("$2"),$>="a"&&Se.push($),Se.push("$"),se<10&&Se.push("0"),Se.push(se.toString()),Se.push("$"),Se.push(f(Ce,Ce.length)),Se.push(f(he,L.length*4-1)),Se.join("")}if(typeof z>"u")return fn(Ve(D,Ce,se));Ve(D,Ce,se,function(he,Se){he?z(he,null):z(null,fn(Se))},k)}return e.encodeBase64=f,e.decodeBase64=m,e})})(jf);var N0=jf.exports;const oi=Nf(N0),j0="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let $0=t=>crypto.getRandomValues(new Uint8Array(t)),O0=(t,e,n)=>{let r=(2<<Math.log2(t.length-1))-1,i=-~(1.6*r*e/t.length);return(s=e)=>{let a="";for(;;){let c=n(i),l=i;for(;l--;)if(a+=t[c[l]&r]||"",a.length===s)return a}}},P0=(t,e=21)=>O0(t,e,$0),ke=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=j0[n[t]&63];return e};const T0=24;function eo(){return P0("0123456789abcdef",T0)()}function Dd(t){if(!t.includes("|"))return console.error("Invalid user_id format"),t;const[,e]=t.split("|");return e}function B0(t){return async(e,n)=>{if(!n.email||!n.email_verified)return t.users.create(e,n);const r=await so({userAdapter:t.users,tenant_id:e,email:n.email});return r?(await t.users.create(e,{...n,linked_to:r.user_id}),r):t.users.create(e,n)}}function we(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:[]}}class ll{constructor(e,n){te(this,"value");te(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 ll(Math.round(this.milliseconds()*e),"ms")}}class R0{constructor(e){te(this,"hash");this.hash=e}async verify(e,n,r){const i=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",i,n,r)}async sign(e,n){const r=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",r,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"]),r=await crypto.subtle.exportKey("pkcs8",n.privateKey),i=await crypto.subtle.exportKey("spki",n.publicKey);return{privateKey:r,publicKey:i}}}async function $f(t){return await crypto.subtle.digest("SHA-256",t)}const Fd="0123456789abcdef";function Ca(t){const e=new Uint8Array(t);let n="";for(let r=0;r<e.length;r++){const i=e[r]>>4;n+=Fd[i];const s=e[r]&15;n+=Fd[s]}return n}class Of{constructor(e,n){te(this,"alphabet");te(this,"padding");te(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 r=0;r<e.length;r++)this.decodeMap.set(e[r],r)}encode(e,n){let r="",i=0,s=0;for(let c=0;c<e.length;c++)for(i=i<<8|e[c],s+=8;s>=5;)s-=5,r+=this.alphabet[i>>s&31];if(s>0&&(r+=this.alphabet[i<<5-s&31]),(n==null?void 0:n.includePadding)??!0){const c=(8-r.length%8)%8;for(let l=0;l<c;l++)r+="="}return r}decode(e,n){const r=(n==null?void 0:n.strict)??!0,i=Math.ceil(e.length/8),s=[];for(let a=0;a<i;a++){let c=0;const l=[];for(let p=0;p<8;p++){const f=e[a*8+p];if(f==="="){if(a+1!==i)throw new Error(`Invalid character: ${f}`);c+=1;continue}if(f===void 0){if(r)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 d=(l[0]<<3)+(l[1]>>2);if(s.push(d),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 Of("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new Of("0123456789ABCDEFGHIJKLMNOPQRSTUV");class Pf{constructor(e,n){te(this,"alphabet");te(this,"padding");te(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 r=0;r<e.length;r++)this.decodeMap.set(e[r],r)}encode(e,n){let r="",i=0,s=0;for(let c=0;c<e.length;c++)for(i=i<<8|e[c],s+=8;s>=6;)s+=-6,r+=this.alphabet[i>>s&63];if(s>0&&(r+=this.alphabet[i<<6-s&63]),(n==null?void 0:n.includePadding)??!0){const c=(4-r.length%4)%4;for(let l=0;l<c;l++)r+="="}return r}decode(e,n){const r=(n==null?void 0:n.strict)??!0,i=Math.ceil(e.length/4),s=[];for(let a=0;a<i;a++){let c=0,l=0;for(let d=0;d<4;d++){const p=e[a*4+d];if(p==="="){if(a+1!==i)throw new Error(`Invalid character: ${p}`);c+=1;continue}if(p===void 0){if(r)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-d)}s.push(l>>16&255),c<2&&s.push(l>>8&255),c<1&&s.push(l&255)}return Uint8Array.from(s)}}const L0=new Pf("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),vn=new Pf("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");async function Kd(t,e,n,r){const i={alg:t,typ:"JWT",...r==null?void 0:r.headers},s={...n};(r==null?void 0:r.audiences)!==void 0&&(s.aud=r.audiences),(r==null?void 0:r.subject)!==void 0&&(s.sub=r.subject),(r==null?void 0:r.issuer)!==void 0&&(s.iss=r.issuer),(r==null?void 0:r.jwtId)!==void 0&&(s.jti=r.jwtId),(r==null?void 0:r.expiresIn)!==void 0&&(s.exp=Math.floor(Date.now()/1e3)+r.expiresIn.seconds()),(r==null?void 0:r.notBefore)!==void 0&&(s.nbf=Math.floor(r.notBefore.getTime()/1e3)),s.iat=Math.floor(Date.now()/1e3);const a=new TextEncoder,c=vn.encode(a.encode(JSON.stringify(i)),{includePadding:!1}),l=vn.encode(a.encode(JSON.stringify(s)),{includePadding:!1}),d=a.encode([c,l].join(".")),p=await V0(t).sign(e,d),f=vn.encode(new Uint8Array(p),{includePadding:!1});return[c,l,f].join(".")}function U0(t){const e=t.split(".");return e.length!==3?null:e}function dl(t){const e=U0(t);if(!e)return null;const n=new TextDecoder,r=vn.decode(e[0],{strict:!1}),i=vn.decode(e[1],{strict:!1}),s=JSON.parse(n.decode(r));if(typeof s!="object"||s===null||!("alg"in s)||!q0(s.alg)||"typ"in s&&s.typ!=="JWT")return null;const a=JSON.parse(n.decode(i));if(typeof a!="object"||a===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 a){if(typeof a.exp!="number")return null;c.expiresAt=new Date(a.exp*1e3)}if("iss"in a){if(typeof a.iss!="string")return null;c.issuer=a.iss}if("sub"in a){if(typeof a.sub!="string")return null;c.subject=a.sub}if("aud"in a)if(Array.isArray(a.aud)){for(const l of a.aud)if(typeof l!="string")return null;c.audiences=a.aud}else{if(typeof a.aud!="string")return null;c.audiences=[a.aud]}if("nbf"in a){if(typeof a.nbf!="number")return null;c.notBefore=new Date(a.nbf*1e3)}if("iat"in a){if(typeof a.iat!="number")return null;c.issuedAt=new Date(a.iat*1e3)}if("jti"in a){if(typeof a.jti!="string")return null;c.jwtId=a.jti}return{value:t,header:{...s,typ:"JWT",alg:s.alg},payload:{...a},parts:e,...c}}function V0(t){return new R0(M0[t])}function q0(t){return typeof t!="string"?!1:["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512","PS256","PS384","PS512"].includes(t)}const M0={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"};function H0(){const t=new Uint8Array(32);return crypto.getRandomValues(t),vn.encode(t,{includePadding:!1})}function D0(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,"")),r=>r.charCodeAt(0)).buffer}finally{t=t.replace(/./g,"\0")}}async function F0(t,e){if(e==="plain")return t;const n=new TextEncoder().encode(t),r=await $f(n);return vn.encode(new Uint8Array(r),{includePadding:!1})}const Oi=60*5,to=30*24*60*60,Qn=24*60*60,K0="auth-token",Na=30*60*1e3,W0=7*24*60*60*1e3,G0=5*60,J0=5*60,Z0=30*60*1e3,Y0=30*60*1e3,X0=24*60*60*1e3;function Tf(t,e,n){const r=[];return r.push([encodeURIComponent(t),encodeURIComponent(e)]),(n==null?void 0:n.domain)!==void 0&&r.push(["Domain",n.domain]),(n==null?void 0:n.expires)!==void 0&&r.push(["Expires",n.expires.toUTCString()]),n!=null&&n.httpOnly&&r.push(["HttpOnly"]),(n==null?void 0:n.maxAge)!==void 0&&r.push(["Max-Age",n.maxAge.toString()]),(n==null?void 0:n.path)!==void 0&&r.push(["Path",n.path]),(n==null?void 0:n.sameSite)==="lax"&&r.push(["SameSite","Lax"]),(n==null?void 0:n.sameSite)==="none"&&r.push(["SameSite","None"]),(n==null?void 0:n.sameSite)==="strict"&&r.push(["SameSite","Strict"]),n!=null&&n.secure&&r.push(["Secure"]),r.map(i=>i.join("=")).join("; ")}function Q0(t){const e=new Map,n=t.split("; ");for(const r of n){const i=r.split("="),s=i[0],a=i[1]??"";s&&e.set(decodeURIComponent(s),decodeURIComponent(a))}return e}function ul(t){return`${t}-${K0}`}function Bf(t){if(!t)return;if(t==="localhost"||/^(\d{1,3}\.){3}\d{1,3}$/.test(t))return t;const e=t.split(".");return e.length>2?`.${e.slice(-2).join(".")}`:`.${t}`}function ds(t,e){return e?Q0(e).get(ul(t)):void 0}function e_(t,e){return Tf(ul(t),"",{path:"/",httpOnly:!0,secure:!0,maxAge:0,sameSite:"none",domain:e?Bf(e):void 0})}function Rf(t,e,n){return Tf(ul(t),e,{path:"/",httpOnly:!0,secure:!0,maxAge:to,sameSite:"none",domain:n?Bf(n):void 0})}var pl={},no={};(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",r="["+e+"]["+n+"]*",i=new RegExp("^"+r+"$"),s=function(c,l){const d=[];let p=l.exec(c);for(;p;){const f=[];f.startIndex=l.lastIndex-p[0].length;const m=p.length;for(let w=0;w<m;w++)f.push(p[w]);d.push(f),p=l.exec(c)}return d},a=function(c){const l=i.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,d){if(l){const p=Object.keys(l),f=p.length;for(let m=0;m<f;m++)d==="strict"?c[p[m]]=[l[p[m]]]:c[p[m]]=l[p[m]]}},t.getValue=function(c){return t.isExist(c)?c:""},t.isName=a,t.getAllMatches=s,t.nameRegexp=r})(no);const fl=no,t_={allowBooleanAttributes:!1,unpairedTags:[]};pl.validate=function(t,e){e=Object.assign({},t_,e);const n=[];let r=!1,i=!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=Gd(t,s),s.err)return s}else if(t[s]==="<"){let a=s;if(s++,t[s]==="!"){s=Jd(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]!==`
6
- `&&t[s]!=="\r";s++)l+=t[s];if(l=l.trim(),l[l.length-1]==="/"&&(l=l.substring(0,l.length-1),s--),!l_(l)){let f;return l.trim().length===0?f="Invalid space after '<'.":f="Tag '"+l+"' is an invalid name.",be("InvalidTag",f,qe(t,s))}const d=i_(t,s);if(d===!1)return be("InvalidAttr","Attributes for '"+l+"' have open quote.",qe(t,s));let p=d.value;if(s=d.index,p[p.length-1]==="/"){const f=s-p.length;p=p.substring(0,p.length-1);const m=Zd(p,e);if(m===!0)r=!0;else return be(m.err.code,m.err.msg,qe(t,f+m.err.line))}else if(c)if(d.tagClosed){if(p.trim().length>0)return be("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",qe(t,a));if(n.length===0)return be("InvalidTag","Closing tag '"+l+"' has not been opened.",qe(t,a));{const f=n.pop();if(l!==f.tagName){let m=qe(t,f.tagStartPos);return be("InvalidTag","Expected closing tag '"+f.tagName+"' (opened in line "+m.line+", col "+m.col+") instead of closing tag '"+l+"'.",qe(t,a))}n.length==0&&(i=!0)}}else return be("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",qe(t,s));else{const f=Zd(p,e);if(f!==!0)return be(f.err.code,f.err.msg,qe(t,s-p.length+f.err.line));if(i===!0)return be("InvalidXml","Multiple possible root nodes found.",qe(t,s));e.unpairedTags.indexOf(l)!==-1||n.push({tagName:l,tagStartPos:a}),r=!0}for(s++;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="!"){s++,s=Jd(t,s);continue}else if(t[s+1]==="?"){if(s=Gd(t,++s),s.err)return s}else break;else if(t[s]==="&"){const f=a_(t,s);if(f==-1)return be("InvalidChar","char '&' is not expected.",qe(t,s));s=f}else if(i===!0&&!Wd(t[s]))return be("InvalidXml","Extra text at the end",qe(t,s));t[s]==="<"&&s--}}else{if(Wd(t[s]))continue;return be("InvalidChar","char '"+t[s]+"' is not expected.",qe(t,s))}if(r){if(n.length==1)return be("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",qe(t,n[0].tagStartPos));if(n.length>0)return be("InvalidXml","Invalid '"+JSON.stringify(n.map(s=>s.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return be("InvalidXml","Start tag expected.",1);return!0};function Wd(t){return t===" "||t===" "||t===`
7
- `||t==="\r"}function Gd(t,e){const n=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){const r=t.substr(n,e-n);if(e>5&&r==="xml")return be("InvalidXml","XML declaration allowed only at the start of the document.",qe(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function Jd(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 n_='"',r_="'";function i_(t,e){let n="",r="",i=!1;for(;e<t.length;e++){if(t[e]===n_||t[e]===r_)r===""?r=t[e]:r!==t[e]||(r="");else if(t[e]===">"&&r===""){i=!0;break}n+=t[e]}return r!==""?!1:{value:n,index:e,tagClosed:i}}const s_=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Zd(t,e){const n=fl.getAllMatches(t,s_),r={};for(let i=0;i<n.length;i++){if(n[i][1].length===0)return be("InvalidAttr","Attribute '"+n[i][2]+"' has no space in starting.",Ir(n[i]));if(n[i][3]!==void 0&&n[i][4]===void 0)return be("InvalidAttr","Attribute '"+n[i][2]+"' is without value.",Ir(n[i]));if(n[i][3]===void 0&&!e.allowBooleanAttributes)return be("InvalidAttr","boolean attribute '"+n[i][2]+"' is not allowed.",Ir(n[i]));const s=n[i][2];if(!c_(s))return be("InvalidAttr","Attribute '"+s+"' is an invalid name.",Ir(n[i]));if(!r.hasOwnProperty(s))r[s]=1;else return be("InvalidAttr","Attribute '"+s+"' is repeated.",Ir(n[i]))}return!0}function o_(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 a_(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,o_(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 be(t,e,n){return{err:{code:t,msg:e,line:n.line||n,col:n.col}}}function c_(t){return fl.isName(t)}function l_(t){return fl.isName(t)}function qe(t,e){const n=t.substring(0,e).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function Ir(t){return t.startIndex+t[1].length}var hl={};const Lf={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}},d_=function(t){return Object.assign({},Lf,t)};hl.buildOptions=d_;hl.defaultOptions=Lf;class u_{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 p_=u_;const f_=no;function h_(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 r=1,i=!1,s=!1,a="";for(;e<t.length;e++)if(t[e]==="<"&&!s){if(i&&__(t,e)){e+=7;let c,l;[c,l,e]=g_(t,e+1),l.indexOf("&")===-1&&(n[b_(c)]={regx:RegExp(`&${c};`,"g"),val:l})}else if(i&&y_(t,e))e+=8;else if(i&&w_(t,e))e+=8;else if(i&&v_(t,e))e+=9;else if(m_)s=!0;else throw new Error("Invalid DOCTYPE");r++,a=""}else if(t[e]===">"){if(s?t[e-1]==="-"&&t[e-2]==="-"&&(s=!1,r--):r--,r===0)break}else t[e]==="["?i=!0:a+=t[e];if(r!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:n,i:e}}function g_(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 r=t[e++];let i="";for(;e<t.length&&t[e]!==r;e++)i+=t[e];return[n,i,e]}function m_(t,e){return t[e+1]==="!"&&t[e+2]==="-"&&t[e+3]==="-"}function __(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 y_(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 w_(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 v_(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 b_(t){if(f_.isName(t))return t;throw new Error(`Invalid entity name ${t}`)}var x_=h_;const k_=/^[-+]?0x[a-fA-F0-9]+$/,S_=/^([\-\+])?(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 A_={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function z_(t,e={}){if(e=Object.assign({},A_,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&&k_.test(n))return Number.parseInt(n,16);{const r=S_.exec(n);if(r){const i=r[1],s=r[2];let a=E_(r[3]);const c=r[4]||r[6];if(!e.leadingZeros&&s.length>0&&i&&n[2]!==".")return t;if(!e.leadingZeros&&s.length>0&&!i&&n[1]!==".")return t;{const l=Number(n),d=""+l;return d.search(/[eE]/)!==-1||c?e.eNotation?l:t:n.indexOf(".")!==-1?d==="0"&&a===""||d===a||i&&d==="-"+a?l:t:s?a===d||i+a===d?l:t:n===d||n===i+d?l:t}}else return t}}function E_(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 I_=z_;function C_(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 Uf=C_;const Vf=no,Cr=p_,N_=x_,j_=I_,$_=Uf;let O_=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,r)=>String.fromCharCode(Number.parseInt(r,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(n,r)=>String.fromCharCode(Number.parseInt(r,16))}},this.addExternalEntities=P_,this.parseXml=U_,this.parseTextData=T_,this.resolveNameSpace=B_,this.buildAttributesMap=L_,this.isItStopNode=H_,this.replaceEntitiesValue=q_,this.readStopNodeData=F_,this.saveTextToParentTag=M_,this.addChild=V_,this.ignoreAttributesFn=$_(this.options.ignoreAttributes)}};function P_(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];this.lastEntities[r]={regex:new RegExp("&"+r+";","g"),val:t[r]}}}function T_(t,e,n,r,i,s,a){if(t!==void 0&&(this.options.trimValues&&!r&&(t=t.trim()),t.length>0)){a||(t=this.replaceEntitiesValue(t));const c=this.options.tagValueProcessor(e,t,n,i,s);return c==null?t:typeof c!=typeof t||c!==t?c:this.options.trimValues?$a(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?$a(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function B_(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 R_=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function L_(t,e,n){if(this.options.ignoreAttributes!==!0&&typeof t=="string"){const r=Vf.getAllMatches(t,R_),i=r.length,s={};for(let a=0;a<i;a++){const c=this.resolveNameSpace(r[a][1]);if(this.ignoreAttributesFn(c,e))continue;let l=r[a][4],d=this.options.attributeNamePrefix+c;if(c.length)if(this.options.transformAttributeName&&(d=this.options.transformAttributeName(d)),d==="__proto__"&&(d="#__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[d]=l:typeof p!=typeof l||p!==l?s[d]=p:s[d]=$a(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[d]=!0)}if(!Object.keys(s).length)return;if(this.options.attributesGroupName){const a={};return a[this.options.attributesGroupName]=s,a}return s}}const U_=function(t){t=t.replace(/\r\n?/g,`
8
- `);const e=new Cr("!xml");let n=e,r="",i="";for(let s=0;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="/"){const c=_n(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&&(r=this.saveTextToParentTag(r,n,i));const d=i.substring(i.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;d&&this.options.unpairedTags.indexOf(d)!==-1?(p=i.lastIndexOf(".",i.lastIndexOf(".")-1),this.tagsNodeStack.pop()):p=i.lastIndexOf("."),i=i.substring(0,p),n=this.tagsNodeStack.pop(),r="",s=c}else if(t[s+1]==="?"){let c=ja(t,s,!1,"?>");if(!c)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,n,i),!(this.options.ignoreDeclaration&&c.tagName==="?xml"||this.options.ignorePiTags)){const l=new Cr(c.tagName);l.add(this.options.textNodeName,""),c.tagName!==c.tagExp&&c.attrExpPresent&&(l[":@"]=this.buildAttributesMap(c.tagExp,i,c.tagName)),this.addChild(n,l,i)}s=c.closeIndex+1}else if(t.substr(s+1,3)==="!--"){const c=_n(t,"-->",s+4,"Comment is not closed.");if(this.options.commentPropName){const l=t.substring(s+4,c-2);r=this.saveTextToParentTag(r,n,i),n.add(this.options.commentPropName,[{[this.options.textNodeName]:l}])}s=c}else if(t.substr(s+1,2)==="!D"){const c=N_(t,s);this.docTypeEntities=c.entities,s=c.i}else if(t.substr(s+1,2)==="!["){const c=_n(t,"]]>",s,"CDATA is not closed.")-2,l=t.substring(s+9,c);r=this.saveTextToParentTag(r,n,i);let d=this.parseTextData(l,n.tagname,i,!0,!1,!0,!0);d==null&&(d=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:l}]):n.add(this.options.textNodeName,d),s=c+2}else{let c=ja(t,s,this.options.removeNSPrefix),l=c.tagName;const d=c.rawTagName;let p=c.tagExp,f=c.attrExpPresent,m=c.closeIndex;this.options.transformTagName&&(l=this.options.transformTagName(l)),n&&r&&n.tagname!=="!xml"&&(r=this.saveTextToParentTag(r,n,i,!1));const w=n;if(w&&this.options.unpairedTags.indexOf(w.tagname)!==-1&&(n=this.tagsNodeStack.pop(),i=i.substring(0,i.lastIndexOf("."))),l!==e.tagname&&(i+=i?"."+l:l),this.isItStopNode(this.options.stopNodes,i,l)){let h="";if(p.length>0&&p.lastIndexOf("/")===p.length-1)l[l.length-1]==="/"?(l=l.substr(0,l.length-1),i=i.substr(0,i.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 v=this.readStopNodeData(t,d,m+1);if(!v)throw new Error(`Unexpected end of ${d}`);s=v.i,h=v.tagContent}const _=new Cr(l);l!==p&&f&&(_[":@"]=this.buildAttributesMap(p,i,l)),h&&(h=this.parseTextData(h,l,i,!0,f,!0,!0)),i=i.substr(0,i.lastIndexOf(".")),_.add(this.options.textNodeName,h),this.addChild(n,_,i)}else{if(p.length>0&&p.lastIndexOf("/")===p.length-1){l[l.length-1]==="/"?(l=l.substr(0,l.length-1),i=i.substr(0,i.length-1),p=l):p=p.substr(0,p.length-1),this.options.transformTagName&&(l=this.options.transformTagName(l));const h=new Cr(l);l!==p&&f&&(h[":@"]=this.buildAttributesMap(p,i,l)),this.addChild(n,h,i),i=i.substr(0,i.lastIndexOf("."))}else{const h=new Cr(l);this.tagsNodeStack.push(n),l!==p&&f&&(h[":@"]=this.buildAttributesMap(p,i,l)),this.addChild(n,h,i),n=h}r="",s=m}}else r+=t[s];return e.child};function V_(t,e,n){const r=this.options.updateTag(e.tagname,n,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),t.addChild(e))}const q_=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 M_(t,e,n,r){return t&&(r===void 0&&(r=Object.keys(e.child).length===0),t=this.parseTextData(t,e.tagname,n,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,r),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function H_(t,e,n){const r="*."+n;for(const i in t){const s=t[i];if(r===s||e===s)return!0}return!1}function D_(t,e,n=">"){let r,i="";for(let s=e;s<t.length;s++){let a=t[s];if(r)a===r&&(r="");else if(a==='"'||a==="'")r=a;else if(a===n[0])if(n[1]){if(t[s+1]===n[1])return{data:i,index:s}}else return{data:i,index:s};else a===" "&&(a=" ");i+=a}}function _n(t,e,n,r){const i=t.indexOf(e,n);if(i===-1)throw new Error(r);return i+e.length-1}function ja(t,e,n,r=">"){const i=D_(t,e+1,r);if(!i)return;let s=i.data;const a=i.index,c=s.search(/\s/);let l=s,d=!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),d=l!==i.data.substr(f+1))}return{tagName:l,tagExp:s,closeIndex:a,attrExpPresent:d,rawTagName:p}}function F_(t,e,n){const r=n;let i=1;for(;n<t.length;n++)if(t[n]==="<")if(t[n+1]==="/"){const s=_n(t,">",n,`${e} is not closed`);if(t.substring(n+2,s).trim()===e&&(i--,i===0))return{tagContent:t.substring(r,n),i:s};n=s}else if(t[n+1]==="?")n=_n(t,"?>",n+1,"StopNode is not closed.");else if(t.substr(n+1,3)==="!--")n=_n(t,"-->",n+3,"StopNode is not closed.");else if(t.substr(n+1,2)==="![")n=_n(t,"]]>",n,"StopNode is not closed.")-2;else{const s=ja(t,n,">");s&&((s&&s.tagName)===e&&s.tagExp[s.tagExp.length-1]!=="/"&&i++,n=s.closeIndex)}}function $a(t,e,n){if(e&&typeof t=="string"){const r=t.trim();return r==="true"?!0:r==="false"?!1:j_(t,n)}else return Vf.isExist(t)?t:""}var K_=O_,qf={};function W_(t,e){return Mf(t,e)}function Mf(t,e,n){let r;const i={};for(let s=0;s<t.length;s++){const a=t[s],c=G_(a);let l="";if(n===void 0?l=c:l=n+"."+c,c===e.textNodeName)r===void 0?r=a[c]:r+=""+a[c];else{if(c===void 0)continue;if(a[c]){let d=Mf(a[c],e,l);const p=Z_(d,e);a[":@"]?J_(d,a[":@"],l,e):Object.keys(d).length===1&&d[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?d=d[e.textNodeName]:Object.keys(d).length===0&&(e.alwaysCreateTextNode?d[e.textNodeName]="":d=""),i[c]!==void 0&&i.hasOwnProperty(c)?(Array.isArray(i[c])||(i[c]=[i[c]]),i[c].push(d)):e.isArray(c,l,p)?i[c]=[d]:i[c]=d}}}return typeof r=="string"?r.length>0&&(i[e.textNodeName]=r):r!==void 0&&(i[e.textNodeName]=r),i}function G_(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];if(r!==":@")return r}}function J_(t,e,n,r){if(e){const i=Object.keys(e),s=i.length;for(let a=0;a<s;a++){const c=i[a];r.isArray(c,n+"."+c,!0,!0)?t[c]=[e[c]]:t[c]=e[c]}}}function Z_(t,e){const{textNodeName:n}=e,r=Object.keys(t).length;return!!(r===0||r===1&&(t[n]||typeof t[n]=="boolean"||t[n]===0))}qf.prettify=W_;const{buildOptions:Y_}=hl,X_=K_,{prettify:Q_}=qf,ey=pl;let ty=class{constructor(e){this.externalEntities={},this.options=Y_(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=ey.validate(e,n);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}const r=new X_(this.options);r.addExternalEntities(this.externalEntities);const i=r.parseXml(e);return this.options.preserveOrder||i===void 0?i:Q_(i,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 '&#xD;'");if(n==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=n}};var ny=ty;const ry=`
9
- `;function iy(t,e){let n="";return e.format&&e.indentBy.length>0&&(n=ry),Hf(t,e,"",n)}function Hf(t,e,n,r){let i="",s=!1;for(let a=0;a<t.length;a++){const c=t[a],l=sy(c);if(l===void 0)continue;let d="";if(n.length===0?d=l:d=`${n}.${l}`,l===e.textNodeName){let h=c[l];oy(d,e)||(h=e.tagValueProcessor(l,h),h=Df(h,e)),s&&(i+=r),i+=h,s=!1;continue}else if(l===e.cdataPropName){s&&(i+=r),i+=`<![CDATA[${c[l][0][e.textNodeName]}]]>`,s=!1;continue}else if(l===e.commentPropName){i+=r+`<!--${c[l][0][e.textNodeName]}-->`,s=!0;continue}else if(l[0]==="?"){const h=Yd(c[":@"],e),_=l==="?xml"?"":r;let v=c[l][0][e.textNodeName];v=v.length!==0?" "+v:"",i+=_+`<${l}${v}${h}?>`,s=!0;continue}let p=r;p!==""&&(p+=e.indentBy);const f=Yd(c[":@"],e),m=r+`<${l}${f}`,w=Hf(c[l],e,d,p);e.unpairedTags.indexOf(l)!==-1?e.suppressUnpairedNode?i+=m+">":i+=m+"/>":(!w||w.length===0)&&e.suppressEmptyNode?i+=m+"/>":w&&w.endsWith(">")?i+=m+`>${w}${r}</${l}>`:(i+=m+">",w&&r!==""&&(w.includes("/>")||w.includes("</"))?i+=r+e.indentBy+w+r:i+=w,i+=`</${l}>`),s=!0}return i}function sy(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];if(t.hasOwnProperty(r)&&r!==":@")return r}}function Yd(t,e){let n="";if(t&&!e.ignoreAttributes)for(let r in t){if(!t.hasOwnProperty(r))continue;let i=e.attributeValueProcessor(r,t[r]);i=Df(i,e),i===!0&&e.suppressBooleanAttributes?n+=` ${r.substr(e.attributeNamePrefix.length)}`:n+=` ${r.substr(e.attributeNamePrefix.length)}="${i}"`}return n}function oy(t,e){t=t.substr(0,t.length-e.textNodeName.length-1);let n=t.substr(t.lastIndexOf(".")+1);for(let r in e.stopNodes)if(e.stopNodes[r]===t||e.stopNodes[r]==="*."+n)return!0;return!1}function Df(t,e){if(t&&t.length>0&&e.processEntities)for(let n=0;n<e.entities.length;n++){const r=e.entities[n];t=t.replace(r.regex,r.val)}return t}var ay=iy;const cy=ay,ly=Uf,dy={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:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function cn(t){this.options=Object.assign({},dy,t),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=ly(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=fy),this.processTextOrObjNode=uy,this.options.format?(this.indentate=py,this.tagEndChar=`>
5
+ */(function(e,n){typeof C0=="function"&&t&&t.exports?t.exports=n():(e.dcodeIO=e.dcodeIO||{}).bcrypt=n()})(ls,function(){var e={},n=null;function r(j){if(t&&t.exports)try{return $0.randomBytes(j)}catch{}try{var N;return(self.crypto||self.msCrypto).getRandomValues(N=new Uint32Array(j)),Array.prototype.slice.call(N)}catch{}if(!n)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return n(j)}var i=!1;try{r(1),i=!0}catch{}n=null,e.setRandomFallback=function(j){n=j},e.genSaltSync=function(j,N){if(j=j||_,typeof j!="number")throw Error("Illegal arguments: "+typeof j+", "+typeof N);j<4?j=4:j>31&&(j=31);var z=[];return z.push("$2a$"),j<10&&z.push("0"),z.push(j.toString()),z.push("$"),z.push(f(r(h),h)),z.join("")},e.genSalt=function(j,N,z){if(typeof N=="function"&&(z=N,N=void 0),typeof j=="function"&&(z=j,j=void 0),typeof j>"u")j=_;else if(typeof j!="number")throw Error("illegal arguments: "+typeof j);function k(x){a(function(){try{x(null,e.genSaltSync(j))}catch($){x($)}})}if(z){if(typeof z!="function")throw Error("Illegal callback: "+typeof z);k(z)}else return new Promise(function(x,$){k(function(U,X){if(U){$(U);return}x(X)})})},e.hashSync=function(j,N){if(typeof N>"u"&&(N=_),typeof N=="number"&&(N=e.genSaltSync(N)),typeof j!="string"||typeof N!="string")throw Error("Illegal arguments: "+typeof j+", "+typeof N);return Re(j,N)},e.hash=function(j,N,z,k){function x($){typeof j=="string"&&typeof N=="number"?e.genSalt(N,function(U,X){Re(j,X,$,k)}):typeof j=="string"&&typeof N=="string"?Re(j,N,$,k):a($.bind(this,Error("Illegal arguments: "+typeof j+", "+typeof N)))}if(z){if(typeof z!="function")throw Error("Illegal callback: "+typeof z);x(z)}else return new Promise(function($,U){x(function(X,G){if(X){U(X);return}$(G)})})};function s(j,N){for(var z=0,k=0,x=0,$=j.length;x<$;++x)j.charCodeAt(x)===N.charCodeAt(x)?++z:++k;return z<0?!1:k===0}e.compareSync=function(j,N){if(typeof j!="string"||typeof N!="string")throw Error("Illegal arguments: "+typeof j+", "+typeof N);return N.length!==60?!1:s(e.hashSync(j,N.substr(0,N.length-31)),N)},e.compare=function(j,N,z,k){function x($){if(typeof j!="string"||typeof N!="string"){a($.bind(this,Error("Illegal arguments: "+typeof j+", "+typeof N)));return}if(N.length!==60){a($.bind(this,null,!1));return}e.hash(j,N.substr(0,29),function(U,X){U?$(U):$(null,s(X,N))},k)}if(z){if(typeof z!="function")throw Error("Illegal callback: "+typeof z);x(z)}else return new Promise(function($,U){x(function(X,G){if(X){U(X);return}$(G)})})},e.getRounds=function(j){if(typeof j!="string")throw Error("Illegal arguments: "+typeof j);return parseInt(j.split("$")[2],10)},e.getSalt=function(j){if(typeof j!="string")throw Error("Illegal arguments: "+typeof j);if(j.length!==60)throw Error("Illegal hash length: "+j.length+" != 60");return j.substring(0,29)};var a=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function c(j){var N=[],z=0;return w.encodeUTF16toUTF8(function(){return z>=j.length?null:j.charCodeAt(z++)},function(k){N.push(k)}),N}var l="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),d=[-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(j,N){var z=0,k=[],x,$;if(N<=0||N>j.length)throw Error("Illegal len: "+N);for(;z<N;){if(x=j[z++]&255,k.push(l[x>>2&63]),x=(x&3)<<4,z>=N){k.push(l[x&63]);break}if($=j[z++]&255,x|=$>>4&15,k.push(l[x&63]),x=($&15)<<2,z>=N){k.push(l[x&63]);break}$=j[z++]&255,x|=$>>6&3,k.push(l[x&63]),k.push(l[$&63])}return k.join("")}function m(j,N){var z=0,k=j.length,x=0,$=[],U,X,G,se,ue,D;if(N<=0)throw Error("Illegal len: "+N);for(;z<k-1&&x<N&&(D=j.charCodeAt(z++),U=D<d.length?d[D]:-1,D=j.charCodeAt(z++),X=D<d.length?d[D]:-1,!(U==-1||X==-1||(ue=U<<2>>>0,ue|=(X&48)>>4,$.push(p(ue)),++x>=N||z>=k)||(D=j.charCodeAt(z++),G=D<d.length?d[D]:-1,G==-1)||(ue=(X&15)<<4>>>0,ue|=(G&60)>>2,$.push(p(ue)),++x>=N||z>=k)));)D=j.charCodeAt(z++),se=D<d.length?d[D]:-1,ue=(G&3)<<6>>>0,ue|=se,$.push(p(ue)),++x;var Ce=[];for(z=0;z<x;z++)Ce.push($[z].charCodeAt(0));return Ce}var w=function(){var j={};return j.MAX_CODEPOINT=1114111,j.encodeUTF8=function(N,z){var k=null;for(typeof N=="number"&&(k=N,N=function(){return null});k!==null||(k=N())!==null;)k<128?z(k&127):k<2048?(z(k>>6&31|192),z(k&63|128)):k<65536?(z(k>>12&15|224),z(k>>6&63|128),z(k&63|128)):(z(k>>18&7|240),z(k>>12&63|128),z(k>>6&63|128),z(k&63|128)),k=null},j.decodeUTF8=function(N,z){for(var k,x,$,U,X=function(G){G=G.slice(0,G.indexOf(null));var se=Error(G.toString());throw se.name="TruncatedError",se.bytes=G,se};(k=N())!==null;)if(!(k&128))z(k);else if((k&224)===192)(x=N())===null&&X([k,x]),z((k&31)<<6|x&63);else if((k&240)===224)((x=N())===null||($=N())===null)&&X([k,x,$]),z((k&15)<<12|(x&63)<<6|$&63);else if((k&248)===240)((x=N())===null||($=N())===null||(U=N())===null)&&X([k,x,$,U]),z((k&7)<<18|(x&63)<<12|($&63)<<6|U&63);else throw RangeError("Illegal starting byte: "+k)},j.UTF16toUTF8=function(N,z){for(var k,x=null;(k=x!==null?x:N())!==null;){if(k>=55296&&k<=57343&&(x=N())!==null&&x>=56320&&x<=57343){z((k-55296)*1024+x-56320+65536),x=null;continue}z(k)}x!==null&&z(x)},j.UTF8toUTF16=function(N,z){var k=null;for(typeof N=="number"&&(k=N,N=function(){return null});k!==null||(k=N())!==null;)k<=65535?z(k):(k-=65536,z((k>>10)+55296),z(k%1024+56320)),k=null},j.encodeUTF16toUTF8=function(N,z){j.UTF16toUTF8(N,function(k){j.encodeUTF8(k,z)})},j.decodeUTF8toUTF16=function(N,z){j.decodeUTF8(N,function(k){j.UTF8toUTF16(k,z)})},j.calculateCodePoint=function(N){return N<128?1:N<2048?2:N<65536?3:4},j.calculateUTF8=function(N){for(var z,k=0;(z=N())!==null;)k+=j.calculateCodePoint(z);return k},j.calculateUTF16asUTF8=function(N){var z=0,k=0;return j.UTF16toUTF8(N,function(x){++z,k+=j.calculateCodePoint(x)}),[z,k]},j}();Date.now=Date.now||function(){return+new Date};var h=16,_=10,v=16,S=100,C=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],O=[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],L=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function Q(j,N,z,k){var x,$=j[N],U=j[N+1];return $^=z[0],x=k[$>>>24],x+=k[256|$>>16&255],x^=k[512|$>>8&255],x+=k[768|$&255],U^=x^z[1],x=k[U>>>24],x+=k[256|U>>16&255],x^=k[512|U>>8&255],x+=k[768|U&255],$^=x^z[2],x=k[$>>>24],x+=k[256|$>>16&255],x^=k[512|$>>8&255],x+=k[768|$&255],U^=x^z[3],x=k[U>>>24],x+=k[256|U>>16&255],x^=k[512|U>>8&255],x+=k[768|U&255],$^=x^z[4],x=k[$>>>24],x+=k[256|$>>16&255],x^=k[512|$>>8&255],x+=k[768|$&255],U^=x^z[5],x=k[U>>>24],x+=k[256|U>>16&255],x^=k[512|U>>8&255],x+=k[768|U&255],$^=x^z[6],x=k[$>>>24],x+=k[256|$>>16&255],x^=k[512|$>>8&255],x+=k[768|$&255],U^=x^z[7],x=k[U>>>24],x+=k[256|U>>16&255],x^=k[512|U>>8&255],x+=k[768|U&255],$^=x^z[8],x=k[$>>>24],x+=k[256|$>>16&255],x^=k[512|$>>8&255],x+=k[768|$&255],U^=x^z[9],x=k[U>>>24],x+=k[256|U>>16&255],x^=k[512|U>>8&255],x+=k[768|U&255],$^=x^z[10],x=k[$>>>24],x+=k[256|$>>16&255],x^=k[512|$>>8&255],x+=k[768|$&255],U^=x^z[11],x=k[U>>>24],x+=k[256|U>>16&255],x^=k[512|U>>8&255],x+=k[768|U&255],$^=x^z[12],x=k[$>>>24],x+=k[256|$>>16&255],x^=k[512|$>>8&255],x+=k[768|$&255],U^=x^z[13],x=k[U>>>24],x+=k[256|U>>16&255],x^=k[512|U>>8&255],x+=k[768|U&255],$^=x^z[14],x=k[$>>>24],x+=k[256|$>>16&255],x^=k[512|$>>8&255],x+=k[768|$&255],U^=x^z[15],x=k[U>>>24],x+=k[256|U>>16&255],x^=k[512|U>>8&255],x+=k[768|U&255],$^=x^z[16],j[N]=U^z[v+1],j[N+1]=$,j}function ce(j,N){for(var z=0,k=0;z<4;++z)k=k<<8|j[N]&255,N=(N+1)%j.length;return{key:k,offp:N}}function le(j,N,z){for(var k=0,x=[0,0],$=N.length,U=z.length,X,G=0;G<$;G++)X=ce(j,k),k=X.offp,N[G]=N[G]^X.key;for(G=0;G<$;G+=2)x=Q(x,0,N,z),N[G]=x[0],N[G+1]=x[1];for(G=0;G<U;G+=2)x=Q(x,0,N,z),z[G]=x[0],z[G+1]=x[1]}function De(j,N,z,k){for(var x=0,$=[0,0],U=z.length,X=k.length,G,se=0;se<U;se++)G=ce(N,x),x=G.offp,z[se]=z[se]^G.key;for(x=0,se=0;se<U;se+=2)G=ce(j,x),x=G.offp,$[0]^=G.key,G=ce(j,x),x=G.offp,$[1]^=G.key,$=Q($,0,z,k),z[se]=$[0],z[se+1]=$[1];for(se=0;se<X;se+=2)G=ce(j,x),x=G.offp,$[0]^=G.key,G=ce(j,x),x=G.offp,$[1]^=G.key,$=Q($,0,z,k),k[se]=$[0],k[se+1]=$[1]}function Ve(j,N,z,k,x){var $=L.slice(),U=$.length,X;if(z<4||z>31)if(X=Error("Illegal number of rounds (4-31): "+z),k){a(k.bind(this,X));return}else throw X;if(N.length!==h)if(X=Error("Illegal salt length: "+N.length+" != "+h),k){a(k.bind(this,X));return}else throw X;z=1<<z>>>0;var G,se,ue=0,D;Int32Array?(G=new Int32Array(C),se=new Int32Array(O)):(G=C.slice(),se=O.slice()),De(N,j,G,se);function Ce(){if(x&&x(ue/z),ue<z)for(var he=Date.now();ue<z&&(ue=ue+1,le(j,G,se),le(N,G,se),!(Date.now()-he>S)););else{for(ue=0;ue<64;ue++)for(D=0;D<U>>1;D++)Q($,D<<1,G,se);var Se=[];for(ue=0;ue<U;ue++)Se.push(($[ue]>>24&255)>>>0),Se.push(($[ue]>>16&255)>>>0),Se.push(($[ue]>>8&255)>>>0),Se.push(($[ue]&255)>>>0);if(k){k(null,Se);return}else return Se}k&&a(Ce)}if(typeof k<"u")Ce();else for(var fn;;)if(typeof(fn=Ce())<"u")return fn||[]}function Re(j,N,z,k){var x;if(typeof j!="string"||typeof N!="string")if(x=Error("Invalid string / salt: Not a string"),z){a(z.bind(this,x));return}else throw x;var $,U;if(N.charAt(0)!=="$"||N.charAt(1)!=="2")if(x=Error("Invalid salt version: "+N.substring(0,2)),z){a(z.bind(this,x));return}else throw x;if(N.charAt(2)==="$")$="\0",U=3;else{if($=N.charAt(2),$!=="a"&&$!=="b"&&$!=="y"||N.charAt(3)!=="$")if(x=Error("Invalid salt revision: "+N.substring(2,4)),z){a(z.bind(this,x));return}else throw x;U=4}if(N.charAt(U+2)>"$")if(x=Error("Missing salt rounds"),z){a(z.bind(this,x));return}else throw x;var X=parseInt(N.substring(U,U+1),10)*10,G=parseInt(N.substring(U+1,U+2),10),se=X+G,ue=N.substring(U+3,U+25);j+=$>="a"?"\0":"";var D=c(j),Ce=m(ue,h);function fn(he){var Se=[];return Se.push("$2"),$>="a"&&Se.push($),Se.push("$"),se<10&&Se.push("0"),Se.push(se.toString()),Se.push("$"),Se.push(f(Ce,Ce.length)),Se.push(f(he,L.length*4-1)),Se.join("")}if(typeof z>"u")return fn(Ve(D,Ce,se));Ve(D,Ce,se,function(he,Se){he?z(he,null):z(null,fn(Se))},k)}return e.encodeBase64=f,e.decodeBase64=m,e})})(Of);var O0=Of.exports;const oi=$f(O0),P0="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let T0=t=>crypto.getRandomValues(new Uint8Array(t)),B0=(t,e,n)=>{let r=(2<<Math.log2(t.length-1))-1,i=-~(1.6*r*e/t.length);return(s=e)=>{let a="";for(;;){let c=n(i),l=i;for(;l--;)if(a+=t[c[l]&r]||"",a.length===s)return a}}},R0=(t,e=21)=>B0(t,e,T0),ke=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=P0[n[t]&63];return e};const L0=24;function eo(){return R0("0123456789abcdef",L0)()}function Dd(t){if(!t.includes("|"))return console.error("Invalid user_id format"),t;const[,e]=t.split("|");return e}function U0(t){return async(e,n)=>{if(!n.email||!n.email_verified)return t.users.create(e,n);const r=await so({userAdapter:t.users,tenant_id:e,email:n.email});return r?(await t.users.create(e,{...n,linked_to:r.user_id}),r):t.users.create(e,n)}}function we(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:[]}}class ll{constructor(e,n){te(this,"value");te(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 ll(Math.round(this.milliseconds()*e),"ms")}}class V0{constructor(e){te(this,"hash");this.hash=e}async verify(e,n,r){const i=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",i,n,r)}async sign(e,n){const r=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",r,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"]),r=await crypto.subtle.exportKey("pkcs8",n.privateKey),i=await crypto.subtle.exportKey("spki",n.publicKey);return{privateKey:r,publicKey:i}}}async function Pf(t){return await crypto.subtle.digest("SHA-256",t)}const Fd="0123456789abcdef";function Ca(t){const e=new Uint8Array(t);let n="";for(let r=0;r<e.length;r++){const i=e[r]>>4;n+=Fd[i];const s=e[r]&15;n+=Fd[s]}return n}class Tf{constructor(e,n){te(this,"alphabet");te(this,"padding");te(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 r=0;r<e.length;r++)this.decodeMap.set(e[r],r)}encode(e,n){let r="",i=0,s=0;for(let c=0;c<e.length;c++)for(i=i<<8|e[c],s+=8;s>=5;)s-=5,r+=this.alphabet[i>>s&31];if(s>0&&(r+=this.alphabet[i<<5-s&31]),(n==null?void 0:n.includePadding)??!0){const c=(8-r.length%8)%8;for(let l=0;l<c;l++)r+="="}return r}decode(e,n){const r=(n==null?void 0:n.strict)??!0,i=Math.ceil(e.length/8),s=[];for(let a=0;a<i;a++){let c=0;const l=[];for(let p=0;p<8;p++){const f=e[a*8+p];if(f==="="){if(a+1!==i)throw new Error(`Invalid character: ${f}`);c+=1;continue}if(f===void 0){if(r)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 d=(l[0]<<3)+(l[1]>>2);if(s.push(d),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 Tf("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");new Tf("0123456789ABCDEFGHIJKLMNOPQRSTUV");class Bf{constructor(e,n){te(this,"alphabet");te(this,"padding");te(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 r=0;r<e.length;r++)this.decodeMap.set(e[r],r)}encode(e,n){let r="",i=0,s=0;for(let c=0;c<e.length;c++)for(i=i<<8|e[c],s+=8;s>=6;)s+=-6,r+=this.alphabet[i>>s&63];if(s>0&&(r+=this.alphabet[i<<6-s&63]),(n==null?void 0:n.includePadding)??!0){const c=(4-r.length%4)%4;for(let l=0;l<c;l++)r+="="}return r}decode(e,n){const r=(n==null?void 0:n.strict)??!0,i=Math.ceil(e.length/4),s=[];for(let a=0;a<i;a++){let c=0,l=0;for(let d=0;d<4;d++){const p=e[a*4+d];if(p==="="){if(a+1!==i)throw new Error(`Invalid character: ${p}`);c+=1;continue}if(p===void 0){if(r)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-d)}s.push(l>>16&255),c<2&&s.push(l>>8&255),c<1&&s.push(l&255)}return Uint8Array.from(s)}}const q0=new Bf("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),vn=new Bf("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");async function Kd(t,e,n,r){const i={alg:t,typ:"JWT",...r==null?void 0:r.headers},s={...n};(r==null?void 0:r.audiences)!==void 0&&(s.aud=r.audiences),(r==null?void 0:r.subject)!==void 0&&(s.sub=r.subject),(r==null?void 0:r.issuer)!==void 0&&(s.iss=r.issuer),(r==null?void 0:r.jwtId)!==void 0&&(s.jti=r.jwtId),(r==null?void 0:r.expiresIn)!==void 0&&(s.exp=Math.floor(Date.now()/1e3)+r.expiresIn.seconds()),(r==null?void 0:r.notBefore)!==void 0&&(s.nbf=Math.floor(r.notBefore.getTime()/1e3)),s.iat=Math.floor(Date.now()/1e3);const a=new TextEncoder,c=vn.encode(a.encode(JSON.stringify(i)),{includePadding:!1}),l=vn.encode(a.encode(JSON.stringify(s)),{includePadding:!1}),d=a.encode([c,l].join(".")),p=await H0(t).sign(e,d),f=vn.encode(new Uint8Array(p),{includePadding:!1});return[c,l,f].join(".")}function M0(t){const e=t.split(".");return e.length!==3?null:e}function dl(t){const e=M0(t);if(!e)return null;const n=new TextDecoder,r=vn.decode(e[0],{strict:!1}),i=vn.decode(e[1],{strict:!1}),s=JSON.parse(n.decode(r));if(typeof s!="object"||s===null||!("alg"in s)||!D0(s.alg)||"typ"in s&&s.typ!=="JWT")return null;const a=JSON.parse(n.decode(i));if(typeof a!="object"||a===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 a){if(typeof a.exp!="number")return null;c.expiresAt=new Date(a.exp*1e3)}if("iss"in a){if(typeof a.iss!="string")return null;c.issuer=a.iss}if("sub"in a){if(typeof a.sub!="string")return null;c.subject=a.sub}if("aud"in a)if(Array.isArray(a.aud)){for(const l of a.aud)if(typeof l!="string")return null;c.audiences=a.aud}else{if(typeof a.aud!="string")return null;c.audiences=[a.aud]}if("nbf"in a){if(typeof a.nbf!="number")return null;c.notBefore=new Date(a.nbf*1e3)}if("iat"in a){if(typeof a.iat!="number")return null;c.issuedAt=new Date(a.iat*1e3)}if("jti"in a){if(typeof a.jti!="string")return null;c.jwtId=a.jti}return{value:t,header:{...s,typ:"JWT",alg:s.alg},payload:{...a},parts:e,...c}}function H0(t){return new V0(F0[t])}function D0(t){return typeof t!="string"?!1:["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512","PS256","PS384","PS512"].includes(t)}const F0={RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"};function K0(){const t=new Uint8Array(32);return crypto.getRandomValues(t),vn.encode(t,{includePadding:!1})}function W0(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,"")),r=>r.charCodeAt(0)).buffer}finally{t=t.replace(/./g,"\0")}}async function G0(t,e){if(e==="plain")return t;const n=new TextEncoder().encode(t),r=await Pf(n);return vn.encode(new Uint8Array(r),{includePadding:!1})}const Oi=60*5,to=30*24*60*60,Qn=24*60*60,J0="auth-token",Na=30*60*1e3,Z0=7*24*60*60*1e3,Y0=5*60,X0=5*60,Q0=30*60*1e3,e_=30*60*1e3,t_=24*60*60*1e3;function Rf(t,e,n){const r=[];return r.push([encodeURIComponent(t),encodeURIComponent(e)]),(n==null?void 0:n.domain)!==void 0&&r.push(["Domain",n.domain]),(n==null?void 0:n.expires)!==void 0&&r.push(["Expires",n.expires.toUTCString()]),n!=null&&n.httpOnly&&r.push(["HttpOnly"]),(n==null?void 0:n.maxAge)!==void 0&&r.push(["Max-Age",n.maxAge.toString()]),(n==null?void 0:n.path)!==void 0&&r.push(["Path",n.path]),(n==null?void 0:n.sameSite)==="lax"&&r.push(["SameSite","Lax"]),(n==null?void 0:n.sameSite)==="none"&&r.push(["SameSite","None"]),(n==null?void 0:n.sameSite)==="strict"&&r.push(["SameSite","Strict"]),n!=null&&n.secure&&r.push(["Secure"]),r.map(i=>i.join("=")).join("; ")}function n_(t){const e=new Map,n=t.split("; ");for(const r of n){const i=r.split("="),s=i[0],a=i[1]??"";s&&e.set(decodeURIComponent(s),decodeURIComponent(a))}return e}function ul(t){return`${t}-${J0}`}function Lf(t){if(!t)return;if(t==="localhost"||/^(\d{1,3}\.){3}\d{1,3}$/.test(t))return t;const e=t.split(".");return e.length>2?`.${e.slice(-2).join(".")}`:`.${t}`}function ds(t,e){return e?n_(e).get(ul(t)):void 0}function r_(t,e){return Rf(ul(t),"",{path:"/",httpOnly:!0,secure:!0,maxAge:0,sameSite:"none",domain:e?Lf(e):void 0})}function Uf(t,e,n){return Rf(ul(t),e,{path:"/",httpOnly:!0,secure:!0,maxAge:to,sameSite:"none",domain:n?Lf(n):void 0})}var pl={},no={};(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",r="["+e+"]["+n+"]*",i=new RegExp("^"+r+"$"),s=function(c,l){const d=[];let p=l.exec(c);for(;p;){const f=[];f.startIndex=l.lastIndex-p[0].length;const m=p.length;for(let w=0;w<m;w++)f.push(p[w]);d.push(f),p=l.exec(c)}return d},a=function(c){const l=i.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,d){if(l){const p=Object.keys(l),f=p.length;for(let m=0;m<f;m++)d==="strict"?c[p[m]]=[l[p[m]]]:c[p[m]]=l[p[m]]}},t.getValue=function(c){return t.isExist(c)?c:""},t.isName=a,t.getAllMatches=s,t.nameRegexp=r})(no);const fl=no,i_={allowBooleanAttributes:!1,unpairedTags:[]};pl.validate=function(t,e){e=Object.assign({},i_,e);const n=[];let r=!1,i=!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=Gd(t,s),s.err)return s}else if(t[s]==="<"){let a=s;if(s++,t[s]==="!"){s=Jd(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]!==`
6
+ `&&t[s]!=="\r";s++)l+=t[s];if(l=l.trim(),l[l.length-1]==="/"&&(l=l.substring(0,l.length-1),s--),!p_(l)){let f;return l.trim().length===0?f="Invalid space after '<'.":f="Tag '"+l+"' is an invalid name.",be("InvalidTag",f,qe(t,s))}const d=a_(t,s);if(d===!1)return be("InvalidAttr","Attributes for '"+l+"' have open quote.",qe(t,s));let p=d.value;if(s=d.index,p[p.length-1]==="/"){const f=s-p.length;p=p.substring(0,p.length-1);const m=Zd(p,e);if(m===!0)r=!0;else return be(m.err.code,m.err.msg,qe(t,f+m.err.line))}else if(c)if(d.tagClosed){if(p.trim().length>0)return be("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",qe(t,a));if(n.length===0)return be("InvalidTag","Closing tag '"+l+"' has not been opened.",qe(t,a));{const f=n.pop();if(l!==f.tagName){let m=qe(t,f.tagStartPos);return be("InvalidTag","Expected closing tag '"+f.tagName+"' (opened in line "+m.line+", col "+m.col+") instead of closing tag '"+l+"'.",qe(t,a))}n.length==0&&(i=!0)}}else return be("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",qe(t,s));else{const f=Zd(p,e);if(f!==!0)return be(f.err.code,f.err.msg,qe(t,s-p.length+f.err.line));if(i===!0)return be("InvalidXml","Multiple possible root nodes found.",qe(t,s));e.unpairedTags.indexOf(l)!==-1||n.push({tagName:l,tagStartPos:a}),r=!0}for(s++;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="!"){s++,s=Jd(t,s);continue}else if(t[s+1]==="?"){if(s=Gd(t,++s),s.err)return s}else break;else if(t[s]==="&"){const f=d_(t,s);if(f==-1)return be("InvalidChar","char '&' is not expected.",qe(t,s));s=f}else if(i===!0&&!Wd(t[s]))return be("InvalidXml","Extra text at the end",qe(t,s));t[s]==="<"&&s--}}else{if(Wd(t[s]))continue;return be("InvalidChar","char '"+t[s]+"' is not expected.",qe(t,s))}if(r){if(n.length==1)return be("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",qe(t,n[0].tagStartPos));if(n.length>0)return be("InvalidXml","Invalid '"+JSON.stringify(n.map(s=>s.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return be("InvalidXml","Start tag expected.",1);return!0};function Wd(t){return t===" "||t===" "||t===`
7
+ `||t==="\r"}function Gd(t,e){const n=e;for(;e<t.length;e++)if(t[e]=="?"||t[e]==" "){const r=t.substr(n,e-n);if(e>5&&r==="xml")return be("InvalidXml","XML declaration allowed only at the start of the document.",qe(t,e));if(t[e]=="?"&&t[e+1]==">"){e++;break}else continue}return e}function Jd(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 s_='"',o_="'";function a_(t,e){let n="",r="",i=!1;for(;e<t.length;e++){if(t[e]===s_||t[e]===o_)r===""?r=t[e]:r!==t[e]||(r="");else if(t[e]===">"&&r===""){i=!0;break}n+=t[e]}return r!==""?!1:{value:n,index:e,tagClosed:i}}const c_=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Zd(t,e){const n=fl.getAllMatches(t,c_),r={};for(let i=0;i<n.length;i++){if(n[i][1].length===0)return be("InvalidAttr","Attribute '"+n[i][2]+"' has no space in starting.",Ir(n[i]));if(n[i][3]!==void 0&&n[i][4]===void 0)return be("InvalidAttr","Attribute '"+n[i][2]+"' is without value.",Ir(n[i]));if(n[i][3]===void 0&&!e.allowBooleanAttributes)return be("InvalidAttr","boolean attribute '"+n[i][2]+"' is not allowed.",Ir(n[i]));const s=n[i][2];if(!u_(s))return be("InvalidAttr","Attribute '"+s+"' is an invalid name.",Ir(n[i]));if(!r.hasOwnProperty(s))r[s]=1;else return be("InvalidAttr","Attribute '"+s+"' is repeated.",Ir(n[i]))}return!0}function l_(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 d_(t,e){if(e++,t[e]===";")return-1;if(t[e]==="#")return e++,l_(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 be(t,e,n){return{err:{code:t,msg:e,line:n.line||n,col:n.col}}}function u_(t){return fl.isName(t)}function p_(t){return fl.isName(t)}function qe(t,e){const n=t.substring(0,e).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function Ir(t){return t.startIndex+t[1].length}var hl={};const Vf={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}},f_=function(t){return Object.assign({},Vf,t)};hl.buildOptions=f_;hl.defaultOptions=Vf;class h_{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 g_=h_;const m_=no;function __(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 r=1,i=!1,s=!1,a="";for(;e<t.length;e++)if(t[e]==="<"&&!s){if(i&&v_(t,e)){e+=7;let c,l;[c,l,e]=y_(t,e+1),l.indexOf("&")===-1&&(n[S_(c)]={regx:RegExp(`&${c};`,"g"),val:l})}else if(i&&b_(t,e))e+=8;else if(i&&x_(t,e))e+=8;else if(i&&k_(t,e))e+=9;else if(w_)s=!0;else throw new Error("Invalid DOCTYPE");r++,a=""}else if(t[e]===">"){if(s?t[e-1]==="-"&&t[e-2]==="-"&&(s=!1,r--):r--,r===0)break}else t[e]==="["?i=!0:a+=t[e];if(r!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:n,i:e}}function y_(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 r=t[e++];let i="";for(;e<t.length&&t[e]!==r;e++)i+=t[e];return[n,i,e]}function w_(t,e){return t[e+1]==="!"&&t[e+2]==="-"&&t[e+3]==="-"}function v_(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 b_(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 x_(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 k_(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 S_(t){if(m_.isName(t))return t;throw new Error(`Invalid entity name ${t}`)}var A_=__;const z_=/^[-+]?0x[a-fA-F0-9]+$/,E_=/^([\-\+])?(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 I_={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function C_(t,e={}){if(e=Object.assign({},I_,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&&z_.test(n))return Number.parseInt(n,16);{const r=E_.exec(n);if(r){const i=r[1],s=r[2];let a=N_(r[3]);const c=r[4]||r[6];if(!e.leadingZeros&&s.length>0&&i&&n[2]!==".")return t;if(!e.leadingZeros&&s.length>0&&!i&&n[1]!==".")return t;{const l=Number(n),d=""+l;return d.search(/[eE]/)!==-1||c?e.eNotation?l:t:n.indexOf(".")!==-1?d==="0"&&a===""||d===a||i&&d==="-"+a?l:t:s?a===d||i+a===d?l:t:n===d||n===i+d?l:t}}else return t}}function N_(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 j_=C_;function $_(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 qf=$_;const Mf=no,Cr=g_,O_=A_,P_=j_,T_=qf;let B_=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,r)=>String.fromCharCode(Number.parseInt(r,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(n,r)=>String.fromCharCode(Number.parseInt(r,16))}},this.addExternalEntities=R_,this.parseXml=M_,this.parseTextData=L_,this.resolveNameSpace=U_,this.buildAttributesMap=q_,this.isItStopNode=K_,this.replaceEntitiesValue=D_,this.readStopNodeData=G_,this.saveTextToParentTag=F_,this.addChild=H_,this.ignoreAttributesFn=T_(this.options.ignoreAttributes)}};function R_(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];this.lastEntities[r]={regex:new RegExp("&"+r+";","g"),val:t[r]}}}function L_(t,e,n,r,i,s,a){if(t!==void 0&&(this.options.trimValues&&!r&&(t=t.trim()),t.length>0)){a||(t=this.replaceEntitiesValue(t));const c=this.options.tagValueProcessor(e,t,n,i,s);return c==null?t:typeof c!=typeof t||c!==t?c:this.options.trimValues?$a(t,this.options.parseTagValue,this.options.numberParseOptions):t.trim()===t?$a(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function U_(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 V_=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function q_(t,e,n){if(this.options.ignoreAttributes!==!0&&typeof t=="string"){const r=Mf.getAllMatches(t,V_),i=r.length,s={};for(let a=0;a<i;a++){const c=this.resolveNameSpace(r[a][1]);if(this.ignoreAttributesFn(c,e))continue;let l=r[a][4],d=this.options.attributeNamePrefix+c;if(c.length)if(this.options.transformAttributeName&&(d=this.options.transformAttributeName(d)),d==="__proto__"&&(d="#__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[d]=l:typeof p!=typeof l||p!==l?s[d]=p:s[d]=$a(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[d]=!0)}if(!Object.keys(s).length)return;if(this.options.attributesGroupName){const a={};return a[this.options.attributesGroupName]=s,a}return s}}const M_=function(t){t=t.replace(/\r\n?/g,`
8
+ `);const e=new Cr("!xml");let n=e,r="",i="";for(let s=0;s<t.length;s++)if(t[s]==="<")if(t[s+1]==="/"){const c=_n(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&&(r=this.saveTextToParentTag(r,n,i));const d=i.substring(i.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;d&&this.options.unpairedTags.indexOf(d)!==-1?(p=i.lastIndexOf(".",i.lastIndexOf(".")-1),this.tagsNodeStack.pop()):p=i.lastIndexOf("."),i=i.substring(0,p),n=this.tagsNodeStack.pop(),r="",s=c}else if(t[s+1]==="?"){let c=ja(t,s,!1,"?>");if(!c)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,n,i),!(this.options.ignoreDeclaration&&c.tagName==="?xml"||this.options.ignorePiTags)){const l=new Cr(c.tagName);l.add(this.options.textNodeName,""),c.tagName!==c.tagExp&&c.attrExpPresent&&(l[":@"]=this.buildAttributesMap(c.tagExp,i,c.tagName)),this.addChild(n,l,i)}s=c.closeIndex+1}else if(t.substr(s+1,3)==="!--"){const c=_n(t,"-->",s+4,"Comment is not closed.");if(this.options.commentPropName){const l=t.substring(s+4,c-2);r=this.saveTextToParentTag(r,n,i),n.add(this.options.commentPropName,[{[this.options.textNodeName]:l}])}s=c}else if(t.substr(s+1,2)==="!D"){const c=O_(t,s);this.docTypeEntities=c.entities,s=c.i}else if(t.substr(s+1,2)==="!["){const c=_n(t,"]]>",s,"CDATA is not closed.")-2,l=t.substring(s+9,c);r=this.saveTextToParentTag(r,n,i);let d=this.parseTextData(l,n.tagname,i,!0,!1,!0,!0);d==null&&(d=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:l}]):n.add(this.options.textNodeName,d),s=c+2}else{let c=ja(t,s,this.options.removeNSPrefix),l=c.tagName;const d=c.rawTagName;let p=c.tagExp,f=c.attrExpPresent,m=c.closeIndex;this.options.transformTagName&&(l=this.options.transformTagName(l)),n&&r&&n.tagname!=="!xml"&&(r=this.saveTextToParentTag(r,n,i,!1));const w=n;if(w&&this.options.unpairedTags.indexOf(w.tagname)!==-1&&(n=this.tagsNodeStack.pop(),i=i.substring(0,i.lastIndexOf("."))),l!==e.tagname&&(i+=i?"."+l:l),this.isItStopNode(this.options.stopNodes,i,l)){let h="";if(p.length>0&&p.lastIndexOf("/")===p.length-1)l[l.length-1]==="/"?(l=l.substr(0,l.length-1),i=i.substr(0,i.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 v=this.readStopNodeData(t,d,m+1);if(!v)throw new Error(`Unexpected end of ${d}`);s=v.i,h=v.tagContent}const _=new Cr(l);l!==p&&f&&(_[":@"]=this.buildAttributesMap(p,i,l)),h&&(h=this.parseTextData(h,l,i,!0,f,!0,!0)),i=i.substr(0,i.lastIndexOf(".")),_.add(this.options.textNodeName,h),this.addChild(n,_,i)}else{if(p.length>0&&p.lastIndexOf("/")===p.length-1){l[l.length-1]==="/"?(l=l.substr(0,l.length-1),i=i.substr(0,i.length-1),p=l):p=p.substr(0,p.length-1),this.options.transformTagName&&(l=this.options.transformTagName(l));const h=new Cr(l);l!==p&&f&&(h[":@"]=this.buildAttributesMap(p,i,l)),this.addChild(n,h,i),i=i.substr(0,i.lastIndexOf("."))}else{const h=new Cr(l);this.tagsNodeStack.push(n),l!==p&&f&&(h[":@"]=this.buildAttributesMap(p,i,l)),this.addChild(n,h,i),n=h}r="",s=m}}else r+=t[s];return e.child};function H_(t,e,n){const r=this.options.updateTag(e.tagname,n,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),t.addChild(e))}const D_=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 F_(t,e,n,r){return t&&(r===void 0&&(r=Object.keys(e.child).length===0),t=this.parseTextData(t,e.tagname,n,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,r),t!==void 0&&t!==""&&e.add(this.options.textNodeName,t),t=""),t}function K_(t,e,n){const r="*."+n;for(const i in t){const s=t[i];if(r===s||e===s)return!0}return!1}function W_(t,e,n=">"){let r,i="";for(let s=e;s<t.length;s++){let a=t[s];if(r)a===r&&(r="");else if(a==='"'||a==="'")r=a;else if(a===n[0])if(n[1]){if(t[s+1]===n[1])return{data:i,index:s}}else return{data:i,index:s};else a===" "&&(a=" ");i+=a}}function _n(t,e,n,r){const i=t.indexOf(e,n);if(i===-1)throw new Error(r);return i+e.length-1}function ja(t,e,n,r=">"){const i=W_(t,e+1,r);if(!i)return;let s=i.data;const a=i.index,c=s.search(/\s/);let l=s,d=!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),d=l!==i.data.substr(f+1))}return{tagName:l,tagExp:s,closeIndex:a,attrExpPresent:d,rawTagName:p}}function G_(t,e,n){const r=n;let i=1;for(;n<t.length;n++)if(t[n]==="<")if(t[n+1]==="/"){const s=_n(t,">",n,`${e} is not closed`);if(t.substring(n+2,s).trim()===e&&(i--,i===0))return{tagContent:t.substring(r,n),i:s};n=s}else if(t[n+1]==="?")n=_n(t,"?>",n+1,"StopNode is not closed.");else if(t.substr(n+1,3)==="!--")n=_n(t,"-->",n+3,"StopNode is not closed.");else if(t.substr(n+1,2)==="![")n=_n(t,"]]>",n,"StopNode is not closed.")-2;else{const s=ja(t,n,">");s&&((s&&s.tagName)===e&&s.tagExp[s.tagExp.length-1]!=="/"&&i++,n=s.closeIndex)}}function $a(t,e,n){if(e&&typeof t=="string"){const r=t.trim();return r==="true"?!0:r==="false"?!1:P_(t,n)}else return Mf.isExist(t)?t:""}var J_=B_,Hf={};function Z_(t,e){return Df(t,e)}function Df(t,e,n){let r;const i={};for(let s=0;s<t.length;s++){const a=t[s],c=Y_(a);let l="";if(n===void 0?l=c:l=n+"."+c,c===e.textNodeName)r===void 0?r=a[c]:r+=""+a[c];else{if(c===void 0)continue;if(a[c]){let d=Df(a[c],e,l);const p=Q_(d,e);a[":@"]?X_(d,a[":@"],l,e):Object.keys(d).length===1&&d[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?d=d[e.textNodeName]:Object.keys(d).length===0&&(e.alwaysCreateTextNode?d[e.textNodeName]="":d=""),i[c]!==void 0&&i.hasOwnProperty(c)?(Array.isArray(i[c])||(i[c]=[i[c]]),i[c].push(d)):e.isArray(c,l,p)?i[c]=[d]:i[c]=d}}}return typeof r=="string"?r.length>0&&(i[e.textNodeName]=r):r!==void 0&&(i[e.textNodeName]=r),i}function Y_(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];if(r!==":@")return r}}function X_(t,e,n,r){if(e){const i=Object.keys(e),s=i.length;for(let a=0;a<s;a++){const c=i[a];r.isArray(c,n+"."+c,!0,!0)?t[c]=[e[c]]:t[c]=e[c]}}}function Q_(t,e){const{textNodeName:n}=e,r=Object.keys(t).length;return!!(r===0||r===1&&(t[n]||typeof t[n]=="boolean"||t[n]===0))}Hf.prettify=Z_;const{buildOptions:ey}=hl,ty=J_,{prettify:ny}=Hf,ry=pl;let iy=class{constructor(e){this.externalEntities={},this.options=ey(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=ry.validate(e,n);if(s!==!0)throw Error(`${s.err.msg}:${s.err.line}:${s.err.col}`)}const r=new ty(this.options);r.addExternalEntities(this.externalEntities);const i=r.parseXml(e);return this.options.preserveOrder||i===void 0?i:ny(i,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 '&#xD;'");if(n==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=n}};var sy=iy;const oy=`
9
+ `;function ay(t,e){let n="";return e.format&&e.indentBy.length>0&&(n=oy),Ff(t,e,"",n)}function Ff(t,e,n,r){let i="",s=!1;for(let a=0;a<t.length;a++){const c=t[a],l=cy(c);if(l===void 0)continue;let d="";if(n.length===0?d=l:d=`${n}.${l}`,l===e.textNodeName){let h=c[l];ly(d,e)||(h=e.tagValueProcessor(l,h),h=Kf(h,e)),s&&(i+=r),i+=h,s=!1;continue}else if(l===e.cdataPropName){s&&(i+=r),i+=`<![CDATA[${c[l][0][e.textNodeName]}]]>`,s=!1;continue}else if(l===e.commentPropName){i+=r+`<!--${c[l][0][e.textNodeName]}-->`,s=!0;continue}else if(l[0]==="?"){const h=Yd(c[":@"],e),_=l==="?xml"?"":r;let v=c[l][0][e.textNodeName];v=v.length!==0?" "+v:"",i+=_+`<${l}${v}${h}?>`,s=!0;continue}let p=r;p!==""&&(p+=e.indentBy);const f=Yd(c[":@"],e),m=r+`<${l}${f}`,w=Ff(c[l],e,d,p);e.unpairedTags.indexOf(l)!==-1?e.suppressUnpairedNode?i+=m+">":i+=m+"/>":(!w||w.length===0)&&e.suppressEmptyNode?i+=m+"/>":w&&w.endsWith(">")?i+=m+`>${w}${r}</${l}>`:(i+=m+">",w&&r!==""&&(w.includes("/>")||w.includes("</"))?i+=r+e.indentBy+w+r:i+=w,i+=`</${l}>`),s=!0}return i}function cy(t){const e=Object.keys(t);for(let n=0;n<e.length;n++){const r=e[n];if(t.hasOwnProperty(r)&&r!==":@")return r}}function Yd(t,e){let n="";if(t&&!e.ignoreAttributes)for(let r in t){if(!t.hasOwnProperty(r))continue;let i=e.attributeValueProcessor(r,t[r]);i=Kf(i,e),i===!0&&e.suppressBooleanAttributes?n+=` ${r.substr(e.attributeNamePrefix.length)}`:n+=` ${r.substr(e.attributeNamePrefix.length)}="${i}"`}return n}function ly(t,e){t=t.substr(0,t.length-e.textNodeName.length-1);let n=t.substr(t.lastIndexOf(".")+1);for(let r in e.stopNodes)if(e.stopNodes[r]===t||e.stopNodes[r]==="*."+n)return!0;return!1}function Kf(t,e){if(t&&t.length>0&&e.processEntities)for(let n=0;n<e.entities.length;n++){const r=e.entities[n];t=t.replace(r.regex,r.val)}return t}var dy=ay;const uy=dy,py=qf,fy={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:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function cn(t){this.options=Object.assign({},fy,t),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=py(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=my),this.processTextOrObjNode=hy,this.options.format?(this.indentate=gy,this.tagEndChar=`>
10
10
  `,this.newLine=`
11
- `):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}cn.prototype.build=function(t){return this.options.preserveOrder?cy(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0,[]).val)};cn.prototype.j2x=function(t,e,n){let r="",i="";const s=n.join(".");for(let a in t)if(Object.prototype.hasOwnProperty.call(t,a))if(typeof t[a]>"u")this.isAttribute(a)&&(i+="");else if(t[a]===null)this.isAttribute(a)?i+="":a[0]==="?"?i+=this.indentate(e)+"<"+a+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+a+"/"+this.tagEndChar;else if(t[a]instanceof Date)i+=this.buildTextValNode(t[a],a,"",e);else if(typeof t[a]!="object"){const c=this.isAttribute(a);if(c&&!this.ignoreAttributesFn(c,s))r+=this.buildAttrPairStr(c,""+t[a]);else if(!c)if(a===this.options.textNodeName){let l=this.options.tagValueProcessor(a,""+t[a]);i+=this.replaceEntitiesValue(l)}else i+=this.buildTextValNode(t[a],a,"",e)}else if(Array.isArray(t[a])){const c=t[a].length;let l="",d="";for(let p=0;p<c;p++){const f=t[a][p];if(!(typeof f>"u"))if(f===null)a[0]==="?"?i+=this.indentate(e)+"<"+a+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+a+"/"+this.tagEndChar;else if(typeof f=="object")if(this.options.oneListGroup){const m=this.j2x(f,e+1,n.concat(a));l+=m.val,this.options.attributesGroupName&&f.hasOwnProperty(this.options.attributesGroupName)&&(d+=m.attrStr)}else l+=this.processTextOrObjNode(f,a,e,n);else if(this.options.oneListGroup){let m=this.options.tagValueProcessor(a,f);m=this.replaceEntitiesValue(m),l+=m}else l+=this.buildTextValNode(f,a,"",e)}this.options.oneListGroup&&(l=this.buildObjectNode(l,a,d,e)),i+=l}else if(this.options.attributesGroupName&&a===this.options.attributesGroupName){const c=Object.keys(t[a]),l=c.length;for(let d=0;d<l;d++)r+=this.buildAttrPairStr(c[d],""+t[a][c[d]])}else i+=this.processTextOrObjNode(t[a],a,e,n);return{attrStr:r,val:i}};cn.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 uy(t,e,n,r){const i=this.j2x(t,n+1,r.concat(e));return t[this.options.textNodeName]!==void 0&&Object.keys(t).length===1?this.buildTextValNode(t[this.options.textNodeName],e,i.attrStr,n):this.buildObjectNode(i.val,e,i.attrStr,n)}cn.prototype.buildObjectNode=function(t,e,n,r){if(t==="")return e[0]==="?"?this.indentate(r)+"<"+e+n+"?"+this.tagEndChar:this.indentate(r)+"<"+e+n+this.closeTag(e)+this.tagEndChar;{let i="</"+e+this.tagEndChar,s="";return e[0]==="?"&&(s="?",i=""),(n||n==="")&&t.indexOf("<")===-1?this.indentate(r)+"<"+e+n+s+">"+t+i:this.options.commentPropName!==!1&&e===this.options.commentPropName&&s.length===0?this.indentate(r)+`<!--${t}-->`+this.newLine:this.indentate(r)+"<"+e+n+s+this.tagEndChar+t+this.indentate(r)+i}};cn.prototype.closeTag=function(t){let e="";return this.options.unpairedTags.indexOf(t)!==-1?this.options.suppressUnpairedNode||(e="/"):this.options.suppressEmptyNode?e="/":e=`></${t}`,e};cn.prototype.buildTextValNode=function(t,e,n,r){if(this.options.cdataPropName!==!1&&e===this.options.cdataPropName)return this.indentate(r)+`<![CDATA[${t}]]>`+this.newLine;if(this.options.commentPropName!==!1&&e===this.options.commentPropName)return this.indentate(r)+`<!--${t}-->`+this.newLine;if(e[0]==="?")return this.indentate(r)+"<"+e+n+"?"+this.tagEndChar;{let i=this.options.tagValueProcessor(e,t);return i=this.replaceEntitiesValue(i),i===""?this.indentate(r)+"<"+e+n+this.closeTag(e)+this.tagEndChar:this.indentate(r)+"<"+e+n+">"+i+"</"+e+this.tagEndChar}};cn.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 py(t){return this.options.indentBy.repeat(t)}function fy(t){return t.startsWith(this.options.attributeNamePrefix)&&t!==this.options.textNodeName?t.substr(this.attrPrefixLen):!1}var hy=cn;const gy=pl,my=ny,_y=hy;var yy={XMLParser:my,XMLValidator:gy,XMLBuilder:_y};function wy(t,e,n){const r=n?`<input type="hidden" name="RelayState" value="${n}" />`:"",i=`
11
+ `):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}cn.prototype.build=function(t){return this.options.preserveOrder?uy(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0,[]).val)};cn.prototype.j2x=function(t,e,n){let r="",i="";const s=n.join(".");for(let a in t)if(Object.prototype.hasOwnProperty.call(t,a))if(typeof t[a]>"u")this.isAttribute(a)&&(i+="");else if(t[a]===null)this.isAttribute(a)?i+="":a[0]==="?"?i+=this.indentate(e)+"<"+a+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+a+"/"+this.tagEndChar;else if(t[a]instanceof Date)i+=this.buildTextValNode(t[a],a,"",e);else if(typeof t[a]!="object"){const c=this.isAttribute(a);if(c&&!this.ignoreAttributesFn(c,s))r+=this.buildAttrPairStr(c,""+t[a]);else if(!c)if(a===this.options.textNodeName){let l=this.options.tagValueProcessor(a,""+t[a]);i+=this.replaceEntitiesValue(l)}else i+=this.buildTextValNode(t[a],a,"",e)}else if(Array.isArray(t[a])){const c=t[a].length;let l="",d="";for(let p=0;p<c;p++){const f=t[a][p];if(!(typeof f>"u"))if(f===null)a[0]==="?"?i+=this.indentate(e)+"<"+a+"?"+this.tagEndChar:i+=this.indentate(e)+"<"+a+"/"+this.tagEndChar;else if(typeof f=="object")if(this.options.oneListGroup){const m=this.j2x(f,e+1,n.concat(a));l+=m.val,this.options.attributesGroupName&&f.hasOwnProperty(this.options.attributesGroupName)&&(d+=m.attrStr)}else l+=this.processTextOrObjNode(f,a,e,n);else if(this.options.oneListGroup){let m=this.options.tagValueProcessor(a,f);m=this.replaceEntitiesValue(m),l+=m}else l+=this.buildTextValNode(f,a,"",e)}this.options.oneListGroup&&(l=this.buildObjectNode(l,a,d,e)),i+=l}else if(this.options.attributesGroupName&&a===this.options.attributesGroupName){const c=Object.keys(t[a]),l=c.length;for(let d=0;d<l;d++)r+=this.buildAttrPairStr(c[d],""+t[a][c[d]])}else i+=this.processTextOrObjNode(t[a],a,e,n);return{attrStr:r,val:i}};cn.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 hy(t,e,n,r){const i=this.j2x(t,n+1,r.concat(e));return t[this.options.textNodeName]!==void 0&&Object.keys(t).length===1?this.buildTextValNode(t[this.options.textNodeName],e,i.attrStr,n):this.buildObjectNode(i.val,e,i.attrStr,n)}cn.prototype.buildObjectNode=function(t,e,n,r){if(t==="")return e[0]==="?"?this.indentate(r)+"<"+e+n+"?"+this.tagEndChar:this.indentate(r)+"<"+e+n+this.closeTag(e)+this.tagEndChar;{let i="</"+e+this.tagEndChar,s="";return e[0]==="?"&&(s="?",i=""),(n||n==="")&&t.indexOf("<")===-1?this.indentate(r)+"<"+e+n+s+">"+t+i:this.options.commentPropName!==!1&&e===this.options.commentPropName&&s.length===0?this.indentate(r)+`<!--${t}-->`+this.newLine:this.indentate(r)+"<"+e+n+s+this.tagEndChar+t+this.indentate(r)+i}};cn.prototype.closeTag=function(t){let e="";return this.options.unpairedTags.indexOf(t)!==-1?this.options.suppressUnpairedNode||(e="/"):this.options.suppressEmptyNode?e="/":e=`></${t}`,e};cn.prototype.buildTextValNode=function(t,e,n,r){if(this.options.cdataPropName!==!1&&e===this.options.cdataPropName)return this.indentate(r)+`<![CDATA[${t}]]>`+this.newLine;if(this.options.commentPropName!==!1&&e===this.options.commentPropName)return this.indentate(r)+`<!--${t}-->`+this.newLine;if(e[0]==="?")return this.indentate(r)+"<"+e+n+"?"+this.tagEndChar;{let i=this.options.tagValueProcessor(e,t);return i=this.replaceEntitiesValue(i),i===""?this.indentate(r)+"<"+e+n+this.closeTag(e)+this.tagEndChar:this.indentate(r)+"<"+e+n+">"+i+"</"+e+this.tagEndChar}};cn.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 gy(t){return this.options.indentBy.repeat(t)}function my(t){return t.startsWith(this.options.attributeNamePrefix)&&t!==this.options.textNodeName?t.substr(this.attrPrefixLen):!1}var _y=cn;const yy=pl,wy=sy,vy=_y;var by={XMLParser:wy,XMLValidator:yy,XMLBuilder:vy};function xy(t,e,n){const r=n?`<input type="hidden" name="RelayState" value="${n}" />`:"",i=`
12
12
  <!DOCTYPE html>
13
13
  <html>
14
14
  <body onload="document.forms[0].submit()">
@@ -26,7 +26,7 @@
26
26
  }};
27
27
  <\/script>
28
28
  </body>
29
- </html>`;return new Response(i,{headers:{"Content-Type":"text/html"}})}async function vy(t,e,n,r,i){var m,w,h;if(!n.redirect_uri)throw new I(400,{message:"Missing redirect_uri in authParams"});if(!r.email)throw new I(400,{message:"Missing email in user"});const[s]=await t.env.data.keys.list();if(!s)throw new I(500,{message:"No signing key found"});if(!((m=e.addons)!=null&&m.samlp))throw new I(400,{message:`SAML Addon is not enabled for client ${e.id}`});const{recipient:a,audience:c}=e.addons.samlp,l=n.state||"";if(!a||!l||!r||!n.state)throw new I(400,{message:"Missing recipient or inResponseTo"});const d=JSON.parse(n.state),p=new URL(n.redirect_uri),f=await by(t,{issuer:t.env.ISSUER,audience:c||n.client_id,destination:p.toString(),inResponseTo:d.requestId,userId:((h=(w=r.app_metadata)==null?void 0:w.vimeo)==null?void 0:h.user_id)||r.user_id,email:r.email,sessionIndex:i,signature:{privateKeyPem:s.pkcs7,cert:s.cert,kid:s.kid}});return wy(p.toString(),f,d.relayState)}async function by(t,e){const n=e.notBefore||new Date().toISOString(),r=e.notAfter||new Date(new Date(n).getTime()+10*60*1e3).toISOString(),i=e.issueInstant||n,s=e.sessionNotOnOrAfter||r,a=e.responseId||`_${ke()}`,c=e.assertionId||`_${ke()}`,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":r,"@_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":r}},{"saml:AuthnStatement":[{"saml:AuthnContext":[{"saml:AuthnContextClassRef":[{"#text":"urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified"}]}]}],":@":{"@_AuthnInstant":i,"@_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":i,"@_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":a,"@_InResponseTo":e.inResponseTo,"@_IssueInstant":i,"@_Version":"2.0"}}];let p=new yy.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)}var xy={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},ky=()=>{var n,r;const t=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[i,s]of Object.entries(xy))if(Sy(s))return i}return typeof(t==null?void 0:t.EdgeRuntime)=="string"?"edge-light":(t==null?void 0:t.fastly)!==void 0?"fastly":((r=(n=t==null?void 0:t.process)==null?void 0:n.release)==null?void 0:r.name)==="node"?"node":"other"},Sy=t=>navigator.userAgent.startsWith(t);function zt(t,e){ky()==="workerd"&&t.executionCtx.waitUntil(e)}function Ht(t){var e,n,r;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:(r=t.header("user-agent"))==null?void 0:r.slice(0,512)}}const Xd=["sub","iss","aud","exp","nbf","iat","jti"];async function ro(t,e){var v,S;const{authParams:n,user:r,client:i,session_id:s}=e,c=(await t.env.data.keys.list()).filter(C=>!C.revoked_at||new Date(C.revoked_at)>new Date),l=c[c.length-1];if(!(l!=null&&l.pkcs7))throw new I(500,{message:"No signing key available"});const d=D0(l.pkcs7),p=t.var.custom_domain?`https://${t.var.custom_domain}/`:t.env.ISSUER,f={aud:n.audience||"default",scope:n.scope||"",sub:(r==null?void 0:r.user_id)||n.client_id,iss:p,tenant_id:t.var.tenant_id,sid:s},m=r&&((v=n.scope)!=null&&v.split(" ").includes("openid"))?{aud:n.client_id,sub:r.user_id,iss:p,sid:s,nonce:n.nonce,given_name:r.given_name,family_name:r.family_name,nickname:r.nickname,picture:r.picture,locale:r.locale,name:r.name,email:r.email,email_verified:r.email_verified}:void 0;(S=t.env.hooks)!=null&&S.onExecuteCredentialsExchange&&await t.env.hooks.onExecuteCredentialsExchange({client:i,user:r,request:{ip:t.req.header("x-real-ip")||"",user_agent:t.req.header("user-agent")||"",method:t.req.method,url:t.req.url},scope:n.scope||"",grant_type:""},{accessToken:{setCustomClaim:(C,O)=>{if(Xd.includes(C))throw new Error(`Cannot overwrite reserved claim '${C}'`);f[C]=O}},idToken:{setCustomClaim:(C,O)=>{if(Xd.includes(C))throw new Error(`Cannot overwrite reserved claim '${C}'`);m&&(m[C]=O)}},access:{deny:C=>{throw new I(400,{message:`Access denied: ${C}`})}}});const w={includeIssuedTimestamp:!0,expiresIn:new ll(1,"d"),headers:{kid:l.kid}},h=await Kd("RS256",d,f,w),_=m?await Kd("RS256",d,m,w):void 0;return{access_token:h,refresh_token:e.refresh_token,id_token:_,token_type:"Bearer",expires_in:86400}}async function Ff(t,e){return e.loginSession||(e.loginSession=await t.env.data.loginSessions.create(e.client.tenant.id,{expires_at:new Date(Date.now()+Qn*1e3).toISOString(),authParams:e.authParams,authorization_url:t.req.url,csrf_token:ke(),...Ht(t.req)})),{code:(await t.env.data.codes.create(e.client.tenant.id,{code_id:ke(),user_id:e.user.user_id,code_type:"authorization_code",login_id:e.loginSession.id,expires_at:new Date(Date.now()+G0*1e3).toISOString()})).code_id,state:e.authParams.state}}async function Ay(t,e){const{client:n,scope:r,audience:i=n.tenant.audience,session_id:s}=e,a=Ht(t.req);return await t.env.data.refreshTokens.create(n.tenant.id,{id:ke(),session_id:s,client_id:n.id,idle_expires_at:new Date(Date.now()+to*1e3).toISOString(),user_id:e.user.user_id,device:{last_ip:a.ip||"",initial_ip:a.ip||"",last_user_agent:a.useragent||"",initial_user_agent:a.useragent||"",initial_asn:"",last_asn:""},resource_servers:[{audience:i,scopes:r}],rotating:!1})}async function Kf(t,{user:e,client:n,loginSession:r}){const i=await t.env.data.sessions.create(n.tenant.id,{id:ke(),user_id:e.user_id,idle_expires_at:new Date(Date.now()+to*1e3).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:[n.id]});await t.env.data.loginSessions.update(n.tenant.id,r.id,{session_id:i.id});const{scope:s,audience:a}=r.authParams,c=s!=null&&s.split(" ").includes("offline_access")?await Ay(t,{session_id:i.id,user:e,client:n,scope:s,audience:a}):void 0;return{...i,refresh_token:c}}async function ln(t,e){var w;const{authParams:n,user:r,client:i,ticketAuth:s}=e,a=we(t,{type:ge.SUCCESS_LOGIN,description:`Successful login for ${r.user_id}`,userId:r.user_id});if(zt(t,t.env.data.logs.create(i.tenant.id,a)),zt(t,t.env.data.users.update(i.tenant.id,r.user_id,{last_login:new Date().toISOString(),last_ip:t.req.header("x-real-ip")||"",login_count:r.login_count+1})),s){if(!e.loginSession)throw new I(500,{message:"Login session not found"});const h=H0(),_=ke(12),v=await t.env.data.codes.create(i.tenant.id,{code_id:ke(),code_type:"ticket",login_id:e.loginSession.id,expires_at:new Date(Date.now()+Z0).toISOString(),code_verifier:[_,h].join("|")});return t.json({login_ticket:v.code_id,co_verifier:h,co_id:_})}let c=e.refreshToken,l=e.sessionId,d=r;if(!l){if(!e.loginSession)throw new I(500,{message:"Login session not found"});d=await Cy(t,t.env.data)(i.tenant.id,r);const h=await Kf(t,{user:r,client:i,loginSession:e.loginSession});l=h.id,c=(w=h.refresh_token)==null?void 0:w.id}if(e.authParams.response_mode===Rt.SAML_POST)return vy(t,e.client,e.authParams,d,l);const p=await ro(t,{authParams:n,user:d,client:i,session_id:l,refresh_token:c}),f=new Headers({"set-cookie":Rf(i.tenant.id,l,t.req.header("host"))});if(n.response_mode===Rt.WEB_MESSAGE)return t.json(p,{headers:f});if((n.response_type||It.CODE)===It.CODE){const h=await Ff(t,e);if(!n.redirect_uri)throw new I(400,{message:"Redirect uri not found"});const _=new URL(n.redirect_uri);_.searchParams.set("code",h.code),h.state&&_.searchParams.set("state",h.state),f.set("location",_.toString())}return new Response("Redirecting",{status:302,headers:f})}async function zy(t,e,n){const r=await t.env.data.tenants.get(e);if(!r)throw new Error(`Tenant not found: ${e}`);return ro(t,{client:{id:t.env.ISSUER,tenant:r,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),name:t.env.ISSUER,disable_sign_ups:!1,connections:[]},authParams:{client_id:t.env.ISSUER,response_type:It.TOKEN,scope:n}})}async function gl(t,e,n){const r=await zy(t,n.tenant_id,"webhook");for await(const i of e)if(!(await fetch(i.url,{method:"POST",headers:{Authorization:`Bearer ${r.access_token}`,"Content-Type":"application/json"},body:JSON.stringify(n)})).ok){const a=we(t,{type:ge.FAILED_HOOK,description:`Failed to invoke hook ${i.hook_id}`});await t.env.data.logs.create(n.tenant_id,a)}}function Ey(t){return async(e,n)=>{const{hooks:r}=await t.env.data.hooks.list(e);return await gl(t,r,{tenant_id:e,user:n,trigger_id:"post-user-registration"}),n}}function Iy(t){return async(e,n)=>{const{hooks:r}=await t.env.data.hooks.list(e,{q:"trigger_id:pre-user-signup",page:0,per_page:100,include_totals:!1});await gl(t,r,{tenant_id:e,email:n,trigger_id:"pre-user-signup"})}}function Cy(t,e){return async(n,r)=>{const{hooks:i}=await e.hooks.list(n,{q:"trigger_id:post-user-login",page:0,per_page:100,include_totals:!1});return await gl(t,i,{tenant_id:n,user:r,trigger_id:"post-user-login"}),r}}function Ny(t,e){return async(n,r)=>{var a,c,l;const i={method:t.req.method,ip:t.req.query("x-real-ip")||"",user_agent:t.req.query("user-agent"),url:((a=t.var.loginSession)==null?void 0:a.authorization_url)||t.req.url};if((c=t.env.hooks)!=null&&c.onExecutePreUserRegistration)try{await t.env.hooks.onExecutePreUserRegistration({user:r,request:i},{user:{setUserMetadata:async(d,p)=>{r[d]=p}}})}catch{const p=we(t,{type:ge.FAILED_SIGNUP,description:"Pre user registration hook failed"});await e.logs.create(n,p)}let s=await B0(e)(n,r);if((l=t.env.hooks)!=null&&l.onExecutePostUserRegistration)try{await t.env.hooks.onExecutePostUserRegistration({user:r,request:i},{user:{}})}catch{const p=we(t,{type:ge.FAILED_SIGNUP,description:"Post user registration hook failed"});await t.env.data.logs.create(n,p)}return await Ey(t)(n,s),s}}async function jy(t,e,n,r){var i;if(e.disable_sign_ups){const s=(i=t.var.loginSession)==null?void 0:i.authorization_url;if(!(s&&new URL(s).searchParams.get("screen_hint")==="signup")&&!await so({userAdapter:n.users,tenant_id:e.tenant.id,email:r})){const l=we(t,{type:ge.FAILED_SIGNUP,description:"Public signup is disabled"});throw await n.logs.create(e.tenant.id,l),new I(400,{message:"Signups are disabled for this client"})}}await Iy(t)(t.var.tenant_id||"",r)}function io(t,e){return{...e,users:{...e.users,create:Ny(t,e)}}}function Wf(t){return io(t,t.env.data)}async function ml(t,e,n){return(await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`})).users}async function fr({userAdapter:t,tenant_id:e,username:n,provider:r}){const i=r==="sms"?`phone_number:${n}`:`email:${n}`,{users:s}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`${i} provider:${r}`});return s.length>1&&console.error("More than one user found for same email and provider"),s[0]||null}async function so({userAdapter:t,tenant_id:e,email:n}){var c;const{users:r}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`}),i=r.filter(l=>!(l.provider==="auth2"&&!l.email_verified));if(i.length===0)return;const s=i.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 a=await t.get(e,(c=i[0])==null?void 0:c.linked_to);if(!a)throw new Error("Primary account not found");return a}async function us({userAdapter:t,tenant_id:e,username:n,provider:r}){const i=await fr({userAdapter:t,tenant_id:e,username:n,provider:r});return i?i.linked_to?t.get(e,i.linked_to):i:null}async function oo(t,e){const{username:n,provider:r,connection:i,client:s,userId:a,isSocial:c,profileData:l={},ip:d=""}=e;let p=await us({userAdapter:t.env.data.users,tenant_id:e.client.tenant.id,username:n,provider:r});if(!p){const f={user_id:`${r}|${a||eo()}`,email:i!=="sms"?n:void 0,phone_number:i==="sms"?n:void 0,name:n,provider:r,connection:i,email_verified:!0,last_ip:d,is_social:c,last_login:new Date().toISOString(),profileData:JSON.stringify(l)};p=await Wf(t).users.create(s.tenant.id,f),t.set("user_id",p.user_id)}return p}const tn=o.z.object({page:o.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:o.z.string().min(1).optional().default("10").transform(t=>parseInt(t,10)).openapi({description:"The number of items per page"}),include_totals:o.z.string().optional().default("false").transform(t=>t==="true").openapi({description:"If the total number of items should be included in the response"}),sort:o.z.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:o.z.string().optional().openapi({description:"A lucene query string used to filter the results"})});function hr(t){if(!t)return;const[e,n]=t.split(":"),r=n==="1"?"asc":"desc";if(!(!e||!r))return{sort_by:e,sort_order:r}}const Qd=an.extend({users:o.z.array(St)}),$y=an.extend({sessions:o.z.array(Qs)}),Oy=new o.OpenAPIHono().openapi(o.createRoute({tags:["users"],method:"get",path:"/",request:{query:tn,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(St),Qd])}},description:"List of users"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),{"tenant-id":a}=t.req.valid("header");if(s!=null&&s.includes("identities.profileData.email")){const p=s.split("=")[1],m=(await t.env.data.users.list(a,{page:e,per_page:n,include_totals:r,q:`email:${p}`})).users.filter(_=>_.linked_to),[w]=m;if(!w)return t.json([]);const h=await t.env.data.users.get(a,w.linked_to);if(!h)throw new I(500,{message:"Primary account not found"});return t.json([St.parse(h)])}const c=["-_exists_:linked_to"];s&&c.push(s);const l=await t.env.data.users.list(a,{page:e,per_page:n,include_totals:r,sort:hr(i),q:c.join(" ")}),d=l.users.filter(p=>!p.linked_to);return r?t.json(Qd.parse({users:d,length:l.length,start:l.start,limit:l.limit})):t.json(o.z.array(St).parse(d))}).openapi(o.createRoute({tags:["users"],method:"get",path:"/{user_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:St}},description:"List of users"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{"tenant-id":n}=t.req.valid("header"),r=await t.env.data.users.get(n,e);if(!r)throw new I(404);if(r.linked_to)throw new I(404,{message:"User is linked to another user"});return t.json(r)}).openapi(o.createRoute({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({user_id:o.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 I(404);return t.text("OK")}).openapi(o.createRoute({tags:["users"],method:"post",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object({...rs.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:St}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");t.set("body",n);const{email:r}=n;if(!r)throw new I(400,{message:"Email is required"});const i=r.toLowerCase(),s=`${n.provider}|${n.user_id||eo()}`;try{const a=await t.env.data.users.create(e,{email:i,user_id:s,name:n.name||i,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",a.user_id);const c=we(t,{type:ge.SUCCESS_API_OPERATION,description:"User created"});zt(t,t.env.data.logs.create(e,c));const l={...a,identities:[{connection:a.connection,provider:a.provider,user_id:Dd(a.user_id),isSocial:a.is_social}]};return t.json(St.parse(l),{status:201})}catch(a){throw a.message==="User already exists"?new I(409,{message:"User already exists"}):a}}).openapi(o.createRoute({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object({...rs.shape,verify_email:o.z.boolean(),password:o.z.string()}).partial()}}},params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{var p;const{data:e}=t.env,{"tenant-id":n}=t.req.valid("header"),r=t.req.valid("json"),{user_id:i}=t.req.valid("param"),{verify_email:s,password:a,...c}=r,l=await e.users.get(n,i);if(!l)throw new I(404);if(c.email&&c.email!==l.email){const f=await ml(t.env.data.users,n,c.email);if(f.length&&f.some(m=>m.user_id!==i))throw new I(409,{message:"Another user with the same email address already exists."})}if(l.linked_to)throw new I(404,{message:"User is linked to another user"});if(await t.env.data.users.update(n,i,c),a){const f=(p=l.identities)==null?void 0:p.find(h=>h.connection==="Username-Password-Authentication");if(!f)throw new I(400,{message:"User does not have a password identity"});const m={user_id:f.user_id,password:await oi.hash(a,10),algorithm:"bcrypt"};await e.passwords.get(n,f.user_id)?await e.passwords.update(n,m):await e.passwords.create(n,m)}const d=await t.env.data.users.get(n,i);if(!d)throw new I(500);return t.json(d)}).openapi(o.createRoute({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.union([o.z.object({link_with:o.z.string()}),o.z.object({user_id:o.z.string(),provider:o.z.string(),connection:o.z.string().optional()})])}}},params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:o.z.array(o.z.object({connection:o.z.string(),provider:o.z.string(),user_id:o.z.string(),isSocial:o.z.boolean()}))}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),{user_id:r}=t.req.valid("param"),i="link_with"in n?n.link_with:n.user_id,s=await t.env.data.users.get(e,r);if(!s)throw new I(400,{message:"Linking an inexistent identity is not allowed."});await t.env.data.users.update(e,i,{linked_to:r});const a=await t.env.data.users.list(e,{page:0,per_page:10,include_totals:!1,q:`linked_to:${r}`}),c=[s,...a.users].map(l=>({connection:l.connection,provider:l.provider,user_id:Dd(l.user_id),isSocial:l.is_social}));return t.json(c,{status:201})}).openapi(o.createRoute({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({user_id:o.z.string(),provider:o.z.string(),linked_user_id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:o.z.array(St)}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{user_id:n,provider:r,linked_user_id:i}=t.req.valid("param");await t.env.data.users.unlink(e,n,r,i);const s=await t.env.data.users.get(e,n);if(!s)throw new I(404);return t.json([St.parse(s)])}).openapi(o.createRoute({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:tn,headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(Qs),$y])}},description:"List of sessions"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{include_totals:n}=t.req.valid("query"),{"tenant-id":r}=t.req.valid("header"),i=await t.env.data.sessions.list(r,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return n?t.json(i):t.json(i.sessions)});/*! *****************************************************************************
29
+ </html>`;return new Response(i,{headers:{"Content-Type":"text/html"}})}async function ky(t,e,n,r,i){var m,w,h;if(!n.redirect_uri)throw new I(400,{message:"Missing redirect_uri in authParams"});if(!r.email)throw new I(400,{message:"Missing email in user"});const[s]=await t.env.data.keys.list();if(!s)throw new I(500,{message:"No signing key found"});if(!((m=e.addons)!=null&&m.samlp))throw new I(400,{message:`SAML Addon is not enabled for client ${e.id}`});const{recipient:a,audience:c}=e.addons.samlp,l=n.state||"";if(!a||!l||!r||!n.state)throw new I(400,{message:"Missing recipient or inResponseTo"});const d=JSON.parse(n.state),p=new URL(n.redirect_uri),f=await Sy(t,{issuer:t.env.ISSUER,audience:c||n.client_id,destination:p.toString(),inResponseTo:d.requestId,userId:((h=(w=r.app_metadata)==null?void 0:w.vimeo)==null?void 0:h.user_id)||r.user_id,email:r.email,sessionIndex:i,signature:{privateKeyPem:s.pkcs7,cert:s.cert,kid:s.kid}});return xy(p.toString(),f,d.relayState)}async function Sy(t,e){const n=e.notBefore||new Date().toISOString(),r=e.notAfter||new Date(new Date(n).getTime()+10*60*1e3).toISOString(),i=e.issueInstant||n,s=e.sessionNotOnOrAfter||r,a=e.responseId||`_${ke()}`,c=e.assertionId||`_${ke()}`,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":r,"@_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":r}},{"saml:AuthnStatement":[{"saml:AuthnContext":[{"saml:AuthnContextClassRef":[{"#text":"urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified"}]}]}],":@":{"@_AuthnInstant":i,"@_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":i,"@_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":a,"@_InResponseTo":e.inResponseTo,"@_IssueInstant":i,"@_Version":"2.0"}}];let p=new by.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)}var Ay={deno:"Deno",bun:"Bun",workerd:"Cloudflare-Workers",node:"Node.js"},zy=()=>{var n,r;const t=globalThis;if(typeof navigator<"u"&&typeof navigator.userAgent=="string"){for(const[i,s]of Object.entries(Ay))if(Ey(s))return i}return typeof(t==null?void 0:t.EdgeRuntime)=="string"?"edge-light":(t==null?void 0:t.fastly)!==void 0?"fastly":((r=(n=t==null?void 0:t.process)==null?void 0:n.release)==null?void 0:r.name)==="node"?"node":"other"},Ey=t=>navigator.userAgent.startsWith(t);function zt(t,e){zy()==="workerd"&&t.executionCtx.waitUntil(e)}function Ht(t){var e,n,r;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:(r=t.header("user-agent"))==null?void 0:r.slice(0,512)}}const Xd=["sub","iss","aud","exp","nbf","iat","jti"];async function ro(t,e){var v,S;const{authParams:n,user:r,client:i,session_id:s}=e,c=(await t.env.data.keys.list()).filter(C=>!C.revoked_at||new Date(C.revoked_at)>new Date),l=c[c.length-1];if(!(l!=null&&l.pkcs7))throw new I(500,{message:"No signing key available"});const d=W0(l.pkcs7),p=t.var.custom_domain?`https://${t.var.custom_domain}/`:t.env.ISSUER,f={aud:n.audience||"default",scope:n.scope||"",sub:(r==null?void 0:r.user_id)||n.client_id,iss:p,tenant_id:t.var.tenant_id,sid:s},m=r&&((v=n.scope)!=null&&v.split(" ").includes("openid"))?{aud:n.client_id,sub:r.user_id,iss:p,sid:s,nonce:n.nonce,given_name:r.given_name,family_name:r.family_name,nickname:r.nickname,picture:r.picture,locale:r.locale,name:r.name,email:r.email,email_verified:r.email_verified}:void 0;(S=t.env.hooks)!=null&&S.onExecuteCredentialsExchange&&await t.env.hooks.onExecuteCredentialsExchange({client:i,user:r,request:{ip:t.req.header("x-real-ip")||"",user_agent:t.req.header("user-agent")||"",method:t.req.method,url:t.req.url},scope:n.scope||"",grant_type:""},{accessToken:{setCustomClaim:(C,O)=>{if(Xd.includes(C))throw new Error(`Cannot overwrite reserved claim '${C}'`);f[C]=O}},idToken:{setCustomClaim:(C,O)=>{if(Xd.includes(C))throw new Error(`Cannot overwrite reserved claim '${C}'`);m&&(m[C]=O)}},access:{deny:C=>{throw new I(400,{message:`Access denied: ${C}`})}}});const w={includeIssuedTimestamp:!0,expiresIn:new ll(1,"d"),headers:{kid:l.kid}},h=await Kd("RS256",d,f,w),_=m?await Kd("RS256",d,m,w):void 0;return{access_token:h,refresh_token:e.refresh_token,id_token:_,token_type:"Bearer",expires_in:86400}}async function Wf(t,e){return e.loginSession||(e.loginSession=await t.env.data.loginSessions.create(e.client.tenant.id,{expires_at:new Date(Date.now()+Qn*1e3).toISOString(),authParams:e.authParams,authorization_url:t.req.url,csrf_token:ke(),...Ht(t.req)})),{code:(await t.env.data.codes.create(e.client.tenant.id,{code_id:ke(),user_id:e.user.user_id,code_type:"authorization_code",login_id:e.loginSession.id,expires_at:new Date(Date.now()+Y0*1e3).toISOString()})).code_id,state:e.authParams.state}}async function Iy(t,e){const{client:n,scope:r,audience:i=n.tenant.audience,session_id:s}=e,a=Ht(t.req);return await t.env.data.refreshTokens.create(n.tenant.id,{id:ke(),session_id:s,client_id:n.id,idle_expires_at:new Date(Date.now()+to*1e3).toISOString(),user_id:e.user.user_id,device:{last_ip:a.ip||"",initial_ip:a.ip||"",last_user_agent:a.useragent||"",initial_user_agent:a.useragent||"",initial_asn:"",last_asn:""},resource_servers:[{audience:i,scopes:r}],rotating:!1})}async function Gf(t,{user:e,client:n,loginSession:r}){const i=await t.env.data.sessions.create(n.tenant.id,{id:ke(),user_id:e.user_id,idle_expires_at:new Date(Date.now()+to*1e3).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:[n.id]});await t.env.data.loginSessions.update(n.tenant.id,r.id,{session_id:i.id});const{scope:s,audience:a}=r.authParams,c=s!=null&&s.split(" ").includes("offline_access")?await Iy(t,{session_id:i.id,user:e,client:n,scope:s,audience:a}):void 0;return{...i,refresh_token:c}}async function ln(t,e){var w;const{authParams:n,user:r,client:i,ticketAuth:s}=e,a=we(t,{type:ge.SUCCESS_LOGIN,description:`Successful login for ${r.user_id}`,userId:r.user_id});if(zt(t,t.env.data.logs.create(i.tenant.id,a)),zt(t,t.env.data.users.update(i.tenant.id,r.user_id,{last_login:new Date().toISOString(),last_ip:t.req.header("x-real-ip")||"",login_count:r.login_count+1})),s){if(!e.loginSession)throw new I(500,{message:"Login session not found"});const h=K0(),_=ke(12),v=await t.env.data.codes.create(i.tenant.id,{code_id:ke(),code_type:"ticket",login_id:e.loginSession.id,expires_at:new Date(Date.now()+Q0).toISOString(),code_verifier:[_,h].join("|")});return t.json({login_ticket:v.code_id,co_verifier:h,co_id:_})}let c=e.refreshToken,l=e.sessionId,d=r;if(!l){if(!e.loginSession)throw new I(500,{message:"Login session not found"});d=await $y(t,t.env.data)(i.tenant.id,r);const h=await Gf(t,{user:r,client:i,loginSession:e.loginSession});l=h.id,c=(w=h.refresh_token)==null?void 0:w.id}if(e.authParams.response_mode===Rt.SAML_POST)return ky(t,e.client,e.authParams,d,l);const p=await ro(t,{authParams:n,user:d,client:i,session_id:l,refresh_token:c}),f=new Headers({"set-cookie":Uf(i.tenant.id,l,t.var.custom_domain||t.req.header("host"))});if(n.response_mode===Rt.WEB_MESSAGE)return t.json(p,{headers:f});if((n.response_type||It.CODE)===It.CODE){const h=await Wf(t,e);if(!n.redirect_uri)throw new I(400,{message:"Redirect uri not found"});const _=new URL(n.redirect_uri);_.searchParams.set("code",h.code),h.state&&_.searchParams.set("state",h.state),f.set("location",_.toString())}return new Response("Redirecting",{status:302,headers:f})}async function Cy(t,e,n){const r=await t.env.data.tenants.get(e);if(!r)throw new Error(`Tenant not found: ${e}`);return ro(t,{client:{id:t.env.ISSUER,tenant:r,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),name:t.env.ISSUER,disable_sign_ups:!1,connections:[]},authParams:{client_id:t.env.ISSUER,response_type:It.TOKEN,scope:n}})}async function gl(t,e,n){const r=await Cy(t,n.tenant_id,"webhook");for await(const i of e)if(!(await fetch(i.url,{method:"POST",headers:{Authorization:`Bearer ${r.access_token}`,"Content-Type":"application/json"},body:JSON.stringify(n)})).ok){const a=we(t,{type:ge.FAILED_HOOK,description:`Failed to invoke hook ${i.hook_id}`});await t.env.data.logs.create(n.tenant_id,a)}}function Ny(t){return async(e,n)=>{const{hooks:r}=await t.env.data.hooks.list(e);return await gl(t,r,{tenant_id:e,user:n,trigger_id:"post-user-registration"}),n}}function jy(t){return async(e,n)=>{const{hooks:r}=await t.env.data.hooks.list(e,{q:"trigger_id:pre-user-signup",page:0,per_page:100,include_totals:!1});await gl(t,r,{tenant_id:e,email:n,trigger_id:"pre-user-signup"})}}function $y(t,e){return async(n,r)=>{const{hooks:i}=await e.hooks.list(n,{q:"trigger_id:post-user-login",page:0,per_page:100,include_totals:!1});return await gl(t,i,{tenant_id:n,user:r,trigger_id:"post-user-login"}),r}}function Oy(t,e){return async(n,r)=>{var a,c,l;const i={method:t.req.method,ip:t.req.query("x-real-ip")||"",user_agent:t.req.query("user-agent"),url:((a=t.var.loginSession)==null?void 0:a.authorization_url)||t.req.url};if((c=t.env.hooks)!=null&&c.onExecutePreUserRegistration)try{await t.env.hooks.onExecutePreUserRegistration({user:r,request:i},{user:{setUserMetadata:async(d,p)=>{r[d]=p}}})}catch{const p=we(t,{type:ge.FAILED_SIGNUP,description:"Pre user registration hook failed"});await e.logs.create(n,p)}let s=await U0(e)(n,r);if((l=t.env.hooks)!=null&&l.onExecutePostUserRegistration)try{await t.env.hooks.onExecutePostUserRegistration({user:r,request:i},{user:{}})}catch{const p=we(t,{type:ge.FAILED_SIGNUP,description:"Post user registration hook failed"});await t.env.data.logs.create(n,p)}return await Ny(t)(n,s),s}}async function Py(t,e,n,r){var i;if(e.disable_sign_ups){const s=(i=t.var.loginSession)==null?void 0:i.authorization_url;if(!(s&&new URL(s).searchParams.get("screen_hint")==="signup")&&!await so({userAdapter:n.users,tenant_id:e.tenant.id,email:r})){const l=we(t,{type:ge.FAILED_SIGNUP,description:"Public signup is disabled"});throw await n.logs.create(e.tenant.id,l),new I(400,{message:"Signups are disabled for this client"})}}await jy(t)(t.var.tenant_id||"",r)}function io(t,e){return{...e,users:{...e.users,create:Oy(t,e)}}}function Jf(t){return io(t,t.env.data)}async function ml(t,e,n){return(await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`})).users}async function fr({userAdapter:t,tenant_id:e,username:n,provider:r}){const i=r==="sms"?`phone_number:${n}`:`email:${n}`,{users:s}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`${i} provider:${r}`});return s.length>1&&console.error("More than one user found for same email and provider"),s[0]||null}async function so({userAdapter:t,tenant_id:e,email:n}){var c;const{users:r}=await t.list(e,{page:0,per_page:10,include_totals:!1,q:`email:${n}`}),i=r.filter(l=>!(l.provider==="auth2"&&!l.email_verified));if(i.length===0)return;const s=i.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 a=await t.get(e,(c=i[0])==null?void 0:c.linked_to);if(!a)throw new Error("Primary account not found");return a}async function us({userAdapter:t,tenant_id:e,username:n,provider:r}){const i=await fr({userAdapter:t,tenant_id:e,username:n,provider:r});return i?i.linked_to?t.get(e,i.linked_to):i:null}async function oo(t,e){const{username:n,provider:r,connection:i,client:s,userId:a,isSocial:c,profileData:l={},ip:d=""}=e;let p=await us({userAdapter:t.env.data.users,tenant_id:e.client.tenant.id,username:n,provider:r});if(!p){const f={user_id:`${r}|${a||eo()}`,email:i!=="sms"?n:void 0,phone_number:i==="sms"?n:void 0,name:n,provider:r,connection:i,email_verified:!0,last_ip:d,is_social:c,last_login:new Date().toISOString(),profileData:JSON.stringify(l)};p=await Jf(t).users.create(s.tenant.id,f),t.set("user_id",p.user_id)}return p}const tn=o.z.object({page:o.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:o.z.string().min(1).optional().default("10").transform(t=>parseInt(t,10)).openapi({description:"The number of items per page"}),include_totals:o.z.string().optional().default("false").transform(t=>t==="true").openapi({description:"If the total number of items should be included in the response"}),sort:o.z.string().regex(/^.+:(-1|1)$/).optional().openapi({description:"A property that should have the format 'string:-1' or 'string:1'"}),q:o.z.string().optional().openapi({description:"A lucene query string used to filter the results"})});function hr(t){if(!t)return;const[e,n]=t.split(":"),r=n==="1"?"asc":"desc";if(!(!e||!r))return{sort_by:e,sort_order:r}}const Qd=an.extend({users:o.z.array(St)}),Ty=an.extend({sessions:o.z.array(Qs)}),By=new o.OpenAPIHono().openapi(o.createRoute({tags:["users"],method:"get",path:"/",request:{query:tn,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(St),Qd])}},description:"List of users"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),{"tenant-id":a}=t.req.valid("header");if(s!=null&&s.includes("identities.profileData.email")){const p=s.split("=")[1],m=(await t.env.data.users.list(a,{page:e,per_page:n,include_totals:r,q:`email:${p}`})).users.filter(_=>_.linked_to),[w]=m;if(!w)return t.json([]);const h=await t.env.data.users.get(a,w.linked_to);if(!h)throw new I(500,{message:"Primary account not found"});return t.json([St.parse(h)])}const c=["-_exists_:linked_to"];s&&c.push(s);const l=await t.env.data.users.list(a,{page:e,per_page:n,include_totals:r,sort:hr(i),q:c.join(" ")}),d=l.users.filter(p=>!p.linked_to);return r?t.json(Qd.parse({users:d,length:l.length,start:l.start,limit:l.limit})):t.json(o.z.array(St).parse(d))}).openapi(o.createRoute({tags:["users"],method:"get",path:"/{user_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:St}},description:"List of users"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{"tenant-id":n}=t.req.valid("header"),r=await t.env.data.users.get(n,e);if(!r)throw new I(404);if(r.linked_to)throw new I(404,{message:"User is linked to another user"});return t.json(r)}).openapi(o.createRoute({tags:["users"],method:"delete",path:"/{user_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({user_id:o.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 I(404);return t.text("OK")}).openapi(o.createRoute({tags:["users"],method:"post",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object({...rs.shape})}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:St}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json");t.set("body",n);const{email:r}=n;if(!r)throw new I(400,{message:"Email is required"});const i=r.toLowerCase(),s=`${n.provider}|${n.user_id||eo()}`;try{const a=await t.env.data.users.create(e,{email:i,user_id:s,name:n.name||i,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",a.user_id);const c=we(t,{type:ge.SUCCESS_API_OPERATION,description:"User created"});zt(t,t.env.data.logs.create(e,c));const l={...a,identities:[{connection:a.connection,provider:a.provider,user_id:Dd(a.user_id),isSocial:a.is_social}]};return t.json(St.parse(l),{status:201})}catch(a){throw a.message==="User already exists"?new I(409,{message:"User already exists"}):a}}).openapi(o.createRoute({tags:["users"],method:"patch",path:"/{user_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object({...rs.shape,verify_email:o.z.boolean(),password:o.z.string()}).partial()}}},params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{description:"Status"}}}),async t=>{var p;const{data:e}=t.env,{"tenant-id":n}=t.req.valid("header"),r=t.req.valid("json"),{user_id:i}=t.req.valid("param"),{verify_email:s,password:a,...c}=r,l=await e.users.get(n,i);if(!l)throw new I(404);if(c.email&&c.email!==l.email){const f=await ml(t.env.data.users,n,c.email);if(f.length&&f.some(m=>m.user_id!==i))throw new I(409,{message:"Another user with the same email address already exists."})}if(l.linked_to)throw new I(404,{message:"User is linked to another user"});if(await t.env.data.users.update(n,i,c),a){const f=(p=l.identities)==null?void 0:p.find(h=>h.connection==="Username-Password-Authentication");if(!f)throw new I(400,{message:"User does not have a password identity"});const m={user_id:f.user_id,password:await oi.hash(a,10),algorithm:"bcrypt"};await e.passwords.get(n,f.user_id)?await e.passwords.update(n,m):await e.passwords.create(n,m)}const d=await t.env.data.users.get(n,i);if(!d)throw new I(500);return t.json(d)}).openapi(o.createRoute({tags:["users"],method:"post",path:"/{user_id}/identities",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.union([o.z.object({link_with:o.z.string()}),o.z.object({user_id:o.z.string(),provider:o.z.string(),connection:o.z.string().optional()})])}}},params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:o.z.array(o.z.object({connection:o.z.string(),provider:o.z.string(),user_id:o.z.string(),isSocial:o.z.boolean()}))}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),{user_id:r}=t.req.valid("param"),i="link_with"in n?n.link_with:n.user_id,s=await t.env.data.users.get(e,r);if(!s)throw new I(400,{message:"Linking an inexistent identity is not allowed."});await t.env.data.users.update(e,i,{linked_to:r});const a=await t.env.data.users.list(e,{page:0,per_page:10,include_totals:!1,q:`linked_to:${r}`}),c=[s,...a.users].map(l=>({connection:l.connection,provider:l.provider,user_id:Dd(l.user_id),isSocial:l.is_social}));return t.json(c,{status:201})}).openapi(o.createRoute({tags:["users"],method:"delete",path:"/{user_id}/identities/{provider}/{linked_user_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({user_id:o.z.string(),provider:o.z.string(),linked_user_id:o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:o.z.array(St)}},description:"Status"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{user_id:n,provider:r,linked_user_id:i}=t.req.valid("param");await t.env.data.users.unlink(e,n,r,i);const s=await t.env.data.users.get(e,n);if(!s)throw new I(404);return t.json([St.parse(s)])}).openapi(o.createRoute({tags:["users"],method:"get",path:"/{user_id}/sessions",request:{query:tn,headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({user_id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(Qs),Ty])}},description:"List of sessions"}}}),async t=>{const{user_id:e}=t.req.valid("param"),{include_totals:n}=t.req.valid("query"),{"tenant-id":r}=t.req.valid("header"),i=await t.env.data.sessions.list(r,{page:0,per_page:10,include_totals:!1,q:`user_id:${e}`});return n?t.json(i):t.json(i.sessions)});/*! *****************************************************************************
30
30
  Copyright (C) Microsoft. All rights reserved.
31
31
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
32
32
  this file except in compliance with the License. You may obtain a copy of the
@@ -39,7 +39,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
39
39
 
40
40
  See the Apache Version 2.0 License for specific language governing permissions
41
41
  and limitations under the License.
42
- ***************************************************************************** */var eu;(function(t){(function(e){var n=typeof globalThis=="object"?globalThis:typeof ls=="object"?ls:typeof self=="object"?self:typeof this=="object"?this:c(),r=i(t);typeof n.Reflect<"u"&&(r=i(n.Reflect,r)),e(r,n),typeof n.Reflect>"u"&&(n.Reflect=t);function i(l,d){return function(p,f){Object.defineProperty(l,p,{configurable:!0,writable:!0,value:f}),d&&d(p,f)}}function s(){try{return Function("return this;")()}catch{}}function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}function c(){return s()||a()}})(function(e,n){var r=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",l={__proto__:[]}instanceof Array,d=!c&&!l,p={create:c?function(){return na(Object.create(null))}:l?function(){return na({__proto__:null})}:function(){return na({})},has:d?function(A,E){return r.call(A,E)}:function(A,E){return E in A},get:d?function(A,E){return r.call(A,E)?A[E]:void 0}:function(A,E){return A[E]}},f=Object.getPrototypeOf(Function),m=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Vm(),w=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:qm(),h=typeof WeakMap=="function"?WeakMap:Mm(),_=i?Symbol.for("@reflect-metadata:registry"):void 0,v=Rm(),S=Lm(v);function C(A,E,P,V){if(D(P)){if(!Sd(A))throw new TypeError;if(!Ad(E))throw new TypeError;return N(A,E)}else{if(!Sd(A))throw new TypeError;if(!he(E))throw new TypeError;if(!he(V)&&!D(V)&&!Ce(V))throw new TypeError;return Ce(V)&&(V=void 0),P=bt(P),z(A,E,P,V)}}e("decorate",C);function O(A,E){function P(V,ee){if(!he(V))throw new TypeError;if(!D(ee)&&!Tm(ee))throw new TypeError;X(A,E,V,ee)}return P}e("metadata",O);function L(A,E,P,V){if(!he(P))throw new TypeError;return D(V)||(V=bt(V)),X(A,E,P,V)}e("defineMetadata",L);function Q(A,E,P){if(!he(E))throw new TypeError;return D(P)||(P=bt(P)),k(A,E,P)}e("hasMetadata",Q);function ce(A,E,P){if(!he(E))throw new TypeError;return D(P)||(P=bt(P)),x(A,E,P)}e("hasOwnMetadata",ce);function le(A,E,P){if(!he(E))throw new TypeError;return D(P)||(P=bt(P)),$(A,E,P)}e("getMetadata",le);function De(A,E,P){if(!he(E))throw new TypeError;return D(P)||(P=bt(P)),U(A,E,P)}e("getOwnMetadata",De);function Ve(A,E){if(!he(A))throw new TypeError;return D(E)||(E=bt(E)),G(A,E)}e("getMetadataKeys",Ve);function Re(A,E){if(!he(A))throw new TypeError;return D(E)||(E=bt(E)),se(A,E)}e("getOwnMetadataKeys",Re);function j(A,E,P){if(!he(E))throw new TypeError;if(D(P)||(P=bt(P)),!he(E))throw new TypeError;D(P)||(P=bt(P));var V=zr(E,P,!1);return D(V)?!1:V.OrdinaryDeleteMetadata(A,E,P)}e("deleteMetadata",j);function N(A,E){for(var P=A.length-1;P>=0;--P){var V=A[P],ee=V(E);if(!D(ee)&&!Ce(ee)){if(!Ad(ee))throw new TypeError;E=ee}}return E}function z(A,E,P,V){for(var ee=A.length-1;ee>=0;--ee){var Ne=A[ee],ze=Ne(E,P,V);if(!D(ze)&&!Ce(ze)){if(!he(ze))throw new TypeError;V=ze}}return V}function k(A,E,P){var V=x(A,E,P);if(V)return!0;var ee=ta(E);return Ce(ee)?!1:k(A,ee,P)}function x(A,E,P){var V=zr(E,P,!1);return D(V)?!1:kd(V.OrdinaryHasOwnMetadata(A,E,P))}function $(A,E,P){var V=x(A,E,P);if(V)return U(A,E,P);var ee=ta(E);if(!Ce(ee))return $(A,ee,P)}function U(A,E,P){var V=zr(E,P,!1);if(!D(V))return V.OrdinaryGetOwnMetadata(A,E,P)}function X(A,E,P,V){var ee=zr(P,V,!0);ee.OrdinaryDefineOwnMetadata(A,E,P,V)}function G(A,E){var P=se(A,E),V=ta(A);if(V===null)return P;var ee=G(V,E);if(ee.length<=0)return P;if(P.length<=0)return ee;for(var Ne=new w,ze=[],oe=0,H=P;oe<H.length;oe++){var W=H[oe],Z=Ne.has(W);Z||(Ne.add(W),ze.push(W))}for(var Y=0,ae=ee;Y<ae.length;Y++){var W=ae[Y],Z=Ne.has(W);Z||(Ne.add(W),ze.push(W))}return ze}function se(A,E){var P=zr(A,E,!1);return P?P.OrdinaryOwnMetadataKeys(A,E):[]}function ue(A){if(A===null)return 1;switch(typeof A){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return A===null?1:6;default:return 6}}function D(A){return A===void 0}function Ce(A){return A===null}function fn(A){return typeof A=="symbol"}function he(A){return typeof A=="object"?A!==null:typeof A=="function"}function Se(A,E){switch(ue(A)){case 0:return A;case 1:return A;case 2:return A;case 3:return A;case 4:return A;case 5:return A}var P="string",V=zd(A,s);if(V!==void 0){var ee=V.call(A,P);if(he(ee))throw new TypeError;return ee}return Om(A)}function Om(A,E){var P,V;{var ee=A.toString;if(ji(ee)){var V=ee.call(A);if(!he(V))return V}var P=A.valueOf;if(ji(P)){var V=P.call(A);if(!he(V))return V}}throw new TypeError}function kd(A){return!!A}function Pm(A){return""+A}function bt(A){var E=Se(A);return fn(E)?E:Pm(E)}function Sd(A){return Array.isArray?Array.isArray(A):A instanceof Object?A instanceof Array:Object.prototype.toString.call(A)==="[object Array]"}function ji(A){return typeof A=="function"}function Ad(A){return typeof A=="function"}function Tm(A){switch(ue(A)){case 3:return!0;case 4:return!0;default:return!1}}function ea(A,E){return A===E||A!==A&&E!==E}function zd(A,E){var P=A[E];if(P!=null){if(!ji(P))throw new TypeError;return P}}function Ed(A){var E=zd(A,a);if(!ji(E))throw new TypeError;var P=E.call(A);if(!he(P))throw new TypeError;return P}function Id(A){return A.value}function Cd(A){var E=A.next();return E.done?!1:E}function Nd(A){var E=A.return;E&&E.call(A)}function ta(A){var E=Object.getPrototypeOf(A);if(typeof A!="function"||A===f||E!==f)return E;var P=A.prototype,V=P&&Object.getPrototypeOf(P);if(V==null||V===Object.prototype)return E;var ee=V.constructor;return typeof ee!="function"||ee===A?E:ee}function Bm(){var A;!D(_)&&typeof n.Reflect<"u"&&!(_ in n.Reflect)&&typeof n.Reflect.defineMetadata=="function"&&(A=Um(n.Reflect));var E,P,V,ee=new h,Ne={registerProvider:ze,getProvider:H,setProvider:Z};return Ne;function ze(Y){if(!Object.isExtensible(Ne))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case A===Y:break;case D(E):E=Y;break;case E===Y:break;case D(P):P=Y;break;case P===Y:break;default:V===void 0&&(V=new w),V.add(Y);break}}function oe(Y,ae){if(!D(E)){if(E.isProviderFor(Y,ae))return E;if(!D(P)){if(P.isProviderFor(Y,ae))return E;if(!D(V))for(var me=Ed(V);;){var ve=Cd(me);if(!ve)return;var ut=Id(ve);if(ut.isProviderFor(Y,ae))return Nd(me),ut}}}if(!D(A)&&A.isProviderFor(Y,ae))return A}function H(Y,ae){var me=ee.get(Y),ve;return D(me)||(ve=me.get(ae)),D(ve)&&(ve=oe(Y,ae),D(ve)||(D(me)&&(me=new m,ee.set(Y,me)),me.set(ae,ve))),ve}function W(Y){if(D(Y))throw new TypeError;return E===Y||P===Y||!D(V)&&V.has(Y)}function Z(Y,ae,me){if(!W(me))throw new Error("Metadata provider not registered.");var ve=H(Y,ae);if(ve!==me){if(!D(ve))return!1;var ut=ee.get(Y);D(ut)&&(ut=new m,ee.set(Y,ut)),ut.set(ae,me)}return!0}}function Rm(){var A;return!D(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&(A=n.Reflect[_]),D(A)&&(A=Bm()),!D(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&Object.defineProperty(n.Reflect,_,{enumerable:!1,configurable:!1,writable:!1,value:A}),A}function Lm(A){var E=new h,P={isProviderFor:function(W,Z){var Y=E.get(W);return D(Y)?!1:Y.has(Z)},OrdinaryDefineOwnMetadata:ze,OrdinaryHasOwnMetadata:ee,OrdinaryGetOwnMetadata:Ne,OrdinaryOwnMetadataKeys:oe,OrdinaryDeleteMetadata:H};return v.registerProvider(P),P;function V(W,Z,Y){var ae=E.get(W),me=!1;if(D(ae)){if(!Y)return;ae=new m,E.set(W,ae),me=!0}var ve=ae.get(Z);if(D(ve)){if(!Y)return;if(ve=new m,ae.set(Z,ve),!A.setProvider(W,Z,P))throw ae.delete(Z),me&&E.delete(W),new Error("Wrong provider for target.")}return ve}function ee(W,Z,Y){var ae=V(Z,Y,!1);return D(ae)?!1:kd(ae.has(W))}function Ne(W,Z,Y){var ae=V(Z,Y,!1);if(!D(ae))return ae.get(W)}function ze(W,Z,Y,ae){var me=V(Y,ae,!0);me.set(W,Z)}function oe(W,Z){var Y=[],ae=V(W,Z,!1);if(D(ae))return Y;for(var me=ae.keys(),ve=Ed(me),ut=0;;){var jd=Cd(ve);if(!jd)return Y.length=ut,Y;var Hm=Id(jd);try{Y[ut]=Hm}catch(Dm){try{Nd(ve)}finally{throw Dm}}ut++}}function H(W,Z,Y){var ae=V(Z,Y,!1);if(D(ae)||!ae.delete(W))return!1;if(ae.size===0){var me=E.get(Z);D(me)||(me.delete(Y),me.size===0&&E.delete(me))}return!0}}function Um(A){var E=A.defineMetadata,P=A.hasOwnMetadata,V=A.getOwnMetadata,ee=A.getOwnMetadataKeys,Ne=A.deleteMetadata,ze=new h,oe={isProviderFor:function(H,W){var Z=ze.get(H);return!D(Z)&&Z.has(W)?!0:ee(H,W).length?(D(Z)&&(Z=new w,ze.set(H,Z)),Z.add(W),!0):!1},OrdinaryDefineOwnMetadata:E,OrdinaryHasOwnMetadata:P,OrdinaryGetOwnMetadata:V,OrdinaryOwnMetadataKeys:ee,OrdinaryDeleteMetadata:Ne};return oe}function zr(A,E,P){var V=v.getProvider(A,E);if(!D(V))return V;if(P){if(v.setProvider(A,E,S))return S;throw new Error("Illegal state.")}}function Vm(){var A={},E=[],P=function(){function oe(H,W,Z){this._index=0,this._keys=H,this._values=W,this._selector=Z}return oe.prototype["@@iterator"]=function(){return this},oe.prototype[a]=function(){return this},oe.prototype.next=function(){var H=this._index;if(H>=0&&H<this._keys.length){var W=this._selector(this._keys[H],this._values[H]);return H+1>=this._keys.length?(this._index=-1,this._keys=E,this._values=E):this._index++,{value:W,done:!1}}return{value:void 0,done:!0}},oe.prototype.throw=function(H){throw this._index>=0&&(this._index=-1,this._keys=E,this._values=E),H},oe.prototype.return=function(H){return this._index>=0&&(this._index=-1,this._keys=E,this._values=E),{value:H,done:!0}},oe}(),V=function(){function oe(){this._keys=[],this._values=[],this._cacheKey=A,this._cacheIndex=-2}return Object.defineProperty(oe.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),oe.prototype.has=function(H){return this._find(H,!1)>=0},oe.prototype.get=function(H){var W=this._find(H,!1);return W>=0?this._values[W]:void 0},oe.prototype.set=function(H,W){var Z=this._find(H,!0);return this._values[Z]=W,this},oe.prototype.delete=function(H){var W=this._find(H,!1);if(W>=0){for(var Z=this._keys.length,Y=W+1;Y<Z;Y++)this._keys[Y-1]=this._keys[Y],this._values[Y-1]=this._values[Y];return this._keys.length--,this._values.length--,ea(H,this._cacheKey)&&(this._cacheKey=A,this._cacheIndex=-2),!0}return!1},oe.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=A,this._cacheIndex=-2},oe.prototype.keys=function(){return new P(this._keys,this._values,ee)},oe.prototype.values=function(){return new P(this._keys,this._values,Ne)},oe.prototype.entries=function(){return new P(this._keys,this._values,ze)},oe.prototype["@@iterator"]=function(){return this.entries()},oe.prototype[a]=function(){return this.entries()},oe.prototype._find=function(H,W){if(!ea(this._cacheKey,H)){this._cacheIndex=-1;for(var Z=0;Z<this._keys.length;Z++)if(ea(this._keys[Z],H)){this._cacheIndex=Z;break}}return this._cacheIndex<0&&W&&(this._cacheIndex=this._keys.length,this._keys.push(H),this._values.push(void 0)),this._cacheIndex},oe}();return V;function ee(oe,H){return oe}function Ne(oe,H){return H}function ze(oe,H){return[oe,H]}}function qm(){var A=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(P){return this._map.has(P)},E.prototype.add=function(P){return this._map.set(P,P),this},E.prototype.delete=function(P){return this._map.delete(P)},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[a]=function(){return this.keys()},E}();return A}function Mm(){var A=16,E=p.create(),P=V();return function(){function H(){this._key=V()}return H.prototype.has=function(W){var Z=ee(W,!1);return Z!==void 0?p.has(Z,this._key):!1},H.prototype.get=function(W){var Z=ee(W,!1);return Z!==void 0?p.get(Z,this._key):void 0},H.prototype.set=function(W,Z){var Y=ee(W,!0);return Y[this._key]=Z,this},H.prototype.delete=function(W){var Z=ee(W,!1);return Z!==void 0?delete Z[this._key]:!1},H.prototype.clear=function(){this._key=V()},H}();function V(){var H;do H="@@WeakMap@@"+oe();while(p.has(E,H));return E[H]=!0,H}function ee(H,W){if(!r.call(H,P)){if(!W)return;Object.defineProperty(H,P,{value:p.create()})}return H[P]}function Ne(H,W){for(var Z=0;Z<W;++Z)H[Z]=Math.random()*255|0;return H}function ze(H){if(typeof Uint8Array=="function"){var W=new Uint8Array(H);return typeof crypto<"u"?crypto.getRandomValues(W):typeof msCrypto<"u"?msCrypto.getRandomValues(W):Ne(W,H),W}return Ne(new Array(H),H)}function oe(){var H=ze(A);H[6]=H[6]&79|64,H[8]=H[8]&191|128;for(var W="",Z=0;Z<A;++Z){var Y=H[Z];(Z===4||Z===6||Z===8)&&(W+="-"),Y<16&&(W+="0"),W+=Y.toString(16).toLowerCase()}return W}}function na(A){return A.__=void 0,delete A.__,A}})})(eu||(eu={}));/*!
42
+ ***************************************************************************** */var eu;(function(t){(function(e){var n=typeof globalThis=="object"?globalThis:typeof ls=="object"?ls:typeof self=="object"?self:typeof this=="object"?this:c(),r=i(t);typeof n.Reflect<"u"&&(r=i(n.Reflect,r)),e(r,n),typeof n.Reflect>"u"&&(n.Reflect=t);function i(l,d){return function(p,f){Object.defineProperty(l,p,{configurable:!0,writable:!0,value:f}),d&&d(p,f)}}function s(){try{return Function("return this;")()}catch{}}function a(){try{return(0,eval)("(function() { return this; })()")}catch{}}function c(){return s()||a()}})(function(e,n){var r=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",a=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",l={__proto__:[]}instanceof Array,d=!c&&!l,p={create:c?function(){return na(Object.create(null))}:l?function(){return na({__proto__:null})}:function(){return na({})},has:d?function(A,E){return r.call(A,E)}:function(A,E){return E in A},get:d?function(A,E){return r.call(A,E)?A[E]:void 0}:function(A,E){return A[E]}},f=Object.getPrototypeOf(Function),m=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Hm(),w=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Dm(),h=typeof WeakMap=="function"?WeakMap:Fm(),_=i?Symbol.for("@reflect-metadata:registry"):void 0,v=Vm(),S=qm(v);function C(A,E,P,V){if(D(P)){if(!Sd(A))throw new TypeError;if(!Ad(E))throw new TypeError;return N(A,E)}else{if(!Sd(A))throw new TypeError;if(!he(E))throw new TypeError;if(!he(V)&&!D(V)&&!Ce(V))throw new TypeError;return Ce(V)&&(V=void 0),P=bt(P),z(A,E,P,V)}}e("decorate",C);function O(A,E){function P(V,ee){if(!he(V))throw new TypeError;if(!D(ee)&&!Lm(ee))throw new TypeError;X(A,E,V,ee)}return P}e("metadata",O);function L(A,E,P,V){if(!he(P))throw new TypeError;return D(V)||(V=bt(V)),X(A,E,P,V)}e("defineMetadata",L);function Q(A,E,P){if(!he(E))throw new TypeError;return D(P)||(P=bt(P)),k(A,E,P)}e("hasMetadata",Q);function ce(A,E,P){if(!he(E))throw new TypeError;return D(P)||(P=bt(P)),x(A,E,P)}e("hasOwnMetadata",ce);function le(A,E,P){if(!he(E))throw new TypeError;return D(P)||(P=bt(P)),$(A,E,P)}e("getMetadata",le);function De(A,E,P){if(!he(E))throw new TypeError;return D(P)||(P=bt(P)),U(A,E,P)}e("getOwnMetadata",De);function Ve(A,E){if(!he(A))throw new TypeError;return D(E)||(E=bt(E)),G(A,E)}e("getMetadataKeys",Ve);function Re(A,E){if(!he(A))throw new TypeError;return D(E)||(E=bt(E)),se(A,E)}e("getOwnMetadataKeys",Re);function j(A,E,P){if(!he(E))throw new TypeError;if(D(P)||(P=bt(P)),!he(E))throw new TypeError;D(P)||(P=bt(P));var V=zr(E,P,!1);return D(V)?!1:V.OrdinaryDeleteMetadata(A,E,P)}e("deleteMetadata",j);function N(A,E){for(var P=A.length-1;P>=0;--P){var V=A[P],ee=V(E);if(!D(ee)&&!Ce(ee)){if(!Ad(ee))throw new TypeError;E=ee}}return E}function z(A,E,P,V){for(var ee=A.length-1;ee>=0;--ee){var Ne=A[ee],ze=Ne(E,P,V);if(!D(ze)&&!Ce(ze)){if(!he(ze))throw new TypeError;V=ze}}return V}function k(A,E,P){var V=x(A,E,P);if(V)return!0;var ee=ta(E);return Ce(ee)?!1:k(A,ee,P)}function x(A,E,P){var V=zr(E,P,!1);return D(V)?!1:kd(V.OrdinaryHasOwnMetadata(A,E,P))}function $(A,E,P){var V=x(A,E,P);if(V)return U(A,E,P);var ee=ta(E);if(!Ce(ee))return $(A,ee,P)}function U(A,E,P){var V=zr(E,P,!1);if(!D(V))return V.OrdinaryGetOwnMetadata(A,E,P)}function X(A,E,P,V){var ee=zr(P,V,!0);ee.OrdinaryDefineOwnMetadata(A,E,P,V)}function G(A,E){var P=se(A,E),V=ta(A);if(V===null)return P;var ee=G(V,E);if(ee.length<=0)return P;if(P.length<=0)return ee;for(var Ne=new w,ze=[],oe=0,H=P;oe<H.length;oe++){var W=H[oe],Z=Ne.has(W);Z||(Ne.add(W),ze.push(W))}for(var Y=0,ae=ee;Y<ae.length;Y++){var W=ae[Y],Z=Ne.has(W);Z||(Ne.add(W),ze.push(W))}return ze}function se(A,E){var P=zr(A,E,!1);return P?P.OrdinaryOwnMetadataKeys(A,E):[]}function ue(A){if(A===null)return 1;switch(typeof A){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return A===null?1:6;default:return 6}}function D(A){return A===void 0}function Ce(A){return A===null}function fn(A){return typeof A=="symbol"}function he(A){return typeof A=="object"?A!==null:typeof A=="function"}function Se(A,E){switch(ue(A)){case 0:return A;case 1:return A;case 2:return A;case 3:return A;case 4:return A;case 5:return A}var P="string",V=zd(A,s);if(V!==void 0){var ee=V.call(A,P);if(he(ee))throw new TypeError;return ee}return Bm(A)}function Bm(A,E){var P,V;{var ee=A.toString;if(ji(ee)){var V=ee.call(A);if(!he(V))return V}var P=A.valueOf;if(ji(P)){var V=P.call(A);if(!he(V))return V}}throw new TypeError}function kd(A){return!!A}function Rm(A){return""+A}function bt(A){var E=Se(A);return fn(E)?E:Rm(E)}function Sd(A){return Array.isArray?Array.isArray(A):A instanceof Object?A instanceof Array:Object.prototype.toString.call(A)==="[object Array]"}function ji(A){return typeof A=="function"}function Ad(A){return typeof A=="function"}function Lm(A){switch(ue(A)){case 3:return!0;case 4:return!0;default:return!1}}function ea(A,E){return A===E||A!==A&&E!==E}function zd(A,E){var P=A[E];if(P!=null){if(!ji(P))throw new TypeError;return P}}function Ed(A){var E=zd(A,a);if(!ji(E))throw new TypeError;var P=E.call(A);if(!he(P))throw new TypeError;return P}function Id(A){return A.value}function Cd(A){var E=A.next();return E.done?!1:E}function Nd(A){var E=A.return;E&&E.call(A)}function ta(A){var E=Object.getPrototypeOf(A);if(typeof A!="function"||A===f||E!==f)return E;var P=A.prototype,V=P&&Object.getPrototypeOf(P);if(V==null||V===Object.prototype)return E;var ee=V.constructor;return typeof ee!="function"||ee===A?E:ee}function Um(){var A;!D(_)&&typeof n.Reflect<"u"&&!(_ in n.Reflect)&&typeof n.Reflect.defineMetadata=="function"&&(A=Mm(n.Reflect));var E,P,V,ee=new h,Ne={registerProvider:ze,getProvider:H,setProvider:Z};return Ne;function ze(Y){if(!Object.isExtensible(Ne))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case A===Y:break;case D(E):E=Y;break;case E===Y:break;case D(P):P=Y;break;case P===Y:break;default:V===void 0&&(V=new w),V.add(Y);break}}function oe(Y,ae){if(!D(E)){if(E.isProviderFor(Y,ae))return E;if(!D(P)){if(P.isProviderFor(Y,ae))return E;if(!D(V))for(var me=Ed(V);;){var ve=Cd(me);if(!ve)return;var ut=Id(ve);if(ut.isProviderFor(Y,ae))return Nd(me),ut}}}if(!D(A)&&A.isProviderFor(Y,ae))return A}function H(Y,ae){var me=ee.get(Y),ve;return D(me)||(ve=me.get(ae)),D(ve)&&(ve=oe(Y,ae),D(ve)||(D(me)&&(me=new m,ee.set(Y,me)),me.set(ae,ve))),ve}function W(Y){if(D(Y))throw new TypeError;return E===Y||P===Y||!D(V)&&V.has(Y)}function Z(Y,ae,me){if(!W(me))throw new Error("Metadata provider not registered.");var ve=H(Y,ae);if(ve!==me){if(!D(ve))return!1;var ut=ee.get(Y);D(ut)&&(ut=new m,ee.set(Y,ut)),ut.set(ae,me)}return!0}}function Vm(){var A;return!D(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&(A=n.Reflect[_]),D(A)&&(A=Um()),!D(_)&&he(n.Reflect)&&Object.isExtensible(n.Reflect)&&Object.defineProperty(n.Reflect,_,{enumerable:!1,configurable:!1,writable:!1,value:A}),A}function qm(A){var E=new h,P={isProviderFor:function(W,Z){var Y=E.get(W);return D(Y)?!1:Y.has(Z)},OrdinaryDefineOwnMetadata:ze,OrdinaryHasOwnMetadata:ee,OrdinaryGetOwnMetadata:Ne,OrdinaryOwnMetadataKeys:oe,OrdinaryDeleteMetadata:H};return v.registerProvider(P),P;function V(W,Z,Y){var ae=E.get(W),me=!1;if(D(ae)){if(!Y)return;ae=new m,E.set(W,ae),me=!0}var ve=ae.get(Z);if(D(ve)){if(!Y)return;if(ve=new m,ae.set(Z,ve),!A.setProvider(W,Z,P))throw ae.delete(Z),me&&E.delete(W),new Error("Wrong provider for target.")}return ve}function ee(W,Z,Y){var ae=V(Z,Y,!1);return D(ae)?!1:kd(ae.has(W))}function Ne(W,Z,Y){var ae=V(Z,Y,!1);if(!D(ae))return ae.get(W)}function ze(W,Z,Y,ae){var me=V(Y,ae,!0);me.set(W,Z)}function oe(W,Z){var Y=[],ae=V(W,Z,!1);if(D(ae))return Y;for(var me=ae.keys(),ve=Ed(me),ut=0;;){var jd=Cd(ve);if(!jd)return Y.length=ut,Y;var Km=Id(jd);try{Y[ut]=Km}catch(Wm){try{Nd(ve)}finally{throw Wm}}ut++}}function H(W,Z,Y){var ae=V(Z,Y,!1);if(D(ae)||!ae.delete(W))return!1;if(ae.size===0){var me=E.get(Z);D(me)||(me.delete(Y),me.size===0&&E.delete(me))}return!0}}function Mm(A){var E=A.defineMetadata,P=A.hasOwnMetadata,V=A.getOwnMetadata,ee=A.getOwnMetadataKeys,Ne=A.deleteMetadata,ze=new h,oe={isProviderFor:function(H,W){var Z=ze.get(H);return!D(Z)&&Z.has(W)?!0:ee(H,W).length?(D(Z)&&(Z=new w,ze.set(H,Z)),Z.add(W),!0):!1},OrdinaryDefineOwnMetadata:E,OrdinaryHasOwnMetadata:P,OrdinaryGetOwnMetadata:V,OrdinaryOwnMetadataKeys:ee,OrdinaryDeleteMetadata:Ne};return oe}function zr(A,E,P){var V=v.getProvider(A,E);if(!D(V))return V;if(P){if(v.setProvider(A,E,S))return S;throw new Error("Illegal state.")}}function Hm(){var A={},E=[],P=function(){function oe(H,W,Z){this._index=0,this._keys=H,this._values=W,this._selector=Z}return oe.prototype["@@iterator"]=function(){return this},oe.prototype[a]=function(){return this},oe.prototype.next=function(){var H=this._index;if(H>=0&&H<this._keys.length){var W=this._selector(this._keys[H],this._values[H]);return H+1>=this._keys.length?(this._index=-1,this._keys=E,this._values=E):this._index++,{value:W,done:!1}}return{value:void 0,done:!0}},oe.prototype.throw=function(H){throw this._index>=0&&(this._index=-1,this._keys=E,this._values=E),H},oe.prototype.return=function(H){return this._index>=0&&(this._index=-1,this._keys=E,this._values=E),{value:H,done:!0}},oe}(),V=function(){function oe(){this._keys=[],this._values=[],this._cacheKey=A,this._cacheIndex=-2}return Object.defineProperty(oe.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),oe.prototype.has=function(H){return this._find(H,!1)>=0},oe.prototype.get=function(H){var W=this._find(H,!1);return W>=0?this._values[W]:void 0},oe.prototype.set=function(H,W){var Z=this._find(H,!0);return this._values[Z]=W,this},oe.prototype.delete=function(H){var W=this._find(H,!1);if(W>=0){for(var Z=this._keys.length,Y=W+1;Y<Z;Y++)this._keys[Y-1]=this._keys[Y],this._values[Y-1]=this._values[Y];return this._keys.length--,this._values.length--,ea(H,this._cacheKey)&&(this._cacheKey=A,this._cacheIndex=-2),!0}return!1},oe.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=A,this._cacheIndex=-2},oe.prototype.keys=function(){return new P(this._keys,this._values,ee)},oe.prototype.values=function(){return new P(this._keys,this._values,Ne)},oe.prototype.entries=function(){return new P(this._keys,this._values,ze)},oe.prototype["@@iterator"]=function(){return this.entries()},oe.prototype[a]=function(){return this.entries()},oe.prototype._find=function(H,W){if(!ea(this._cacheKey,H)){this._cacheIndex=-1;for(var Z=0;Z<this._keys.length;Z++)if(ea(this._keys[Z],H)){this._cacheIndex=Z;break}}return this._cacheIndex<0&&W&&(this._cacheIndex=this._keys.length,this._keys.push(H),this._values.push(void 0)),this._cacheIndex},oe}();return V;function ee(oe,H){return oe}function Ne(oe,H){return H}function ze(oe,H){return[oe,H]}}function Dm(){var A=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(P){return this._map.has(P)},E.prototype.add=function(P){return this._map.set(P,P),this},E.prototype.delete=function(P){return this._map.delete(P)},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[a]=function(){return this.keys()},E}();return A}function Fm(){var A=16,E=p.create(),P=V();return function(){function H(){this._key=V()}return H.prototype.has=function(W){var Z=ee(W,!1);return Z!==void 0?p.has(Z,this._key):!1},H.prototype.get=function(W){var Z=ee(W,!1);return Z!==void 0?p.get(Z,this._key):void 0},H.prototype.set=function(W,Z){var Y=ee(W,!0);return Y[this._key]=Z,this},H.prototype.delete=function(W){var Z=ee(W,!1);return Z!==void 0?delete Z[this._key]:!1},H.prototype.clear=function(){this._key=V()},H}();function V(){var H;do H="@@WeakMap@@"+oe();while(p.has(E,H));return E[H]=!0,H}function ee(H,W){if(!r.call(H,P)){if(!W)return;Object.defineProperty(H,P,{value:p.create()})}return H[P]}function Ne(H,W){for(var Z=0;Z<W;++Z)H[Z]=Math.random()*255|0;return H}function ze(H){if(typeof Uint8Array=="function"){var W=new Uint8Array(H);return typeof crypto<"u"?crypto.getRandomValues(W):typeof msCrypto<"u"?msCrypto.getRandomValues(W):Ne(W,H),W}return Ne(new Array(H),H)}function oe(){var H=ze(A);H[6]=H[6]&79|64,H[8]=H[8]&191|128;for(var W="",Z=0;Z<A;++Z){var Y=H[Z];(Z===4||Z===6||Z===8)&&(W+="-"),Y<16&&(W+="0"),W+=Y.toString(16).toLowerCase()}return W}}function na(A){return A.__=void 0,delete A.__,A}})})(eu||(eu={}));/*!
43
43
  * MIT License
44
44
  *
45
45
  * Copyright (c) 2017-2022 Peculiar Ventures, LLC
@@ -62,9 +62,9 @@ and limitations under the License.
62
62
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
63
63
  * SOFTWARE.
64
64
  *
65
- */const Py="[object ArrayBuffer]";class M{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Py}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 r=M.toUint8Array(e),i=M.toUint8Array(n);if(r.length!==i.byteLength)return!1;for(let s=0;s<r.length;s++)if(r[s]!==i[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 r=0;for(const a of n)r+=a.byteLength;const i=new Uint8Array(r);let s=0;for(const a of n){const c=this.toUint8Array(a);i.set(c,s),s+=c.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}}const ia="string",Ty=/^[0-9a-f]+$/i,By=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Ry=/^[a-zA-Z0-9-_]+$/;class tu{static fromString(e){const n=unescape(encodeURIComponent(e)),r=new Uint8Array(n.length);for(let i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return r.buffer}static toString(e){const n=M.toUint8Array(e);let r="";for(let s=0;s<n.length;s++)r+=String.fromCharCode(n[s]);return decodeURIComponent(escape(r))}}class xt{static toString(e,n=!1){const r=M.toArrayBuffer(e),i=new DataView(r);let s="";for(let a=0;a<r.byteLength;a+=2){const c=i.getUint16(a,n);s+=String.fromCharCode(c)}return s}static fromString(e,n=!1){const r=new ArrayBuffer(e.length*2),i=new DataView(r);for(let s=0;s<e.length;s++)i.setUint16(s*2,e.charCodeAt(s),n);return r}}class J{static isHex(e){return typeof e===ia&&Ty.test(e)}static isBase64(e){return typeof e===ia&&By.test(e)}static isBase64Url(e){return typeof e===ia&&Ry.test(e)}static ToString(e,n="utf8"){const r=M.toUint8Array(e);switch(n.toLowerCase()){case"utf8":return this.ToUtf8String(r);case"binary":return this.ToBinary(r);case"hex":return this.ToHex(r);case"base64":return this.ToBase64(r);case"base64url":return this.ToBase64Url(r);case"utf16le":return xt.toString(r,!0);case"utf16":case"utf16be":return xt.toString(r);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 xt.fromString(e,!0);case"utf16":case"utf16be":return xt.fromString(e);default:throw new Error(`Unknown type of encoding '${n}'`)}}static ToBase64(e){const n=M.toUint8Array(e);if(typeof btoa<"u"){const r=this.ToString(n,"binary");return btoa(r)}else return Buffer.from(n).toString("base64")}static FromBase64(e){const n=this.formatString(e);if(!n)return new ArrayBuffer(0);if(!J.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(!J.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=J.DEFAULT_UTF8_ENCODING){switch(n){case"ascii":return this.FromBinary(e);case"utf8":return tu.fromString(e);case"utf16":case"utf16be":return xt.fromString(e);case"utf16le":case"usc2":return xt.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${n}'`)}}static ToUtf8String(e,n=J.DEFAULT_UTF8_ENCODING){switch(n){case"ascii":return this.ToBinary(e);case"utf8":return tu.toString(e);case"utf16":case"utf16be":return xt.toString(e);case"utf16le":case"usc2":return xt.toString(e,!0);default:throw new Error(`Unknown type of encoding '${n}'`)}}static FromBinary(e){const n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.charCodeAt(i);return r.buffer}static ToBinary(e){const n=M.toUint8Array(e);let r="";for(let i=0;i<n.length;i++)r+=String.fromCharCode(n[i]);return r}static ToHex(e){const n=M.toUint8Array(e);let r="";const i=n.length;for(let s=0;s<i;s++){const a=n[s];a<16&&(r+="0"),r+=a.toString(16)}return r}static FromHex(e){let n=this.formatString(e);if(!n)return new ArrayBuffer(0);if(!J.isHex(n))throw new TypeError("Argument 'hexString' is not HEX encoded");n.length%2&&(n=`0${n}`);const r=new Uint8Array(n.length/2);for(let i=0;i<n.length;i=i+2){const s=n.slice(i,i+2);r[i/2]=parseInt(s,16)}return r.buffer}static ToUtf16String(e,n=!1){return xt.toString(e,n)}static FromUtf16String(e,n=!1){return xt.fromString(e,n)}static Base64Padding(e){const n=4-e.length%4;if(n<4)for(let r=0;r<n;r++)e+="=";return e}static formatString(e){return(e==null?void 0:e.replace(/[\n\r\t ]/g,""))||""}}J.DEFAULT_UTF8_ENCODING="utf8";function Ly(...t){const e=t.map(i=>i.byteLength).reduce((i,s)=>i+s),n=new Uint8Array(e);let r=0;return t.map(i=>new Uint8Array(i)).forEach(i=>{for(const s of i)n[r++]=s}),n.buffer}function Gf(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<t.byteLength;i++)if(n[i]!==r[i])return!1;return!0}/*!
65
+ */const Ry="[object ArrayBuffer]";class M{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Ry}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 r=M.toUint8Array(e),i=M.toUint8Array(n);if(r.length!==i.byteLength)return!1;for(let s=0;s<r.length;s++)if(r[s]!==i[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 r=0;for(const a of n)r+=a.byteLength;const i=new Uint8Array(r);let s=0;for(const a of n){const c=this.toUint8Array(a);i.set(c,s),s+=c.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}}const ia="string",Ly=/^[0-9a-f]+$/i,Uy=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Vy=/^[a-zA-Z0-9-_]+$/;class tu{static fromString(e){const n=unescape(encodeURIComponent(e)),r=new Uint8Array(n.length);for(let i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return r.buffer}static toString(e){const n=M.toUint8Array(e);let r="";for(let s=0;s<n.length;s++)r+=String.fromCharCode(n[s]);return decodeURIComponent(escape(r))}}class xt{static toString(e,n=!1){const r=M.toArrayBuffer(e),i=new DataView(r);let s="";for(let a=0;a<r.byteLength;a+=2){const c=i.getUint16(a,n);s+=String.fromCharCode(c)}return s}static fromString(e,n=!1){const r=new ArrayBuffer(e.length*2),i=new DataView(r);for(let s=0;s<e.length;s++)i.setUint16(s*2,e.charCodeAt(s),n);return r}}class J{static isHex(e){return typeof e===ia&&Ly.test(e)}static isBase64(e){return typeof e===ia&&Uy.test(e)}static isBase64Url(e){return typeof e===ia&&Vy.test(e)}static ToString(e,n="utf8"){const r=M.toUint8Array(e);switch(n.toLowerCase()){case"utf8":return this.ToUtf8String(r);case"binary":return this.ToBinary(r);case"hex":return this.ToHex(r);case"base64":return this.ToBase64(r);case"base64url":return this.ToBase64Url(r);case"utf16le":return xt.toString(r,!0);case"utf16":case"utf16be":return xt.toString(r);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 xt.fromString(e,!0);case"utf16":case"utf16be":return xt.fromString(e);default:throw new Error(`Unknown type of encoding '${n}'`)}}static ToBase64(e){const n=M.toUint8Array(e);if(typeof btoa<"u"){const r=this.ToString(n,"binary");return btoa(r)}else return Buffer.from(n).toString("base64")}static FromBase64(e){const n=this.formatString(e);if(!n)return new ArrayBuffer(0);if(!J.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(!J.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=J.DEFAULT_UTF8_ENCODING){switch(n){case"ascii":return this.FromBinary(e);case"utf8":return tu.fromString(e);case"utf16":case"utf16be":return xt.fromString(e);case"utf16le":case"usc2":return xt.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${n}'`)}}static ToUtf8String(e,n=J.DEFAULT_UTF8_ENCODING){switch(n){case"ascii":return this.ToBinary(e);case"utf8":return tu.toString(e);case"utf16":case"utf16be":return xt.toString(e);case"utf16le":case"usc2":return xt.toString(e,!0);default:throw new Error(`Unknown type of encoding '${n}'`)}}static FromBinary(e){const n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.charCodeAt(i);return r.buffer}static ToBinary(e){const n=M.toUint8Array(e);let r="";for(let i=0;i<n.length;i++)r+=String.fromCharCode(n[i]);return r}static ToHex(e){const n=M.toUint8Array(e);let r="";const i=n.length;for(let s=0;s<i;s++){const a=n[s];a<16&&(r+="0"),r+=a.toString(16)}return r}static FromHex(e){let n=this.formatString(e);if(!n)return new ArrayBuffer(0);if(!J.isHex(n))throw new TypeError("Argument 'hexString' is not HEX encoded");n.length%2&&(n=`0${n}`);const r=new Uint8Array(n.length/2);for(let i=0;i<n.length;i=i+2){const s=n.slice(i,i+2);r[i/2]=parseInt(s,16)}return r.buffer}static ToUtf16String(e,n=!1){return xt.toString(e,n)}static FromUtf16String(e,n=!1){return xt.fromString(e,n)}static Base64Padding(e){const n=4-e.length%4;if(n<4)for(let r=0;r<n;r++)e+="=";return e}static formatString(e){return(e==null?void 0:e.replace(/[\n\r\t ]/g,""))||""}}J.DEFAULT_UTF8_ENCODING="utf8";function qy(...t){const e=t.map(i=>i.byteLength).reduce((i,s)=>i+s),n=new Uint8Array(e);let r=0;return t.map(i=>new Uint8Array(i)).forEach(i=>{for(const s of i)n[r++]=s}),n.buffer}function Zf(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<t.byteLength;i++)if(n[i]!==r[i])return!1;return!0}/*!
66
66
  Copyright (c) Peculiar Ventures, LLC
67
- */function er(t,e){let n=0;if(t.length===1)return t[0];for(let r=t.length-1;r>=0;r--)n+=t[t.length-1-r]*Math.pow(2,e*r);return n}function kn(t,e,n=-1){const r=n;let i=t,s=0,a=Math.pow(2,e);for(let c=1;c<8;c++){if(t<a){let l;if(r<0)l=new ArrayBuffer(c),s=c;else{if(r<c)return new ArrayBuffer(0);l=new ArrayBuffer(r),s=r}const d=new Uint8Array(l);for(let p=c-1;p>=0;p--){const f=Math.pow(2,p*e);d[s-p-1]=Math.floor(i/f),i-=d[s-p-1]*f}return l}a*=Math.pow(2,e)}return new ArrayBuffer(0)}function Oa(...t){let e=0,n=0;for(const s of t)e+=s.length;const r=new ArrayBuffer(e),i=new Uint8Array(r);for(const s of t)i.set(s,n),n+=s.length;return i}function Jf(){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 r=er(n,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let c=0;c<this.valueHex.byteLength;c++)s[c]=t[c];return s[0]&=127,er(s,8)-r}function Uy(t){const e=t<0?t*-1:t;let n=128;for(let r=1;r<8;r++){if(e<=n){if(t<0){const a=n-e,c=kn(a,8,r),l=new Uint8Array(c);return l[0]|=128,c}let i=kn(e,8,r),s=new Uint8Array(i);if(s[0]&128){const a=i.slice(0),c=new Uint8Array(a);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let l=0;l<a.byteLength;l++)s[l+1]=c[l];s[0]=0}return i}n*=Math.pow(2,8)}return new ArrayBuffer(0)}function Vy(t,e){if(t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<n.length;i++)if(n[i]!==r[i])return!1;return!0}function Qe(t,e){const n=t.toString(10);if(e<n.length)return"";const r=e-n.length,i=new Array(r);for(let a=0;a<r;a++)i[a]="0";return i.join("").concat(n)}/*!
67
+ */function er(t,e){let n=0;if(t.length===1)return t[0];for(let r=t.length-1;r>=0;r--)n+=t[t.length-1-r]*Math.pow(2,e*r);return n}function kn(t,e,n=-1){const r=n;let i=t,s=0,a=Math.pow(2,e);for(let c=1;c<8;c++){if(t<a){let l;if(r<0)l=new ArrayBuffer(c),s=c;else{if(r<c)return new ArrayBuffer(0);l=new ArrayBuffer(r),s=r}const d=new Uint8Array(l);for(let p=c-1;p>=0;p--){const f=Math.pow(2,p*e);d[s-p-1]=Math.floor(i/f),i-=d[s-p-1]*f}return l}a*=Math.pow(2,e)}return new ArrayBuffer(0)}function Oa(...t){let e=0,n=0;for(const s of t)e+=s.length;const r=new ArrayBuffer(e),i=new Uint8Array(r);for(const s of t)i.set(s,n),n+=s.length;return i}function Yf(){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 r=er(n,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let c=0;c<this.valueHex.byteLength;c++)s[c]=t[c];return s[0]&=127,er(s,8)-r}function My(t){const e=t<0?t*-1:t;let n=128;for(let r=1;r<8;r++){if(e<=n){if(t<0){const a=n-e,c=kn(a,8,r),l=new Uint8Array(c);return l[0]|=128,c}let i=kn(e,8,r),s=new Uint8Array(i);if(s[0]&128){const a=i.slice(0),c=new Uint8Array(a);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let l=0;l<a.byteLength;l++)s[l+1]=c[l];s[0]=0}return i}n*=Math.pow(2,8)}return new ArrayBuffer(0)}function Hy(t,e){if(t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<n.length;i++)if(n[i]!==r[i])return!1;return!0}function Qe(t,e){const n=t.toString(10);if(e<n.length)return"";const r=e-n.length,i=new Array(r);for(let a=0;a<r;a++)i[a]="0";return i.join("").concat(n)}/*!
68
68
  * Copyright (c) 2014, GMO GlobalSign
69
69
  * Copyright (c) 2015-2022, Peculiar Ventures
70
70
  * All rights reserved.
@@ -96,11 +96,11 @@ and limitations under the License.
96
96
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
97
97
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
98
98
  *
99
- */function ps(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function _l(t){let e=0,n=0;for(let i=0;i<t.length;i++){const s=t[i];e+=s.byteLength}const r=new Uint8Array(e);for(let i=0;i<t.length;i++){const s=t[i];r.set(new Uint8Array(s),n),n+=s.byteLength}return r.buffer}function Dt(t,e,n,r){return e instanceof Uint8Array?e.byteLength?n<0?(t.error="Wrong parameter: inputOffset less than zero",!1):r<0?(t.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-n-r<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 ao{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return _l(this.items)}}const Nr=[new Uint8Array([1])],nu="0123456789",sa="name",ru="valueHexView",qy="isHexOnly",My="idBlock",Hy="tagClass",Dy="tagNumber",Fy="isConstructed",Ky="fromBER",Wy="toBER",Gy="local",Ke="",wt=new ArrayBuffer(0),co=new Uint8Array(0),Hr="EndOfContent",Zf="OCTET STRING",Yf="BIT STRING";function Nt(t){var e;return e=class extends t{constructor(...r){var i;super(...r);const s=r[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?M.toUint8Array(s.valueHex):co}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(r){this.valueHexView=new Uint8Array(r)}fromBER(r,i,s){const a=r instanceof ArrayBuffer?new Uint8Array(r):r;if(!Dt(this,a,i,s))return-1;const c=i+s;return this.valueHexView=a.subarray(i,c),this.valueHexView.length?(this.blockLength=s,c):(this.warnings.push("Zero buffer length"),i)}toBER(r=!1){return this.isHexOnly?r?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",wt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:J.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class Bn{constructor({blockLength:e=0,error:n=Ke,warnings:r=[],valueBeforeDecode:i=co}={}){this.blockLength=e,this.error=n,this.warnings=r,this.valueBeforeDecodeView=M.toUint8Array(i)}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:J.ToHex(this.valueBeforeDecodeView)}}}Bn.NAME="baseBlock";class He extends Bn{fromBER(e,n,r){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'")}}He.NAME="valueBlock";class Xf extends Nt(Bn){constructor({idBlock:e={}}={}){var n,r,i,s;super(),e?(this.isHexOnly=(n=e.isHexOnly)!==null&&n!==void 0?n:!1,this.valueHexView=e.valueHex?M.toUint8Array(e.valueHex):co,this.tagClass=(r=e.tagClass)!==null&&r!==void 0?r:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-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",wt}if(this.isConstructed&&(n|=32),this.tagNumber<31&&!this.isHexOnly){const i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,n|=s,i[0]=n}return i.buffer}if(!this.isHexOnly){const i=kn(this.tagNumber,7),s=new Uint8Array(i),a=i.byteLength,c=new Uint8Array(a+1);if(c[0]=n|31,!e){for(let l=0;l<a-1;l++)c[l+1]=s[l]|128;c[a]=s[a-1]}return c.buffer}const r=new Uint8Array(this.valueHexView.byteLength+1);if(r[0]=n|31,!e){const i=this.valueHexView;for(let s=0;s<i.length-1;s++)r[s+1]=i[s]|128;r[this.valueHexView.byteLength]=i[i.length-1]}return r.buffer}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Dt(this,i,n,r))return-1;const s=i.subarray(n,n+r);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,d=this.valueHexView=new Uint8Array(255),p=255;for(;s[l]&128;){if(d[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 w=0;w<d.length;w++)m[w]=d[w];d=this.valueHexView=new Uint8Array(p)}}this.blockLength=l+1,d[l-1]=s[l]&127;const f=new Uint8Array(l);for(let m=0;m<l;m++)f[m]=d[m];d=this.valueHexView=new Uint8Array(l),d.set(f),this.blockLength<=9?this.tagNumber=er(d,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}}}Xf.NAME="identificationBlock";class Qf extends Bn{constructor({lenBlock:e={}}={}){var n,r,i;super(),this.isIndefiniteForm=(n=e.isIndefiniteForm)!==null&&n!==void 0?n:!1,this.longFormUsed=(r=e.longFormUsed)!==null&&r!==void 0?r:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Dt(this,i,n,r))return-1;const s=i.subarray(n,n+r);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 a=s[0]&127;if(a>8)return this.error="Too big integer",-1;if(a+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const c=n+1,l=i.subarray(c,c+a);return l[a-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=er(l,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=a+1,n+this.blockLength}toBER(e=!1){let n,r;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return n=new ArrayBuffer(1),e===!1&&(r=new Uint8Array(n),r[0]=128),n;if(this.longFormUsed){const i=kn(this.length,8);if(i.byteLength>127)return this.error="Too big length",wt;if(n=new ArrayBuffer(i.byteLength+1),e)return n;const s=new Uint8Array(i);r=new Uint8Array(n),r[0]=i.byteLength|128;for(let a=0;a<i.byteLength;a++)r[a+1]=s[a];return n}return n=new ArrayBuffer(1),e===!1&&(r=new Uint8Array(n),r[0]=this.length),n}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}Qf.NAME="lengthBlock";const K={};class Pe extends Bn{constructor({name:e=Ke,optional:n=!1,primitiveSchema:r,...i}={},s){super(i),this.name=e,this.optional=n,r&&(this.primitiveSchema=r),this.idBlock=new Xf(i),this.lenBlock=new Qf(i),this.valueBlock=s?new s(i):new He(i)}fromBER(e,n,r){const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(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),i)}toBER(e,n){const r=n||new ao;n||eh(this);const i=this.idBlock.toBER(e);if(r.write(i),this.lenBlock.isIndefiniteForm)r.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,r),r.write(new ArrayBuffer(2));else{const s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;const a=this.lenBlock.toBER(e);r.write(a),r.write(s)}return n?wt:r.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():J.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${J.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const n=this.toBER(),r=e.toBER();return Vy(n,r)}}Pe.NAME="BaseBlock";function eh(t){if(t instanceof K.Constructed)for(const e of t.valueBlock.value)eh(e)&&(t.lenBlock.isIndefiniteForm=!0);return!!t.lenBlock.isIndefiniteForm}class yl extends Pe{constructor({value:e=Ke,...n}={},r){super(n,r),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,n,r){const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(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),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}yl.NAME="BaseStringBlock";class th extends Nt(He){constructor({isHexOnly:e=!0,...n}={}){super(n),this.isHexOnly=e}}th.NAME="PrimitiveValueBlock";var nh;class ai extends Pe{constructor(e={}){super(e,th),this.idBlock.isConstructed=!1}}nh=ai;K.Primitive=nh;ai.NAME="PRIMITIVE";function Jy(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 gr(t,e=0,n=t.length){const r=e;let i=new Pe({},He);const s=new Bn;if(!Dt(s,t,e,n))return i.error=s.error,{offset:-1,result:i};if(!t.subarray(e,e+n).length)return i.error="Zero buffer length",{offset:-1,result:i};let c=i.idBlock.fromBER(t,e,n);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),c===-1)return i.error=i.idBlock.error,{offset:-1,result:i};if(e=c,n-=i.idBlock.blockLength,c=i.lenBlock.fromBER(t,e,n),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),c===-1)return i.error=i.lenBlock.error,{offset:-1,result:i};if(e=c,n-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let l=Pe;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};l=K.EndOfContent;break;case 1:l=K.Boolean;break;case 2:l=K.Integer;break;case 3:l=K.BitString;break;case 4:l=K.OctetString;break;case 5:l=K.Null;break;case 6:l=K.ObjectIdentifier;break;case 10:l=K.Enumerated;break;case 12:l=K.Utf8String;break;case 13:l=K.RelativeObjectIdentifier;break;case 14:l=K.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:l=K.Sequence;break;case 17:l=K.Set;break;case 18:l=K.NumericString;break;case 19:l=K.PrintableString;break;case 20:l=K.TeletexString;break;case 21:l=K.VideotexString;break;case 22:l=K.IA5String;break;case 23:l=K.UTCTime;break;case 24:l=K.GeneralizedTime;break;case 25:l=K.GraphicString;break;case 26:l=K.VisibleString;break;case 27:l=K.GeneralString;break;case 28:l=K.UniversalString;break;case 29:l=K.CharacterString;break;case 30:l=K.BmpString;break;case 31:l=K.DATE;break;case 32:l=K.TimeOfDay;break;case 33:l=K.DateTime;break;case 34:l=K.Duration;break;default:{const d=i.idBlock.isConstructed?new K.Constructed:new K.Primitive;d.idBlock=i.idBlock,d.lenBlock=i.lenBlock,d.warnings=i.warnings,i=d}}break;case 2:case 3:case 4:default:l=i.idBlock.isConstructed?K.Constructed:K.Primitive}return i=Jy(i,l),c=i.fromBER(t,e,i.lenBlock.isIndefiniteForm?n:i.lenBlock.length),i.valueBeforeDecodeView=t.subarray(r,r+i.blockLength),{offset:c,result:i}}function Zn(t){if(!t.byteLength){const e=new Pe({},He);return e.error="Input buffer has zero length",{offset:-1,result:e}}return gr(M.toUint8Array(t).slice(),0,t.byteLength)}function Zy(t,e){return t?1:e}class Xt extends He{constructor({value:e=[],isIndefiniteForm:n=!1,...r}={}){super(r),this.value=e,this.isIndefiniteForm=n}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Dt(this,i,n,r))return-1;if(this.valueBeforeDecodeView=i.subarray(n,n+r),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),n;let s=n;for(;Zy(this.isIndefiniteForm,r)>0;){const a=gr(i,s,r);if(a.offset===-1)return this.error=a.result.error,this.warnings.concat(a.result.warnings),-1;if(s=a.offset,this.blockLength+=a.result.blockLength,r-=a.result.blockLength,this.value.push(a.result),this.isIndefiniteForm&&a.result.constructor.NAME===Hr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Hr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,n){const r=n||new ao;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,r);return n?wt:r.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const n of this.value)e.value.push(n.toJSON());return e}}Xt.NAME="ConstructedValueBlock";var rh;class We extends Pe{constructor(e={}){super(e,Xt),this.idBlock.isConstructed=!0}fromBER(e,n,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(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),i)}onAsciiEncoding(){const e=[];for(const r of this.valueBlock.value)e.push(r.toString("ascii").split(`
99
+ */function ps(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function _l(t){let e=0,n=0;for(let i=0;i<t.length;i++){const s=t[i];e+=s.byteLength}const r=new Uint8Array(e);for(let i=0;i<t.length;i++){const s=t[i];r.set(new Uint8Array(s),n),n+=s.byteLength}return r.buffer}function Dt(t,e,n,r){return e instanceof Uint8Array?e.byteLength?n<0?(t.error="Wrong parameter: inputOffset less than zero",!1):r<0?(t.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-n-r<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 ao{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return _l(this.items)}}const Nr=[new Uint8Array([1])],nu="0123456789",sa="name",ru="valueHexView",Dy="isHexOnly",Fy="idBlock",Ky="tagClass",Wy="tagNumber",Gy="isConstructed",Jy="fromBER",Zy="toBER",Yy="local",Ke="",wt=new ArrayBuffer(0),co=new Uint8Array(0),Hr="EndOfContent",Xf="OCTET STRING",Qf="BIT STRING";function Nt(t){var e;return e=class extends t{constructor(...r){var i;super(...r);const s=r[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?M.toUint8Array(s.valueHex):co}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(r){this.valueHexView=new Uint8Array(r)}fromBER(r,i,s){const a=r instanceof ArrayBuffer?new Uint8Array(r):r;if(!Dt(this,a,i,s))return-1;const c=i+s;return this.valueHexView=a.subarray(i,c),this.valueHexView.length?(this.blockLength=s,c):(this.warnings.push("Zero buffer length"),i)}toBER(r=!1){return this.isHexOnly?r?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",wt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:J.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class Bn{constructor({blockLength:e=0,error:n=Ke,warnings:r=[],valueBeforeDecode:i=co}={}){this.blockLength=e,this.error=n,this.warnings=r,this.valueBeforeDecodeView=M.toUint8Array(i)}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:J.ToHex(this.valueBeforeDecodeView)}}}Bn.NAME="baseBlock";class He extends Bn{fromBER(e,n,r){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'")}}He.NAME="valueBlock";class eh extends Nt(Bn){constructor({idBlock:e={}}={}){var n,r,i,s;super(),e?(this.isHexOnly=(n=e.isHexOnly)!==null&&n!==void 0?n:!1,this.valueHexView=e.valueHex?M.toUint8Array(e.valueHex):co,this.tagClass=(r=e.tagClass)!==null&&r!==void 0?r:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-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",wt}if(this.isConstructed&&(n|=32),this.tagNumber<31&&!this.isHexOnly){const i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,n|=s,i[0]=n}return i.buffer}if(!this.isHexOnly){const i=kn(this.tagNumber,7),s=new Uint8Array(i),a=i.byteLength,c=new Uint8Array(a+1);if(c[0]=n|31,!e){for(let l=0;l<a-1;l++)c[l+1]=s[l]|128;c[a]=s[a-1]}return c.buffer}const r=new Uint8Array(this.valueHexView.byteLength+1);if(r[0]=n|31,!e){const i=this.valueHexView;for(let s=0;s<i.length-1;s++)r[s+1]=i[s]|128;r[this.valueHexView.byteLength]=i[i.length-1]}return r.buffer}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Dt(this,i,n,r))return-1;const s=i.subarray(n,n+r);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,d=this.valueHexView=new Uint8Array(255),p=255;for(;s[l]&128;){if(d[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 w=0;w<d.length;w++)m[w]=d[w];d=this.valueHexView=new Uint8Array(p)}}this.blockLength=l+1,d[l-1]=s[l]&127;const f=new Uint8Array(l);for(let m=0;m<l;m++)f[m]=d[m];d=this.valueHexView=new Uint8Array(l),d.set(f),this.blockLength<=9?this.tagNumber=er(d,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}}}eh.NAME="identificationBlock";class th extends Bn{constructor({lenBlock:e={}}={}){var n,r,i;super(),this.isIndefiniteForm=(n=e.isIndefiniteForm)!==null&&n!==void 0?n:!1,this.longFormUsed=(r=e.longFormUsed)!==null&&r!==void 0?r:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Dt(this,i,n,r))return-1;const s=i.subarray(n,n+r);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 a=s[0]&127;if(a>8)return this.error="Too big integer",-1;if(a+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const c=n+1,l=i.subarray(c,c+a);return l[a-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=er(l,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=a+1,n+this.blockLength}toBER(e=!1){let n,r;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return n=new ArrayBuffer(1),e===!1&&(r=new Uint8Array(n),r[0]=128),n;if(this.longFormUsed){const i=kn(this.length,8);if(i.byteLength>127)return this.error="Too big length",wt;if(n=new ArrayBuffer(i.byteLength+1),e)return n;const s=new Uint8Array(i);r=new Uint8Array(n),r[0]=i.byteLength|128;for(let a=0;a<i.byteLength;a++)r[a+1]=s[a];return n}return n=new ArrayBuffer(1),e===!1&&(r=new Uint8Array(n),r[0]=this.length),n}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}th.NAME="lengthBlock";const K={};class Pe extends Bn{constructor({name:e=Ke,optional:n=!1,primitiveSchema:r,...i}={},s){super(i),this.name=e,this.optional=n,r&&(this.primitiveSchema=r),this.idBlock=new eh(i),this.lenBlock=new th(i),this.valueBlock=s?new s(i):new He(i)}fromBER(e,n,r){const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(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),i)}toBER(e,n){const r=n||new ao;n||nh(this);const i=this.idBlock.toBER(e);if(r.write(i),this.lenBlock.isIndefiniteForm)r.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,r),r.write(new ArrayBuffer(2));else{const s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;const a=this.lenBlock.toBER(e);r.write(a),r.write(s)}return n?wt:r.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():J.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${J.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const n=this.toBER(),r=e.toBER();return Hy(n,r)}}Pe.NAME="BaseBlock";function nh(t){if(t instanceof K.Constructed)for(const e of t.valueBlock.value)nh(e)&&(t.lenBlock.isIndefiniteForm=!0);return!!t.lenBlock.isIndefiniteForm}class yl extends Pe{constructor({value:e=Ke,...n}={},r){super(n,r),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,n,r){const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(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),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}yl.NAME="BaseStringBlock";class rh extends Nt(He){constructor({isHexOnly:e=!0,...n}={}){super(n),this.isHexOnly=e}}rh.NAME="PrimitiveValueBlock";var ih;class ai extends Pe{constructor(e={}){super(e,rh),this.idBlock.isConstructed=!1}}ih=ai;K.Primitive=ih;ai.NAME="PRIMITIVE";function Xy(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 gr(t,e=0,n=t.length){const r=e;let i=new Pe({},He);const s=new Bn;if(!Dt(s,t,e,n))return i.error=s.error,{offset:-1,result:i};if(!t.subarray(e,e+n).length)return i.error="Zero buffer length",{offset:-1,result:i};let c=i.idBlock.fromBER(t,e,n);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),c===-1)return i.error=i.idBlock.error,{offset:-1,result:i};if(e=c,n-=i.idBlock.blockLength,c=i.lenBlock.fromBER(t,e,n),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),c===-1)return i.error=i.lenBlock.error,{offset:-1,result:i};if(e=c,n-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let l=Pe;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};l=K.EndOfContent;break;case 1:l=K.Boolean;break;case 2:l=K.Integer;break;case 3:l=K.BitString;break;case 4:l=K.OctetString;break;case 5:l=K.Null;break;case 6:l=K.ObjectIdentifier;break;case 10:l=K.Enumerated;break;case 12:l=K.Utf8String;break;case 13:l=K.RelativeObjectIdentifier;break;case 14:l=K.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:l=K.Sequence;break;case 17:l=K.Set;break;case 18:l=K.NumericString;break;case 19:l=K.PrintableString;break;case 20:l=K.TeletexString;break;case 21:l=K.VideotexString;break;case 22:l=K.IA5String;break;case 23:l=K.UTCTime;break;case 24:l=K.GeneralizedTime;break;case 25:l=K.GraphicString;break;case 26:l=K.VisibleString;break;case 27:l=K.GeneralString;break;case 28:l=K.UniversalString;break;case 29:l=K.CharacterString;break;case 30:l=K.BmpString;break;case 31:l=K.DATE;break;case 32:l=K.TimeOfDay;break;case 33:l=K.DateTime;break;case 34:l=K.Duration;break;default:{const d=i.idBlock.isConstructed?new K.Constructed:new K.Primitive;d.idBlock=i.idBlock,d.lenBlock=i.lenBlock,d.warnings=i.warnings,i=d}}break;case 2:case 3:case 4:default:l=i.idBlock.isConstructed?K.Constructed:K.Primitive}return i=Xy(i,l),c=i.fromBER(t,e,i.lenBlock.isIndefiniteForm?n:i.lenBlock.length),i.valueBeforeDecodeView=t.subarray(r,r+i.blockLength),{offset:c,result:i}}function Zn(t){if(!t.byteLength){const e=new Pe({},He);return e.error="Input buffer has zero length",{offset:-1,result:e}}return gr(M.toUint8Array(t).slice(),0,t.byteLength)}function Qy(t,e){return t?1:e}class Xt extends He{constructor({value:e=[],isIndefiniteForm:n=!1,...r}={}){super(r),this.value=e,this.isIndefiniteForm=n}fromBER(e,n,r){const i=M.toUint8Array(e);if(!Dt(this,i,n,r))return-1;if(this.valueBeforeDecodeView=i.subarray(n,n+r),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),n;let s=n;for(;Qy(this.isIndefiniteForm,r)>0;){const a=gr(i,s,r);if(a.offset===-1)return this.error=a.result.error,this.warnings.concat(a.result.warnings),-1;if(s=a.offset,this.blockLength+=a.result.blockLength,r-=a.result.blockLength,this.value.push(a.result),this.isIndefiniteForm&&a.result.constructor.NAME===Hr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Hr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,n){const r=n||new ao;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,r);return n?wt:r.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const n of this.value)e.value.push(n.toJSON());return e}}Xt.NAME="ConstructedValueBlock";var sh;class We extends Pe{constructor(e={}){super(e,Xt),this.idBlock.isConstructed=!0}fromBER(e,n,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const i=this.valueBlock.fromBER(e,n,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return i===-1?(this.error=this.valueBlock.error,i):(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),i)}onAsciiEncoding(){const e=[];for(const r of this.valueBlock.value)e.push(r.toString("ascii").split(`
100
100
  `).map(i=>` ${i}`).join(`
101
101
  `));const n=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${n} :
102
102
  ${e.join(`
103
- `)}`:`${n} :`}}rh=We;K.Constructed=rh;We.NAME="CONSTRUCTED";class ih extends He{fromBER(e,n,r){return n}toBER(e){return wt}}ih.override="EndOfContentValueBlock";var sh;class wl extends Pe{constructor(e={}){super(e,ih),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}sh=wl;K.EndOfContent=sh;wl.NAME=Hr;var oh;class Sn extends Pe{constructor(e={}){super(e,He),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,n,r){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+=r,n+r>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):n+r}toBER(e,n){const r=new ArrayBuffer(2);if(!e){const i=new Uint8Array(r);i[0]=5,i[1]=0}return n&&n.write(r),r}onAsciiEncoding(){return`${this.constructor.NAME}`}}oh=Sn;K.Null=oh;Sn.NAME="NULL";class ah extends Nt(He){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,r){const i=M.toUint8Array(e);return Dt(this,i,n,r)?(this.valueHexView=i.subarray(n,n+r),r>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Jf.call(this),this.blockLength=r,n+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}ah.NAME="BooleanValueBlock";var ch;class lo extends Pe{constructor(e={}){super(e,ah),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}`}}ch=lo;K.Boolean=ch;lo.NAME="BOOLEAN";class lh extends Nt(Xt){constructor({isConstructed:e=!1,...n}={}){super(n),this.isConstructed=e}fromBER(e,n,r){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=Xt.prototype.fromBER.call(this,e,n,r),i===-1)return i;for(let s=0;s<this.value.length;s++){const a=this.value[s].constructor.NAME;if(a===Hr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==Zf)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,i=super.fromBER(e,n,r),this.blockLength=r;return i}toBER(e,n){return this.isConstructed?Xt.prototype.toBER.call(this,e,n):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}lh.NAME="OctetStringValueBlock";var dh;let bn=class uh extends Pe{constructor({idBlock:e={},lenBlock:n={},...r}={}){var i,s;(i=r.isConstructed)!==null&&i!==void 0||(r.isConstructed=!!(!((s=r.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...n,isIndefiniteForm:!!r.isIndefiniteForm},...r},lh),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,n,r){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,r===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+r);try{if(s.byteLength){const a=gr(s,0,s.byteLength);a.offset!==-1&&a.offset===r&&(this.valueBlock.value=[a.result])}}catch{}}return super.fromBER(e,n,r)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?We.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${J.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 uh&&e.push(n.valueBlock.valueHexView);return M.concat(e)}};dh=bn;K.OctetString=dh;bn.NAME=Zf;class ph extends Nt(Xt){constructor({unusedBits:e=0,isConstructed:n=!1,...r}={}){super(r),this.unusedBits=e,this.isConstructed=n,this.blockLength=this.valueHexView.byteLength}fromBER(e,n,r){if(!r)return n;let i=-1;if(this.isConstructed){if(i=Xt.prototype.fromBER.call(this,e,n,r),i===-1)return i;for(const c of this.value){const l=c.constructor.NAME;if(l===Hr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(l!==Yf)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const d=c.valueBlock;if(this.unusedBits>0&&d.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=d.unusedBits}return i}const s=M.toUint8Array(e);if(!Dt(this,s,n,r))return-1;const a=s.subarray(n,n+r);if(this.unusedBits=a[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const c=a.subarray(1);try{if(c.byteLength){const l=gr(c,0,c.byteLength);l.offset!==-1&&l.offset===r-1&&(this.value=[l.result])}}catch{}}return this.valueHexView=a.subarray(1),this.blockLength=a.length,n+r}toBER(e,n){if(this.isConstructed)return Xt.prototype.toBER.call(this,e,n);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return wt;const r=new Uint8Array(this.valueHexView.length+1);return r[0]=this.unusedBits,r.set(this.valueHexView,1),r.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}ph.NAME="BitStringValueBlock";var fh;let xn=class extends Pe{constructor({idBlock:e={},lenBlock:n={},...r}={}){var i,s;(i=r.isConstructed)!==null&&i!==void 0||(r.isConstructed=!!(!((s=r.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...n,isIndefiniteForm:!!r.isIndefiniteForm},...r},ph),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,n,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,n,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return We.prototype.onAsciiEncoding.call(this);{const e=[],n=this.valueBlock.valueHexView;for(const i of n)e.push(i.toString(2).padStart(8,"0"));const r=e.join("");return`${this.constructor.NAME} : ${r.substring(0,r.length-this.valueBlock.unusedBits)}`}}};fh=xn;K.BitString=fh;xn.NAME=Yf;var hh;function Yy(t,e){const n=new Uint8Array([0]),r=new Uint8Array(t),i=new Uint8Array(e);let s=r.slice(0);const a=s.length-1,c=i.slice(0),l=c.length-1;let d=0;const p=l<a?a:l;let f=0;for(let m=p;m>=0;m--,f++){switch(!0){case f<c.length:d=s[a-f]+c[l-f]+n[0];break;default:d=s[a-f]+n[0]}switch(n[0]=d/10,!0){case f>=s.length:s=Oa(new Uint8Array([d%10]),s);break;default:s[a-f]=d%10}}return n[0]>0&&(s=Oa(n,s)),s}function iu(t){if(t>=Nr.length)for(let e=Nr.length;e<=t;e++){const n=new Uint8Array([0]);let r=Nr[e-1].slice(0);for(let i=r.length-1;i>=0;i--){const s=new Uint8Array([(r[i]<<1)+n[0]]);n[0]=s[0]/10,r[i]=s[0]%10}n[0]>0&&(r=Oa(n,r)),Nr.push(r)}return Nr[t]}function Xy(t,e){let n=0;const r=new Uint8Array(t),i=new Uint8Array(e),s=r.slice(0),a=s.length-1,c=i.slice(0),l=c.length-1;let d,p=0;for(let f=l;f>=0;f--,p++)switch(d=s[a-p]-c[l-p]-n,!0){case d<0:n=1,s[a-p]=d+10;break;default:n=0,s[a-p]=d}if(n>0)for(let f=a-l+1;f>=0;f--,p++)if(d=s[a-p]-n,d<0)n=1,s[a-p]=d+10;else{n=0,s[a-p]=d;break}return s.slice()}class vl extends Nt(He){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=Jf.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Uy(e))}get valueDec(){return this._valueDec}fromDER(e,n,r,i=0){const s=this.fromBER(e,n,r);if(s===-1)return s;const a=this.valueHexView;return a[0]===0&&a[1]&128?this.valueHexView=a.subarray(1):i!==0&&a.length<i&&(i-a.length>1&&(i=a.length+1),this.valueHexView=a.subarray(i-a.length)),s}toDER(e=!1){const n=this.valueHexView;switch(!0){case(n[0]&128)!==0:{const r=new Uint8Array(this.valueHexView.length+1);r[0]=0,r.set(n,1),this.valueHexView=r}break;case(n[0]===0&&(n[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,n,r){const i=super.fromBER(e,n,r);return i===-1||this.setValueHex(),i}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),r=0,i;const s=this.valueHexView;let a="",c=!1;for(let l=s.byteLength-1;l>=0;l--){i=s[l];for(let d=0;d<8;d++){if((i&1)===1)switch(r){case e:n=Xy(iu(r),n),a="-";break;default:n=Yy(n,iu(r))}r++,i>>=1}}for(let l=0;l<n.length;l++)n[l]&&(c=!0),c&&(a+=nu.charAt(n[l]));return c===!1&&(a+=nu.charAt(0)),a}}hh=vl;vl.NAME="IntegerValueBlock";Object.defineProperty(hh.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var gh;class Et extends Pe{constructor(e={}){super(e,vl),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return ps(),BigInt(this.valueBlock.toString())}static fromBigInt(e){ps();const n=BigInt(e),r=new ao,i=n.toString(16).replace(/^-/,""),s=new Uint8Array(J.FromHex(i));if(n<0){const c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;const d=BigInt(`0x${J.ToHex(c)}`)+n,p=M.toUint8Array(J.FromHex(d.toString(16)));p[0]|=128,r.write(p)}else s[0]&128&&r.write(new Uint8Array([0])),r.write(s);return new Et({valueHex:r.final()})}convertToDER(){const e=new Et({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Et({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}gh=Et;K.Integer=gh;Et.NAME="INTEGER";var mh;class uo extends Et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}mh=uo;K.Enumerated=mh;uo.NAME="ENUMERATED";class Pa extends Nt(He){constructor({valueDec:e=-1,isFirstSid:n=!1,...r}={}){super(r),this.valueDec=e,this.isFirstSid=n}fromBER(e,n,r){if(!r)return n;const i=M.toUint8Array(e);if(!Dt(this,i,n,r))return-1;const s=i.subarray(n,n+r);this.valueHexView=new Uint8Array(r);for(let c=0;c<r&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const a=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)a[c]=this.valueHexView[c];return this.valueHexView=a,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=er(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}set valueBigInt(e){ps();let n=BigInt(e).toString(2);for(;n.length%7;)n="0"+n;const r=new Uint8Array(n.length/7);for(let i=0;i<r.length;i++)r[i]=parseInt(n.slice(i*7,i*7+7),2)+(i+1<r.length?128:0);this.fromBER(r.buffer,0,r.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const n=kn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",wt;const r=new Uint8Array(n.byteLength);if(!e){const i=new Uint8Array(n),s=n.byteLength-1;for(let a=0;a<s;a++)r[a]=i[a]|128;r[s]=i[s]}return r}toString(){let e="";if(this.isHexOnly)e=J.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}}}Pa.NAME="sidBlock";class _h extends He{constructor({value:e=Ke,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new Pa;if(i=s.fromBER(e,i,r),i===-1)return this.blockLength=0,this.error=s.error,i;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,r-=s.blockLength,this.value.push(s)}return i}toBER(e){const n=[];for(let r=0;r<this.value.length;r++){const i=this.value[r].toBER(e);if(i.byteLength===0)return this.error=this.value[r].error,wt;n.push(i)}return _l(n)}fromString(e){this.value=[];let n=0,r=0,i="",s=!1;do if(r=e.indexOf(".",n),r===-1?i=e.substring(n):i=e.substring(n,r),n=r+1,s){const a=this.value[0];let c=0;switch(a.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}const l=parseInt(i,10);if(isNaN(l))return;a.valueDec=l+c,s=!1}else{const a=new Pa;if(i>Number.MAX_SAFE_INTEGER){ps();const c=BigInt(i);a.valueBigInt=c}else if(a.valueDec=parseInt(i,10),isNaN(a.valueDec))return;this.value.length||(a.isFirstSid=!0,s=!0),this.value.push(a)}while(r!==-1)}toString(){let e="",n=!1;for(let r=0;r<this.value.length;r++){n=this.value[r].isHexOnly;let i=this.value[r].toString();r!==0&&(e=`${e}.`),n?(i=`{${i}}`,this.value[r].isFirstSid?e=`2.{${i} - 80}`:e+=i):e+=i}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}}_h.NAME="ObjectIdentifierValueBlock";var yh;class po extends Pe{constructor(e={}){super(e,_h),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()}}}yh=po;K.ObjectIdentifier=yh;po.NAME="OBJECT IDENTIFIER";class Ta extends Nt(Bn){constructor({valueDec:e=0,...n}={}){super(n),this.valueDec=e}fromBER(e,n,r){if(r===0)return n;const i=M.toUint8Array(e);if(!Dt(this,i,n,r))return-1;const s=i.subarray(n,n+r);this.valueHexView=new Uint8Array(r);for(let c=0;c<r&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const a=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)a[c]=this.valueHexView[c];return this.valueHexView=a,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=er(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 i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const n=kn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",wt;const r=new Uint8Array(n.byteLength);if(!e){const i=new Uint8Array(n),s=n.byteLength-1;for(let a=0;a<s;a++)r[a]=i[a]|128;r[s]=i[s]}return r.buffer}toString(){let e="";return this.isHexOnly?e=J.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Ta.NAME="relativeSidBlock";class wh extends He{constructor({value:e=Ke,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new Ta;if(i=s.fromBER(e,i,r),i===-1)return this.blockLength=0,this.error=s.error,i;this.blockLength+=s.blockLength,r-=s.blockLength,this.value.push(s)}return i}toBER(e,n){const r=[];for(let i=0;i<this.value.length;i++){const s=this.value[i].toBER(e);if(s.byteLength===0)return this.error=this.value[i].error,wt;r.push(s)}return _l(r)}fromString(e){this.value=[];let n=0,r=0,i="";do{r=e.indexOf(".",n),r===-1?i=e.substring(n):i=e.substring(n,r),n=r+1;const s=new Ta;if(s.valueDec=parseInt(i,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(r!==-1);return!0}toString(){let e="",n=!1;for(let r=0;r<this.value.length;r++){n=this.value[r].isHexOnly;let i=this.value[r].toString();r!==0&&(e=`${e}.`),n&&(i=`{${i}}`),e+=i}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}}wh.NAME="RelativeObjectIdentifierValueBlock";var vh;class bl extends Pe{constructor(e={}){super(e,wh),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()}}}vh=bl;K.RelativeObjectIdentifier=vh;bl.NAME="RelativeObjectIdentifier";var bh;class Tt extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}bh=Tt;K.Sequence=bh;Tt.NAME="SEQUENCE";var xh;let Bt=class extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};xh=Bt;K.Set=xh;Bt.NAME="SET";class kh extends Nt(He){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Ke}toJSON(){return{...super.toJSON(),value:this.value}}}kh.NAME="StringValueBlock";class Sh extends kh{}Sh.NAME="SimpleStringValueBlock";class tt extends yl{constructor({...e}={}){super(e,Sh)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,M.toUint8Array(e))}fromString(e){const n=e.length,r=this.valueBlock.valueHexView=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.charCodeAt(i);this.valueBlock.value=e}}tt.NAME="SIMPLE STRING";class Ah extends tt{fromBuffer(e){this.valueBlock.valueHexView=M.toUint8Array(e);try{this.valueBlock.value=J.ToUtf8String(e)}catch(n){this.warnings.push(`Error during "decodeURIComponent": ${n}, using raw string`),this.valueBlock.value=J.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(J.FromUtf8String(e)),this.valueBlock.value=e}}Ah.NAME="Utf8StringValueBlock";var zh;class Ft extends Ah{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}zh=Ft;K.Utf8String=zh;Ft.NAME="UTF8String";class Eh extends tt{fromBuffer(e){this.valueBlock.value=J.ToUtf16String(e),this.valueBlock.valueHexView=M.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(J.FromUtf16String(e))}}Eh.NAME="BmpStringValueBlock";var Ih;class fo extends Eh{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Ih=fo;K.BmpString=Ih;fo.NAME="BMPString";class Ch extends tt{fromBuffer(e){const n=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),r=new Uint8Array(n);for(let i=0;i<r.length;i+=4)r[i]=r[i+3],r[i+1]=r[i+2],r[i+2]=0,r[i+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(n))}fromString(e){const n=e.length,r=this.valueBlock.valueHexView=new Uint8Array(n*4);for(let i=0;i<n;i++){const s=kn(e.charCodeAt(i),8),a=new Uint8Array(s);if(a.length>4)continue;const c=4-a.length;for(let l=a.length-1;l>=0;l--)r[i*4+l+c]=a[l]}this.valueBlock.value=e}}Ch.NAME="UniversalStringValueBlock";var Nh;class ho extends Ch{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}Nh=ho;K.UniversalString=Nh;ho.NAME="UniversalString";var jh;class go extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}jh=go;K.NumericString=jh;go.NAME="NumericString";var $h;class mo extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}$h=mo;K.PrintableString=$h;mo.NAME="PrintableString";var Oh;class _o extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Oh=_o;K.TeletexString=Oh;_o.NAME="TeletexString";var Ph;class yo extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Ph=yo;K.VideotexString=Ph;yo.NAME="VideotexString";var Th;class wo extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Th=wo;K.IA5String=Th;wo.NAME="IA5String";var Bh;class vo extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Bh=vo;K.GraphicString=Bh;vo.NAME="GraphicString";var Rh;class ci extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Rh=ci;K.VisibleString=Rh;ci.NAME="VisibleString";var Lh;class bo extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Lh=bo;K.GeneralString=Lh;bo.NAME="GeneralString";var Uh;class xo extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Uh=xo;K.CharacterString=Uh;xo.NAME="CharacterString";var Vh;class li extends ci{constructor({value:e,valueDate:n,...r}={}){if(super(r),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 i=0;i<e.length;i++)this.valueBlock.valueHexView[i]=e.charCodeAt(i)}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),r=new Uint8Array(n);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);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 r=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(r===null){this.error="Wrong input string for conversion";return}const i=parseInt(r[1],10);i>=50?this.year=1900+i:this.year=2e3+i,this.month=parseInt(r[2],10),this.day=parseInt(r[3],10),this.hour=parseInt(r[4],10),this.minute=parseInt(r[5],10),this.second=parseInt(r[6],10)}toString(e="iso"){if(e==="iso"){const n=new Array(7);return n[0]=Qe(this.year<2e3?this.year-1900:this.year-2e3,2),n[1]=Qe(this.month,2),n[2]=Qe(this.day,2),n[3]=Qe(this.hour,2),n[4]=Qe(this.minute,2),n[5]=Qe(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}}}Vh=li;K.UTCTime=Vh;li.NAME="UTCTime";var qh;class ko extends li{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,r="",i="",s=0,a,c=0,l=0;if(e[e.length-1]==="Z")r=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");r=e}if(n){if(r.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(r.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let f=1,m=r.indexOf("+"),w="";if(m===-1&&(m=r.indexOf("-"),f=-1),m!==-1){if(w=r.substring(m+1),r=r.substring(0,m),w.length!==2&&w.length!==4)throw new Error("Wrong input string for conversion");let h=parseInt(w.substring(0,2),10);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");if(c=f*h,w.length===4){if(h=parseInt(w.substring(2,4),10),isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");l=f*h}}}let d=r.indexOf(".");if(d===-1&&(d=r.indexOf(",")),d!==-1){const f=new Number(`0${r.substring(d)}`);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");s=f.valueOf(),i=r.substring(0,d)}else i=r;switch(!0){case i.length===8:if(a=/(\d{4})(\d{2})(\d{2})/ig,d!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,d!==-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 i.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,d!==-1){let f=60*s;this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case i.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,d!==-1){const f=1e3*s;this.millisecond=Math.floor(f)}break;default:throw new Error("Wrong input string for conversion")}const p=a.exec(i);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(Qe(this.year,4)),n.push(Qe(this.month,2)),n.push(Qe(this.day,2)),n.push(Qe(this.hour,2)),n.push(Qe(this.minute,2)),n.push(Qe(this.second,2)),this.millisecond!==0&&(n.push("."),n.push(Qe(this.millisecond,3))),n.push("Z"),n.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}qh=ko;K.GeneralizedTime=qh;ko.NAME="GeneralizedTime";var Mh;class xl extends Ft{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Mh=xl;K.DATE=Mh;xl.NAME="DATE";var Hh;class kl extends Ft{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Hh=kl;K.TimeOfDay=Hh;kl.NAME="TimeOfDay";var Dh;class Sl extends Ft{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Dh=Sl;K.DateTime=Dh;Sl.NAME="DateTime";var Fh;class Al extends Ft{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Fh=Al;K.Duration=Fh;Al.NAME="Duration";var Kh;class zl extends Ft{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Kh=zl;K.TIME=Kh;zl.NAME="TIME";class An{constructor({name:e=Ke,optional:n=!1}={}){this.name=e,this.optional=n}}class El extends An{constructor({value:e=[],...n}={}){super(n),this.value=e}}class fs extends An{constructor({value:e=new An,local:n=!1,...r}={}){super(r),this.value=e,this.local=n}}class Qy{constructor({data:e=co}={}){this.dataView=M.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=M.toUint8Array(e)}fromBER(e,n,r){const i=n+r;return this.dataView=M.toUint8Array(e).subarray(n,i),i}toBER(e){return this.dataView.slice().buffer}}function yn(t,e,n){if(n instanceof El){for(let s=0;s<n.value.length;s++)if(yn(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(sa)&&(s.name=n.name),s}}if(n instanceof An)return n.hasOwnProperty(sa)&&(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(!(My in n))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Ky in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Wy in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const r=n.idBlock.toBER(!1);if(r.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(n.idBlock.fromBER(r,0,r.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(n.idBlock.hasOwnProperty(Hy)===!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(Dy)===!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(Fy)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:t};if(!(qy 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(!(ru in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=n.idBlock.valueHexView,a=e.idBlock.valueHexView;if(s.length!==a.length)return{verified:!1,result:t};for(let c=0;c<s.length;c++)if(s[c]!==a[1])return{verified:!1,result:t}}if(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ke),n.name&&(t[n.name]=e)),n instanceof K.Constructed){let s=0,a={verified:!1,result:{error:"Unknown error"}},c=n.valueBlock.value.length;if(c>0&&n.valueBlock.value[0]instanceof fs&&(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 d=0;d<n.valueBlock.value.length;d++)l=l&&(n.valueBlock.value[d].optional||!1);return l?{verified:!0,result:t}:(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ke),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 d={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,Ke),n.name&&(delete t[n.name],d.name=n.name)),d}}else if(n.valueBlock.value[0]instanceof fs){if(a=yn(t,e.valueBlock.value[l],n.valueBlock.value[0].value),a.verified===!1)if(n.valueBlock.value[0].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ke),n.name&&delete t[n.name]),a;if(sa in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let d={};Gy in n.valueBlock.value[0]&&n.valueBlock.value[0].local?d=e:d=t,typeof d[n.valueBlock.value[0].name]>"u"&&(d[n.valueBlock.value[0].name]=[]),d[n.valueBlock.value[0].name].push(e.valueBlock.value[l])}}else if(a=yn(t,e.valueBlock.value[l-s],n.valueBlock.value[l]),a.verified===!1)if(n.valueBlock.value[l].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ke),n.name&&delete t[n.name]),a;if(a.verified===!1){const l={verified:!1,result:t};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ke),n.name&&(delete t[n.name],l.name=n.name)),l}return{verified:!0,result:t}}if(n.primitiveSchema&&ru in e.valueBlock){const s=gr(e.valueBlock.valueHexView);if(s.offset===-1){const a={verified:!1,result:s.result};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ke),n.name&&(delete t[n.name],a.name=n.name)),a}return yn(t,s.result,n.primitiveSchema)}return{verified:!0,result:t}}function ew(t,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const n=gr(M.toUint8Array(t));return n.offset===-1?{verified:!1,result:n.result}:yn(n.result,n.result,e)}const Wh=Object.freeze(Object.defineProperty({__proto__:null,Any:An,BaseBlock:Pe,BaseStringBlock:yl,BitString:xn,BmpString:fo,Boolean:lo,CharacterString:xo,Choice:El,Constructed:We,DATE:xl,DateTime:Sl,Duration:Al,EndOfContent:wl,Enumerated:uo,GeneralString:bo,GeneralizedTime:ko,GraphicString:vo,HexBlock:Nt,IA5String:wo,Integer:Et,Null:Sn,NumericString:go,ObjectIdentifier:po,OctetString:bn,Primitive:ai,PrintableString:mo,RawData:Qy,RelativeObjectIdentifier:bl,Repeated:fs,Sequence:Tt,Set:Bt,TIME:zl,TeletexString:_o,TimeOfDay:kl,UTCTime:li,UniversalString:ho,Utf8String:Ft,ValueBlock:He,VideotexString:yo,ViewWriter:ao,VisibleString:ci,compareSchema:yn,fromBER:Zn,verifySchema:ew},Symbol.toStringTag,{value:"Module"}));var B;(function(t){t[t.Sequence=0]="Sequence",t[t.Set=1]="Set",t[t.Choice=2]="Choice"})(B||(B={}));var b;(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"})(b||(b={}));class So{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 xn))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 xn({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new xn({name:e})}toNumber(){let e="";const n=new Uint8Array(this.value);for(const r of n)e+=r.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 r=n.length+7>>3;this.unusedBits=(r<<3)-n.length;const i=new Uint8Array(r);n=n.padStart(r<<3,"0").split("").reverse().join("");let s=0;for(;s<r;)i[s]=parseInt(n.slice(s<<3,(s<<3)+8),2),s++;this.value=i.buffer}}class de{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 bn))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new bn({valueHex:this.buffer})}toSchema(e){return new bn({name:e})}}const tw={fromASN:t=>t instanceof Sn?null:t.valueBeforeDecodeView,toASN:t=>{if(t===null)return new Sn;const e=Zn(t);if(e.result.error)throw new Error(e.result.error);return e.result}},nw={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new Et({value:+t})},rw={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new uo({value:t})},_e={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new Et({valueHex:t})},iw={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new xn({valueHex:t})},sw={fromASN:t=>t.valueBlock.toString(),toASN:t=>new po({value:t})},ow={fromASN:t=>t.valueBlock.value,toASN:t=>new lo({value:t})},hs={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new bn({valueHex:t})},aw={fromASN:t=>new de(t.getValue()),toASN:t=>t.toASN()};function ct(t){return{fromASN:e=>e.valueBlock.value,toASN:e=>new t({value:e})}}const Gh=ct(Ft),cw=ct(fo),lw=ct(ho),dw=ct(go),uw=ct(mo),pw=ct(_o),fw=ct(yo),hw=ct(wo),gw=ct(vo),mw=ct(ci),_w=ct(bo),yw=ct(xo),ww={fromASN:t=>t.toDate(),toASN:t=>new li({valueDate:t})},vw={fromASN:t=>t.toDate(),toASN:t=>new ko({valueDate:t})},bw={fromASN:()=>null,toASN:()=>new Sn};function Il(t){switch(t){case b.Any:return tw;case b.BitString:return iw;case b.BmpString:return cw;case b.Boolean:return ow;case b.CharacterString:return yw;case b.Enumerated:return rw;case b.GeneralString:return _w;case b.GeneralizedTime:return vw;case b.GraphicString:return gw;case b.IA5String:return hw;case b.Integer:return nw;case b.Null:return bw;case b.NumericString:return dw;case b.ObjectIdentifier:return sw;case b.OctetString:return hs;case b.PrintableString:return uw;case b.TeletexString:return pw;case b.UTCTime:return ww;case b.UniversalString:return lw;case b.Utf8String:return Gh;case b.VideotexString:return fw;case b.VisibleString:return mw;default:return null}}function Pt(t){return typeof t=="function"&&t.prototype?t.prototype.toASN&&t.prototype.fromASN?!0:Pt(t.prototype):!!(t&&typeof t=="object"&&"toASN"in t&&"fromASN"in t)}function Jh(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:Jh(n)}return!1}function xw(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<t.byteLength;i++)if(n[i]!==r[i])return!1;return!0}class kw{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,n=!1){const r=this.items.get(e);if(!r)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(n&&!r.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return r}cache(e){const n=this.get(e);n.schema||(n.schema=this.create(e,!0))}createDefault(e){const n={type:B.Sequence,items:{}},r=this.findParentSchema(e);return r&&(Object.assign(n,r),n.items=Object.assign({},n.items,r.items)),n}create(e,n){const r=this.items.get(e)||this.createDefault(e),i=[];for(const s in r.items){const a=r.items[s],c=n?s:"";let l;if(typeof a.type=="number"){const p=b[a.type],f=Wh[p];if(!f)throw new Error(`Cannot get ASN1 class by name '${p}'`);l=new f({name:c})}else Pt(a.type)?l=new a.type().toSchema(c):a.optional?this.get(a.type).type===B.Choice?l=new An({name:c}):(l=this.create(a.type,!1),l.name=c):l=new An({name:c});const d=!!a.optional||a.defaultValue!==void 0;if(a.repeated){l.name="";const p=a.repeated==="set"?Bt:Tt;l=new p({name:"",value:[new fs({name:c,value:l})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||Pt(a.type)){const p=a.repeated?We:ai;i.push(new p({name:c,optional:d,idBlock:{tagClass:3,tagNumber:a.context}}))}else{this.cache(a.type);const p=!!a.repeated;let f=p?l:this.get(a.type,!0).schema;f="valueBlock"in f?f.valueBlock.value:f.value,i.push(new We({name:p?"":c,optional:d,idBlock:{tagClass:3,tagNumber:a.context},value:f}))}else i.push(new We({optional:d,idBlock:{tagClass:3,tagNumber:a.context},value:[l]}));else l.optional=d,i.push(l)}switch(r.type){case B.Sequence:return new Tt({value:i,name:""});case B.Set:return new Bt({value:i,name:""});case B.Choice:return new El({value:i,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 rt=new kw,R=t=>e=>{let n;rt.has(e)?n=rt.get(e):(n=rt.createDefault(e),rt.set(e,n)),Object.assign(n,t)},g=t=>(e,n)=>{let r;rt.has(e.constructor)?r=rt.get(e.constructor):(r=rt.createDefault(e.constructor),rt.set(e.constructor,r));const i=Object.assign({},t);if(typeof i.type=="number"&&!i.converter){const s=Il(t.type);if(!s)throw new Error(`Cannot get default converter for property '${n}' of ${e.constructor.name}`);i.converter=s}r.items[n]=i};class su extends Error{constructor(){super(...arguments),this.schemas=[]}}class Sw{static parse(e,n){const r=Zn(e);if(r.result.error)throw new Error(r.result.error);return this.fromASN(r.result,n)}static fromASN(e,n){var r;try{if(Pt(n))return new n().fromASN(e);const i=rt.get(n);rt.cache(n);let s=i.schema;if(e.constructor===We&&i.type!==B.Choice){s=new We({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const l in i.items)delete e[l]}const a=yn({},e,s);if(!a.verified)throw new su(`Data does not match to ${n.name} ASN1 schema. ${a.result.error}`);const c=new n;if(Jh(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=i.itemType;if(typeof l=="number"){const d=Il(l);if(!d)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,p=>d.fromASN(p))}else return n.from(e.valueBlock.value,d=>this.fromASN(d,l))}for(const l in i.items){const d=a.result[l];if(!d)continue;const p=i.items[l],f=p.type;if(typeof f=="number"||Pt(f)){const m=(r=p.converter)!==null&&r!==void 0?r:Pt(f)?new f:null;if(!m)throw new Error("Converter is empty");if(p.repeated)if(p.implicit){const w=p.repeated==="sequence"?Tt:Bt,h=new w;h.valueBlock=d.valueBlock;const _=Zn(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 v=_.result.valueBlock.value;c[l]=Array.from(v,S=>m.fromASN(S))}else c[l]=Array.from(d,w=>m.fromASN(w));else{let w=d;if(p.implicit){let h;if(Pt(f))h=new f().toSchema("");else{const _=b[f],v=Wh[_];if(!v)throw new Error(`Cannot get '${_}' class from asn1js module`);h=new v}h.valueBlock=w.valueBlock,w=Zn(h.toBER(!1)).result}c[l]=m.fromASN(w)}}else if(p.repeated){if(!Array.isArray(d))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");c[l]=Array.from(d,m=>this.fromASN(m,f))}else c[l]=this.fromASN(d,f)}return c}catch(i){throw i instanceof su&&i.schemas.push(n.name),i}}}class Cl{static serialize(e){return e instanceof Pe?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Pt(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const n=e.constructor,r=rt.get(n);rt.cache(n);let i=[];if(r.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof r.itemType=="number"){const a=Il(r.itemType);if(!a)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);i=e.map(c=>a.toASN(c))}else i=e.map(a=>this.toAsnItem({type:r.itemType},"[]",n,a))}else for(const a in r.items){const c=r.items[a],l=e[a];if(l===void 0||c.defaultValue===l||typeof c.defaultValue=="object"&&typeof l=="object"&&xw(this.serialize(c.defaultValue),this.serialize(l)))continue;const d=Cl.toAsnItem(c,a,n,l);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||Pt(c.type))){const p={};p.valueHex=d instanceof Sn?d.valueBeforeDecodeView:d.valueBlock.toBER(),i.push(new ai({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...p}))}else i.push(new We({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:d.valueBlock.value}));else i.push(new We({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[d]}));else c.repeated?i=i.concat(d):i.push(d)}let s;switch(r.type){case B.Sequence:s=new Tt({value:i});break;case B.Set:s=new Bt({value:i});break;case B.Choice:if(!i[0])throw new Error(`Schema '${n.name}' has wrong data. Choice cannot be empty.`);s=i[0];break}return s}static toAsnItem(e,n,r,i){let s;if(typeof e.type=="number"){const a=e.converter;if(!a)throw new Error(`Property '${n}' doesn't have converter for type ${b[e.type]} in schema '${r.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const c=Array.from(i,d=>a.toASN(d)),l=e.repeated==="sequence"?Tt:Bt;s=new l({value:c})}else s=a.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const a=Array.from(i,l=>this.toASN(l)),c=e.repeated==="sequence"?Tt:Bt;s=new c({value:a})}else s=this.toASN(i);return s}}class fe extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const n of e)this.push(n)}}}class q{static serialize(e){return Cl.serialize(e)}static parse(e,n){return Sw.parse(e,n)}static toString(e){const n=M.isBufferSource(e)?M.toArrayBuffer(e):q.serialize(e),r=Zn(n);if(r.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${r.result.error}`);return r.result.toString()}}function u(t,e,n,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,n):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,n,r);else for(var c=t.length-1;c>=0;c--)(a=t[c])&&(s=(i<3?a(s):i>3?a(e,n,s):a(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s}var Zh={exports:{}};(function(t){(function(e){const n="(0?\\d+|0x[a-f0-9]+)",r={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")},i=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),a="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",l={zoneIndex:new RegExp(a,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${a})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${a})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${n}\\.${n}\\.${n}\\.${n}(${a})?$`,"i")};function d(h,_){if(h.indexOf("::")!==h.lastIndexOf("::"))return null;let v=0,S=-1,C=(h.match(l.zoneIndex)||[])[0],O,L;for(C&&(C=C.substring(1),h=h.replace(/%.+$/,""));(S=h.indexOf(":",S+1))>=0;)v++;if(h.substr(0,2)==="::"&&v--,h.substr(-2,2)==="::"&&v--,v>_)return null;for(L=_-v,O=":";L--;)O+="0:";return h=h.replace("::",O),h[0]===":"&&(h=h.slice(1)),h[h.length-1]===":"&&(h=h.slice(0,-1)),_=function(){const Q=h.split(":"),ce=[];for(let le=0;le<Q.length;le++)ce.push(parseInt(Q[le],16));return ce}(),{parts:_,zoneId:C}}function p(h,_,v,S){if(h.length!==_.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let C=0,O;for(;S>0;){if(O=v-S,O<0&&(O=0),h[C]>>O!==_[C]>>O)return!1;S-=v,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(i.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 w={};w.IPv4=function(){function h(_){if(_.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let v,S;for(v=0;v<_.length;v++)if(S=_[v],!(0<=S&&S<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=_}return h.prototype.SpecialRanges={unspecified:[[new h([0,0,0,0]),8]],broadcast:[[new h([255,255,255,255]),32]],multicast:[[new h([224,0,0,0]),4]],linkLocal:[[new h([169,254,0,0]),16]],loopback:[[new h([127,0,0,0]),8]],carrierGradeNat:[[new h([100,64,0,0]),10]],private:[[new h([10,0,0,0]),8],[new h([172,16,0,0]),12],[new h([192,168,0,0]),16]],reserved:[[new h([192,0,0,0]),24],[new h([192,0,2,0]),24],[new h([192,88,99,0]),24],[new h([198,18,0,0]),15],[new h([198,51,100,0]),24],[new h([203,0,113,0]),24],[new h([240,0,0,0]),4]],as112:[[new h([192,175,48,0]),24],[new h([192,31,196,0]),24]],amt:[[new h([192,52,193,0]),24]]},h.prototype.kind=function(){return"ipv4"},h.prototype.match=function(_,v){let S;if(v===void 0&&(S=_,_=S[0],v=S[1]),_.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return p(this.octets,_.octets,8,v)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,v=!1;const S={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let C,O,L;for(C=3;C>=0;C-=1)if(O=this.octets[C],O in S){if(L=S[O],v&&L!==0)return null;L!==8&&(v=!0),_+=L}else return null;return 32-_},h.prototype.range=function(){return w.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){return this.octets.slice(0)},h.prototype.toIPv4MappedAddress=function(){return w.IPv6.parse(`::ffff:${this.toString()}`)},h.prototype.toNormalizedString=function(){return this.toString()},h.prototype.toString=function(){return this.octets.join(".")},h}(),w.IPv4.broadcastAddressFromCIDR=function(h){try{const _=this.parseCIDR(h),v=_[0].toByteArray(),S=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[];let O=0;for(;O<4;)C.push(parseInt(v[O],10)|parseInt(S[O],10)^255),O++;return new this(C)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},w.IPv4.isIPv4=function(h){return this.parser(h)!==null},w.IPv4.isValid=function(h){try{return new this(this.parser(h)),!0}catch{return!1}},w.IPv4.isValidCIDR=function(h){try{return this.parseCIDR(h),!0}catch{return!1}},w.IPv4.isValidFourPartDecimal=function(h){return!!(w.IPv4.isValid(h)&&h.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},w.IPv4.networkAddressFromCIDR=function(h){let _,v,S,C,O;try{for(_=this.parseCIDR(h),S=_[0].toByteArray(),O=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[],v=0;v<4;)C.push(parseInt(S[v],10)&parseInt(O[v],10)),v++;return new this(C)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},w.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(_)},w.IPv4.parseCIDR=function(h){let _;if(_=h.match(/^(.+)\/(\d+)$/)){const v=parseInt(_[2]);if(v>=0&&v<=32){const S=[this.parse(_[1]),v];return Object.defineProperty(S,"toString",{value:function(){return this.join("/")}}),S}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},w.IPv4.parser=function(h){let _,v,S;if(_=h.match(r.fourOctet))return function(){const C=_.slice(1,6),O=[];for(let L=0;L<C.length;L++)v=C[L],O.push(f(v));return O}();if(_=h.match(r.longValue)){if(S=f(_[1]),S>4294967295||S<0)throw new Error("ipaddr: address outside defined range");return function(){const C=[];let O;for(O=0;O<=24;O+=8)C.push(S>>O&255);return C}().reverse()}else return(_=h.match(r.twoOctet))?function(){const C=_.slice(1,4),O=[];if(S=f(C[1]),S>16777215||S<0)throw new Error("ipaddr: address outside defined range");return O.push(f(C[0])),O.push(S>>16&255),O.push(S>>8&255),O.push(S&255),O}():(_=h.match(r.threeOctet))?function(){const C=_.slice(1,5),O=[];if(S=f(C[2]),S>65535||S<0)throw new Error("ipaddr: address outside defined range");return O.push(f(C[0])),O.push(f(C[1])),O.push(S>>8&255),O.push(S&255),O}():null},w.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 v=0;const S=Math.floor(h/8);for(;v<S;)_[v]=255,v++;return S<4&&(_[S]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},w.IPv6=function(){function h(_,v){let S,C;if(_.length===16)for(this.parts=[],S=0;S<=14;S+=2)this.parts.push(_[S]<<8|_[S+1]);else if(_.length===8)this.parts=_;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(S=0;S<this.parts.length;S++)if(C=this.parts[S],!(0<=C&&C<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");v&&(this.zoneId=v)}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(_,v){let S;if(v===void 0&&(S=_,_=S[0],v=S[1]),_.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return p(this.parts,_.parts,16,v)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,v=!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 C,O;for(let L=7;L>=0;L-=1)if(C=this.parts[L],C in S){if(O=S[C],v&&O!==0)return null;O!==16&&(v=!0),_+=O}else return null;return 128-_},h.prototype.range=function(){return w.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){let _;const v=[],S=this.parts;for(let C=0;C<S.length;C++)_=S[C],v.push(_>>8),v.push(_&255);return v},h.prototype.toFixedLengthString=function(){const _=(function(){const S=[];for(let C=0;C<this.parts.length;C++)S.push(m(this.parts[C].toString(16),4));return S}).call(this).join(":");let v="";return this.zoneId&&(v=`%${this.zoneId}`),_+v},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),v=_[0],S=_[1];return new w.IPv4([v>>8,v&255,S>>8,S&255])},h.prototype.toNormalizedString=function(){const _=(function(){const S=[];for(let C=0;C<this.parts.length;C++)S.push(this.parts[C].toString(16));return S}).call(this).join(":");let v="";return this.zoneId&&(v=`%${this.zoneId}`),_+v},h.prototype.toRFC5952String=function(){const _=/((^|:)(0(:|$)){2,})/g,v=this.toNormalizedString();let S=0,C=-1,O;for(;O=_.exec(v);)O[0].length>C&&(S=O.index,C=O[0].length);return C<0?v:`${v.substring(0,S)}::${v.substring(S+C)}`},h.prototype.toString=function(){return this.toRFC5952String()},h}(),w.IPv6.broadcastAddressFromCIDR=function(h){try{const _=this.parseCIDR(h),v=_[0].toByteArray(),S=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[];let O=0;for(;O<16;)C.push(parseInt(v[O],10)|parseInt(S[O],10)^255),O++;return new this(C)}catch(_){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${_})`)}},w.IPv6.isIPv6=function(h){return this.parser(h)!==null},w.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}},w.IPv6.isValidCIDR=function(h){if(typeof h=="string"&&h.indexOf(":")===-1)return!1;try{return this.parseCIDR(h),!0}catch{return!1}},w.IPv6.networkAddressFromCIDR=function(h){let _,v,S,C,O;try{for(_=this.parseCIDR(h),S=_[0].toByteArray(),O=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[],v=0;v<16;)C.push(parseInt(S[v],10)&parseInt(O[v],10)),v++;return new this(C)}catch(L){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${L})`)}},w.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)},w.IPv6.parseCIDR=function(h){let _,v,S;if((v=h.match(/^(.+)\/(\d+)$/))&&(_=parseInt(v[2]),_>=0&&_<=128))return S=[this.parse(v[1]),_],Object.defineProperty(S,"toString",{value:function(){return this.join("/")}}),S;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},w.IPv6.parser=function(h){let _,v,S,C,O,L;if(S=h.match(l.deprecatedTransitional))return this.parser(`::ffff:${S[1]}`);if(l.native.test(h))return d(h,8);if((S=h.match(l.transitional))&&(L=S[6]||"",_=S[1],S[1].endsWith("::")||(_=_.slice(0,-1)),_=d(_+L,6),_.parts)){for(O=[parseInt(S[2]),parseInt(S[3]),parseInt(S[4]),parseInt(S[5])],v=0;v<O.length;v++)if(C=O[v],!(0<=C&&C<=255))return null;return _.parts.push(O[0]<<8|O[1]),_.parts.push(O[2]<<8|O[3]),{parts:_.parts,zoneId:_.zoneId}}return null},w.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 v=0;const S=Math.floor(h/8);for(;v<S;)_[v]=255,v++;return S<16&&(_[S]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},w.fromByteArray=function(h){const _=h.length;if(_===4)return new w.IPv4(h);if(_===16)return new w.IPv6(h);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},w.isValid=function(h){return w.IPv6.isValid(h)||w.IPv4.isValid(h)},w.isValidCIDR=function(h){return w.IPv6.isValidCIDR(h)||w.IPv4.isValidCIDR(h)},w.parse=function(h){if(w.IPv6.isValid(h))return w.IPv6.parse(h);if(w.IPv4.isValid(h))return w.IPv4.parse(h);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},w.parseCIDR=function(h){try{return w.IPv6.parseCIDR(h)}catch{try{return w.IPv4.parseCIDR(h)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},w.process=function(h){const _=this.parse(h);return _.kind()==="ipv6"&&_.isIPv4MappedAddress()?_.toIPv4Address():_},w.subnetMatch=function(h,_,v){let S,C,O,L;v==null&&(v="unicast");for(C in _)if(Object.prototype.hasOwnProperty.call(_,C)){for(O=_[C],O[0]&&!(O[0]instanceof Array)&&(O=[O]),S=0;S<O.length;S++)if(L=O[S],h.kind()===L[0].kind()&&h.match.apply(h,L))return C}return v},t.exports?t.exports=w:e.ipaddr=w})(ls)})(Zh);var ou=Zh.exports;class au{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((i,s)=>i+ +s,0);let r=e.slice(0,8).replace(/(.{2})/g,i=>`${parseInt(i,16)}.`);return r=r.slice(0,-1),`${r}/${n}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const n=new Uint8Array(e);return ou.fromByteArray(Array.from(n)).toString()}return this.decodeIP(J.ToHex(e))}static fromString(e){const n=ou.parse(e);return new Uint8Array(n.toByteArray()).buffer}}var Ba,Ra,La;let Te=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};u([g({type:b.TeletexString})],Te.prototype,"teletexString",void 0);u([g({type:b.PrintableString})],Te.prototype,"printableString",void 0);u([g({type:b.UniversalString})],Te.prototype,"universalString",void 0);u([g({type:b.Utf8String})],Te.prototype,"utf8String",void 0);u([g({type:b.BmpString})],Te.prototype,"bmpString",void 0);Te=u([R({type:B.Choice})],Te);let tr=class extends Te{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?J.ToHex(this.anyValue):super.toString())}};u([g({type:b.IA5String})],tr.prototype,"ia5String",void 0);u([g({type:b.Any})],tr.prototype,"anyValue",void 0);tr=u([R({type:B.Choice})],tr);class Ao{constructor(e={}){this.type="",this.value=new tr,Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Ao.prototype,"type",void 0);u([g({type:tr})],Ao.prototype,"value",void 0);let nr=Ba=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ba.prototype)}};nr=Ba=u([R({type:B.Set,itemType:Ao})],nr);let Ua=Ra=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ra.prototype)}};Ua=Ra=u([R({type:B.Sequence,itemType:nr})],Ua);let xe=La=class extends Ua{constructor(e){super(e),Object.setPrototypeOf(this,La.prototype)}};xe=La=u([R({type:B.Sequence})],xe);const Aw={fromASN:t=>au.toString(hs.fromASN(t)),toASN:t=>hs.toASN(au.fromString(t))};class Dr{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Dr.prototype,"typeId",void 0);u([g({type:b.Any,context:0})],Dr.prototype,"value",void 0);class Nl{constructor(e={}){this.partyName=new Te,Object.assign(this,e)}}u([g({type:Te,optional:!0,context:0,implicit:!0})],Nl.prototype,"nameAssigner",void 0);u([g({type:Te,context:1,implicit:!0})],Nl.prototype,"partyName",void 0);let ie=class{constructor(e={}){Object.assign(this,e)}};u([g({type:Dr,context:0,implicit:!0})],ie.prototype,"otherName",void 0);u([g({type:b.IA5String,context:1,implicit:!0})],ie.prototype,"rfc822Name",void 0);u([g({type:b.IA5String,context:2,implicit:!0})],ie.prototype,"dNSName",void 0);u([g({type:b.Any,context:3,implicit:!0})],ie.prototype,"x400Address",void 0);u([g({type:xe,context:4,implicit:!1})],ie.prototype,"directoryName",void 0);u([g({type:Nl,context:5})],ie.prototype,"ediPartyName",void 0);u([g({type:b.IA5String,context:6,implicit:!0})],ie.prototype,"uniformResourceIdentifier",void 0);u([g({type:b.OctetString,context:7,implicit:!0,converter:Aw})],ie.prototype,"iPAddress",void 0);u([g({type:b.ObjectIdentifier,context:8,implicit:!0})],ie.prototype,"registeredID",void 0);ie=u([R({type:B.Choice})],ie);const jl="1.3.6.1.5.5.7",zw=`${jl}.1`,mr=`${jl}.3`,zo=`${jl}.48`,cu=`${zo}.1`,lu=`${zo}.2`,du=`${zo}.3`,uu=`${zo}.5`,dn="2.5.29";var Va;const qa=`${zw}.1`;class di{constructor(e={}){this.accessMethod="",this.accessLocation=new ie,Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],di.prototype,"accessMethod",void 0);u([g({type:ie})],di.prototype,"accessLocation",void 0);let Gn=Va=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Va.prototype)}};Gn=Va=u([R({type:B.Sequence,itemType:di})],Gn);const Ma=`${dn}.35`;class $l extends de{}class wn{constructor(e={}){e&&Object.assign(this,e)}}u([g({type:$l,context:0,optional:!0,implicit:!0})],wn.prototype,"keyIdentifier",void 0);u([g({type:ie,context:1,optional:!0,implicit:!0,repeated:"sequence"})],wn.prototype,"authorityCertIssuer",void 0);u([g({type:b.Integer,context:2,optional:!0,implicit:!0,converter:_e})],wn.prototype,"authorityCertSerialNumber",void 0);const Yh=`${dn}.19`;class gs{constructor(e={}){this.cA=!1,Object.assign(this,e)}}u([g({type:b.Boolean,defaultValue:!1})],gs.prototype,"cA",void 0);u([g({type:b.Integer,optional:!0})],gs.prototype,"pathLenConstraint",void 0);var Ha;let Me=Ha=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ha.prototype)}};Me=Ha=u([R({type:B.Sequence,itemType:ie})],Me);var Da;let pu=Da=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Da.prototype)}};pu=Da=u([R({type:B.Sequence})],pu);var Fa;const Xh=`${dn}.32`;let Lt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};u([g({type:b.IA5String})],Lt.prototype,"ia5String",void 0);u([g({type:b.VisibleString})],Lt.prototype,"visibleString",void 0);u([g({type:b.BmpString})],Lt.prototype,"bmpString",void 0);u([g({type:b.Utf8String})],Lt.prototype,"utf8String",void 0);Lt=u([R({type:B.Choice})],Lt);class Ol{constructor(e={}){this.organization=new Lt,this.noticeNumbers=[],Object.assign(this,e)}}u([g({type:Lt})],Ol.prototype,"organization",void 0);u([g({type:b.Integer,repeated:"sequence"})],Ol.prototype,"noticeNumbers",void 0);class Pl{constructor(e={}){Object.assign(this,e)}}u([g({type:Ol,optional:!0})],Pl.prototype,"noticeRef",void 0);u([g({type:Lt,optional:!0})],Pl.prototype,"explicitText",void 0);let ms=class{constructor(e={}){Object.assign(this,e)}};u([g({type:b.IA5String})],ms.prototype,"cPSuri",void 0);u([g({type:Pl})],ms.prototype,"userNotice",void 0);ms=u([R({type:B.Choice})],ms);class Tl{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Tl.prototype,"policyQualifierId",void 0);u([g({type:b.Any})],Tl.prototype,"qualifier",void 0);class Eo{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Eo.prototype,"policyIdentifier",void 0);u([g({type:Tl,repeated:"sequence",optional:!0})],Eo.prototype,"policyQualifiers",void 0);let _s=Fa=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Fa.prototype)}};_s=Fa=u([R({type:B.Sequence,itemType:Eo})],_s);let ys=class{constructor(e=0){this.value=e}};u([g({type:b.Integer})],ys.prototype,"value",void 0);ys=u([R({type:B.Choice})],ys);let fu=class extends ys{};fu=u([R({type:B.Choice})],fu);var Ka;const Wa=`${dn}.31`;var pt;(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"})(pt||(pt={}));class Qh extends So{toJSON(){const e=[],n=this.toNumber();return n&pt.aACompromise&&e.push("aACompromise"),n&pt.affiliationChanged&&e.push("affiliationChanged"),n&pt.cACompromise&&e.push("cACompromise"),n&pt.certificateHold&&e.push("certificateHold"),n&pt.cessationOfOperation&&e.push("cessationOfOperation"),n&pt.keyCompromise&&e.push("keyCompromise"),n&pt.privilegeWithdrawn&&e.push("privilegeWithdrawn"),n&pt.superseded&&e.push("superseded"),n&pt.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let zn=class{constructor(e={}){Object.assign(this,e)}};u([g({type:ie,context:0,repeated:"sequence",implicit:!0})],zn.prototype,"fullName",void 0);u([g({type:nr,context:1,implicit:!0})],zn.prototype,"nameRelativeToCRLIssuer",void 0);zn=u([R({type:B.Choice})],zn);class _r{constructor(e={}){Object.assign(this,e)}}u([g({type:zn,context:0,optional:!0})],_r.prototype,"distributionPoint",void 0);u([g({type:Qh,context:1,optional:!0,implicit:!0})],_r.prototype,"reasons",void 0);u([g({type:ie,context:2,optional:!0,repeated:"sequence",implicit:!0})],_r.prototype,"cRLIssuer",void 0);let Yn=Ka=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ka.prototype)}};Yn=Ka=u([R({type:B.Sequence,itemType:_r})],Yn);var Ga;let hu=Ga=class extends Yn{constructor(e){super(e),Object.setPrototypeOf(this,Ga.prototype)}};hu=Ga=u([R({type:B.Sequence,itemType:_r})],hu);class Le{constructor(e={}){this.onlyContainsUserCerts=Le.ONLY,this.onlyContainsCACerts=Le.ONLY,this.indirectCRL=Le.ONLY,this.onlyContainsAttributeCerts=Le.ONLY,Object.assign(this,e)}}Le.ONLY=!1;u([g({type:zn,context:0,optional:!0})],Le.prototype,"distributionPoint",void 0);u([g({type:b.Boolean,context:1,defaultValue:Le.ONLY,implicit:!0})],Le.prototype,"onlyContainsUserCerts",void 0);u([g({type:b.Boolean,context:2,defaultValue:Le.ONLY,implicit:!0})],Le.prototype,"onlyContainsCACerts",void 0);u([g({type:Qh,context:3,optional:!0,implicit:!0})],Le.prototype,"onlySomeReasons",void 0);u([g({type:b.Boolean,context:4,defaultValue:Le.ONLY,implicit:!0})],Le.prototype,"indirectCRL",void 0);u([g({type:b.Boolean,context:5,defaultValue:Le.ONLY,implicit:!0})],Le.prototype,"onlyContainsAttributeCerts",void 0);var Tr;(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"})(Tr||(Tr={}));let Ja=class{constructor(e=Tr.unspecified){this.reason=Tr.unspecified,this.reason=e}toJSON(){return Tr[this.reason]}toString(){return this.toJSON()}};u([g({type:b.Enumerated})],Ja.prototype,"reason",void 0);Ja=u([R({type:B.Choice})],Ja);var Za;const eg=`${dn}.37`;let ws=Za=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Za.prototype)}};ws=Za=u([R({type:B.Sequence,itemType:b.ObjectIdentifier})],ws);const Ew=`${mr}.1`,Iw=`${mr}.2`,Cw=`${mr}.3`,Nw=`${mr}.4`,jw=`${mr}.8`,$w=`${mr}.9`;let Ya=class{constructor(e=new ArrayBuffer(0)){this.value=e}};u([g({type:b.Integer,converter:_e})],Ya.prototype,"value",void 0);Ya=u([R({type:B.Choice})],Ya);let Xa=class{constructor(e){this.value=new Date,e&&(this.value=e)}};u([g({type:b.GeneralizedTime})],Xa.prototype,"value",void 0);Xa=u([R({type:B.Choice})],Xa);var Qa;let gu=Qa=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Qa.prototype)}};gu=Qa=u([R({type:B.Sequence})],gu);const tg=`${dn}.15`;var ft;(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"})(ft||(ft={}));class oa extends So{toJSON(){const e=this.toNumber(),n=[];return e&ft.cRLSign&&n.push("crlSign"),e&ft.dataEncipherment&&n.push("dataEncipherment"),e&ft.decipherOnly&&n.push("decipherOnly"),e&ft.digitalSignature&&n.push("digitalSignature"),e&ft.encipherOnly&&n.push("encipherOnly"),e&ft.keyAgreement&&n.push("keyAgreement"),e&ft.keyCertSign&&n.push("keyCertSign"),e&ft.keyEncipherment&&n.push("keyEncipherment"),e&ft.nonRepudiation&&n.push("nonRepudiation"),n}toString(){return`[${this.toJSON().join(", ")}]`}}var ec;class Io{constructor(e={}){this.base=new ie,this.minimum=0,Object.assign(this,e)}}u([g({type:ie})],Io.prototype,"base",void 0);u([g({type:b.Integer,context:0,defaultValue:0,implicit:!0})],Io.prototype,"minimum",void 0);u([g({type:b.Integer,context:1,optional:!0,implicit:!0})],Io.prototype,"maximum",void 0);let vs=ec=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,ec.prototype)}};vs=ec=u([R({type:B.Sequence,itemType:Io})],vs);class ng{constructor(e={}){Object.assign(this,e)}}u([g({type:vs,context:0,optional:!0,implicit:!0})],ng.prototype,"permittedSubtrees",void 0);u([g({type:vs,context:1,optional:!0,implicit:!0})],ng.prototype,"excludedSubtrees",void 0);class rg{constructor(e={}){Object.assign(this,e)}}u([g({type:b.Integer,context:0,implicit:!0,optional:!0,converter:_e})],rg.prototype,"requireExplicitPolicy",void 0);u([g({type:b.Integer,context:1,implicit:!0,optional:!0,converter:_e})],rg.prototype,"inhibitPolicyMapping",void 0);var tc;class Bl{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Bl.prototype,"issuerDomainPolicy",void 0);u([g({type:b.ObjectIdentifier})],Bl.prototype,"subjectDomainPolicy",void 0);let mu=tc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,tc.prototype)}};mu=tc=u([R({type:B.Sequence,itemType:Bl})],mu);var nc;const ig=`${dn}.17`;let rc=nc=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,nc.prototype)}};rc=nc=u([R({type:B.Sequence})],rc);let Ut=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};u([g({type:b.ObjectIdentifier})],Ut.prototype,"type",void 0);u([g({type:b.Any,repeated:"set"})],Ut.prototype,"values",void 0);var ic;let _u=ic=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,ic.prototype)}};_u=ic=u([R({type:B.Sequence,itemType:Ut})],_u);const sg=`${dn}.14`;class Qt extends $l{}class og{constructor(e={}){Object.assign(this,e)}}u([g({type:b.GeneralizedTime,context:0,implicit:!0,optional:!0})],og.prototype,"notBefore",void 0);u([g({type:b.GeneralizedTime,context:1,implicit:!0,optional:!0})],og.prototype,"notAfter",void 0);var Br;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate"})(Br||(Br={}));class ag extends So{toJSON(){const e=[],n=this.toNumber();return n&Br.pKIXCertificate&&e.push("pKIXCertificate"),n&Br.newExtensions&&e.push("newExtensions"),n&Br.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class cg{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new ag,Object.assign(this,e)}}u([g({type:b.GeneralString})],cg.prototype,"entrustVers",void 0);u([g({type:ag})],cg.prototype,"entrustInfoFlags",void 0);var sc;let yu=sc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,sc.prototype)}};yu=sc=u([R({type:B.Sequence,itemType:di})],yu);class F{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof F&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Gf(e.parameters,this.parameters)||e.parameters===this.parameters)}}u([g({type:b.ObjectIdentifier})],F.prototype,"algorithm",void 0);u([g({type:b.Any,optional:!0})],F.prototype,"parameters",void 0);class ht{constructor(e={}){this.algorithm=new F,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:F})],ht.prototype,"algorithm",void 0);u([g({type:b.BitString})],ht.prototype,"subjectPublicKey",void 0);let Oe=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}};u([g({type:b.UTCTime})],Oe.prototype,"utcTime",void 0);u([g({type:b.GeneralizedTime})],Oe.prototype,"generalTime",void 0);Oe=u([R({type:B.Choice})],Oe);class ui{constructor(e){this.notBefore=new Oe(new Date),this.notAfter=new Oe(new Date),e&&(this.notBefore=new Oe(e.notBefore),this.notAfter=new Oe(e.notAfter))}}u([g({type:Oe})],ui.prototype,"notBefore",void 0);u([g({type:Oe})],ui.prototype,"notAfter",void 0);var oc;let ot=class lg{constructor(e={}){this.extnID="",this.critical=lg.CRITICAL,this.extnValue=new de,Object.assign(this,e)}};ot.CRITICAL=!1;u([g({type:b.ObjectIdentifier})],ot.prototype,"extnID",void 0);u([g({type:b.Boolean,defaultValue:ot.CRITICAL})],ot.prototype,"critical",void 0);u([g({type:de})],ot.prototype,"extnValue",void 0);let nn=oc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,oc.prototype)}};nn=oc=u([R({type:B.Sequence,itemType:ot})],nn);var En;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3"})(En||(En={}));class nt{constructor(e={}){this.version=En.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new F,this.issuer=new xe,this.validity=new ui,this.subject=new xe,this.subjectPublicKeyInfo=new ht,Object.assign(this,e)}}u([g({type:b.Integer,context:0,defaultValue:En.v1})],nt.prototype,"version",void 0);u([g({type:b.Integer,converter:_e})],nt.prototype,"serialNumber",void 0);u([g({type:F})],nt.prototype,"signature",void 0);u([g({type:xe})],nt.prototype,"issuer",void 0);u([g({type:ui})],nt.prototype,"validity",void 0);u([g({type:xe})],nt.prototype,"subject",void 0);u([g({type:ht})],nt.prototype,"subjectPublicKeyInfo",void 0);u([g({type:b.BitString,context:1,implicit:!0,optional:!0})],nt.prototype,"issuerUniqueID",void 0);u([g({type:b.BitString,context:2,implicit:!0,optional:!0})],nt.prototype,"subjectUniqueID",void 0);u([g({type:nn,context:3,optional:!0})],nt.prototype,"extensions",void 0);class In{constructor(e={}){this.tbsCertificate=new nt,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:nt})],In.prototype,"tbsCertificate",void 0);u([g({type:F})],In.prototype,"signatureAlgorithm",void 0);u([g({type:b.BitString})],In.prototype,"signatureValue",void 0);class Co{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Oe,Object.assign(this,e)}}u([g({type:b.Integer,converter:_e})],Co.prototype,"userCertificate",void 0);u([g({type:Oe})],Co.prototype,"revocationDate",void 0);u([g({type:ot,optional:!0,repeated:"sequence"})],Co.prototype,"crlEntryExtensions",void 0);class Kt{constructor(e={}){this.signature=new F,this.issuer=new xe,this.thisUpdate=new Oe,Object.assign(this,e)}}u([g({type:b.Integer,optional:!0})],Kt.prototype,"version",void 0);u([g({type:F})],Kt.prototype,"signature",void 0);u([g({type:xe})],Kt.prototype,"issuer",void 0);u([g({type:Oe})],Kt.prototype,"thisUpdate",void 0);u([g({type:Oe,optional:!0})],Kt.prototype,"nextUpdate",void 0);u([g({type:Co,repeated:"sequence",optional:!0})],Kt.prototype,"revokedCertificates",void 0);u([g({type:ot,optional:!0,context:0,repeated:"sequence"})],Kt.prototype,"crlExtensions",void 0);class Rl{constructor(e={}){this.tbsCertList=new Kt,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:Kt})],Rl.prototype,"tbsCertList",void 0);u([g({type:F})],Rl.prototype,"signatureAlgorithm",void 0);u([g({type:b.BitString})],Rl.prototype,"signature",void 0);class yr{constructor(e={}){this.issuer=new xe,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:xe})],yr.prototype,"issuer",void 0);u([g({type:b.Integer,converter:_e})],yr.prototype,"serialNumber",void 0);let rr=class{constructor(e={}){Object.assign(this,e)}};u([g({type:Qt,context:0,implicit:!0})],rr.prototype,"subjectKeyIdentifier",void 0);u([g({type:yr})],rr.prototype,"issuerAndSerialNumber",void 0);rr=u([R({type:B.Choice})],rr);var Vt;(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"})(Vt||(Vt={}));let Fr=class extends F{};Fr=u([R({type:B.Sequence})],Fr);let bs=class extends F{};bs=u([R({type:B.Sequence})],bs);let Ct=class extends F{};Ct=u([R({type:B.Sequence})],Ct);let xs=class extends F{};xs=u([R({type:B.Sequence})],xs);let wu=class extends F{};wu=u([R({type:B.Sequence})],wu);let ac=class extends F{};ac=u([R({type:B.Sequence})],ac);let wr=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};u([g({type:b.ObjectIdentifier})],wr.prototype,"attrType",void 0);u([g({type:b.Any,repeated:"set"})],wr.prototype,"attrValues",void 0);var cc;class jt{constructor(e={}){this.version=Vt.v0,this.sid=new rr,this.digestAlgorithm=new Fr,this.signatureAlgorithm=new bs,this.signature=new de,Object.assign(this,e)}}u([g({type:b.Integer})],jt.prototype,"version",void 0);u([g({type:rr})],jt.prototype,"sid",void 0);u([g({type:Fr})],jt.prototype,"digestAlgorithm",void 0);u([g({type:wr,repeated:"set",context:0,implicit:!0,optional:!0})],jt.prototype,"signedAttrs",void 0);u([g({type:bs})],jt.prototype,"signatureAlgorithm",void 0);u([g({type:de})],jt.prototype,"signature",void 0);u([g({type:wr,repeated:"set",context:1,implicit:!0,optional:!0})],jt.prototype,"unsignedAttrs",void 0);let ks=cc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,cc.prototype)}};ks=cc=u([R({type:B.Set,itemType:jt})],ks);let vu=class extends Oe{};vu=u([R({type:B.Choice})],vu);let bu=class extends jt{};bu=u([R({type:B.Sequence})],bu);class Ll{constructor(e={}){this.acIssuer=new ie,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}u([g({type:ie})],Ll.prototype,"acIssuer",void 0);u([g({type:b.Integer})],Ll.prototype,"acSerial",void 0);u([g({type:Ut,repeated:"sequence"})],Ll.prototype,"attrs",void 0);var lc;let Ss=lc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,lc.prototype)}};Ss=lc=u([R({type:B.Sequence,itemType:b.ObjectIdentifier})],Ss);class No{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}u([g({type:b.Integer,optional:!0})],No.prototype,"pathLenConstraint",void 0);u([g({type:Ss,implicit:!0,context:0,optional:!0})],No.prototype,"permittedAttrs",void 0);u([g({type:Ss,implicit:!0,context:1,optional:!0})],No.prototype,"excludedAttrs",void 0);u([g({type:b.Boolean,defaultValue:!0})],No.prototype,"permitUnSpecified",void 0);class Rn{constructor(e={}){this.issuer=new Me,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:Me})],Rn.prototype,"issuer",void 0);u([g({type:b.Integer,converter:_e})],Rn.prototype,"serial",void 0);u([g({type:b.BitString,optional:!0})],Rn.prototype,"issuerUID",void 0);var dc;(function(t){t[t.publicKey=0]="publicKey",t[t.publicKeyCert=1]="publicKeyCert",t[t.otherObjectTypes=2]="otherObjectTypes"})(dc||(dc={}));class Ln{constructor(e={}){this.digestedObjectType=dc.publicKey,this.digestAlgorithm=new F,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.Enumerated})],Ln.prototype,"digestedObjectType",void 0);u([g({type:b.ObjectIdentifier,optional:!0})],Ln.prototype,"otherObjectTypeID",void 0);u([g({type:F})],Ln.prototype,"digestAlgorithm",void 0);u([g({type:b.BitString})],Ln.prototype,"objectDigest",void 0);class jo{constructor(e={}){Object.assign(this,e)}}u([g({type:Me,optional:!0})],jo.prototype,"issuerName",void 0);u([g({type:Rn,context:0,implicit:!0,optional:!0})],jo.prototype,"baseCertificateID",void 0);u([g({type:Ln,context:1,implicit:!0,optional:!0})],jo.prototype,"objectDigestInfo",void 0);let ir=class{constructor(e={}){Object.assign(this,e)}};u([g({type:ie,repeated:"sequence"})],ir.prototype,"v1Form",void 0);u([g({type:jo,context:0,implicit:!0})],ir.prototype,"v2Form",void 0);ir=u([R({type:B.Choice})],ir);class $o{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}u([g({type:b.GeneralizedTime})],$o.prototype,"notBeforeTime",void 0);u([g({type:b.GeneralizedTime})],$o.prototype,"notAfterTime",void 0);class pi{constructor(e={}){Object.assign(this,e)}}u([g({type:Rn,implicit:!0,context:0,optional:!0})],pi.prototype,"baseCertificateID",void 0);u([g({type:Me,implicit:!0,context:1,optional:!0})],pi.prototype,"entityName",void 0);u([g({type:Ln,implicit:!0,context:2,optional:!0})],pi.prototype,"objectDigestInfo",void 0);var uc;(function(t){t[t.v2=1]="v2"})(uc||(uc={}));class vt{constructor(e={}){this.version=uc.v2,this.holder=new pi,this.issuer=new ir,this.signature=new F,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new $o,this.attributes=[],Object.assign(this,e)}}u([g({type:b.Integer})],vt.prototype,"version",void 0);u([g({type:pi})],vt.prototype,"holder",void 0);u([g({type:ir})],vt.prototype,"issuer",void 0);u([g({type:F})],vt.prototype,"signature",void 0);u([g({type:b.Integer,converter:_e})],vt.prototype,"serialNumber",void 0);u([g({type:$o})],vt.prototype,"attrCertValidityPeriod",void 0);u([g({type:Ut,repeated:"sequence"})],vt.prototype,"attributes",void 0);u([g({type:b.BitString,optional:!0})],vt.prototype,"issuerUniqueID",void 0);u([g({type:nn,optional:!0})],vt.prototype,"extensions",void 0);class Oo{constructor(e={}){this.acinfo=new vt,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:vt})],Oo.prototype,"acinfo",void 0);u([g({type:F})],Oo.prototype,"signatureAlgorithm",void 0);u([g({type:b.BitString})],Oo.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 pc extends So{}class Ul{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier,implicit:!0,context:0})],Ul.prototype,"type",void 0);u([g({type:b.Any,implicit:!0,context:1})],Ul.prototype,"value",void 0);class Vl{constructor(e={}){this.policyId="",this.classList=new pc(As.unclassified),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Vl.prototype,"policyId",void 0);u([g({type:pc,defaultValue:new pc(As.unclassified)})],Vl.prototype,"classList",void 0);u([g({type:Ul,repeated:"set"})],Vl.prototype,"securityCategories",void 0);class Po{constructor(e={}){Object.assign(this,e)}}u([g({type:de})],Po.prototype,"cotets",void 0);u([g({type:b.ObjectIdentifier})],Po.prototype,"oid",void 0);u([g({type:b.Utf8String})],Po.prototype,"string",void 0);class dg{constructor(e={}){this.values=[],Object.assign(this,e)}}u([g({type:Me,implicit:!0,context:0,optional:!0})],dg.prototype,"policyAuthority",void 0);u([g({type:Po,repeated:"sequence"})],dg.prototype,"values",void 0);var fc;class To{constructor(e={}){this.targetCertificate=new Rn,Object.assign(this,e)}}u([g({type:Rn})],To.prototype,"targetCertificate",void 0);u([g({type:ie,optional:!0})],To.prototype,"targetName",void 0);u([g({type:Ln,optional:!0})],To.prototype,"certDigestInfo",void 0);let sr=class{constructor(e={}){Object.assign(this,e)}};u([g({type:ie,context:0,implicit:!0})],sr.prototype,"targetName",void 0);u([g({type:ie,context:1,implicit:!0})],sr.prototype,"targetGroup",void 0);u([g({type:To,context:2,implicit:!0})],sr.prototype,"targetCert",void 0);sr=u([R({type:B.Choice})],sr);let hc=fc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,fc.prototype)}};hc=fc=u([R({type:B.Sequence,itemType:sr})],hc);var gc;let xu=gc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,gc.prototype)}};xu=gc=u([R({type:B.Sequence,itemType:hc})],xu);class ug{constructor(e={}){Object.assign(this,e)}}u([g({type:Me,implicit:!0,context:0,optional:!0})],ug.prototype,"roleAuthority",void 0);u([g({type:ie,implicit:!0,context:1})],ug.prototype,"roleName",void 0);class ql{constructor(e={}){this.service=new ie,this.ident=new ie,Object.assign(this,e)}}u([g({type:ie})],ql.prototype,"service",void 0);u([g({type:ie})],ql.prototype,"ident",void 0);u([g({type:de,optional:!0})],ql.prototype,"authInfo",void 0);var mc;class Ml{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Ml.prototype,"otherCertFormat",void 0);u([g({type:b.Any})],Ml.prototype,"otherCert",void 0);let or=class{constructor(e={}){Object.assign(this,e)}};u([g({type:In})],or.prototype,"certificate",void 0);u([g({type:Oo,context:2,implicit:!0})],or.prototype,"v2AttrCert",void 0);u([g({type:Ml,context:3,implicit:!0})],or.prototype,"other",void 0);or=u([R({type:B.Choice})],or);let zs=mc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,mc.prototype)}};zs=mc=u([R({type:B.Set,itemType:or})],zs);class vr{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],vr.prototype,"contentType",void 0);u([g({type:b.Any,context:0})],vr.prototype,"content",void 0);let Kr=class{constructor(e={}){Object.assign(this,e)}};u([g({type:de})],Kr.prototype,"single",void 0);u([g({type:b.Any})],Kr.prototype,"any",void 0);Kr=u([R({type:B.Choice})],Kr);class Bo{constructor(e={}){this.eContentType="",Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Bo.prototype,"eContentType",void 0);u([g({type:Kr,context:0,optional:!0})],Bo.prototype,"eContent",void 0);let Wr=class{constructor(e={}){Object.assign(this,e)}};u([g({type:de,context:0,implicit:!0,optional:!0})],Wr.prototype,"value",void 0);u([g({type:de,converter:aw,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Wr.prototype,"constructedValue",void 0);Wr=u([R({type:B.Choice})],Wr);class fi{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new xs,Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],fi.prototype,"contentType",void 0);u([g({type:xs})],fi.prototype,"contentEncryptionAlgorithm",void 0);u([g({type:Wr,optional:!0})],fi.prototype,"encryptedContent",void 0);class Ro{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Ro.prototype,"keyAttrId",void 0);u([g({type:b.Any,optional:!0})],Ro.prototype,"keyAttr",void 0);var _c;class Lo{constructor(e={}){this.subjectKeyIdentifier=new Qt,Object.assign(this,e)}}u([g({type:Qt})],Lo.prototype,"subjectKeyIdentifier",void 0);u([g({type:b.GeneralizedTime,optional:!0})],Lo.prototype,"date",void 0);u([g({type:Ro,optional:!0})],Lo.prototype,"other",void 0);let ar=class{constructor(e={}){Object.assign(this,e)}};u([g({type:Lo,context:0,implicit:!0,optional:!0})],ar.prototype,"rKeyId",void 0);u([g({type:yr,optional:!0})],ar.prototype,"issuerAndSerialNumber",void 0);ar=u([R({type:B.Choice})],ar);class Hl{constructor(e={}){this.rid=new ar,this.encryptedKey=new de,Object.assign(this,e)}}u([g({type:ar})],Hl.prototype,"rid",void 0);u([g({type:de})],Hl.prototype,"encryptedKey",void 0);let Es=_c=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,_c.prototype)}};Es=_c=u([R({type:B.Sequence,itemType:Hl})],Es);class Dl{constructor(e={}){this.algorithm=new F,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:F})],Dl.prototype,"algorithm",void 0);u([g({type:b.BitString})],Dl.prototype,"publicKey",void 0);let Cn=class{constructor(e={}){Object.assign(this,e)}};u([g({type:Qt,context:0,implicit:!0,optional:!0})],Cn.prototype,"subjectKeyIdentifier",void 0);u([g({type:Dl,context:1,implicit:!0,optional:!0})],Cn.prototype,"originatorKey",void 0);u([g({type:yr,optional:!0})],Cn.prototype,"issuerAndSerialNumber",void 0);Cn=u([R({type:B.Choice})],Cn);class br{constructor(e={}){this.version=Vt.v3,this.originator=new Cn,this.keyEncryptionAlgorithm=new Ct,this.recipientEncryptedKeys=new Es,Object.assign(this,e)}}u([g({type:b.Integer})],br.prototype,"version",void 0);u([g({type:Cn,context:0})],br.prototype,"originator",void 0);u([g({type:de,context:1,optional:!0})],br.prototype,"ukm",void 0);u([g({type:Ct})],br.prototype,"keyEncryptionAlgorithm",void 0);u([g({type:Es})],br.prototype,"recipientEncryptedKeys",void 0);let cr=class{constructor(e={}){Object.assign(this,e)}};u([g({type:Qt,context:0,implicit:!0})],cr.prototype,"subjectKeyIdentifier",void 0);u([g({type:yr})],cr.prototype,"issuerAndSerialNumber",void 0);cr=u([R({type:B.Choice})],cr);class hi{constructor(e={}){this.version=Vt.v0,this.rid=new cr,this.keyEncryptionAlgorithm=new Ct,this.encryptedKey=new de,Object.assign(this,e)}}u([g({type:b.Integer})],hi.prototype,"version",void 0);u([g({type:cr})],hi.prototype,"rid",void 0);u([g({type:Ct})],hi.prototype,"keyEncryptionAlgorithm",void 0);u([g({type:de})],hi.prototype,"encryptedKey",void 0);class gi{constructor(e={}){this.keyIdentifier=new de,Object.assign(this,e)}}u([g({type:de})],gi.prototype,"keyIdentifier",void 0);u([g({type:b.GeneralizedTime,optional:!0})],gi.prototype,"date",void 0);u([g({type:Ro,optional:!0})],gi.prototype,"other",void 0);class mi{constructor(e={}){this.version=Vt.v4,this.kekid=new gi,this.keyEncryptionAlgorithm=new Ct,this.encryptedKey=new de,Object.assign(this,e)}}u([g({type:b.Integer})],mi.prototype,"version",void 0);u([g({type:gi})],mi.prototype,"kekid",void 0);u([g({type:Ct})],mi.prototype,"keyEncryptionAlgorithm",void 0);u([g({type:de})],mi.prototype,"encryptedKey",void 0);class _i{constructor(e={}){this.version=Vt.v0,this.keyEncryptionAlgorithm=new Ct,this.encryptedKey=new de,Object.assign(this,e)}}u([g({type:b.Integer})],_i.prototype,"version",void 0);u([g({type:ac,context:0,optional:!0})],_i.prototype,"keyDerivationAlgorithm",void 0);u([g({type:Ct})],_i.prototype,"keyEncryptionAlgorithm",void 0);u([g({type:de})],_i.prototype,"encryptedKey",void 0);class Fl{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Fl.prototype,"oriType",void 0);u([g({type:b.Any})],Fl.prototype,"oriValue",void 0);let rn=class{constructor(e={}){Object.assign(this,e)}};u([g({type:hi,optional:!0})],rn.prototype,"ktri",void 0);u([g({type:br,context:1,implicit:!0,optional:!0})],rn.prototype,"kari",void 0);u([g({type:mi,context:2,implicit:!0,optional:!0})],rn.prototype,"kekri",void 0);u([g({type:_i,context:3,implicit:!0,optional:!0})],rn.prototype,"pwri",void 0);u([g({type:Fl,context:4,implicit:!0,optional:!0})],rn.prototype,"ori",void 0);rn=u([R({type:B.Choice})],rn);var yc;let Is=yc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,yc.prototype)}};Is=yc=u([R({type:B.Set,itemType:rn})],Is);var wc;class Uo{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Uo.prototype,"otherRevInfoFormat",void 0);u([g({type:b.Any})],Uo.prototype,"otherRevInfo",void 0);let Cs=class{constructor(e={}){this.other=new Uo,Object.assign(this,e)}};u([g({type:Uo,context:1,implicit:!0})],Cs.prototype,"other",void 0);Cs=u([R({type:B.Choice})],Cs);let Ns=wc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,wc.prototype)}};Ns=wc=u([R({type:B.Set,itemType:Cs})],Ns);class Kl{constructor(e={}){Object.assign(this,e)}}u([g({type:zs,context:0,implicit:!0,optional:!0})],Kl.prototype,"certs",void 0);u([g({type:Ns,context:1,implicit:!0,optional:!0})],Kl.prototype,"crls",void 0);var vc;let bc=vc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,vc.prototype)}};bc=vc=u([R({type:B.Set,itemType:wr})],bc);class yi{constructor(e={}){this.version=Vt.v0,this.recipientInfos=new Is,this.encryptedContentInfo=new fi,Object.assign(this,e)}}u([g({type:b.Integer})],yi.prototype,"version",void 0);u([g({type:Kl,context:0,implicit:!0,optional:!0})],yi.prototype,"originatorInfo",void 0);u([g({type:Is})],yi.prototype,"recipientInfos",void 0);u([g({type:fi})],yi.prototype,"encryptedContentInfo",void 0);u([g({type:bc,context:1,implicit:!0,optional:!0})],yi.prototype,"unprotectedAttrs",void 0);const Ow="1.2.840.113549.1.7.2";var xc;let js=xc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,xc.prototype)}};js=xc=u([R({type:B.Set,itemType:Fr})],js);class xr{constructor(e={}){this.version=Vt.v0,this.digestAlgorithms=new js,this.encapContentInfo=new Bo,this.signerInfos=new ks,Object.assign(this,e)}}u([g({type:b.Integer})],xr.prototype,"version",void 0);u([g({type:js})],xr.prototype,"digestAlgorithms",void 0);u([g({type:Bo})],xr.prototype,"encapContentInfo",void 0);u([g({type:zs,context:0,implicit:!0,optional:!0})],xr.prototype,"certificates",void 0);u([g({type:Ns,context:1,implicit:!0,optional:!0})],xr.prototype,"crls",void 0);u([g({type:ks})],xr.prototype,"signerInfos",void 0);const Gr="1.2.840.10045.2.1",Wl="1.2.840.10045.4.1",pg="1.2.840.10045.4.3.1",Gl="1.2.840.10045.4.3.2",Jl="1.2.840.10045.4.3.3",Zl="1.2.840.10045.4.3.4",ku="1.2.840.10045.3.1.7",Su="1.3.132.0.34",Au="1.3.132.0.35";function wi(t){return new F({algorithm:t})}const Pw=wi(Wl);wi(pg);const Tw=wi(Gl),Bw=wi(Jl),Rw=wi(Zl);let Jr=class{constructor(e={}){Object.assign(this,e)}};u([g({type:b.ObjectIdentifier})],Jr.prototype,"fieldType",void 0);u([g({type:b.Any})],Jr.prototype,"parameters",void 0);Jr=u([R({type:B.Sequence})],Jr);class Lw extends de{}let lr=class{constructor(e={}){Object.assign(this,e)}};u([g({type:b.OctetString})],lr.prototype,"a",void 0);u([g({type:b.OctetString})],lr.prototype,"b",void 0);u([g({type:b.BitString,optional:!0})],lr.prototype,"seed",void 0);lr=u([R({type:B.Sequence})],lr);var kc;(function(t){t[t.ecpVer1=1]="ecpVer1"})(kc||(kc={}));let qt=class{constructor(e={}){this.version=kc.ecpVer1,Object.assign(this,e)}};u([g({type:b.Integer})],qt.prototype,"version",void 0);u([g({type:Jr})],qt.prototype,"fieldID",void 0);u([g({type:lr})],qt.prototype,"curve",void 0);u([g({type:Lw})],qt.prototype,"base",void 0);u([g({type:b.Integer,converter:_e})],qt.prototype,"order",void 0);u([g({type:b.Integer,optional:!0})],qt.prototype,"cofactor",void 0);qt=u([R({type:B.Sequence})],qt);let sn=class{constructor(e={}){Object.assign(this,e)}};u([g({type:b.ObjectIdentifier})],sn.prototype,"namedCurve",void 0);u([g({type:b.Null})],sn.prototype,"implicitCurve",void 0);u([g({type:qt})],sn.prototype,"specifiedCurve",void 0);sn=u([R({type:B.Choice})],sn);class Vo{constructor(e={}){this.version=1,this.privateKey=new de,Object.assign(this,e)}}u([g({type:b.Integer})],Vo.prototype,"version",void 0);u([g({type:de})],Vo.prototype,"privateKey",void 0);u([g({type:sn,context:0,optional:!0})],Vo.prototype,"parameters",void 0);u([g({type:b.BitString,context:1,optional:!0})],Vo.prototype,"publicKey",void 0);class $s{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.Integer,converter:_e})],$s.prototype,"r",void 0);u([g({type:b.Integer,converter:_e})],$s.prototype,"s",void 0);const Ye="1.2.840.113549.1.1",Nn=`${Ye}.1`,Uw=`${Ye}.7`,Vw=`${Ye}.9`,Rr=`${Ye}.10`,qw=`${Ye}.2`,Mw=`${Ye}.4`,Os=`${Ye}.5`,Hw=`${Ye}.14`,Sc=`${Ye}.11`,Ps=`${Ye}.12`,Ts=`${Ye}.13`,fg=`${Ye}.15`,hg=`${Ye}.16`,Bs="1.3.14.3.2.26",gg="2.16.840.1.101.3.4.2.4",Rs="2.16.840.1.101.3.4.2.1",Ls="2.16.840.1.101.3.4.2.2",Us="2.16.840.1.101.3.4.2.3",Dw="2.16.840.1.101.3.4.2.5",Fw="2.16.840.1.101.3.4.2.6",Kw="1.2.840.113549.2.2",Ww="1.2.840.113549.2.5",qo=`${Ye}.8`;function Ie(t){return new F({algorithm:t,parameters:null})}Ie(Kw);Ie(Ww);const jn=Ie(Bs);Ie(gg);Ie(Rs);Ie(Ls);Ie(Us);Ie(Dw);Ie(Fw);const mg=new F({algorithm:qo,parameters:q.serialize(jn)}),_g=new F({algorithm:Vw,parameters:q.serialize(hs.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Ie(Nn);Ie(qw);Ie(Mw);Ie(Os);Ie(fg);Ie(hg);Ie(Ps);Ie(Ts);Ie(fg);Ie(hg);class Mo{constructor(e={}){this.hashAlgorithm=new F(jn),this.maskGenAlgorithm=new F({algorithm:qo,parameters:q.serialize(jn)}),this.pSourceAlgorithm=new F(_g),Object.assign(this,e)}}u([g({type:F,context:0,defaultValue:jn})],Mo.prototype,"hashAlgorithm",void 0);u([g({type:F,context:1,defaultValue:mg})],Mo.prototype,"maskGenAlgorithm",void 0);u([g({type:F,context:2,defaultValue:_g})],Mo.prototype,"pSourceAlgorithm",void 0);new F({algorithm:Uw,parameters:q.serialize(new Mo)});class $n{constructor(e={}){this.hashAlgorithm=new F(jn),this.maskGenAlgorithm=new F({algorithm:qo,parameters:q.serialize(jn)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}u([g({type:F,context:0,defaultValue:jn})],$n.prototype,"hashAlgorithm",void 0);u([g({type:F,context:1,defaultValue:mg})],$n.prototype,"maskGenAlgorithm",void 0);u([g({type:b.Integer,context:2,defaultValue:20})],$n.prototype,"saltLength",void 0);u([g({type:b.Integer,context:3,defaultValue:1})],$n.prototype,"trailerField",void 0);new F({algorithm:Rr,parameters:q.serialize(new $n)});class Ho{constructor(e={}){this.digestAlgorithm=new F,this.digest=new de,Object.assign(this,e)}}u([g({type:F})],Ho.prototype,"digestAlgorithm",void 0);u([g({type:de})],Ho.prototype,"digest",void 0);var Ac;class Do{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.Integer,converter:_e})],Do.prototype,"prime",void 0);u([g({type:b.Integer,converter:_e})],Do.prototype,"exponent",void 0);u([g({type:b.Integer,converter:_e})],Do.prototype,"coefficient",void 0);let zc=Ac=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ac.prototype)}};zc=Ac=u([R({type:B.Sequence,itemType:Do})],zc);class $t{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)}}u([g({type:b.Integer})],$t.prototype,"version",void 0);u([g({type:b.Integer,converter:_e})],$t.prototype,"modulus",void 0);u([g({type:b.Integer,converter:_e})],$t.prototype,"publicExponent",void 0);u([g({type:b.Integer,converter:_e})],$t.prototype,"privateExponent",void 0);u([g({type:b.Integer,converter:_e})],$t.prototype,"prime1",void 0);u([g({type:b.Integer,converter:_e})],$t.prototype,"prime2",void 0);u([g({type:b.Integer,converter:_e})],$t.prototype,"exponent1",void 0);u([g({type:b.Integer,converter:_e})],$t.prototype,"exponent2",void 0);u([g({type:b.Integer,converter:_e})],$t.prototype,"coefficient",void 0);u([g({type:zc,optional:!0})],$t.prototype,"otherPrimeInfos",void 0);class Yl{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.Integer,converter:_e})],Yl.prototype,"modulus",void 0);u([g({type:b.Integer,converter:_e})],Yl.prototype,"publicExponent",void 0);var Ec;(function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"})(Ec||(Ec={}));const Fe=Ec;/*! *****************************************************************************
103
+ `)}`:`${n} :`}}sh=We;K.Constructed=sh;We.NAME="CONSTRUCTED";class oh extends He{fromBER(e,n,r){return n}toBER(e){return wt}}oh.override="EndOfContentValueBlock";var ah;class wl extends Pe{constructor(e={}){super(e,oh),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}ah=wl;K.EndOfContent=ah;wl.NAME=Hr;var ch;class Sn extends Pe{constructor(e={}){super(e,He),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,n,r){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+=r,n+r>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):n+r}toBER(e,n){const r=new ArrayBuffer(2);if(!e){const i=new Uint8Array(r);i[0]=5,i[1]=0}return n&&n.write(r),r}onAsciiEncoding(){return`${this.constructor.NAME}`}}ch=Sn;K.Null=ch;Sn.NAME="NULL";class lh extends Nt(He){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,r){const i=M.toUint8Array(e);return Dt(this,i,n,r)?(this.valueHexView=i.subarray(n,n+r),r>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Yf.call(this),this.blockLength=r,n+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}lh.NAME="BooleanValueBlock";var dh;class lo extends Pe{constructor(e={}){super(e,lh),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}`}}dh=lo;K.Boolean=dh;lo.NAME="BOOLEAN";class uh extends Nt(Xt){constructor({isConstructed:e=!1,...n}={}){super(n),this.isConstructed=e}fromBER(e,n,r){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=Xt.prototype.fromBER.call(this,e,n,r),i===-1)return i;for(let s=0;s<this.value.length;s++){const a=this.value[s].constructor.NAME;if(a===Hr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==Xf)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,i=super.fromBER(e,n,r),this.blockLength=r;return i}toBER(e,n){return this.isConstructed?Xt.prototype.toBER.call(this,e,n):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}uh.NAME="OctetStringValueBlock";var ph;let bn=class fh extends Pe{constructor({idBlock:e={},lenBlock:n={},...r}={}){var i,s;(i=r.isConstructed)!==null&&i!==void 0||(r.isConstructed=!!(!((s=r.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...n,isIndefiniteForm:!!r.isIndefiniteForm},...r},uh),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,n,r){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,r===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+r);try{if(s.byteLength){const a=gr(s,0,s.byteLength);a.offset!==-1&&a.offset===r&&(this.valueBlock.value=[a.result])}}catch{}}return super.fromBER(e,n,r)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?We.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${J.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 fh&&e.push(n.valueBlock.valueHexView);return M.concat(e)}};ph=bn;K.OctetString=ph;bn.NAME=Xf;class hh extends Nt(Xt){constructor({unusedBits:e=0,isConstructed:n=!1,...r}={}){super(r),this.unusedBits=e,this.isConstructed=n,this.blockLength=this.valueHexView.byteLength}fromBER(e,n,r){if(!r)return n;let i=-1;if(this.isConstructed){if(i=Xt.prototype.fromBER.call(this,e,n,r),i===-1)return i;for(const c of this.value){const l=c.constructor.NAME;if(l===Hr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(l!==Qf)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const d=c.valueBlock;if(this.unusedBits>0&&d.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=d.unusedBits}return i}const s=M.toUint8Array(e);if(!Dt(this,s,n,r))return-1;const a=s.subarray(n,n+r);if(this.unusedBits=a[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const c=a.subarray(1);try{if(c.byteLength){const l=gr(c,0,c.byteLength);l.offset!==-1&&l.offset===r-1&&(this.value=[l.result])}}catch{}}return this.valueHexView=a.subarray(1),this.blockLength=a.length,n+r}toBER(e,n){if(this.isConstructed)return Xt.prototype.toBER.call(this,e,n);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return wt;const r=new Uint8Array(this.valueHexView.length+1);return r[0]=this.unusedBits,r.set(this.valueHexView,1),r.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}hh.NAME="BitStringValueBlock";var gh;let xn=class extends Pe{constructor({idBlock:e={},lenBlock:n={},...r}={}){var i,s;(i=r.isConstructed)!==null&&i!==void 0||(r.isConstructed=!!(!((s=r.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...n,isIndefiniteForm:!!r.isIndefiniteForm},...r},hh),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,n,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,n,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return We.prototype.onAsciiEncoding.call(this);{const e=[],n=this.valueBlock.valueHexView;for(const i of n)e.push(i.toString(2).padStart(8,"0"));const r=e.join("");return`${this.constructor.NAME} : ${r.substring(0,r.length-this.valueBlock.unusedBits)}`}}};gh=xn;K.BitString=gh;xn.NAME=Qf;var mh;function ew(t,e){const n=new Uint8Array([0]),r=new Uint8Array(t),i=new Uint8Array(e);let s=r.slice(0);const a=s.length-1,c=i.slice(0),l=c.length-1;let d=0;const p=l<a?a:l;let f=0;for(let m=p;m>=0;m--,f++){switch(!0){case f<c.length:d=s[a-f]+c[l-f]+n[0];break;default:d=s[a-f]+n[0]}switch(n[0]=d/10,!0){case f>=s.length:s=Oa(new Uint8Array([d%10]),s);break;default:s[a-f]=d%10}}return n[0]>0&&(s=Oa(n,s)),s}function iu(t){if(t>=Nr.length)for(let e=Nr.length;e<=t;e++){const n=new Uint8Array([0]);let r=Nr[e-1].slice(0);for(let i=r.length-1;i>=0;i--){const s=new Uint8Array([(r[i]<<1)+n[0]]);n[0]=s[0]/10,r[i]=s[0]%10}n[0]>0&&(r=Oa(n,r)),Nr.push(r)}return Nr[t]}function tw(t,e){let n=0;const r=new Uint8Array(t),i=new Uint8Array(e),s=r.slice(0),a=s.length-1,c=i.slice(0),l=c.length-1;let d,p=0;for(let f=l;f>=0;f--,p++)switch(d=s[a-p]-c[l-p]-n,!0){case d<0:n=1,s[a-p]=d+10;break;default:n=0,s[a-p]=d}if(n>0)for(let f=a-l+1;f>=0;f--,p++)if(d=s[a-p]-n,d<0)n=1,s[a-p]=d+10;else{n=0,s[a-p]=d;break}return s.slice()}class vl extends Nt(He){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=Yf.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(My(e))}get valueDec(){return this._valueDec}fromDER(e,n,r,i=0){const s=this.fromBER(e,n,r);if(s===-1)return s;const a=this.valueHexView;return a[0]===0&&a[1]&128?this.valueHexView=a.subarray(1):i!==0&&a.length<i&&(i-a.length>1&&(i=a.length+1),this.valueHexView=a.subarray(i-a.length)),s}toDER(e=!1){const n=this.valueHexView;switch(!0){case(n[0]&128)!==0:{const r=new Uint8Array(this.valueHexView.length+1);r[0]=0,r.set(n,1),this.valueHexView=r}break;case(n[0]===0&&(n[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,n,r){const i=super.fromBER(e,n,r);return i===-1||this.setValueHex(),i}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),r=0,i;const s=this.valueHexView;let a="",c=!1;for(let l=s.byteLength-1;l>=0;l--){i=s[l];for(let d=0;d<8;d++){if((i&1)===1)switch(r){case e:n=tw(iu(r),n),a="-";break;default:n=ew(n,iu(r))}r++,i>>=1}}for(let l=0;l<n.length;l++)n[l]&&(c=!0),c&&(a+=nu.charAt(n[l]));return c===!1&&(a+=nu.charAt(0)),a}}mh=vl;vl.NAME="IntegerValueBlock";Object.defineProperty(mh.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var _h;class Et extends Pe{constructor(e={}){super(e,vl),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return ps(),BigInt(this.valueBlock.toString())}static fromBigInt(e){ps();const n=BigInt(e),r=new ao,i=n.toString(16).replace(/^-/,""),s=new Uint8Array(J.FromHex(i));if(n<0){const c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;const d=BigInt(`0x${J.ToHex(c)}`)+n,p=M.toUint8Array(J.FromHex(d.toString(16)));p[0]|=128,r.write(p)}else s[0]&128&&r.write(new Uint8Array([0])),r.write(s);return new Et({valueHex:r.final()})}convertToDER(){const e=new Et({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Et({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}_h=Et;K.Integer=_h;Et.NAME="INTEGER";var yh;class uo extends Et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}yh=uo;K.Enumerated=yh;uo.NAME="ENUMERATED";class Pa extends Nt(He){constructor({valueDec:e=-1,isFirstSid:n=!1,...r}={}){super(r),this.valueDec=e,this.isFirstSid=n}fromBER(e,n,r){if(!r)return n;const i=M.toUint8Array(e);if(!Dt(this,i,n,r))return-1;const s=i.subarray(n,n+r);this.valueHexView=new Uint8Array(r);for(let c=0;c<r&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const a=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)a[c]=this.valueHexView[c];return this.valueHexView=a,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=er(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),n+this.blockLength)}set valueBigInt(e){ps();let n=BigInt(e).toString(2);for(;n.length%7;)n="0"+n;const r=new Uint8Array(n.length/7);for(let i=0;i<r.length;i++)r[i]=parseInt(n.slice(i*7,i*7+7),2)+(i+1<r.length?128:0);this.fromBER(r.buffer,0,r.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const n=kn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",wt;const r=new Uint8Array(n.byteLength);if(!e){const i=new Uint8Array(n),s=n.byteLength-1;for(let a=0;a<s;a++)r[a]=i[a]|128;r[s]=i[s]}return r}toString(){let e="";if(this.isHexOnly)e=J.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}}}Pa.NAME="sidBlock";class wh extends He{constructor({value:e=Ke,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new Pa;if(i=s.fromBER(e,i,r),i===-1)return this.blockLength=0,this.error=s.error,i;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,r-=s.blockLength,this.value.push(s)}return i}toBER(e){const n=[];for(let r=0;r<this.value.length;r++){const i=this.value[r].toBER(e);if(i.byteLength===0)return this.error=this.value[r].error,wt;n.push(i)}return _l(n)}fromString(e){this.value=[];let n=0,r=0,i="",s=!1;do if(r=e.indexOf(".",n),r===-1?i=e.substring(n):i=e.substring(n,r),n=r+1,s){const a=this.value[0];let c=0;switch(a.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}const l=parseInt(i,10);if(isNaN(l))return;a.valueDec=l+c,s=!1}else{const a=new Pa;if(i>Number.MAX_SAFE_INTEGER){ps();const c=BigInt(i);a.valueBigInt=c}else if(a.valueDec=parseInt(i,10),isNaN(a.valueDec))return;this.value.length||(a.isFirstSid=!0,s=!0),this.value.push(a)}while(r!==-1)}toString(){let e="",n=!1;for(let r=0;r<this.value.length;r++){n=this.value[r].isHexOnly;let i=this.value[r].toString();r!==0&&(e=`${e}.`),n?(i=`{${i}}`,this.value[r].isFirstSid?e=`2.{${i} - 80}`:e+=i):e+=i}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}}wh.NAME="ObjectIdentifierValueBlock";var vh;class po extends Pe{constructor(e={}){super(e,wh),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()}}}vh=po;K.ObjectIdentifier=vh;po.NAME="OBJECT IDENTIFIER";class Ta extends Nt(Bn){constructor({valueDec:e=0,...n}={}){super(n),this.valueDec=e}fromBER(e,n,r){if(r===0)return n;const i=M.toUint8Array(e);if(!Dt(this,i,n,r))return-1;const s=i.subarray(n,n+r);this.valueHexView=new Uint8Array(r);for(let c=0;c<r&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const a=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)a[c]=this.valueHexView[c];return this.valueHexView=a,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=er(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 i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)s[a]=i[a]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const n=kn(this.valueDec,7);if(n.byteLength===0)return this.error="Error during encoding SID value",wt;const r=new Uint8Array(n.byteLength);if(!e){const i=new Uint8Array(n),s=n.byteLength-1;for(let a=0;a<s;a++)r[a]=i[a]|128;r[s]=i[s]}return r.buffer}toString(){let e="";return this.isHexOnly?e=J.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Ta.NAME="relativeSidBlock";class bh extends He{constructor({value:e=Ke,...n}={}){super(n),this.value=[],e&&this.fromString(e)}fromBER(e,n,r){let i=n;for(;r>0;){const s=new Ta;if(i=s.fromBER(e,i,r),i===-1)return this.blockLength=0,this.error=s.error,i;this.blockLength+=s.blockLength,r-=s.blockLength,this.value.push(s)}return i}toBER(e,n){const r=[];for(let i=0;i<this.value.length;i++){const s=this.value[i].toBER(e);if(s.byteLength===0)return this.error=this.value[i].error,wt;r.push(s)}return _l(r)}fromString(e){this.value=[];let n=0,r=0,i="";do{r=e.indexOf(".",n),r===-1?i=e.substring(n):i=e.substring(n,r),n=r+1;const s=new Ta;if(s.valueDec=parseInt(i,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(r!==-1);return!0}toString(){let e="",n=!1;for(let r=0;r<this.value.length;r++){n=this.value[r].isHexOnly;let i=this.value[r].toString();r!==0&&(e=`${e}.`),n&&(i=`{${i}}`),e+=i}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}}bh.NAME="RelativeObjectIdentifierValueBlock";var xh;class bl extends Pe{constructor(e={}){super(e,bh),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()}}}xh=bl;K.RelativeObjectIdentifier=xh;bl.NAME="RelativeObjectIdentifier";var kh;class Tt extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}kh=Tt;K.Sequence=kh;Tt.NAME="SEQUENCE";var Sh;let Bt=class extends We{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Sh=Bt;K.Set=Sh;Bt.NAME="SET";class Ah extends Nt(He){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Ke}toJSON(){return{...super.toJSON(),value:this.value}}}Ah.NAME="StringValueBlock";class zh extends Ah{}zh.NAME="SimpleStringValueBlock";class tt extends yl{constructor({...e}={}){super(e,zh)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,M.toUint8Array(e))}fromString(e){const n=e.length,r=this.valueBlock.valueHexView=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.charCodeAt(i);this.valueBlock.value=e}}tt.NAME="SIMPLE STRING";class Eh extends tt{fromBuffer(e){this.valueBlock.valueHexView=M.toUint8Array(e);try{this.valueBlock.value=J.ToUtf8String(e)}catch(n){this.warnings.push(`Error during "decodeURIComponent": ${n}, using raw string`),this.valueBlock.value=J.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(J.FromUtf8String(e)),this.valueBlock.value=e}}Eh.NAME="Utf8StringValueBlock";var Ih;class Ft extends Eh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}Ih=Ft;K.Utf8String=Ih;Ft.NAME="UTF8String";class Ch extends tt{fromBuffer(e){this.valueBlock.value=J.ToUtf16String(e),this.valueBlock.valueHexView=M.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(J.FromUtf16String(e))}}Ch.NAME="BmpStringValueBlock";var Nh;class fo extends Ch{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Nh=fo;K.BmpString=Nh;fo.NAME="BMPString";class jh extends tt{fromBuffer(e){const n=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),r=new Uint8Array(n);for(let i=0;i<r.length;i+=4)r[i]=r[i+3],r[i+1]=r[i+2],r[i+2]=0,r[i+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(n))}fromString(e){const n=e.length,r=this.valueBlock.valueHexView=new Uint8Array(n*4);for(let i=0;i<n;i++){const s=kn(e.charCodeAt(i),8),a=new Uint8Array(s);if(a.length>4)continue;const c=4-a.length;for(let l=a.length-1;l>=0;l--)r[i*4+l+c]=a[l]}this.valueBlock.value=e}}jh.NAME="UniversalStringValueBlock";var $h;class ho extends jh{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}$h=ho;K.UniversalString=$h;ho.NAME="UniversalString";var Oh;class go extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Oh=go;K.NumericString=Oh;go.NAME="NumericString";var Ph;class mo extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Ph=mo;K.PrintableString=Ph;mo.NAME="PrintableString";var Th;class _o extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Th=_o;K.TeletexString=Th;_o.NAME="TeletexString";var Bh;class yo extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Bh=yo;K.VideotexString=Bh;yo.NAME="VideotexString";var Rh;class wo extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Rh=wo;K.IA5String=Rh;wo.NAME="IA5String";var Lh;class vo extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Lh=vo;K.GraphicString=Lh;vo.NAME="GraphicString";var Uh;class ci extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Uh=ci;K.VisibleString=Uh;ci.NAME="VisibleString";var Vh;class bo extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Vh=bo;K.GeneralString=Vh;bo.NAME="GeneralString";var qh;class xo extends tt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}qh=xo;K.CharacterString=qh;xo.NAME="CharacterString";var Mh;class li extends ci{constructor({value:e,valueDate:n,...r}={}){if(super(r),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 i=0;i<e.length;i++)this.valueBlock.valueHexView[i]=e.charCodeAt(i)}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),r=new Uint8Array(n);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);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 r=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(r===null){this.error="Wrong input string for conversion";return}const i=parseInt(r[1],10);i>=50?this.year=1900+i:this.year=2e3+i,this.month=parseInt(r[2],10),this.day=parseInt(r[3],10),this.hour=parseInt(r[4],10),this.minute=parseInt(r[5],10),this.second=parseInt(r[6],10)}toString(e="iso"){if(e==="iso"){const n=new Array(7);return n[0]=Qe(this.year<2e3?this.year-1900:this.year-2e3,2),n[1]=Qe(this.month,2),n[2]=Qe(this.day,2),n[3]=Qe(this.hour,2),n[4]=Qe(this.minute,2),n[5]=Qe(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}}}Mh=li;K.UTCTime=Mh;li.NAME="UTCTime";var Hh;class ko extends li{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,r="",i="",s=0,a,c=0,l=0;if(e[e.length-1]==="Z")r=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");r=e}if(n){if(r.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(r.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let f=1,m=r.indexOf("+"),w="";if(m===-1&&(m=r.indexOf("-"),f=-1),m!==-1){if(w=r.substring(m+1),r=r.substring(0,m),w.length!==2&&w.length!==4)throw new Error("Wrong input string for conversion");let h=parseInt(w.substring(0,2),10);if(isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");if(c=f*h,w.length===4){if(h=parseInt(w.substring(2,4),10),isNaN(h.valueOf()))throw new Error("Wrong input string for conversion");l=f*h}}}let d=r.indexOf(".");if(d===-1&&(d=r.indexOf(",")),d!==-1){const f=new Number(`0${r.substring(d)}`);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");s=f.valueOf(),i=r.substring(0,d)}else i=r;switch(!0){case i.length===8:if(a=/(\d{4})(\d{2})(\d{2})/ig,d!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,d!==-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 i.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,d!==-1){let f=60*s;this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case i.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,d!==-1){const f=1e3*s;this.millisecond=Math.floor(f)}break;default:throw new Error("Wrong input string for conversion")}const p=a.exec(i);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(Qe(this.year,4)),n.push(Qe(this.month,2)),n.push(Qe(this.day,2)),n.push(Qe(this.hour,2)),n.push(Qe(this.minute,2)),n.push(Qe(this.second,2)),this.millisecond!==0&&(n.push("."),n.push(Qe(this.millisecond,3))),n.push("Z"),n.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Hh=ko;K.GeneralizedTime=Hh;ko.NAME="GeneralizedTime";var Dh;class xl extends Ft{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Dh=xl;K.DATE=Dh;xl.NAME="DATE";var Fh;class kl extends Ft{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Fh=kl;K.TimeOfDay=Fh;kl.NAME="TimeOfDay";var Kh;class Sl extends Ft{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Kh=Sl;K.DateTime=Kh;Sl.NAME="DateTime";var Wh;class Al extends Ft{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Wh=Al;K.Duration=Wh;Al.NAME="Duration";var Gh;class zl extends Ft{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Gh=zl;K.TIME=Gh;zl.NAME="TIME";class An{constructor({name:e=Ke,optional:n=!1}={}){this.name=e,this.optional=n}}class El extends An{constructor({value:e=[],...n}={}){super(n),this.value=e}}class fs extends An{constructor({value:e=new An,local:n=!1,...r}={}){super(r),this.value=e,this.local=n}}class nw{constructor({data:e=co}={}){this.dataView=M.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=M.toUint8Array(e)}fromBER(e,n,r){const i=n+r;return this.dataView=M.toUint8Array(e).subarray(n,i),i}toBER(e){return this.dataView.slice().buffer}}function yn(t,e,n){if(n instanceof El){for(let s=0;s<n.value.length;s++)if(yn(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(sa)&&(s.name=n.name),s}}if(n instanceof An)return n.hasOwnProperty(sa)&&(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(!(Fy in n))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Jy in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Zy in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const r=n.idBlock.toBER(!1);if(r.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(n.idBlock.fromBER(r,0,r.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(n.idBlock.hasOwnProperty(Ky)===!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(Wy)===!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(Gy)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(n.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:t};if(!(Dy 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(!(ru in n.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=n.idBlock.valueHexView,a=e.idBlock.valueHexView;if(s.length!==a.length)return{verified:!1,result:t};for(let c=0;c<s.length;c++)if(s[c]!==a[1])return{verified:!1,result:t}}if(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ke),n.name&&(t[n.name]=e)),n instanceof K.Constructed){let s=0,a={verified:!1,result:{error:"Unknown error"}},c=n.valueBlock.value.length;if(c>0&&n.valueBlock.value[0]instanceof fs&&(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 d=0;d<n.valueBlock.value.length;d++)l=l&&(n.valueBlock.value[d].optional||!1);return l?{verified:!0,result:t}:(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ke),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 d={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,Ke),n.name&&(delete t[n.name],d.name=n.name)),d}}else if(n.valueBlock.value[0]instanceof fs){if(a=yn(t,e.valueBlock.value[l],n.valueBlock.value[0].value),a.verified===!1)if(n.valueBlock.value[0].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ke),n.name&&delete t[n.name]),a;if(sa in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let d={};Yy in n.valueBlock.value[0]&&n.valueBlock.value[0].local?d=e:d=t,typeof d[n.valueBlock.value[0].name]>"u"&&(d[n.valueBlock.value[0].name]=[]),d[n.valueBlock.value[0].name].push(e.valueBlock.value[l])}}else if(a=yn(t,e.valueBlock.value[l-s],n.valueBlock.value[l]),a.verified===!1)if(n.valueBlock.value[l].optional)s++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ke),n.name&&delete t[n.name]),a;if(a.verified===!1){const l={verified:!1,result:t};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ke),n.name&&(delete t[n.name],l.name=n.name)),l}return{verified:!0,result:t}}if(n.primitiveSchema&&ru in e.valueBlock){const s=gr(e.valueBlock.valueHexView);if(s.offset===-1){const a={verified:!1,result:s.result};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,Ke),n.name&&(delete t[n.name],a.name=n.name)),a}return yn(t,s.result,n.primitiveSchema)}return{verified:!0,result:t}}function rw(t,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const n=gr(M.toUint8Array(t));return n.offset===-1?{verified:!1,result:n.result}:yn(n.result,n.result,e)}const Jh=Object.freeze(Object.defineProperty({__proto__:null,Any:An,BaseBlock:Pe,BaseStringBlock:yl,BitString:xn,BmpString:fo,Boolean:lo,CharacterString:xo,Choice:El,Constructed:We,DATE:xl,DateTime:Sl,Duration:Al,EndOfContent:wl,Enumerated:uo,GeneralString:bo,GeneralizedTime:ko,GraphicString:vo,HexBlock:Nt,IA5String:wo,Integer:Et,Null:Sn,NumericString:go,ObjectIdentifier:po,OctetString:bn,Primitive:ai,PrintableString:mo,RawData:nw,RelativeObjectIdentifier:bl,Repeated:fs,Sequence:Tt,Set:Bt,TIME:zl,TeletexString:_o,TimeOfDay:kl,UTCTime:li,UniversalString:ho,Utf8String:Ft,ValueBlock:He,VideotexString:yo,ViewWriter:ao,VisibleString:ci,compareSchema:yn,fromBER:Zn,verifySchema:rw},Symbol.toStringTag,{value:"Module"}));var B;(function(t){t[t.Sequence=0]="Sequence",t[t.Set=1]="Set",t[t.Choice=2]="Choice"})(B||(B={}));var b;(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"})(b||(b={}));class So{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 xn))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 xn({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new xn({name:e})}toNumber(){let e="";const n=new Uint8Array(this.value);for(const r of n)e+=r.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 r=n.length+7>>3;this.unusedBits=(r<<3)-n.length;const i=new Uint8Array(r);n=n.padStart(r<<3,"0").split("").reverse().join("");let s=0;for(;s<r;)i[s]=parseInt(n.slice(s<<3,(s<<3)+8),2),s++;this.value=i.buffer}}class de{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 bn))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new bn({valueHex:this.buffer})}toSchema(e){return new bn({name:e})}}const iw={fromASN:t=>t instanceof Sn?null:t.valueBeforeDecodeView,toASN:t=>{if(t===null)return new Sn;const e=Zn(t);if(e.result.error)throw new Error(e.result.error);return e.result}},sw={fromASN:t=>t.valueBlock.valueHexView.byteLength>=4?t.valueBlock.toString():t.valueBlock.valueDec,toASN:t=>new Et({value:+t})},ow={fromASN:t=>t.valueBlock.valueDec,toASN:t=>new uo({value:t})},_e={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new Et({valueHex:t})},aw={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new xn({valueHex:t})},cw={fromASN:t=>t.valueBlock.toString(),toASN:t=>new po({value:t})},lw={fromASN:t=>t.valueBlock.value,toASN:t=>new lo({value:t})},hs={fromASN:t=>t.valueBlock.valueHexView,toASN:t=>new bn({valueHex:t})},dw={fromASN:t=>new de(t.getValue()),toASN:t=>t.toASN()};function ct(t){return{fromASN:e=>e.valueBlock.value,toASN:e=>new t({value:e})}}const Zh=ct(Ft),uw=ct(fo),pw=ct(ho),fw=ct(go),hw=ct(mo),gw=ct(_o),mw=ct(yo),_w=ct(wo),yw=ct(vo),ww=ct(ci),vw=ct(bo),bw=ct(xo),xw={fromASN:t=>t.toDate(),toASN:t=>new li({valueDate:t})},kw={fromASN:t=>t.toDate(),toASN:t=>new ko({valueDate:t})},Sw={fromASN:()=>null,toASN:()=>new Sn};function Il(t){switch(t){case b.Any:return iw;case b.BitString:return aw;case b.BmpString:return uw;case b.Boolean:return lw;case b.CharacterString:return bw;case b.Enumerated:return ow;case b.GeneralString:return vw;case b.GeneralizedTime:return kw;case b.GraphicString:return yw;case b.IA5String:return _w;case b.Integer:return sw;case b.Null:return Sw;case b.NumericString:return fw;case b.ObjectIdentifier:return cw;case b.OctetString:return hs;case b.PrintableString:return hw;case b.TeletexString:return gw;case b.UTCTime:return xw;case b.UniversalString:return pw;case b.Utf8String:return Zh;case b.VideotexString:return mw;case b.VisibleString:return ww;default:return null}}function Pt(t){return typeof t=="function"&&t.prototype?t.prototype.toASN&&t.prototype.fromASN?!0:Pt(t.prototype):!!(t&&typeof t=="object"&&"toASN"in t&&"fromASN"in t)}function Yh(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:Yh(n)}return!1}function Aw(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;const n=new Uint8Array(t),r=new Uint8Array(e);for(let i=0;i<t.byteLength;i++)if(n[i]!==r[i])return!1;return!0}class zw{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,n=!1){const r=this.items.get(e);if(!r)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(n&&!r.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return r}cache(e){const n=this.get(e);n.schema||(n.schema=this.create(e,!0))}createDefault(e){const n={type:B.Sequence,items:{}},r=this.findParentSchema(e);return r&&(Object.assign(n,r),n.items=Object.assign({},n.items,r.items)),n}create(e,n){const r=this.items.get(e)||this.createDefault(e),i=[];for(const s in r.items){const a=r.items[s],c=n?s:"";let l;if(typeof a.type=="number"){const p=b[a.type],f=Jh[p];if(!f)throw new Error(`Cannot get ASN1 class by name '${p}'`);l=new f({name:c})}else Pt(a.type)?l=new a.type().toSchema(c):a.optional?this.get(a.type).type===B.Choice?l=new An({name:c}):(l=this.create(a.type,!1),l.name=c):l=new An({name:c});const d=!!a.optional||a.defaultValue!==void 0;if(a.repeated){l.name="";const p=a.repeated==="set"?Bt:Tt;l=new p({name:"",value:[new fs({name:c,value:l})]})}if(a.context!==null&&a.context!==void 0)if(a.implicit)if(typeof a.type=="number"||Pt(a.type)){const p=a.repeated?We:ai;i.push(new p({name:c,optional:d,idBlock:{tagClass:3,tagNumber:a.context}}))}else{this.cache(a.type);const p=!!a.repeated;let f=p?l:this.get(a.type,!0).schema;f="valueBlock"in f?f.valueBlock.value:f.value,i.push(new We({name:p?"":c,optional:d,idBlock:{tagClass:3,tagNumber:a.context},value:f}))}else i.push(new We({optional:d,idBlock:{tagClass:3,tagNumber:a.context},value:[l]}));else l.optional=d,i.push(l)}switch(r.type){case B.Sequence:return new Tt({value:i,name:""});case B.Set:return new Bt({value:i,name:""});case B.Choice:return new El({value:i,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 rt=new zw,R=t=>e=>{let n;rt.has(e)?n=rt.get(e):(n=rt.createDefault(e),rt.set(e,n)),Object.assign(n,t)},g=t=>(e,n)=>{let r;rt.has(e.constructor)?r=rt.get(e.constructor):(r=rt.createDefault(e.constructor),rt.set(e.constructor,r));const i=Object.assign({},t);if(typeof i.type=="number"&&!i.converter){const s=Il(t.type);if(!s)throw new Error(`Cannot get default converter for property '${n}' of ${e.constructor.name}`);i.converter=s}r.items[n]=i};class su extends Error{constructor(){super(...arguments),this.schemas=[]}}class Ew{static parse(e,n){const r=Zn(e);if(r.result.error)throw new Error(r.result.error);return this.fromASN(r.result,n)}static fromASN(e,n){var r;try{if(Pt(n))return new n().fromASN(e);const i=rt.get(n);rt.cache(n);let s=i.schema;if(e.constructor===We&&i.type!==B.Choice){s=new We({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const l in i.items)delete e[l]}const a=yn({},e,s);if(!a.verified)throw new su(`Data does not match to ${n.name} ASN1 schema. ${a.result.error}`);const c=new n;if(Yh(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=i.itemType;if(typeof l=="number"){const d=Il(l);if(!d)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,p=>d.fromASN(p))}else return n.from(e.valueBlock.value,d=>this.fromASN(d,l))}for(const l in i.items){const d=a.result[l];if(!d)continue;const p=i.items[l],f=p.type;if(typeof f=="number"||Pt(f)){const m=(r=p.converter)!==null&&r!==void 0?r:Pt(f)?new f:null;if(!m)throw new Error("Converter is empty");if(p.repeated)if(p.implicit){const w=p.repeated==="sequence"?Tt:Bt,h=new w;h.valueBlock=d.valueBlock;const _=Zn(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 v=_.result.valueBlock.value;c[l]=Array.from(v,S=>m.fromASN(S))}else c[l]=Array.from(d,w=>m.fromASN(w));else{let w=d;if(p.implicit){let h;if(Pt(f))h=new f().toSchema("");else{const _=b[f],v=Jh[_];if(!v)throw new Error(`Cannot get '${_}' class from asn1js module`);h=new v}h.valueBlock=w.valueBlock,w=Zn(h.toBER(!1)).result}c[l]=m.fromASN(w)}}else if(p.repeated){if(!Array.isArray(d))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");c[l]=Array.from(d,m=>this.fromASN(m,f))}else c[l]=this.fromASN(d,f)}return c}catch(i){throw i instanceof su&&i.schemas.push(n.name),i}}}class Cl{static serialize(e){return e instanceof Pe?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&Pt(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const n=e.constructor,r=rt.get(n);rt.cache(n);let i=[];if(r.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof r.itemType=="number"){const a=Il(r.itemType);if(!a)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);i=e.map(c=>a.toASN(c))}else i=e.map(a=>this.toAsnItem({type:r.itemType},"[]",n,a))}else for(const a in r.items){const c=r.items[a],l=e[a];if(l===void 0||c.defaultValue===l||typeof c.defaultValue=="object"&&typeof l=="object"&&Aw(this.serialize(c.defaultValue),this.serialize(l)))continue;const d=Cl.toAsnItem(c,a,n,l);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||Pt(c.type))){const p={};p.valueHex=d instanceof Sn?d.valueBeforeDecodeView:d.valueBlock.toBER(),i.push(new ai({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...p}))}else i.push(new We({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:d.valueBlock.value}));else i.push(new We({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[d]}));else c.repeated?i=i.concat(d):i.push(d)}let s;switch(r.type){case B.Sequence:s=new Tt({value:i});break;case B.Set:s=new Bt({value:i});break;case B.Choice:if(!i[0])throw new Error(`Schema '${n.name}' has wrong data. Choice cannot be empty.`);s=i[0];break}return s}static toAsnItem(e,n,r,i){let s;if(typeof e.type=="number"){const a=e.converter;if(!a)throw new Error(`Property '${n}' doesn't have converter for type ${b[e.type]} in schema '${r.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const c=Array.from(i,d=>a.toASN(d)),l=e.repeated==="sequence"?Tt:Bt;s=new l({value:c})}else s=a.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const a=Array.from(i,l=>this.toASN(l)),c=e.repeated==="sequence"?Tt:Bt;s=new c({value:a})}else s=this.toASN(i);return s}}class fe extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const n of e)this.push(n)}}}class q{static serialize(e){return Cl.serialize(e)}static parse(e,n){return Ew.parse(e,n)}static toString(e){const n=M.isBufferSource(e)?M.toArrayBuffer(e):q.serialize(e),r=Zn(n);if(r.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${r.result.error}`);return r.result.toString()}}function u(t,e,n,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,n):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,n,r);else for(var c=t.length-1;c>=0;c--)(a=t[c])&&(s=(i<3?a(s):i>3?a(e,n,s):a(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s}var Xh={exports:{}};(function(t){(function(e){const n="(0?\\d+|0x[a-f0-9]+)",r={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")},i=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),a="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",l={zoneIndex:new RegExp(a,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${a})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${n}\\.${n}\\.${n}\\.${n}(${a})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${n}\\.${n}\\.${n}\\.${n}(${a})?$`,"i")};function d(h,_){if(h.indexOf("::")!==h.lastIndexOf("::"))return null;let v=0,S=-1,C=(h.match(l.zoneIndex)||[])[0],O,L;for(C&&(C=C.substring(1),h=h.replace(/%.+$/,""));(S=h.indexOf(":",S+1))>=0;)v++;if(h.substr(0,2)==="::"&&v--,h.substr(-2,2)==="::"&&v--,v>_)return null;for(L=_-v,O=":";L--;)O+="0:";return h=h.replace("::",O),h[0]===":"&&(h=h.slice(1)),h[h.length-1]===":"&&(h=h.slice(0,-1)),_=function(){const Q=h.split(":"),ce=[];for(let le=0;le<Q.length;le++)ce.push(parseInt(Q[le],16));return ce}(),{parts:_,zoneId:C}}function p(h,_,v,S){if(h.length!==_.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let C=0,O;for(;S>0;){if(O=v-S,O<0&&(O=0),h[C]>>O!==_[C]>>O)return!1;S-=v,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(i.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 w={};w.IPv4=function(){function h(_){if(_.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let v,S;for(v=0;v<_.length;v++)if(S=_[v],!(0<=S&&S<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=_}return h.prototype.SpecialRanges={unspecified:[[new h([0,0,0,0]),8]],broadcast:[[new h([255,255,255,255]),32]],multicast:[[new h([224,0,0,0]),4]],linkLocal:[[new h([169,254,0,0]),16]],loopback:[[new h([127,0,0,0]),8]],carrierGradeNat:[[new h([100,64,0,0]),10]],private:[[new h([10,0,0,0]),8],[new h([172,16,0,0]),12],[new h([192,168,0,0]),16]],reserved:[[new h([192,0,0,0]),24],[new h([192,0,2,0]),24],[new h([192,88,99,0]),24],[new h([198,18,0,0]),15],[new h([198,51,100,0]),24],[new h([203,0,113,0]),24],[new h([240,0,0,0]),4]],as112:[[new h([192,175,48,0]),24],[new h([192,31,196,0]),24]],amt:[[new h([192,52,193,0]),24]]},h.prototype.kind=function(){return"ipv4"},h.prototype.match=function(_,v){let S;if(v===void 0&&(S=_,_=S[0],v=S[1]),_.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return p(this.octets,_.octets,8,v)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,v=!1;const S={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let C,O,L;for(C=3;C>=0;C-=1)if(O=this.octets[C],O in S){if(L=S[O],v&&L!==0)return null;L!==8&&(v=!0),_+=L}else return null;return 32-_},h.prototype.range=function(){return w.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){return this.octets.slice(0)},h.prototype.toIPv4MappedAddress=function(){return w.IPv6.parse(`::ffff:${this.toString()}`)},h.prototype.toNormalizedString=function(){return this.toString()},h.prototype.toString=function(){return this.octets.join(".")},h}(),w.IPv4.broadcastAddressFromCIDR=function(h){try{const _=this.parseCIDR(h),v=_[0].toByteArray(),S=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[];let O=0;for(;O<4;)C.push(parseInt(v[O],10)|parseInt(S[O],10)^255),O++;return new this(C)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},w.IPv4.isIPv4=function(h){return this.parser(h)!==null},w.IPv4.isValid=function(h){try{return new this(this.parser(h)),!0}catch{return!1}},w.IPv4.isValidCIDR=function(h){try{return this.parseCIDR(h),!0}catch{return!1}},w.IPv4.isValidFourPartDecimal=function(h){return!!(w.IPv4.isValid(h)&&h.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},w.IPv4.networkAddressFromCIDR=function(h){let _,v,S,C,O;try{for(_=this.parseCIDR(h),S=_[0].toByteArray(),O=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[],v=0;v<4;)C.push(parseInt(S[v],10)&parseInt(O[v],10)),v++;return new this(C)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},w.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(_)},w.IPv4.parseCIDR=function(h){let _;if(_=h.match(/^(.+)\/(\d+)$/)){const v=parseInt(_[2]);if(v>=0&&v<=32){const S=[this.parse(_[1]),v];return Object.defineProperty(S,"toString",{value:function(){return this.join("/")}}),S}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},w.IPv4.parser=function(h){let _,v,S;if(_=h.match(r.fourOctet))return function(){const C=_.slice(1,6),O=[];for(let L=0;L<C.length;L++)v=C[L],O.push(f(v));return O}();if(_=h.match(r.longValue)){if(S=f(_[1]),S>4294967295||S<0)throw new Error("ipaddr: address outside defined range");return function(){const C=[];let O;for(O=0;O<=24;O+=8)C.push(S>>O&255);return C}().reverse()}else return(_=h.match(r.twoOctet))?function(){const C=_.slice(1,4),O=[];if(S=f(C[1]),S>16777215||S<0)throw new Error("ipaddr: address outside defined range");return O.push(f(C[0])),O.push(S>>16&255),O.push(S>>8&255),O.push(S&255),O}():(_=h.match(r.threeOctet))?function(){const C=_.slice(1,5),O=[];if(S=f(C[2]),S>65535||S<0)throw new Error("ipaddr: address outside defined range");return O.push(f(C[0])),O.push(f(C[1])),O.push(S>>8&255),O.push(S&255),O}():null},w.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 v=0;const S=Math.floor(h/8);for(;v<S;)_[v]=255,v++;return S<4&&(_[S]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},w.IPv6=function(){function h(_,v){let S,C;if(_.length===16)for(this.parts=[],S=0;S<=14;S+=2)this.parts.push(_[S]<<8|_[S+1]);else if(_.length===8)this.parts=_;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(S=0;S<this.parts.length;S++)if(C=this.parts[S],!(0<=C&&C<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");v&&(this.zoneId=v)}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(_,v){let S;if(v===void 0&&(S=_,_=S[0],v=S[1]),_.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return p(this.parts,_.parts,16,v)},h.prototype.prefixLengthFromSubnetMask=function(){let _=0,v=!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 C,O;for(let L=7;L>=0;L-=1)if(C=this.parts[L],C in S){if(O=S[C],v&&O!==0)return null;O!==16&&(v=!0),_+=O}else return null;return 128-_},h.prototype.range=function(){return w.subnetMatch(this,this.SpecialRanges)},h.prototype.toByteArray=function(){let _;const v=[],S=this.parts;for(let C=0;C<S.length;C++)_=S[C],v.push(_>>8),v.push(_&255);return v},h.prototype.toFixedLengthString=function(){const _=(function(){const S=[];for(let C=0;C<this.parts.length;C++)S.push(m(this.parts[C].toString(16),4));return S}).call(this).join(":");let v="";return this.zoneId&&(v=`%${this.zoneId}`),_+v},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),v=_[0],S=_[1];return new w.IPv4([v>>8,v&255,S>>8,S&255])},h.prototype.toNormalizedString=function(){const _=(function(){const S=[];for(let C=0;C<this.parts.length;C++)S.push(this.parts[C].toString(16));return S}).call(this).join(":");let v="";return this.zoneId&&(v=`%${this.zoneId}`),_+v},h.prototype.toRFC5952String=function(){const _=/((^|:)(0(:|$)){2,})/g,v=this.toNormalizedString();let S=0,C=-1,O;for(;O=_.exec(v);)O[0].length>C&&(S=O.index,C=O[0].length);return C<0?v:`${v.substring(0,S)}::${v.substring(S+C)}`},h.prototype.toString=function(){return this.toRFC5952String()},h}(),w.IPv6.broadcastAddressFromCIDR=function(h){try{const _=this.parseCIDR(h),v=_[0].toByteArray(),S=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[];let O=0;for(;O<16;)C.push(parseInt(v[O],10)|parseInt(S[O],10)^255),O++;return new this(C)}catch(_){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${_})`)}},w.IPv6.isIPv6=function(h){return this.parser(h)!==null},w.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}},w.IPv6.isValidCIDR=function(h){if(typeof h=="string"&&h.indexOf(":")===-1)return!1;try{return this.parseCIDR(h),!0}catch{return!1}},w.IPv6.networkAddressFromCIDR=function(h){let _,v,S,C,O;try{for(_=this.parseCIDR(h),S=_[0].toByteArray(),O=this.subnetMaskFromPrefixLength(_[1]).toByteArray(),C=[],v=0;v<16;)C.push(parseInt(S[v],10)&parseInt(O[v],10)),v++;return new this(C)}catch(L){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${L})`)}},w.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)},w.IPv6.parseCIDR=function(h){let _,v,S;if((v=h.match(/^(.+)\/(\d+)$/))&&(_=parseInt(v[2]),_>=0&&_<=128))return S=[this.parse(v[1]),_],Object.defineProperty(S,"toString",{value:function(){return this.join("/")}}),S;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},w.IPv6.parser=function(h){let _,v,S,C,O,L;if(S=h.match(l.deprecatedTransitional))return this.parser(`::ffff:${S[1]}`);if(l.native.test(h))return d(h,8);if((S=h.match(l.transitional))&&(L=S[6]||"",_=S[1],S[1].endsWith("::")||(_=_.slice(0,-1)),_=d(_+L,6),_.parts)){for(O=[parseInt(S[2]),parseInt(S[3]),parseInt(S[4]),parseInt(S[5])],v=0;v<O.length;v++)if(C=O[v],!(0<=C&&C<=255))return null;return _.parts.push(O[0]<<8|O[1]),_.parts.push(O[2]<<8|O[3]),{parts:_.parts,zoneId:_.zoneId}}return null},w.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 v=0;const S=Math.floor(h/8);for(;v<S;)_[v]=255,v++;return S<16&&(_[S]=Math.pow(2,h%8)-1<<8-h%8),new this(_)},w.fromByteArray=function(h){const _=h.length;if(_===4)return new w.IPv4(h);if(_===16)return new w.IPv6(h);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},w.isValid=function(h){return w.IPv6.isValid(h)||w.IPv4.isValid(h)},w.isValidCIDR=function(h){return w.IPv6.isValidCIDR(h)||w.IPv4.isValidCIDR(h)},w.parse=function(h){if(w.IPv6.isValid(h))return w.IPv6.parse(h);if(w.IPv4.isValid(h))return w.IPv4.parse(h);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},w.parseCIDR=function(h){try{return w.IPv6.parseCIDR(h)}catch{try{return w.IPv4.parseCIDR(h)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},w.process=function(h){const _=this.parse(h);return _.kind()==="ipv6"&&_.isIPv4MappedAddress()?_.toIPv4Address():_},w.subnetMatch=function(h,_,v){let S,C,O,L;v==null&&(v="unicast");for(C in _)if(Object.prototype.hasOwnProperty.call(_,C)){for(O=_[C],O[0]&&!(O[0]instanceof Array)&&(O=[O]),S=0;S<O.length;S++)if(L=O[S],h.kind()===L[0].kind()&&h.match.apply(h,L))return C}return v},t.exports?t.exports=w:e.ipaddr=w})(ls)})(Xh);var ou=Xh.exports;class au{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((i,s)=>i+ +s,0);let r=e.slice(0,8).replace(/(.{2})/g,i=>`${parseInt(i,16)}.`);return r=r.slice(0,-1),`${r}/${n}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const n=new Uint8Array(e);return ou.fromByteArray(Array.from(n)).toString()}return this.decodeIP(J.ToHex(e))}static fromString(e){const n=ou.parse(e);return new Uint8Array(n.toByteArray()).buffer}}var Ba,Ra,La;let Te=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};u([g({type:b.TeletexString})],Te.prototype,"teletexString",void 0);u([g({type:b.PrintableString})],Te.prototype,"printableString",void 0);u([g({type:b.UniversalString})],Te.prototype,"universalString",void 0);u([g({type:b.Utf8String})],Te.prototype,"utf8String",void 0);u([g({type:b.BmpString})],Te.prototype,"bmpString",void 0);Te=u([R({type:B.Choice})],Te);let tr=class extends Te{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?J.ToHex(this.anyValue):super.toString())}};u([g({type:b.IA5String})],tr.prototype,"ia5String",void 0);u([g({type:b.Any})],tr.prototype,"anyValue",void 0);tr=u([R({type:B.Choice})],tr);class Ao{constructor(e={}){this.type="",this.value=new tr,Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Ao.prototype,"type",void 0);u([g({type:tr})],Ao.prototype,"value",void 0);let nr=Ba=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ba.prototype)}};nr=Ba=u([R({type:B.Set,itemType:Ao})],nr);let Ua=Ra=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ra.prototype)}};Ua=Ra=u([R({type:B.Sequence,itemType:nr})],Ua);let xe=La=class extends Ua{constructor(e){super(e),Object.setPrototypeOf(this,La.prototype)}};xe=La=u([R({type:B.Sequence})],xe);const Iw={fromASN:t=>au.toString(hs.fromASN(t)),toASN:t=>hs.toASN(au.fromString(t))};class Dr{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Dr.prototype,"typeId",void 0);u([g({type:b.Any,context:0})],Dr.prototype,"value",void 0);class Nl{constructor(e={}){this.partyName=new Te,Object.assign(this,e)}}u([g({type:Te,optional:!0,context:0,implicit:!0})],Nl.prototype,"nameAssigner",void 0);u([g({type:Te,context:1,implicit:!0})],Nl.prototype,"partyName",void 0);let ie=class{constructor(e={}){Object.assign(this,e)}};u([g({type:Dr,context:0,implicit:!0})],ie.prototype,"otherName",void 0);u([g({type:b.IA5String,context:1,implicit:!0})],ie.prototype,"rfc822Name",void 0);u([g({type:b.IA5String,context:2,implicit:!0})],ie.prototype,"dNSName",void 0);u([g({type:b.Any,context:3,implicit:!0})],ie.prototype,"x400Address",void 0);u([g({type:xe,context:4,implicit:!1})],ie.prototype,"directoryName",void 0);u([g({type:Nl,context:5})],ie.prototype,"ediPartyName",void 0);u([g({type:b.IA5String,context:6,implicit:!0})],ie.prototype,"uniformResourceIdentifier",void 0);u([g({type:b.OctetString,context:7,implicit:!0,converter:Iw})],ie.prototype,"iPAddress",void 0);u([g({type:b.ObjectIdentifier,context:8,implicit:!0})],ie.prototype,"registeredID",void 0);ie=u([R({type:B.Choice})],ie);const jl="1.3.6.1.5.5.7",Cw=`${jl}.1`,mr=`${jl}.3`,zo=`${jl}.48`,cu=`${zo}.1`,lu=`${zo}.2`,du=`${zo}.3`,uu=`${zo}.5`,dn="2.5.29";var Va;const qa=`${Cw}.1`;class di{constructor(e={}){this.accessMethod="",this.accessLocation=new ie,Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],di.prototype,"accessMethod",void 0);u([g({type:ie})],di.prototype,"accessLocation",void 0);let Gn=Va=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Va.prototype)}};Gn=Va=u([R({type:B.Sequence,itemType:di})],Gn);const Ma=`${dn}.35`;class $l extends de{}class wn{constructor(e={}){e&&Object.assign(this,e)}}u([g({type:$l,context:0,optional:!0,implicit:!0})],wn.prototype,"keyIdentifier",void 0);u([g({type:ie,context:1,optional:!0,implicit:!0,repeated:"sequence"})],wn.prototype,"authorityCertIssuer",void 0);u([g({type:b.Integer,context:2,optional:!0,implicit:!0,converter:_e})],wn.prototype,"authorityCertSerialNumber",void 0);const Qh=`${dn}.19`;class gs{constructor(e={}){this.cA=!1,Object.assign(this,e)}}u([g({type:b.Boolean,defaultValue:!1})],gs.prototype,"cA",void 0);u([g({type:b.Integer,optional:!0})],gs.prototype,"pathLenConstraint",void 0);var Ha;let Me=Ha=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ha.prototype)}};Me=Ha=u([R({type:B.Sequence,itemType:ie})],Me);var Da;let pu=Da=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Da.prototype)}};pu=Da=u([R({type:B.Sequence})],pu);var Fa;const eg=`${dn}.32`;let Lt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};u([g({type:b.IA5String})],Lt.prototype,"ia5String",void 0);u([g({type:b.VisibleString})],Lt.prototype,"visibleString",void 0);u([g({type:b.BmpString})],Lt.prototype,"bmpString",void 0);u([g({type:b.Utf8String})],Lt.prototype,"utf8String",void 0);Lt=u([R({type:B.Choice})],Lt);class Ol{constructor(e={}){this.organization=new Lt,this.noticeNumbers=[],Object.assign(this,e)}}u([g({type:Lt})],Ol.prototype,"organization",void 0);u([g({type:b.Integer,repeated:"sequence"})],Ol.prototype,"noticeNumbers",void 0);class Pl{constructor(e={}){Object.assign(this,e)}}u([g({type:Ol,optional:!0})],Pl.prototype,"noticeRef",void 0);u([g({type:Lt,optional:!0})],Pl.prototype,"explicitText",void 0);let ms=class{constructor(e={}){Object.assign(this,e)}};u([g({type:b.IA5String})],ms.prototype,"cPSuri",void 0);u([g({type:Pl})],ms.prototype,"userNotice",void 0);ms=u([R({type:B.Choice})],ms);class Tl{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Tl.prototype,"policyQualifierId",void 0);u([g({type:b.Any})],Tl.prototype,"qualifier",void 0);class Eo{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Eo.prototype,"policyIdentifier",void 0);u([g({type:Tl,repeated:"sequence",optional:!0})],Eo.prototype,"policyQualifiers",void 0);let _s=Fa=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Fa.prototype)}};_s=Fa=u([R({type:B.Sequence,itemType:Eo})],_s);let ys=class{constructor(e=0){this.value=e}};u([g({type:b.Integer})],ys.prototype,"value",void 0);ys=u([R({type:B.Choice})],ys);let fu=class extends ys{};fu=u([R({type:B.Choice})],fu);var Ka;const Wa=`${dn}.31`;var pt;(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"})(pt||(pt={}));class tg extends So{toJSON(){const e=[],n=this.toNumber();return n&pt.aACompromise&&e.push("aACompromise"),n&pt.affiliationChanged&&e.push("affiliationChanged"),n&pt.cACompromise&&e.push("cACompromise"),n&pt.certificateHold&&e.push("certificateHold"),n&pt.cessationOfOperation&&e.push("cessationOfOperation"),n&pt.keyCompromise&&e.push("keyCompromise"),n&pt.privilegeWithdrawn&&e.push("privilegeWithdrawn"),n&pt.superseded&&e.push("superseded"),n&pt.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let zn=class{constructor(e={}){Object.assign(this,e)}};u([g({type:ie,context:0,repeated:"sequence",implicit:!0})],zn.prototype,"fullName",void 0);u([g({type:nr,context:1,implicit:!0})],zn.prototype,"nameRelativeToCRLIssuer",void 0);zn=u([R({type:B.Choice})],zn);class _r{constructor(e={}){Object.assign(this,e)}}u([g({type:zn,context:0,optional:!0})],_r.prototype,"distributionPoint",void 0);u([g({type:tg,context:1,optional:!0,implicit:!0})],_r.prototype,"reasons",void 0);u([g({type:ie,context:2,optional:!0,repeated:"sequence",implicit:!0})],_r.prototype,"cRLIssuer",void 0);let Yn=Ka=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ka.prototype)}};Yn=Ka=u([R({type:B.Sequence,itemType:_r})],Yn);var Ga;let hu=Ga=class extends Yn{constructor(e){super(e),Object.setPrototypeOf(this,Ga.prototype)}};hu=Ga=u([R({type:B.Sequence,itemType:_r})],hu);class Le{constructor(e={}){this.onlyContainsUserCerts=Le.ONLY,this.onlyContainsCACerts=Le.ONLY,this.indirectCRL=Le.ONLY,this.onlyContainsAttributeCerts=Le.ONLY,Object.assign(this,e)}}Le.ONLY=!1;u([g({type:zn,context:0,optional:!0})],Le.prototype,"distributionPoint",void 0);u([g({type:b.Boolean,context:1,defaultValue:Le.ONLY,implicit:!0})],Le.prototype,"onlyContainsUserCerts",void 0);u([g({type:b.Boolean,context:2,defaultValue:Le.ONLY,implicit:!0})],Le.prototype,"onlyContainsCACerts",void 0);u([g({type:tg,context:3,optional:!0,implicit:!0})],Le.prototype,"onlySomeReasons",void 0);u([g({type:b.Boolean,context:4,defaultValue:Le.ONLY,implicit:!0})],Le.prototype,"indirectCRL",void 0);u([g({type:b.Boolean,context:5,defaultValue:Le.ONLY,implicit:!0})],Le.prototype,"onlyContainsAttributeCerts",void 0);var Tr;(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"})(Tr||(Tr={}));let Ja=class{constructor(e=Tr.unspecified){this.reason=Tr.unspecified,this.reason=e}toJSON(){return Tr[this.reason]}toString(){return this.toJSON()}};u([g({type:b.Enumerated})],Ja.prototype,"reason",void 0);Ja=u([R({type:B.Choice})],Ja);var Za;const ng=`${dn}.37`;let ws=Za=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Za.prototype)}};ws=Za=u([R({type:B.Sequence,itemType:b.ObjectIdentifier})],ws);const Nw=`${mr}.1`,jw=`${mr}.2`,$w=`${mr}.3`,Ow=`${mr}.4`,Pw=`${mr}.8`,Tw=`${mr}.9`;let Ya=class{constructor(e=new ArrayBuffer(0)){this.value=e}};u([g({type:b.Integer,converter:_e})],Ya.prototype,"value",void 0);Ya=u([R({type:B.Choice})],Ya);let Xa=class{constructor(e){this.value=new Date,e&&(this.value=e)}};u([g({type:b.GeneralizedTime})],Xa.prototype,"value",void 0);Xa=u([R({type:B.Choice})],Xa);var Qa;let gu=Qa=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,Qa.prototype)}};gu=Qa=u([R({type:B.Sequence})],gu);const rg=`${dn}.15`;var ft;(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"})(ft||(ft={}));class oa extends So{toJSON(){const e=this.toNumber(),n=[];return e&ft.cRLSign&&n.push("crlSign"),e&ft.dataEncipherment&&n.push("dataEncipherment"),e&ft.decipherOnly&&n.push("decipherOnly"),e&ft.digitalSignature&&n.push("digitalSignature"),e&ft.encipherOnly&&n.push("encipherOnly"),e&ft.keyAgreement&&n.push("keyAgreement"),e&ft.keyCertSign&&n.push("keyCertSign"),e&ft.keyEncipherment&&n.push("keyEncipherment"),e&ft.nonRepudiation&&n.push("nonRepudiation"),n}toString(){return`[${this.toJSON().join(", ")}]`}}var ec;class Io{constructor(e={}){this.base=new ie,this.minimum=0,Object.assign(this,e)}}u([g({type:ie})],Io.prototype,"base",void 0);u([g({type:b.Integer,context:0,defaultValue:0,implicit:!0})],Io.prototype,"minimum",void 0);u([g({type:b.Integer,context:1,optional:!0,implicit:!0})],Io.prototype,"maximum",void 0);let vs=ec=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,ec.prototype)}};vs=ec=u([R({type:B.Sequence,itemType:Io})],vs);class ig{constructor(e={}){Object.assign(this,e)}}u([g({type:vs,context:0,optional:!0,implicit:!0})],ig.prototype,"permittedSubtrees",void 0);u([g({type:vs,context:1,optional:!0,implicit:!0})],ig.prototype,"excludedSubtrees",void 0);class sg{constructor(e={}){Object.assign(this,e)}}u([g({type:b.Integer,context:0,implicit:!0,optional:!0,converter:_e})],sg.prototype,"requireExplicitPolicy",void 0);u([g({type:b.Integer,context:1,implicit:!0,optional:!0,converter:_e})],sg.prototype,"inhibitPolicyMapping",void 0);var tc;class Bl{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Bl.prototype,"issuerDomainPolicy",void 0);u([g({type:b.ObjectIdentifier})],Bl.prototype,"subjectDomainPolicy",void 0);let mu=tc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,tc.prototype)}};mu=tc=u([R({type:B.Sequence,itemType:Bl})],mu);var nc;const og=`${dn}.17`;let rc=nc=class extends Me{constructor(e){super(e),Object.setPrototypeOf(this,nc.prototype)}};rc=nc=u([R({type:B.Sequence})],rc);let Ut=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};u([g({type:b.ObjectIdentifier})],Ut.prototype,"type",void 0);u([g({type:b.Any,repeated:"set"})],Ut.prototype,"values",void 0);var ic;let _u=ic=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,ic.prototype)}};_u=ic=u([R({type:B.Sequence,itemType:Ut})],_u);const ag=`${dn}.14`;class Qt extends $l{}class cg{constructor(e={}){Object.assign(this,e)}}u([g({type:b.GeneralizedTime,context:0,implicit:!0,optional:!0})],cg.prototype,"notBefore",void 0);u([g({type:b.GeneralizedTime,context:1,implicit:!0,optional:!0})],cg.prototype,"notAfter",void 0);var Br;(function(t){t[t.keyUpdateAllowed=1]="keyUpdateAllowed",t[t.newExtensions=2]="newExtensions",t[t.pKIXCertificate=4]="pKIXCertificate"})(Br||(Br={}));class lg extends So{toJSON(){const e=[],n=this.toNumber();return n&Br.pKIXCertificate&&e.push("pKIXCertificate"),n&Br.newExtensions&&e.push("newExtensions"),n&Br.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class dg{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new lg,Object.assign(this,e)}}u([g({type:b.GeneralString})],dg.prototype,"entrustVers",void 0);u([g({type:lg})],dg.prototype,"entrustInfoFlags",void 0);var sc;let yu=sc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,sc.prototype)}};yu=sc=u([R({type:B.Sequence,itemType:di})],yu);class F{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof F&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Zf(e.parameters,this.parameters)||e.parameters===this.parameters)}}u([g({type:b.ObjectIdentifier})],F.prototype,"algorithm",void 0);u([g({type:b.Any,optional:!0})],F.prototype,"parameters",void 0);class ht{constructor(e={}){this.algorithm=new F,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:F})],ht.prototype,"algorithm",void 0);u([g({type:b.BitString})],ht.prototype,"subjectPublicKey",void 0);let Oe=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}};u([g({type:b.UTCTime})],Oe.prototype,"utcTime",void 0);u([g({type:b.GeneralizedTime})],Oe.prototype,"generalTime",void 0);Oe=u([R({type:B.Choice})],Oe);class ui{constructor(e){this.notBefore=new Oe(new Date),this.notAfter=new Oe(new Date),e&&(this.notBefore=new Oe(e.notBefore),this.notAfter=new Oe(e.notAfter))}}u([g({type:Oe})],ui.prototype,"notBefore",void 0);u([g({type:Oe})],ui.prototype,"notAfter",void 0);var oc;let ot=class ug{constructor(e={}){this.extnID="",this.critical=ug.CRITICAL,this.extnValue=new de,Object.assign(this,e)}};ot.CRITICAL=!1;u([g({type:b.ObjectIdentifier})],ot.prototype,"extnID",void 0);u([g({type:b.Boolean,defaultValue:ot.CRITICAL})],ot.prototype,"critical",void 0);u([g({type:de})],ot.prototype,"extnValue",void 0);let nn=oc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,oc.prototype)}};nn=oc=u([R({type:B.Sequence,itemType:ot})],nn);var En;(function(t){t[t.v1=0]="v1",t[t.v2=1]="v2",t[t.v3=2]="v3"})(En||(En={}));class nt{constructor(e={}){this.version=En.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new F,this.issuer=new xe,this.validity=new ui,this.subject=new xe,this.subjectPublicKeyInfo=new ht,Object.assign(this,e)}}u([g({type:b.Integer,context:0,defaultValue:En.v1})],nt.prototype,"version",void 0);u([g({type:b.Integer,converter:_e})],nt.prototype,"serialNumber",void 0);u([g({type:F})],nt.prototype,"signature",void 0);u([g({type:xe})],nt.prototype,"issuer",void 0);u([g({type:ui})],nt.prototype,"validity",void 0);u([g({type:xe})],nt.prototype,"subject",void 0);u([g({type:ht})],nt.prototype,"subjectPublicKeyInfo",void 0);u([g({type:b.BitString,context:1,implicit:!0,optional:!0})],nt.prototype,"issuerUniqueID",void 0);u([g({type:b.BitString,context:2,implicit:!0,optional:!0})],nt.prototype,"subjectUniqueID",void 0);u([g({type:nn,context:3,optional:!0})],nt.prototype,"extensions",void 0);class In{constructor(e={}){this.tbsCertificate=new nt,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:nt})],In.prototype,"tbsCertificate",void 0);u([g({type:F})],In.prototype,"signatureAlgorithm",void 0);u([g({type:b.BitString})],In.prototype,"signatureValue",void 0);class Co{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Oe,Object.assign(this,e)}}u([g({type:b.Integer,converter:_e})],Co.prototype,"userCertificate",void 0);u([g({type:Oe})],Co.prototype,"revocationDate",void 0);u([g({type:ot,optional:!0,repeated:"sequence"})],Co.prototype,"crlEntryExtensions",void 0);class Kt{constructor(e={}){this.signature=new F,this.issuer=new xe,this.thisUpdate=new Oe,Object.assign(this,e)}}u([g({type:b.Integer,optional:!0})],Kt.prototype,"version",void 0);u([g({type:F})],Kt.prototype,"signature",void 0);u([g({type:xe})],Kt.prototype,"issuer",void 0);u([g({type:Oe})],Kt.prototype,"thisUpdate",void 0);u([g({type:Oe,optional:!0})],Kt.prototype,"nextUpdate",void 0);u([g({type:Co,repeated:"sequence",optional:!0})],Kt.prototype,"revokedCertificates",void 0);u([g({type:ot,optional:!0,context:0,repeated:"sequence"})],Kt.prototype,"crlExtensions",void 0);class Rl{constructor(e={}){this.tbsCertList=new Kt,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:Kt})],Rl.prototype,"tbsCertList",void 0);u([g({type:F})],Rl.prototype,"signatureAlgorithm",void 0);u([g({type:b.BitString})],Rl.prototype,"signature",void 0);class yr{constructor(e={}){this.issuer=new xe,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:xe})],yr.prototype,"issuer",void 0);u([g({type:b.Integer,converter:_e})],yr.prototype,"serialNumber",void 0);let rr=class{constructor(e={}){Object.assign(this,e)}};u([g({type:Qt,context:0,implicit:!0})],rr.prototype,"subjectKeyIdentifier",void 0);u([g({type:yr})],rr.prototype,"issuerAndSerialNumber",void 0);rr=u([R({type:B.Choice})],rr);var Vt;(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"})(Vt||(Vt={}));let Fr=class extends F{};Fr=u([R({type:B.Sequence})],Fr);let bs=class extends F{};bs=u([R({type:B.Sequence})],bs);let Ct=class extends F{};Ct=u([R({type:B.Sequence})],Ct);let xs=class extends F{};xs=u([R({type:B.Sequence})],xs);let wu=class extends F{};wu=u([R({type:B.Sequence})],wu);let ac=class extends F{};ac=u([R({type:B.Sequence})],ac);let wr=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};u([g({type:b.ObjectIdentifier})],wr.prototype,"attrType",void 0);u([g({type:b.Any,repeated:"set"})],wr.prototype,"attrValues",void 0);var cc;class jt{constructor(e={}){this.version=Vt.v0,this.sid=new rr,this.digestAlgorithm=new Fr,this.signatureAlgorithm=new bs,this.signature=new de,Object.assign(this,e)}}u([g({type:b.Integer})],jt.prototype,"version",void 0);u([g({type:rr})],jt.prototype,"sid",void 0);u([g({type:Fr})],jt.prototype,"digestAlgorithm",void 0);u([g({type:wr,repeated:"set",context:0,implicit:!0,optional:!0})],jt.prototype,"signedAttrs",void 0);u([g({type:bs})],jt.prototype,"signatureAlgorithm",void 0);u([g({type:de})],jt.prototype,"signature",void 0);u([g({type:wr,repeated:"set",context:1,implicit:!0,optional:!0})],jt.prototype,"unsignedAttrs",void 0);let ks=cc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,cc.prototype)}};ks=cc=u([R({type:B.Set,itemType:jt})],ks);let vu=class extends Oe{};vu=u([R({type:B.Choice})],vu);let bu=class extends jt{};bu=u([R({type:B.Sequence})],bu);class Ll{constructor(e={}){this.acIssuer=new ie,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}u([g({type:ie})],Ll.prototype,"acIssuer",void 0);u([g({type:b.Integer})],Ll.prototype,"acSerial",void 0);u([g({type:Ut,repeated:"sequence"})],Ll.prototype,"attrs",void 0);var lc;let Ss=lc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,lc.prototype)}};Ss=lc=u([R({type:B.Sequence,itemType:b.ObjectIdentifier})],Ss);class No{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}u([g({type:b.Integer,optional:!0})],No.prototype,"pathLenConstraint",void 0);u([g({type:Ss,implicit:!0,context:0,optional:!0})],No.prototype,"permittedAttrs",void 0);u([g({type:Ss,implicit:!0,context:1,optional:!0})],No.prototype,"excludedAttrs",void 0);u([g({type:b.Boolean,defaultValue:!0})],No.prototype,"permitUnSpecified",void 0);class Rn{constructor(e={}){this.issuer=new Me,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:Me})],Rn.prototype,"issuer",void 0);u([g({type:b.Integer,converter:_e})],Rn.prototype,"serial",void 0);u([g({type:b.BitString,optional:!0})],Rn.prototype,"issuerUID",void 0);var dc;(function(t){t[t.publicKey=0]="publicKey",t[t.publicKeyCert=1]="publicKeyCert",t[t.otherObjectTypes=2]="otherObjectTypes"})(dc||(dc={}));class Ln{constructor(e={}){this.digestedObjectType=dc.publicKey,this.digestAlgorithm=new F,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.Enumerated})],Ln.prototype,"digestedObjectType",void 0);u([g({type:b.ObjectIdentifier,optional:!0})],Ln.prototype,"otherObjectTypeID",void 0);u([g({type:F})],Ln.prototype,"digestAlgorithm",void 0);u([g({type:b.BitString})],Ln.prototype,"objectDigest",void 0);class jo{constructor(e={}){Object.assign(this,e)}}u([g({type:Me,optional:!0})],jo.prototype,"issuerName",void 0);u([g({type:Rn,context:0,implicit:!0,optional:!0})],jo.prototype,"baseCertificateID",void 0);u([g({type:Ln,context:1,implicit:!0,optional:!0})],jo.prototype,"objectDigestInfo",void 0);let ir=class{constructor(e={}){Object.assign(this,e)}};u([g({type:ie,repeated:"sequence"})],ir.prototype,"v1Form",void 0);u([g({type:jo,context:0,implicit:!0})],ir.prototype,"v2Form",void 0);ir=u([R({type:B.Choice})],ir);class $o{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}u([g({type:b.GeneralizedTime})],$o.prototype,"notBeforeTime",void 0);u([g({type:b.GeneralizedTime})],$o.prototype,"notAfterTime",void 0);class pi{constructor(e={}){Object.assign(this,e)}}u([g({type:Rn,implicit:!0,context:0,optional:!0})],pi.prototype,"baseCertificateID",void 0);u([g({type:Me,implicit:!0,context:1,optional:!0})],pi.prototype,"entityName",void 0);u([g({type:Ln,implicit:!0,context:2,optional:!0})],pi.prototype,"objectDigestInfo",void 0);var uc;(function(t){t[t.v2=1]="v2"})(uc||(uc={}));class vt{constructor(e={}){this.version=uc.v2,this.holder=new pi,this.issuer=new ir,this.signature=new F,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new $o,this.attributes=[],Object.assign(this,e)}}u([g({type:b.Integer})],vt.prototype,"version",void 0);u([g({type:pi})],vt.prototype,"holder",void 0);u([g({type:ir})],vt.prototype,"issuer",void 0);u([g({type:F})],vt.prototype,"signature",void 0);u([g({type:b.Integer,converter:_e})],vt.prototype,"serialNumber",void 0);u([g({type:$o})],vt.prototype,"attrCertValidityPeriod",void 0);u([g({type:Ut,repeated:"sequence"})],vt.prototype,"attributes",void 0);u([g({type:b.BitString,optional:!0})],vt.prototype,"issuerUniqueID",void 0);u([g({type:nn,optional:!0})],vt.prototype,"extensions",void 0);class Oo{constructor(e={}){this.acinfo=new vt,this.signatureAlgorithm=new F,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:vt})],Oo.prototype,"acinfo",void 0);u([g({type:F})],Oo.prototype,"signatureAlgorithm",void 0);u([g({type:b.BitString})],Oo.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 pc extends So{}class Ul{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier,implicit:!0,context:0})],Ul.prototype,"type",void 0);u([g({type:b.Any,implicit:!0,context:1})],Ul.prototype,"value",void 0);class Vl{constructor(e={}){this.policyId="",this.classList=new pc(As.unclassified),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Vl.prototype,"policyId",void 0);u([g({type:pc,defaultValue:new pc(As.unclassified)})],Vl.prototype,"classList",void 0);u([g({type:Ul,repeated:"set"})],Vl.prototype,"securityCategories",void 0);class Po{constructor(e={}){Object.assign(this,e)}}u([g({type:de})],Po.prototype,"cotets",void 0);u([g({type:b.ObjectIdentifier})],Po.prototype,"oid",void 0);u([g({type:b.Utf8String})],Po.prototype,"string",void 0);class pg{constructor(e={}){this.values=[],Object.assign(this,e)}}u([g({type:Me,implicit:!0,context:0,optional:!0})],pg.prototype,"policyAuthority",void 0);u([g({type:Po,repeated:"sequence"})],pg.prototype,"values",void 0);var fc;class To{constructor(e={}){this.targetCertificate=new Rn,Object.assign(this,e)}}u([g({type:Rn})],To.prototype,"targetCertificate",void 0);u([g({type:ie,optional:!0})],To.prototype,"targetName",void 0);u([g({type:Ln,optional:!0})],To.prototype,"certDigestInfo",void 0);let sr=class{constructor(e={}){Object.assign(this,e)}};u([g({type:ie,context:0,implicit:!0})],sr.prototype,"targetName",void 0);u([g({type:ie,context:1,implicit:!0})],sr.prototype,"targetGroup",void 0);u([g({type:To,context:2,implicit:!0})],sr.prototype,"targetCert",void 0);sr=u([R({type:B.Choice})],sr);let hc=fc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,fc.prototype)}};hc=fc=u([R({type:B.Sequence,itemType:sr})],hc);var gc;let xu=gc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,gc.prototype)}};xu=gc=u([R({type:B.Sequence,itemType:hc})],xu);class fg{constructor(e={}){Object.assign(this,e)}}u([g({type:Me,implicit:!0,context:0,optional:!0})],fg.prototype,"roleAuthority",void 0);u([g({type:ie,implicit:!0,context:1})],fg.prototype,"roleName",void 0);class ql{constructor(e={}){this.service=new ie,this.ident=new ie,Object.assign(this,e)}}u([g({type:ie})],ql.prototype,"service",void 0);u([g({type:ie})],ql.prototype,"ident",void 0);u([g({type:de,optional:!0})],ql.prototype,"authInfo",void 0);var mc;class Ml{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Ml.prototype,"otherCertFormat",void 0);u([g({type:b.Any})],Ml.prototype,"otherCert",void 0);let or=class{constructor(e={}){Object.assign(this,e)}};u([g({type:In})],or.prototype,"certificate",void 0);u([g({type:Oo,context:2,implicit:!0})],or.prototype,"v2AttrCert",void 0);u([g({type:Ml,context:3,implicit:!0})],or.prototype,"other",void 0);or=u([R({type:B.Choice})],or);let zs=mc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,mc.prototype)}};zs=mc=u([R({type:B.Set,itemType:or})],zs);class vr{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],vr.prototype,"contentType",void 0);u([g({type:b.Any,context:0})],vr.prototype,"content",void 0);let Kr=class{constructor(e={}){Object.assign(this,e)}};u([g({type:de})],Kr.prototype,"single",void 0);u([g({type:b.Any})],Kr.prototype,"any",void 0);Kr=u([R({type:B.Choice})],Kr);class Bo{constructor(e={}){this.eContentType="",Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Bo.prototype,"eContentType",void 0);u([g({type:Kr,context:0,optional:!0})],Bo.prototype,"eContent",void 0);let Wr=class{constructor(e={}){Object.assign(this,e)}};u([g({type:de,context:0,implicit:!0,optional:!0})],Wr.prototype,"value",void 0);u([g({type:de,converter:dw,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Wr.prototype,"constructedValue",void 0);Wr=u([R({type:B.Choice})],Wr);class fi{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new xs,Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],fi.prototype,"contentType",void 0);u([g({type:xs})],fi.prototype,"contentEncryptionAlgorithm",void 0);u([g({type:Wr,optional:!0})],fi.prototype,"encryptedContent",void 0);class Ro{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Ro.prototype,"keyAttrId",void 0);u([g({type:b.Any,optional:!0})],Ro.prototype,"keyAttr",void 0);var _c;class Lo{constructor(e={}){this.subjectKeyIdentifier=new Qt,Object.assign(this,e)}}u([g({type:Qt})],Lo.prototype,"subjectKeyIdentifier",void 0);u([g({type:b.GeneralizedTime,optional:!0})],Lo.prototype,"date",void 0);u([g({type:Ro,optional:!0})],Lo.prototype,"other",void 0);let ar=class{constructor(e={}){Object.assign(this,e)}};u([g({type:Lo,context:0,implicit:!0,optional:!0})],ar.prototype,"rKeyId",void 0);u([g({type:yr,optional:!0})],ar.prototype,"issuerAndSerialNumber",void 0);ar=u([R({type:B.Choice})],ar);class Hl{constructor(e={}){this.rid=new ar,this.encryptedKey=new de,Object.assign(this,e)}}u([g({type:ar})],Hl.prototype,"rid",void 0);u([g({type:de})],Hl.prototype,"encryptedKey",void 0);let Es=_c=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,_c.prototype)}};Es=_c=u([R({type:B.Sequence,itemType:Hl})],Es);class Dl{constructor(e={}){this.algorithm=new F,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:F})],Dl.prototype,"algorithm",void 0);u([g({type:b.BitString})],Dl.prototype,"publicKey",void 0);let Cn=class{constructor(e={}){Object.assign(this,e)}};u([g({type:Qt,context:0,implicit:!0,optional:!0})],Cn.prototype,"subjectKeyIdentifier",void 0);u([g({type:Dl,context:1,implicit:!0,optional:!0})],Cn.prototype,"originatorKey",void 0);u([g({type:yr,optional:!0})],Cn.prototype,"issuerAndSerialNumber",void 0);Cn=u([R({type:B.Choice})],Cn);class br{constructor(e={}){this.version=Vt.v3,this.originator=new Cn,this.keyEncryptionAlgorithm=new Ct,this.recipientEncryptedKeys=new Es,Object.assign(this,e)}}u([g({type:b.Integer})],br.prototype,"version",void 0);u([g({type:Cn,context:0})],br.prototype,"originator",void 0);u([g({type:de,context:1,optional:!0})],br.prototype,"ukm",void 0);u([g({type:Ct})],br.prototype,"keyEncryptionAlgorithm",void 0);u([g({type:Es})],br.prototype,"recipientEncryptedKeys",void 0);let cr=class{constructor(e={}){Object.assign(this,e)}};u([g({type:Qt,context:0,implicit:!0})],cr.prototype,"subjectKeyIdentifier",void 0);u([g({type:yr})],cr.prototype,"issuerAndSerialNumber",void 0);cr=u([R({type:B.Choice})],cr);class hi{constructor(e={}){this.version=Vt.v0,this.rid=new cr,this.keyEncryptionAlgorithm=new Ct,this.encryptedKey=new de,Object.assign(this,e)}}u([g({type:b.Integer})],hi.prototype,"version",void 0);u([g({type:cr})],hi.prototype,"rid",void 0);u([g({type:Ct})],hi.prototype,"keyEncryptionAlgorithm",void 0);u([g({type:de})],hi.prototype,"encryptedKey",void 0);class gi{constructor(e={}){this.keyIdentifier=new de,Object.assign(this,e)}}u([g({type:de})],gi.prototype,"keyIdentifier",void 0);u([g({type:b.GeneralizedTime,optional:!0})],gi.prototype,"date",void 0);u([g({type:Ro,optional:!0})],gi.prototype,"other",void 0);class mi{constructor(e={}){this.version=Vt.v4,this.kekid=new gi,this.keyEncryptionAlgorithm=new Ct,this.encryptedKey=new de,Object.assign(this,e)}}u([g({type:b.Integer})],mi.prototype,"version",void 0);u([g({type:gi})],mi.prototype,"kekid",void 0);u([g({type:Ct})],mi.prototype,"keyEncryptionAlgorithm",void 0);u([g({type:de})],mi.prototype,"encryptedKey",void 0);class _i{constructor(e={}){this.version=Vt.v0,this.keyEncryptionAlgorithm=new Ct,this.encryptedKey=new de,Object.assign(this,e)}}u([g({type:b.Integer})],_i.prototype,"version",void 0);u([g({type:ac,context:0,optional:!0})],_i.prototype,"keyDerivationAlgorithm",void 0);u([g({type:Ct})],_i.prototype,"keyEncryptionAlgorithm",void 0);u([g({type:de})],_i.prototype,"encryptedKey",void 0);class Fl{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Fl.prototype,"oriType",void 0);u([g({type:b.Any})],Fl.prototype,"oriValue",void 0);let rn=class{constructor(e={}){Object.assign(this,e)}};u([g({type:hi,optional:!0})],rn.prototype,"ktri",void 0);u([g({type:br,context:1,implicit:!0,optional:!0})],rn.prototype,"kari",void 0);u([g({type:mi,context:2,implicit:!0,optional:!0})],rn.prototype,"kekri",void 0);u([g({type:_i,context:3,implicit:!0,optional:!0})],rn.prototype,"pwri",void 0);u([g({type:Fl,context:4,implicit:!0,optional:!0})],rn.prototype,"ori",void 0);rn=u([R({type:B.Choice})],rn);var yc;let Is=yc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,yc.prototype)}};Is=yc=u([R({type:B.Set,itemType:rn})],Is);var wc;class Uo{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Uo.prototype,"otherRevInfoFormat",void 0);u([g({type:b.Any})],Uo.prototype,"otherRevInfo",void 0);let Cs=class{constructor(e={}){this.other=new Uo,Object.assign(this,e)}};u([g({type:Uo,context:1,implicit:!0})],Cs.prototype,"other",void 0);Cs=u([R({type:B.Choice})],Cs);let Ns=wc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,wc.prototype)}};Ns=wc=u([R({type:B.Set,itemType:Cs})],Ns);class Kl{constructor(e={}){Object.assign(this,e)}}u([g({type:zs,context:0,implicit:!0,optional:!0})],Kl.prototype,"certs",void 0);u([g({type:Ns,context:1,implicit:!0,optional:!0})],Kl.prototype,"crls",void 0);var vc;let bc=vc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,vc.prototype)}};bc=vc=u([R({type:B.Set,itemType:wr})],bc);class yi{constructor(e={}){this.version=Vt.v0,this.recipientInfos=new Is,this.encryptedContentInfo=new fi,Object.assign(this,e)}}u([g({type:b.Integer})],yi.prototype,"version",void 0);u([g({type:Kl,context:0,implicit:!0,optional:!0})],yi.prototype,"originatorInfo",void 0);u([g({type:Is})],yi.prototype,"recipientInfos",void 0);u([g({type:fi})],yi.prototype,"encryptedContentInfo",void 0);u([g({type:bc,context:1,implicit:!0,optional:!0})],yi.prototype,"unprotectedAttrs",void 0);const Bw="1.2.840.113549.1.7.2";var xc;let js=xc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,xc.prototype)}};js=xc=u([R({type:B.Set,itemType:Fr})],js);class xr{constructor(e={}){this.version=Vt.v0,this.digestAlgorithms=new js,this.encapContentInfo=new Bo,this.signerInfos=new ks,Object.assign(this,e)}}u([g({type:b.Integer})],xr.prototype,"version",void 0);u([g({type:js})],xr.prototype,"digestAlgorithms",void 0);u([g({type:Bo})],xr.prototype,"encapContentInfo",void 0);u([g({type:zs,context:0,implicit:!0,optional:!0})],xr.prototype,"certificates",void 0);u([g({type:Ns,context:1,implicit:!0,optional:!0})],xr.prototype,"crls",void 0);u([g({type:ks})],xr.prototype,"signerInfos",void 0);const Gr="1.2.840.10045.2.1",Wl="1.2.840.10045.4.1",hg="1.2.840.10045.4.3.1",Gl="1.2.840.10045.4.3.2",Jl="1.2.840.10045.4.3.3",Zl="1.2.840.10045.4.3.4",ku="1.2.840.10045.3.1.7",Su="1.3.132.0.34",Au="1.3.132.0.35";function wi(t){return new F({algorithm:t})}const Rw=wi(Wl);wi(hg);const Lw=wi(Gl),Uw=wi(Jl),Vw=wi(Zl);let Jr=class{constructor(e={}){Object.assign(this,e)}};u([g({type:b.ObjectIdentifier})],Jr.prototype,"fieldType",void 0);u([g({type:b.Any})],Jr.prototype,"parameters",void 0);Jr=u([R({type:B.Sequence})],Jr);class qw extends de{}let lr=class{constructor(e={}){Object.assign(this,e)}};u([g({type:b.OctetString})],lr.prototype,"a",void 0);u([g({type:b.OctetString})],lr.prototype,"b",void 0);u([g({type:b.BitString,optional:!0})],lr.prototype,"seed",void 0);lr=u([R({type:B.Sequence})],lr);var kc;(function(t){t[t.ecpVer1=1]="ecpVer1"})(kc||(kc={}));let qt=class{constructor(e={}){this.version=kc.ecpVer1,Object.assign(this,e)}};u([g({type:b.Integer})],qt.prototype,"version",void 0);u([g({type:Jr})],qt.prototype,"fieldID",void 0);u([g({type:lr})],qt.prototype,"curve",void 0);u([g({type:qw})],qt.prototype,"base",void 0);u([g({type:b.Integer,converter:_e})],qt.prototype,"order",void 0);u([g({type:b.Integer,optional:!0})],qt.prototype,"cofactor",void 0);qt=u([R({type:B.Sequence})],qt);let sn=class{constructor(e={}){Object.assign(this,e)}};u([g({type:b.ObjectIdentifier})],sn.prototype,"namedCurve",void 0);u([g({type:b.Null})],sn.prototype,"implicitCurve",void 0);u([g({type:qt})],sn.prototype,"specifiedCurve",void 0);sn=u([R({type:B.Choice})],sn);class Vo{constructor(e={}){this.version=1,this.privateKey=new de,Object.assign(this,e)}}u([g({type:b.Integer})],Vo.prototype,"version",void 0);u([g({type:de})],Vo.prototype,"privateKey",void 0);u([g({type:sn,context:0,optional:!0})],Vo.prototype,"parameters",void 0);u([g({type:b.BitString,context:1,optional:!0})],Vo.prototype,"publicKey",void 0);class $s{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.Integer,converter:_e})],$s.prototype,"r",void 0);u([g({type:b.Integer,converter:_e})],$s.prototype,"s",void 0);const Ye="1.2.840.113549.1.1",Nn=`${Ye}.1`,Mw=`${Ye}.7`,Hw=`${Ye}.9`,Rr=`${Ye}.10`,Dw=`${Ye}.2`,Fw=`${Ye}.4`,Os=`${Ye}.5`,Kw=`${Ye}.14`,Sc=`${Ye}.11`,Ps=`${Ye}.12`,Ts=`${Ye}.13`,gg=`${Ye}.15`,mg=`${Ye}.16`,Bs="1.3.14.3.2.26",_g="2.16.840.1.101.3.4.2.4",Rs="2.16.840.1.101.3.4.2.1",Ls="2.16.840.1.101.3.4.2.2",Us="2.16.840.1.101.3.4.2.3",Ww="2.16.840.1.101.3.4.2.5",Gw="2.16.840.1.101.3.4.2.6",Jw="1.2.840.113549.2.2",Zw="1.2.840.113549.2.5",qo=`${Ye}.8`;function Ie(t){return new F({algorithm:t,parameters:null})}Ie(Jw);Ie(Zw);const jn=Ie(Bs);Ie(_g);Ie(Rs);Ie(Ls);Ie(Us);Ie(Ww);Ie(Gw);const yg=new F({algorithm:qo,parameters:q.serialize(jn)}),wg=new F({algorithm:Hw,parameters:q.serialize(hs.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Ie(Nn);Ie(Dw);Ie(Fw);Ie(Os);Ie(gg);Ie(mg);Ie(Ps);Ie(Ts);Ie(gg);Ie(mg);class Mo{constructor(e={}){this.hashAlgorithm=new F(jn),this.maskGenAlgorithm=new F({algorithm:qo,parameters:q.serialize(jn)}),this.pSourceAlgorithm=new F(wg),Object.assign(this,e)}}u([g({type:F,context:0,defaultValue:jn})],Mo.prototype,"hashAlgorithm",void 0);u([g({type:F,context:1,defaultValue:yg})],Mo.prototype,"maskGenAlgorithm",void 0);u([g({type:F,context:2,defaultValue:wg})],Mo.prototype,"pSourceAlgorithm",void 0);new F({algorithm:Mw,parameters:q.serialize(new Mo)});class $n{constructor(e={}){this.hashAlgorithm=new F(jn),this.maskGenAlgorithm=new F({algorithm:qo,parameters:q.serialize(jn)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}u([g({type:F,context:0,defaultValue:jn})],$n.prototype,"hashAlgorithm",void 0);u([g({type:F,context:1,defaultValue:yg})],$n.prototype,"maskGenAlgorithm",void 0);u([g({type:b.Integer,context:2,defaultValue:20})],$n.prototype,"saltLength",void 0);u([g({type:b.Integer,context:3,defaultValue:1})],$n.prototype,"trailerField",void 0);new F({algorithm:Rr,parameters:q.serialize(new $n)});class Ho{constructor(e={}){this.digestAlgorithm=new F,this.digest=new de,Object.assign(this,e)}}u([g({type:F})],Ho.prototype,"digestAlgorithm",void 0);u([g({type:de})],Ho.prototype,"digest",void 0);var Ac;class Do{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.Integer,converter:_e})],Do.prototype,"prime",void 0);u([g({type:b.Integer,converter:_e})],Do.prototype,"exponent",void 0);u([g({type:b.Integer,converter:_e})],Do.prototype,"coefficient",void 0);let zc=Ac=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Ac.prototype)}};zc=Ac=u([R({type:B.Sequence,itemType:Do})],zc);class $t{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)}}u([g({type:b.Integer})],$t.prototype,"version",void 0);u([g({type:b.Integer,converter:_e})],$t.prototype,"modulus",void 0);u([g({type:b.Integer,converter:_e})],$t.prototype,"publicExponent",void 0);u([g({type:b.Integer,converter:_e})],$t.prototype,"privateExponent",void 0);u([g({type:b.Integer,converter:_e})],$t.prototype,"prime1",void 0);u([g({type:b.Integer,converter:_e})],$t.prototype,"prime2",void 0);u([g({type:b.Integer,converter:_e})],$t.prototype,"exponent1",void 0);u([g({type:b.Integer,converter:_e})],$t.prototype,"exponent2",void 0);u([g({type:b.Integer,converter:_e})],$t.prototype,"coefficient",void 0);u([g({type:zc,optional:!0})],$t.prototype,"otherPrimeInfos",void 0);class Yl{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.Integer,converter:_e})],Yl.prototype,"modulus",void 0);u([g({type:b.Integer,converter:_e})],Yl.prototype,"publicExponent",void 0);var Ec;(function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"})(Ec||(Ec={}));const Fe=Ec;/*! *****************************************************************************
104
104
  Copyright (c) Microsoft Corporation.
105
105
 
106
106
  Permission to use, copy, modify, and/or distribute this software for any
@@ -113,9 +113,9 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
113
113
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
114
114
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
115
115
  PERFORMANCE OF THIS SOFTWARE.
116
- ***************************************************************************** */var Ic=function(t,e){return Ic=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)r.hasOwnProperty(i)&&(n[i]=r[i])},Ic(t,e)};function Xl(t,e){Ic(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function Gw(t,e,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function c(p){try{d(r.next(p))}catch(f){a(f)}}function l(p){try{d(r.throw(p))}catch(f){a(f)}}function d(p){p.done?s(p.value):i(p.value).then(c,l)}d((r=r.apply(t,[])).next())})}function Jw(t,e){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,a;return a={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(d){return function(p){return l([d,p])}}function l(d){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,i&&(s=d[0]&2?i.return:d[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,d[1])).done)return s;switch(i=0,s&&(d=[d[0]&2,s.value]),d[0]){case 0:case 1:s=d;break;case 4:return n.label++,{value:d[1],done:!1};case 5:n.label++,i=d[1],d=[0];continue;case 7:d=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(d[0]===6||d[0]===2)){n=0;continue}if(d[0]===3&&(!s||d[1]>s[0]&&d[1]<s[3])){n.label=d[1];break}if(d[0]===6&&n.label<s[1]){n.label=s[1],s=d;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(d);break}s[2]&&n.ops.pop(),n.trys.pop();continue}d=e.call(t,n)}catch(p){d=[6,p],i=0}finally{r=s=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}function Pi(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Vs(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){a={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(a)throw a.error}}return s}function gn(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Vs(arguments[e]));return t}var Zw="injectionTokens";function Yw(t){var e=Reflect.getMetadata("design:paramtypes",t)||[],n=Reflect.getOwnMetadata(Zw,t)||{};return Object.keys(n).forEach(function(r){e[+r]=n[r]}),e}function yg(t){return!!t.useClass}function Cc(t){return!!t.useFactory}var wg=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,r={},i=!1,s,a=function(){return i||(s=e(n.wrap()),i=!0),s};return new Proxy(r,this.createHandler(a))},t.prototype.createHandler=function(e){var n={},r=function(i){n[i]=function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];s[0]=e();var c=Reflect[i];return c.apply(void 0,gn(s))}};return this.reflectMethods.forEach(r),n},t}();function Mn(t){return typeof t=="string"||typeof t=="symbol"}function Xw(t){return typeof t=="object"&&"token"in t&&"multiple"in t}function zu(t){return typeof t=="object"&&"token"in t&&"transform"in t}function Qw(t){return typeof t=="function"||t instanceof wg}function qi(t){return!!t.useToken}function Mi(t){return t.useValue!=null}function ev(t){return yg(t)||Mi(t)||qi(t)||Cc(t)}var Ql=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}(),tv=function(t){Xl(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Ql),Eu=function(){function t(){this.scopedResolutions=new Map}return t}();function nv(t,e){if(t===null)return"at position #"+e;var n=t.split(",")[e].trim();return'"'+n+'" at position #'+e}function rv(t,e,n){return n===void 0&&(n=" "),gn([t],e.message.split(`
116
+ ***************************************************************************** */var Ic=function(t,e){return Ic=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)r.hasOwnProperty(i)&&(n[i]=r[i])},Ic(t,e)};function Xl(t,e){Ic(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function Yw(t,e,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function c(p){try{d(r.next(p))}catch(f){a(f)}}function l(p){try{d(r.throw(p))}catch(f){a(f)}}function d(p){p.done?s(p.value):i(p.value).then(c,l)}d((r=r.apply(t,[])).next())})}function Xw(t,e){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,a;return a={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(d){return function(p){return l([d,p])}}function l(d){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,i&&(s=d[0]&2?i.return:d[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,d[1])).done)return s;switch(i=0,s&&(d=[d[0]&2,s.value]),d[0]){case 0:case 1:s=d;break;case 4:return n.label++,{value:d[1],done:!1};case 5:n.label++,i=d[1],d=[0];continue;case 7:d=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(d[0]===6||d[0]===2)){n=0;continue}if(d[0]===3&&(!s||d[1]>s[0]&&d[1]<s[3])){n.label=d[1];break}if(d[0]===6&&n.label<s[1]){n.label=s[1],s=d;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(d);break}s[2]&&n.ops.pop(),n.trys.pop();continue}d=e.call(t,n)}catch(p){d=[6,p],i=0}finally{r=s=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}function Pi(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Vs(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){a={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(a)throw a.error}}return s}function gn(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Vs(arguments[e]));return t}var Qw="injectionTokens";function ev(t){var e=Reflect.getMetadata("design:paramtypes",t)||[],n=Reflect.getOwnMetadata(Qw,t)||{};return Object.keys(n).forEach(function(r){e[+r]=n[r]}),e}function vg(t){return!!t.useClass}function Cc(t){return!!t.useFactory}var bg=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,r={},i=!1,s,a=function(){return i||(s=e(n.wrap()),i=!0),s};return new Proxy(r,this.createHandler(a))},t.prototype.createHandler=function(e){var n={},r=function(i){n[i]=function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];s[0]=e();var c=Reflect[i];return c.apply(void 0,gn(s))}};return this.reflectMethods.forEach(r),n},t}();function Mn(t){return typeof t=="string"||typeof t=="symbol"}function tv(t){return typeof t=="object"&&"token"in t&&"multiple"in t}function zu(t){return typeof t=="object"&&"token"in t&&"transform"in t}function nv(t){return typeof t=="function"||t instanceof bg}function qi(t){return!!t.useToken}function Mi(t){return t.useValue!=null}function rv(t){return vg(t)||Mi(t)||qi(t)||Cc(t)}var Ql=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}(),iv=function(t){Xl(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Ql),Eu=function(){function t(){this.scopedResolutions=new Map}return t}();function sv(t,e){if(t===null)return"at position #"+e;var n=t.split(",")[e].trim();return'"'+n+'" at position #'+e}function ov(t,e,n){return n===void 0&&(n=" "),gn([t],e.message.split(`
117
117
  `).map(function(r){return n+r})).join(`
118
- `)}function iv(t,e,n){var r=Vs(t.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=r[1],s=i===void 0?null:i,a=nv(s,e);return rv("Cannot inject the dependency "+a+' of "'+t.name+'" constructor. Reason:',n)}function sv(t){if(typeof t.dispose!="function")return!1;var e=t.dispose;return!(e.length>0)}var ov=function(t){Xl(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Ql),av=function(t){Xl(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Ql),cv=function(){function t(){this.preResolution=new ov,this.postResolution=new av}return t}(),vg=new Map,lv=function(){function t(e){this.parent=e,this._registry=new tv,this.interceptors=new cv,this.disposed=!1,this.disposables=new Set}return t.prototype.register=function(e,n,r){r===void 0&&(r={lifecycle:Fe.Transient}),this.ensureNotDisposed();var i;if(ev(n)?i=n:i={useClass:n},qi(i))for(var s=[e],a=i;a!=null;){var c=a.useToken;if(s.includes(c))throw new Error("Token registration cycle detected! "+gn(s,[c]).join(" -> "));s.push(c);var l=this._registry.get(c);l&&qi(l.provider)?a=l.provider:a=null}if((r.lifecycle===Fe.Singleton||r.lifecycle==Fe.ContainerScoped||r.lifecycle==Fe.ResolutionScoped)&&(Mi(i)||Cc(i)))throw new Error('Cannot use lifecycle "'+Fe[r.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:i,options:r}),this},t.prototype.registerType=function(e,n){return this.ensureNotDisposed(),Mn(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(),Mn(e)){if(Mn(n))return this.register(e,{useToken:n},{lifecycle:Fe.Singleton});if(n)return this.register(e,{useClass:n},{lifecycle:Fe.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=e;return n&&!Mn(n)&&(r=n),this.register(e,{useClass:r},{lifecycle:Fe.Singleton})},t.prototype.resolve=function(e,n){n===void 0&&(n=new Eu),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&Mn(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),r){var i=this.resolveRegistration(r,n);return this.executePostResolutionInterceptor(e,i,"Single"),i}if(Qw(e)){var i=this.construct(e,n);return this.executePostResolutionInterceptor(e,i,"Single"),i}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 r,i;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var a=Pi(this.interceptors.preResolution.getAll(e)),c=a.next();!c.done;c=a.next()){var l=c.value;l.options.frequency!="Once"&&s.push(l),l.callback(e,n)}}catch(d){r={error:d}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}this.interceptors.preResolution.setAll(e,s)}},t.prototype.executePostResolutionInterceptor=function(e,n,r){var i,s;if(this.interceptors.postResolution.has(e)){var a=[];try{for(var c=Pi(this.interceptors.postResolution.getAll(e)),l=c.next();!l.done;l=c.next()){var d=l.value;d.options.frequency!="Once"&&a.push(d),d.callback(e,n,r)}}catch(p){i={error:p}}finally{try{l&&!l.done&&(s=c.return)&&s.call(c)}finally{if(i)throw i.error}}this.interceptors.postResolution.setAll(e,a)}},t.prototype.resolveRegistration=function(e,n){if(this.ensureNotDisposed(),e.options.lifecycle===Fe.ResolutionScoped&&n.scopedResolutions.has(e))return n.scopedResolutions.get(e);var r=e.options.lifecycle===Fe.Singleton,i=e.options.lifecycle===Fe.ContainerScoped,s=r||i,a;return Mi(e.provider)?a=e.provider.useValue:qi(e.provider)?a=s?e.instance||(e.instance=this.resolve(e.provider.useToken,n)):this.resolve(e.provider.useToken,n):yg(e.provider)?a=s?e.instance||(e.instance=this.construct(e.provider.useClass,n)):this.construct(e.provider.useClass,n):Cc(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,n),e.options.lifecycle===Fe.ResolutionScoped&&n.scopedResolutions.set(e,a),a},t.prototype.resolveAll=function(e,n){var r=this;n===void 0&&(n=new Eu),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&Mn(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),i){var s=i.map(function(c){return r.resolveRegistration(c,n)});return this.executePostResolutionInterceptor(e,s,"All"),s}var a=[this.construct(e,n)];return this.executePostResolutionInterceptor(e,a,"All"),a},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 r=Pi(this._registry.entries()),i=r.next();!i.done;i=r.next()){var s=Vs(i.value,2),a=s[0],c=s[1];this._registry.setAll(a,c.filter(function(l){return!Mi(l.provider)}).map(function(l){return l.instance=void 0,l}))}}catch(l){e={error:l}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}},t.prototype.createChildContainer=function(){var e,n;this.ensureNotDisposed();var r=new t(this);try{for(var i=Pi(this._registry.entries()),s=i.next();!s.done;s=i.next()){var a=Vs(s.value,2),c=a[0],l=a[1];l.some(function(d){var p=d.options;return p.lifecycle===Fe.ContainerScoped})&&r._registry.setAll(c,l.map(function(d){return d.options.lifecycle===Fe.ContainerScoped?{provider:d.provider,options:d.options}:d}))}}catch(d){e={error:d}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r},t.prototype.beforeResolution=function(e,n,r){r===void 0&&(r={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:n,options:r})},t.prototype.afterResolution=function(e,n,r){r===void 0&&(r={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:n,options:r})},t.prototype.dispose=function(){return Gw(this,void 0,void 0,function(){var e;return Jw(this,function(n){switch(n.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(r){var i=r.dispose();i&&e.push(i)}),[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 r=this;if(e instanceof wg)return e.createProxy(function(s){return r.resolve(s,n)});var i=function(){var s=vg.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var a=s.map(r.resolveParams(n,e));return new(e.bind.apply(e,gn([void 0],a)))}();return sv(i)&&this.disposables.add(i),i},t.prototype.resolveParams=function(e,n){var r=this;return function(i,s){var a,c,l;try{return Xw(i)?zu(i)?i.multiple?(a=r.resolve(i.transform)).transform.apply(a,gn([r.resolveAll(i.token)],i.transformArgs)):(c=r.resolve(i.transform)).transform.apply(c,gn([r.resolve(i.token,e)],i.transformArgs)):i.multiple?r.resolveAll(i.token):r.resolve(i.token,e):zu(i)?(l=r.resolve(i.transform,e)).transform.apply(l,gn([r.resolve(i.token,e)],i.transformArgs)):r.resolve(i,e)}catch(d){throw new Error(iv(n,s,d))}}},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 lv;function Fo(){return function(t){vg.set(t,Yw(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 Nc;class Ko{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}u([g({type:b.ObjectIdentifier})],Ko.prototype,"attrId",void 0);u([g({type:b.Any,repeated:"set"})],Ko.prototype,"attrValues",void 0);let Iu=Nc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Nc.prototype)}};Iu=Nc=u([R({type:B.Sequence,itemType:Ko})],Iu);var jc;let Cu=jc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,jc.prototype)}};Cu=jc=u([R({type:B.Sequence,itemType:vr})],Cu);class bg{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],bg.prototype,"certId",void 0);u([g({type:b.Any,context:0})],bg.prototype,"certValue",void 0);class xg{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],xg.prototype,"crlId",void 0);u([g({type:b.Any,context:0})],xg.prototype,"crltValue",void 0);class kg extends de{}let Wo=class{constructor(e={}){this.encryptionAlgorithm=new F,this.encryptedData=new kg,Object.assign(this,e)}};u([g({type:F})],Wo.prototype,"encryptionAlgorithm",void 0);u([g({type:kg})],Wo.prototype,"encryptedData",void 0);var $c,Oc;(function(t){t[t.v1=0]="v1"})(Oc||(Oc={}));class Sg extends de{}let Pc=$c=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,$c.prototype)}};Pc=$c=u([R({type:B.Sequence,itemType:Ut})],Pc);class vi{constructor(e={}){this.version=Oc.v1,this.privateKeyAlgorithm=new F,this.privateKey=new Sg,Object.assign(this,e)}}u([g({type:b.Integer})],vi.prototype,"version",void 0);u([g({type:F})],vi.prototype,"privateKeyAlgorithm",void 0);u([g({type:Sg})],vi.prototype,"privateKey",void 0);u([g({type:Pc,implicit:!0,context:0,optional:!0})],vi.prototype,"attributes",void 0);let Nu=class extends vi{};Nu=u([R({type:B.Sequence})],Nu);let ju=class extends Wo{};ju=u([R({type:B.Sequence})],ju);class Ag{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Ag.prototype,"secretTypeId",void 0);u([g({type:b.Any,context:0})],Ag.prototype,"secretValue",void 0);class bi{constructor(e={}){this.mac=new Ho,this.macSalt=new de,this.iterations=1,Object.assign(this,e)}}u([g({type:Ho})],bi.prototype,"mac",void 0);u([g({type:de})],bi.prototype,"macSalt",void 0);u([g({type:b.Integer,defaultValue:1})],bi.prototype,"iterations",void 0);class Go{constructor(e={}){this.version=3,this.authSafe=new vr,this.macData=new bi,Object.assign(this,e)}}u([g({type:b.Integer})],Go.prototype,"version",void 0);u([g({type:vr})],Go.prototype,"authSafe",void 0);u([g({type:bi,optional:!0})],Go.prototype,"macData",void 0);var Tc;class Jo{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Jo.prototype,"bagId",void 0);u([g({type:b.Any,context:0})],Jo.prototype,"bagValue",void 0);u([g({type:Ko,repeated:"set",optional:!0})],Jo.prototype,"bagAttributes",void 0);let $u=Tc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Tc.prototype)}};$u=Tc=u([R({type:B.Sequence,itemType:Jo})],$u);var Bc,Rc,Lc;const zg="1.2.840.113549.1.9",Eg=`${zg}.7`,ed=`${zg}.14`;let qs=class extends Te{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};u([g({type:b.IA5String})],qs.prototype,"ia5String",void 0);qs=u([R({type:B.Choice})],qs);let Ou=class extends vr{};Ou=u([R({type:B.Sequence})],Ou);let Pu=class extends Go{};Pu=u([R({type:B.Sequence})],Pu);let Tu=class extends Wo{};Tu=u([R({type:B.Sequence})],Tu);let Uc=class{constructor(e=""){this.value=e}toString(){return this.value}};u([g({type:b.IA5String})],Uc.prototype,"value",void 0);Uc=u([R({type:B.Choice})],Uc);let Bu=class extends qs{};Bu=u([R({type:B.Choice})],Bu);let Ru=class extends Te{};Ru=u([R({type:B.Choice})],Ru);let Vc=class{constructor(e=new Date){this.value=e}};u([g({type:b.GeneralizedTime})],Vc.prototype,"value",void 0);Vc=u([R({type:B.Choice})],Vc);let Lu=class extends Te{};Lu=u([R({type:B.Choice})],Lu);let qc=class{constructor(e="M"){this.value=e}toString(){return this.value}};u([g({type:b.PrintableString})],qc.prototype,"value",void 0);qc=u([R({type:B.Choice})],qc);let Ms=class{constructor(e=""){this.value=e}toString(){return this.value}};u([g({type:b.PrintableString})],Ms.prototype,"value",void 0);Ms=u([R({type:B.Choice})],Ms);let Uu=class extends Ms{};Uu=u([R({type:B.Choice})],Uu);let Vu=class extends Te{};Vu=u([R({type:B.Choice})],Vu);let Mc=class{constructor(e=""){this.value=e}toString(){return this.value}};u([g({type:b.ObjectIdentifier})],Mc.prototype,"value",void 0);Mc=u([R({type:B.Choice})],Mc);let qu=class extends Oe{};qu=u([R({type:B.Choice})],qu);let Hc=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};u([g({type:b.Integer})],Hc.prototype,"value",void 0);Hc=u([R({type:B.Choice})],Hc);let Mu=class extends jt{};Mu=u([R({type:B.Sequence})],Mu);let Hs=class extends Te{};Hs=u([R({type:B.Choice})],Hs);let Hu=Bc=class extends nn{constructor(e){super(e),Object.setPrototypeOf(this,Bc.prototype)}};Hu=Bc=u([R({type:B.Sequence})],Hu);let Du=Rc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Rc.prototype)}};Du=Rc=u([R({type:B.Set,itemType:wr})],Du);let Dc=class{constructor(e=""){this.value=e}toString(){return this.value}};u([g({type:b.BmpString})],Dc.prototype,"value",void 0);Dc=u([R({type:B.Choice})],Dc);let Fc=class extends F{};Fc=u([R({type:B.Sequence})],Fc);let Fu=Lc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Lc.prototype)}};Fu=Lc=u([R({type:B.Sequence,itemType:Fc})],Fu);var Kc;let Ds=Kc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Kc.prototype)}};Ds=Kc=u([R({type:B.Sequence,itemType:Ut})],Ds);class kr{constructor(e={}){this.version=0,this.subject=new xe,this.subjectPKInfo=new ht,this.attributes=new Ds,Object.assign(this,e)}}u([g({type:b.Integer})],kr.prototype,"version",void 0);u([g({type:xe})],kr.prototype,"subject",void 0);u([g({type:ht})],kr.prototype,"subjectPKInfo",void 0);u([g({type:Ds,implicit:!0,context:0})],kr.prototype,"attributes",void 0);class Zr{constructor(e={}){this.certificationRequestInfo=new kr,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:kr})],Zr.prototype,"certificationRequestInfo",void 0);u([g({type:F})],Zr.prototype,"signatureAlgorithm",void 0);u([g({type:b.BitString})],Zr.prototype,"signature",void 0);/*!
118
+ `)}function av(t,e,n){var r=Vs(t.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=r[1],s=i===void 0?null:i,a=sv(s,e);return ov("Cannot inject the dependency "+a+' of "'+t.name+'" constructor. Reason:',n)}function cv(t){if(typeof t.dispose!="function")return!1;var e=t.dispose;return!(e.length>0)}var lv=function(t){Xl(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Ql),dv=function(t){Xl(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Ql),uv=function(){function t(){this.preResolution=new lv,this.postResolution=new dv}return t}(),xg=new Map,pv=function(){function t(e){this.parent=e,this._registry=new iv,this.interceptors=new uv,this.disposed=!1,this.disposables=new Set}return t.prototype.register=function(e,n,r){r===void 0&&(r={lifecycle:Fe.Transient}),this.ensureNotDisposed();var i;if(rv(n)?i=n:i={useClass:n},qi(i))for(var s=[e],a=i;a!=null;){var c=a.useToken;if(s.includes(c))throw new Error("Token registration cycle detected! "+gn(s,[c]).join(" -> "));s.push(c);var l=this._registry.get(c);l&&qi(l.provider)?a=l.provider:a=null}if((r.lifecycle===Fe.Singleton||r.lifecycle==Fe.ContainerScoped||r.lifecycle==Fe.ResolutionScoped)&&(Mi(i)||Cc(i)))throw new Error('Cannot use lifecycle "'+Fe[r.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:i,options:r}),this},t.prototype.registerType=function(e,n){return this.ensureNotDisposed(),Mn(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(),Mn(e)){if(Mn(n))return this.register(e,{useToken:n},{lifecycle:Fe.Singleton});if(n)return this.register(e,{useClass:n},{lifecycle:Fe.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=e;return n&&!Mn(n)&&(r=n),this.register(e,{useClass:r},{lifecycle:Fe.Singleton})},t.prototype.resolve=function(e,n){n===void 0&&(n=new Eu),this.ensureNotDisposed();var r=this.getRegistration(e);if(!r&&Mn(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),r){var i=this.resolveRegistration(r,n);return this.executePostResolutionInterceptor(e,i,"Single"),i}if(nv(e)){var i=this.construct(e,n);return this.executePostResolutionInterceptor(e,i,"Single"),i}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 r,i;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var a=Pi(this.interceptors.preResolution.getAll(e)),c=a.next();!c.done;c=a.next()){var l=c.value;l.options.frequency!="Once"&&s.push(l),l.callback(e,n)}}catch(d){r={error:d}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}this.interceptors.preResolution.setAll(e,s)}},t.prototype.executePostResolutionInterceptor=function(e,n,r){var i,s;if(this.interceptors.postResolution.has(e)){var a=[];try{for(var c=Pi(this.interceptors.postResolution.getAll(e)),l=c.next();!l.done;l=c.next()){var d=l.value;d.options.frequency!="Once"&&a.push(d),d.callback(e,n,r)}}catch(p){i={error:p}}finally{try{l&&!l.done&&(s=c.return)&&s.call(c)}finally{if(i)throw i.error}}this.interceptors.postResolution.setAll(e,a)}},t.prototype.resolveRegistration=function(e,n){if(this.ensureNotDisposed(),e.options.lifecycle===Fe.ResolutionScoped&&n.scopedResolutions.has(e))return n.scopedResolutions.get(e);var r=e.options.lifecycle===Fe.Singleton,i=e.options.lifecycle===Fe.ContainerScoped,s=r||i,a;return Mi(e.provider)?a=e.provider.useValue:qi(e.provider)?a=s?e.instance||(e.instance=this.resolve(e.provider.useToken,n)):this.resolve(e.provider.useToken,n):vg(e.provider)?a=s?e.instance||(e.instance=this.construct(e.provider.useClass,n)):this.construct(e.provider.useClass,n):Cc(e.provider)?a=e.provider.useFactory(this):a=this.construct(e.provider,n),e.options.lifecycle===Fe.ResolutionScoped&&n.scopedResolutions.set(e,a),a},t.prototype.resolveAll=function(e,n){var r=this;n===void 0&&(n=new Eu),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&Mn(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),i){var s=i.map(function(c){return r.resolveRegistration(c,n)});return this.executePostResolutionInterceptor(e,s,"All"),s}var a=[this.construct(e,n)];return this.executePostResolutionInterceptor(e,a,"All"),a},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 r=Pi(this._registry.entries()),i=r.next();!i.done;i=r.next()){var s=Vs(i.value,2),a=s[0],c=s[1];this._registry.setAll(a,c.filter(function(l){return!Mi(l.provider)}).map(function(l){return l.instance=void 0,l}))}}catch(l){e={error:l}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}},t.prototype.createChildContainer=function(){var e,n;this.ensureNotDisposed();var r=new t(this);try{for(var i=Pi(this._registry.entries()),s=i.next();!s.done;s=i.next()){var a=Vs(s.value,2),c=a[0],l=a[1];l.some(function(d){var p=d.options;return p.lifecycle===Fe.ContainerScoped})&&r._registry.setAll(c,l.map(function(d){return d.options.lifecycle===Fe.ContainerScoped?{provider:d.provider,options:d.options}:d}))}}catch(d){e={error:d}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r},t.prototype.beforeResolution=function(e,n,r){r===void 0&&(r={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:n,options:r})},t.prototype.afterResolution=function(e,n,r){r===void 0&&(r={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:n,options:r})},t.prototype.dispose=function(){return Yw(this,void 0,void 0,function(){var e;return Xw(this,function(n){switch(n.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(r){var i=r.dispose();i&&e.push(i)}),[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 r=this;if(e instanceof bg)return e.createProxy(function(s){return r.resolve(s,n)});var i=function(){var s=xg.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var a=s.map(r.resolveParams(n,e));return new(e.bind.apply(e,gn([void 0],a)))}();return cv(i)&&this.disposables.add(i),i},t.prototype.resolveParams=function(e,n){var r=this;return function(i,s){var a,c,l;try{return tv(i)?zu(i)?i.multiple?(a=r.resolve(i.transform)).transform.apply(a,gn([r.resolveAll(i.token)],i.transformArgs)):(c=r.resolve(i.transform)).transform.apply(c,gn([r.resolve(i.token,e)],i.transformArgs)):i.multiple?r.resolveAll(i.token):r.resolve(i.token,e):zu(i)?(l=r.resolve(i.transform,e)).transform.apply(l,gn([r.resolve(i.token,e)],i.transformArgs)):r.resolve(i,e)}catch(d){throw new Error(av(n,s,d))}}},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 pv;function Fo(){return function(t){xg.set(t,ev(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 Nc;class Ko{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}u([g({type:b.ObjectIdentifier})],Ko.prototype,"attrId",void 0);u([g({type:b.Any,repeated:"set"})],Ko.prototype,"attrValues",void 0);let Iu=Nc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Nc.prototype)}};Iu=Nc=u([R({type:B.Sequence,itemType:Ko})],Iu);var jc;let Cu=jc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,jc.prototype)}};Cu=jc=u([R({type:B.Sequence,itemType:vr})],Cu);class kg{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],kg.prototype,"certId",void 0);u([g({type:b.Any,context:0})],kg.prototype,"certValue",void 0);class Sg{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Sg.prototype,"crlId",void 0);u([g({type:b.Any,context:0})],Sg.prototype,"crltValue",void 0);class Ag extends de{}let Wo=class{constructor(e={}){this.encryptionAlgorithm=new F,this.encryptedData=new Ag,Object.assign(this,e)}};u([g({type:F})],Wo.prototype,"encryptionAlgorithm",void 0);u([g({type:Ag})],Wo.prototype,"encryptedData",void 0);var $c,Oc;(function(t){t[t.v1=0]="v1"})(Oc||(Oc={}));class zg extends de{}let Pc=$c=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,$c.prototype)}};Pc=$c=u([R({type:B.Sequence,itemType:Ut})],Pc);class vi{constructor(e={}){this.version=Oc.v1,this.privateKeyAlgorithm=new F,this.privateKey=new zg,Object.assign(this,e)}}u([g({type:b.Integer})],vi.prototype,"version",void 0);u([g({type:F})],vi.prototype,"privateKeyAlgorithm",void 0);u([g({type:zg})],vi.prototype,"privateKey",void 0);u([g({type:Pc,implicit:!0,context:0,optional:!0})],vi.prototype,"attributes",void 0);let Nu=class extends vi{};Nu=u([R({type:B.Sequence})],Nu);let ju=class extends Wo{};ju=u([R({type:B.Sequence})],ju);class Eg{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Eg.prototype,"secretTypeId",void 0);u([g({type:b.Any,context:0})],Eg.prototype,"secretValue",void 0);class bi{constructor(e={}){this.mac=new Ho,this.macSalt=new de,this.iterations=1,Object.assign(this,e)}}u([g({type:Ho})],bi.prototype,"mac",void 0);u([g({type:de})],bi.prototype,"macSalt",void 0);u([g({type:b.Integer,defaultValue:1})],bi.prototype,"iterations",void 0);class Go{constructor(e={}){this.version=3,this.authSafe=new vr,this.macData=new bi,Object.assign(this,e)}}u([g({type:b.Integer})],Go.prototype,"version",void 0);u([g({type:vr})],Go.prototype,"authSafe",void 0);u([g({type:bi,optional:!0})],Go.prototype,"macData",void 0);var Tc;class Jo{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:b.ObjectIdentifier})],Jo.prototype,"bagId",void 0);u([g({type:b.Any,context:0})],Jo.prototype,"bagValue",void 0);u([g({type:Ko,repeated:"set",optional:!0})],Jo.prototype,"bagAttributes",void 0);let $u=Tc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Tc.prototype)}};$u=Tc=u([R({type:B.Sequence,itemType:Jo})],$u);var Bc,Rc,Lc;const Ig="1.2.840.113549.1.9",Cg=`${Ig}.7`,ed=`${Ig}.14`;let qs=class extends Te{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};u([g({type:b.IA5String})],qs.prototype,"ia5String",void 0);qs=u([R({type:B.Choice})],qs);let Ou=class extends vr{};Ou=u([R({type:B.Sequence})],Ou);let Pu=class extends Go{};Pu=u([R({type:B.Sequence})],Pu);let Tu=class extends Wo{};Tu=u([R({type:B.Sequence})],Tu);let Uc=class{constructor(e=""){this.value=e}toString(){return this.value}};u([g({type:b.IA5String})],Uc.prototype,"value",void 0);Uc=u([R({type:B.Choice})],Uc);let Bu=class extends qs{};Bu=u([R({type:B.Choice})],Bu);let Ru=class extends Te{};Ru=u([R({type:B.Choice})],Ru);let Vc=class{constructor(e=new Date){this.value=e}};u([g({type:b.GeneralizedTime})],Vc.prototype,"value",void 0);Vc=u([R({type:B.Choice})],Vc);let Lu=class extends Te{};Lu=u([R({type:B.Choice})],Lu);let qc=class{constructor(e="M"){this.value=e}toString(){return this.value}};u([g({type:b.PrintableString})],qc.prototype,"value",void 0);qc=u([R({type:B.Choice})],qc);let Ms=class{constructor(e=""){this.value=e}toString(){return this.value}};u([g({type:b.PrintableString})],Ms.prototype,"value",void 0);Ms=u([R({type:B.Choice})],Ms);let Uu=class extends Ms{};Uu=u([R({type:B.Choice})],Uu);let Vu=class extends Te{};Vu=u([R({type:B.Choice})],Vu);let Mc=class{constructor(e=""){this.value=e}toString(){return this.value}};u([g({type:b.ObjectIdentifier})],Mc.prototype,"value",void 0);Mc=u([R({type:B.Choice})],Mc);let qu=class extends Oe{};qu=u([R({type:B.Choice})],qu);let Hc=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};u([g({type:b.Integer})],Hc.prototype,"value",void 0);Hc=u([R({type:B.Choice})],Hc);let Mu=class extends jt{};Mu=u([R({type:B.Sequence})],Mu);let Hs=class extends Te{};Hs=u([R({type:B.Choice})],Hs);let Hu=Bc=class extends nn{constructor(e){super(e),Object.setPrototypeOf(this,Bc.prototype)}};Hu=Bc=u([R({type:B.Sequence})],Hu);let Du=Rc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Rc.prototype)}};Du=Rc=u([R({type:B.Set,itemType:wr})],Du);let Dc=class{constructor(e=""){this.value=e}toString(){return this.value}};u([g({type:b.BmpString})],Dc.prototype,"value",void 0);Dc=u([R({type:B.Choice})],Dc);let Fc=class extends F{};Fc=u([R({type:B.Sequence})],Fc);let Fu=Lc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Lc.prototype)}};Fu=Lc=u([R({type:B.Sequence,itemType:Fc})],Fu);var Kc;let Ds=Kc=class extends fe{constructor(e){super(e),Object.setPrototypeOf(this,Kc.prototype)}};Ds=Kc=u([R({type:B.Sequence,itemType:Ut})],Ds);class kr{constructor(e={}){this.version=0,this.subject=new xe,this.subjectPKInfo=new ht,this.attributes=new Ds,Object.assign(this,e)}}u([g({type:b.Integer})],kr.prototype,"version",void 0);u([g({type:xe})],kr.prototype,"subject",void 0);u([g({type:ht})],kr.prototype,"subjectPKInfo",void 0);u([g({type:Ds,implicit:!0,context:0})],kr.prototype,"attributes",void 0);class Zr{constructor(e={}){this.certificationRequestInfo=new kr,this.signatureAlgorithm=new F,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}u([g({type:kr})],Zr.prototype,"certificationRequestInfo",void 0);u([g({type:F})],Zr.prototype,"signatureAlgorithm",void 0);u([g({type:b.BitString})],Zr.prototype,"signature",void 0);/*!
119
119
  * MIT License
120
120
  *
121
121
  * Copyright (c) Peculiar Ventures. All rights reserved.
@@ -138,15 +138,15 @@ PERFORMANCE OF THIS SOFTWARE.
138
138
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
139
139
  * SOFTWARE.
140
140
  *
141
- */const xi="crypto.algorithm";class dv{getAlgorithms(){return Be.resolveAll(xi)}toAsnAlgorithm(e){({...e});for(const n of this.getAlgorithms()){const r=n.toAsnAlgorithm(e);if(r)return r}if(/^[0-9.]+$/.test(e.name)){const n=new F({algorithm:e.name});if("parameters"in e){const r=e;n.parameters=r.parameters}return n}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(const r of this.getAlgorithms()){const i=r.toWebAlgorithm(e);if(i)return i}return{name:e.algorithm,parameters:e.parameters}}}const On="crypto.algorithmProvider";Be.registerSingleton(On,dv);var Hi;const Xe="1.3.36.3.3.2.8.1.1",Ku=`${Xe}.1`,Wu=`${Xe}.2`,Gu=`${Xe}.3`,Ju=`${Xe}.4`,Zu=`${Xe}.5`,Yu=`${Xe}.6`,Xu=`${Xe}.7`,Qu=`${Xe}.8`,ep=`${Xe}.9`,tp=`${Xe}.10`,np=`${Xe}.11`,rp=`${Xe}.12`,ip=`${Xe}.13`,sp=`${Xe}.14`,op="brainpoolP160r1",ap="brainpoolP160t1",cp="brainpoolP192r1",lp="brainpoolP192t1",dp="brainpoolP224r1",up="brainpoolP224t1",pp="brainpoolP256r1",fp="brainpoolP256t1",hp="brainpoolP320r1",gp="brainpoolP320t1",mp="brainpoolP384r1",_p="brainpoolP384t1",yp="brainpoolP512r1",wp="brainpoolP512t1",ye="ECDSA";let Yr=Hi=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 Pw;case"sha-256":return Tw;case"sha-384":return Bw;case"sha-512":return Rw}else if("namedCurve"in e){let n="";switch(e.namedCurve){case"P-256":n=ku;break;case"K-256":n=Hi.SECP256K1;break;case"P-384":n=Su;break;case"P-521":n=Au;break;case op:n=Ku;break;case ap:n=Wu;break;case cp:n=Gu;break;case lp:n=Ju;break;case dp:n=Zu;break;case up:n=Yu;break;case pp:n=Xu;break;case fp:n=Qu;break;case hp:n=ep;break;case gp:n=tp;break;case mp:n=np;break;case _p:n=rp;break;case yp:n=ip;break;case wp:n=sp;break}if(n)return new F({algorithm:Gr,parameters:q.serialize(new sn({namedCurve:n}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case Wl:return{name:ye,hash:{name:"SHA-1"}};case Gl:return{name:ye,hash:{name:"SHA-256"}};case Jl:return{name:ye,hash:{name:"SHA-384"}};case Zl:return{name:ye,hash:{name:"SHA-512"}};case Gr:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(q.parse(e.parameters,sn).namedCurve){case ku:return{name:ye,namedCurve:"P-256"};case Hi.SECP256K1:return{name:ye,namedCurve:"K-256"};case Su:return{name:ye,namedCurve:"P-384"};case Au:return{name:ye,namedCurve:"P-521"};case Ku:return{name:ye,namedCurve:op};case Wu:return{name:ye,namedCurve:ap};case Gu:return{name:ye,namedCurve:cp};case Ju:return{name:ye,namedCurve:lp};case Zu:return{name:ye,namedCurve:dp};case Yu:return{name:ye,namedCurve:up};case Xu:return{name:ye,namedCurve:pp};case Qu:return{name:ye,namedCurve:fp};case ep:return{name:ye,namedCurve:hp};case tp:return{name:ye,namedCurve:gp};case np:return{name:ye,namedCurve:mp};case rp:return{name:ye,namedCurve:_p};case ip:return{name:ye,namedCurve:yp};case sp:return{name:ye,namedCurve:wp}}}}return null}};Yr.SECP256K1="1.3.132.0.10";Yr=Hi=u([Fo()],Yr);Be.registerSingleton(xi,Yr);const Ig=Symbol("name"),Cg=Symbol("value");class pe{constructor(e,n={},r=""){this[Ig]=e,this[Cg]=r;for(const i in n)this[i]=n[i]}}pe.NAME=Ig;pe.VALUE=Cg;class uv{static toTextObject(e){const n=new pe("Algorithm Identifier",{},un.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case Gr:{const r=new Yr().toWebAlgorithm(e);r&&"namedCurve"in r?n["Named Curve"]=r.namedCurve:n.Parameters=e.parameters;break}default:n.Parameters=e.parameters}return n}}class un{static toString(e){const n=this.items[e];return n||e}}un.items={[Bs]:"sha1",[gg]:"sha224",[Rs]:"sha256",[Ls]:"sha384",[Us]:"sha512",[Nn]:"rsaEncryption",[Os]:"sha1WithRSAEncryption",[Hw]:"sha224WithRSAEncryption",[Sc]:"sha256WithRSAEncryption",[Ps]:"sha384WithRSAEncryption",[Ts]:"sha512WithRSAEncryption",[Gr]:"ecPublicKey",[Wl]:"ecdsaWithSHA1",[pg]:"ecdsaWithSHA224",[Gl]:"ecdsaWithSHA256",[Jl]:"ecdsaWithSHA384",[Zl]:"ecdsaWithSHA512",[Ew]:"TLS WWW server authentication",[Iw]:"TLS WWW client authentication",[Cw]:"Code Signing",[Nw]:"E-mail Protection",[jw]:"Time Stamping",[$w]:"OCSP Signing",[Ow]:"Signed Data"};class Pn{static serialize(e){return this.serializeObj(e).join(`
142
- `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,n=0){const r=[];let i=this.pad(n++),s="";const a=e[pe.VALUE];a&&(s=` ${a}`),r.push(`${i}${e[pe.NAME]}:${s}`),i=this.pad(n);for(const c in e){if(typeof c=="symbol")continue;const l=e[c],d=c?`${c}: `:"";if(typeof l=="string"||typeof l=="number"||typeof l=="boolean")r.push(`${i}${d}${l}`);else if(l instanceof Date)r.push(`${i}${d}${l.toUTCString()}`);else if(Array.isArray(l))for(const p of l)p[pe.NAME]=c,r.push(...this.serializeObj(p,n));else if(l instanceof pe)l[pe.NAME]=c,r.push(...this.serializeObj(l,n));else if(M.isBufferSource(l))c?(r.push(`${i}${d}`),r.push(...this.serializeBufferSource(l,n+1))):r.push(...this.serializeBufferSource(l,n));else if("toTextObject"in l){const p=l.toTextObject();p[pe.NAME]=c,r.push(...this.serializeObj(p,n))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return r}static serializeBufferSource(e,n=0){const r=this.pad(n),i=M.toUint8Array(e),s=[];for(let a=0;a<i.length;){const c=[];for(let l=0;l<16&&a<i.length;l++){l===8&&c.push("");const d=i[a++].toString(16).padStart(2,"0");c.push(d)}s.push(`${r}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}Pn.oidSerializer=un;Pn.algorithmSerializer=uv;class pn{constructor(...e){if(e.length===1){const n=e[0];this.rawData=q.serialize(n),this.onInit(n)}else{const n=q.parse(e[0],e[1]);this.rawData=M.toArrayBuffer(e[0]),this.onInit(n)}}equal(e){return e instanceof pn?Gf(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return q.toString(this.rawData);case"text":return Pn.serialize(this.toTextObject());case"hex":return J.ToHex(this.rawData);case"base64":return J.ToBase64(this.rawData);case"base64url":return J.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 pe(this.getTextName(),{},e)}}pn.NAME="ASN";class lt extends pn{constructor(...e){let n;M.isBufferSource(e[0])?n=M.toArrayBuffer(e[0]):n=q.serialize(new ot({extnID:e[0],critical:e[1],extnValue:new de(M.toArrayBuffer(e[2]))})),super(n,ot)}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[pe.NAME]===lt.NAME&&(e[pe.NAME]=un.toString(this.type)),e}}var Ng;class Zt{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[Ng]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(Zt.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(Zt.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=Zt.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(Zt.DEFAULT,e);return this}}Ng=Symbol.toStringTag;Zt.DEFAULT="default";const $e=new Zt,pv=/^[0-2](?:\.[1-9][0-9]*)+$/;function fv(t){return new RegExp(pv).test(t)}class jg{constructor(e={}){this.items={};for(const n in e)this.register(n,e[n])}get(e){return this.items[e]||null}findId(e){return fv(e)?e:this.get(e)}register(e,n){this.items[e]=n,this.items[n]=e}}const Je=new jg;Je.register("CN","2.5.4.3");Je.register("L","2.5.4.7");Je.register("ST","2.5.4.8");Je.register("O","2.5.4.10");Je.register("OU","2.5.4.11");Je.register("C","2.5.4.6");Je.register("DC","0.9.2342.19200300.100.1.25");Je.register("E","1.2.840.113549.1.9.1");Je.register("G","2.5.4.42");Je.register("I","2.5.4.43");Je.register("SN","2.5.4.4");Je.register("T","2.5.4.12");function hv(t,e){return`\\${J.ToHex(J.FromUtf8String(e)).toUpperCase()}`}function gv(t){return t.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,hv)}class it{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 jg,this.asn=new xe;for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const i=n[r];this.extraNames.register(r,i)}typeof e=="string"?this.asn=this.fromString(e):e instanceof xe?this.asn=e:M.isBufferSource(e)?this.asn=q.parse(e,xe):this.asn=this.fromJSON(e)}getField(e){const n=this.extraNames.findId(e)||Je.findId(e),r=[];for(const i of this.asn)for(const s of i)s.type===n&&r.push(s.value.toString());return r}getName(e){return this.extraNames.get(e)||Je.get(e)}toString(){return this.asn.map(e=>e.map(n=>{const r=this.getName(n.type)||n.type,i=n.value.anyValue?`#${J.ToHex(n.value.anyValue)}`:gv(n.value.toString());return`${r}=${i}`}).join("+")).join(", ")}toJSON(){var e;const n=[];for(const r of this.asn){const i={};for(const s of r){const a=this.getName(s.type)||s.type;(e=i[a])!==null&&e!==void 0||(i[a]=[]),i[a].push(s.value.anyValue?`#${J.ToHex(s.value.anyValue)}`:s.value.toString())}n.push(i)}return n}fromString(e){const n=new xe,r=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,s=",";for(;i=r.exec(`${e},`);){let[,a,c]=i;const l=c[c.length-1];(l===","||l==="+")&&(c=c.slice(0,c.length-1),i[3]=l);const d=i[3];a=this.getTypeOid(a);const p=this.createAttribute(a,c);s==="+"?n[n.length-1].push(p):n.push(new nr([p])),s=d}return n}fromJSON(e){const n=new xe;for(const r of e){const i=new nr;for(const s in r){const a=this.getTypeOid(s),c=r[s];for(const l of c){const d=this.createAttribute(a,l);i.push(d)}}n.push(i)}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 r=new Ao({type:e});if(typeof n=="object")for(const i in n)switch(i){case"ia5String":r.value.ia5String=n[i];break;case"utf8String":r.value.utf8String=n[i];break;case"universalString":r.value.universalString=n[i];break;case"bmpString":r.value.bmpString=n[i];break;case"printableString":r.value.printableString=n[i];break}else if(n[0]==="#")r.value.anyValue=J.FromHex(n.slice(1));else{const i=this.processStringValue(n);e===this.getName("E")||e===this.getName("DC")?r.value.ia5String=i:it.isPrintableString(i)?r.value.printableString=i:r.value.utf8String=i}return r}processStringValue(e){const n=/"(.*?[^\\])?"/.exec(e);return n&&(e=n[1]),e.replace(/\\0a/ig,`
143
- `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return q.serialize(this.asn)}async getThumbprint(...e){var n;let r,i="SHA-1";return e.length>=1&&!(!((n=e[0])===null||n===void 0)&&n.subtle)?(i=e[0]||i,r=e[1]||$e.get()):r=e[0]||$e.get(),await r.subtle.digest(i,this.toArrayBuffer())}}const $g="Cannot initialize GeneralName from ASN.1 data.",vp=`${$g} Unsupported string format in use.`,mv=`${$g} Value doesn't match to GUID regular expression.`,bp=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,xp="1.3.6.1.4.1.311.25.1",kp="1.3.6.1.4.1.311.20.2.3",aa="dns",ca="dn",la="email",da="ip",ua="url",pa="guid",fa="upn",Ti="id";class Yt extends pn{constructor(...e){let n;if(e.length===2)switch(e[0]){case ca:{const r=new it(e[1]).toArrayBuffer(),i=q.parse(r,xe);n=new ie({directoryName:i});break}case aa:n=new ie({dNSName:e[1]});break;case la:n=new ie({rfc822Name:e[1]});break;case pa:{const r=new RegExp(bp,"i").exec(e[1]);if(!r)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=r.slice(1).map((s,a)=>a<3?J.ToHex(new Uint8Array(J.FromHex(s)).reverse()):s).join("");n=new ie({otherName:new Dr({typeId:xp,value:q.serialize(new de(J.FromHex(i)))})});break}case da:n=new ie({iPAddress:e[1]});break;case Ti:n=new ie({registeredID:e[1]});break;case fa:{n=new ie({otherName:new Dr({typeId:kp,value:q.serialize(Gh.toASN(e[1]))})});break}case ua:n=new ie({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else M.isBufferSource(e[0])?n=q.parse(e[0],ie):n=e[0];super(n)}onInit(e){if(e.dNSName!=null)this.type=aa,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=la,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=da,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=ua,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=Ti,this.value=e.registeredID;else if(e.directoryName!=null)this.type=ca,this.value=new it(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===xp){this.type=pa;const n=q.parse(e.otherName.value,de),r=new RegExp(bp,"i").exec(J.ToHex(n));if(!r)throw new Error(mv);this.value=r.slice(1).map((i,s)=>s<3?J.ToHex(new Uint8Array(J.FromHex(i)).reverse()):i).join("-")}else if(e.otherName.typeId===kp)this.type=fa,this.value=q.parse(e.otherName.value,Te).toString();else throw new Error(vp);else throw new Error(vp)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case ca:case aa:case pa:case da:case Ti:case fa:case ua:e=this.type.toUpperCase();break;case la:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let n=this.value;return this.type===Ti&&(n=un.toString(n)),new pe(e,void 0,n)}}class Xr extends pn{constructor(e){let n;if(e instanceof Me)n=e;else if(Array.isArray(e)){const r=[];for(const i of e)if(i instanceof ie)r.push(i);else{const s=q.parse(new Yt(i.type,i.value).rawData,ie);r.push(s)}n=new Me(r)}else if(M.isBufferSource(e))n=q.parse(e,Me);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(n)}onInit(e){const n=[];for(const r of e){let i=null;try{i=new Yt(r)}catch{continue}n.push(i)}this.items=n}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){const e=super.toTextObjectEmpty();for(const n of this.items){const r=n.toTextObject();let i=e[r[pe.NAME]];Array.isArray(i)||(i=[],e[r[pe.NAME]]=i),i.push(r)}return e}}Xr.NAME="GeneralNames";const Lr="-{5}",Qr="\\n",_v=`[^${Qr}]+`,yv=`${Lr}BEGIN (${_v}(?=${Lr}))${Lr}`,wv=`${Lr}END \\1${Lr}`,dr="\\n",vv=`[^:${Qr}]+`,bv=`(?:[^${Qr}]+${dr}(?: +[^${Qr}]+${dr})*)`,xv="[a-zA-Z0-9=+/]+",kv=`(?:${xv}${dr})+`,Sp=`${yv}${dr}(?:((?:${vv}: ${bv})+))?${dr}?(${kv})${wv}`;class et{static isPem(e){return typeof e=="string"&&new RegExp(Sp,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const n=new RegExp(Sp,"g"),r=[];let i=null;for(;i=n.exec(e);){const s=i[3].replace(new RegExp(`[${Qr}]+`,"g"),""),a={type:i[1],headers:[],rawData:J.FromBase64(s)},c=i[2];if(c){const l=c.split(new RegExp(dr,"g"));let d=null;for(const p of l){const[f,m]=p.split(/:(.*)/);if(m===void 0){if(!d)throw new Error("Cannot parse PEM string. Incorrect header value");d.value+=f.trim()}else d&&a.headers.push(d),d={key:f,value:m.trim()}}d&&a.headers.push(d)}r.push(a)}return r}static decode(e){return this.decodeWithHeaders(e).map(r=>r.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 r=new Array;return n?e.forEach(i=>{if(!M.isBufferSource(i))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");r.push(this.encodeStruct({type:n,rawData:M.toArrayBuffer(i)}))}):e.forEach(i=>{if(!("type"in i))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");r.push(this.encodeStruct(i))}),r.join(`
141
+ */const xi="crypto.algorithm";class fv{getAlgorithms(){return Be.resolveAll(xi)}toAsnAlgorithm(e){({...e});for(const n of this.getAlgorithms()){const r=n.toAsnAlgorithm(e);if(r)return r}if(/^[0-9.]+$/.test(e.name)){const n=new F({algorithm:e.name});if("parameters"in e){const r=e;n.parameters=r.parameters}return n}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(const r of this.getAlgorithms()){const i=r.toWebAlgorithm(e);if(i)return i}return{name:e.algorithm,parameters:e.parameters}}}const On="crypto.algorithmProvider";Be.registerSingleton(On,fv);var Hi;const Xe="1.3.36.3.3.2.8.1.1",Ku=`${Xe}.1`,Wu=`${Xe}.2`,Gu=`${Xe}.3`,Ju=`${Xe}.4`,Zu=`${Xe}.5`,Yu=`${Xe}.6`,Xu=`${Xe}.7`,Qu=`${Xe}.8`,ep=`${Xe}.9`,tp=`${Xe}.10`,np=`${Xe}.11`,rp=`${Xe}.12`,ip=`${Xe}.13`,sp=`${Xe}.14`,op="brainpoolP160r1",ap="brainpoolP160t1",cp="brainpoolP192r1",lp="brainpoolP192t1",dp="brainpoolP224r1",up="brainpoolP224t1",pp="brainpoolP256r1",fp="brainpoolP256t1",hp="brainpoolP320r1",gp="brainpoolP320t1",mp="brainpoolP384r1",_p="brainpoolP384t1",yp="brainpoolP512r1",wp="brainpoolP512t1",ye="ECDSA";let Yr=Hi=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 Rw;case"sha-256":return Lw;case"sha-384":return Uw;case"sha-512":return Vw}else if("namedCurve"in e){let n="";switch(e.namedCurve){case"P-256":n=ku;break;case"K-256":n=Hi.SECP256K1;break;case"P-384":n=Su;break;case"P-521":n=Au;break;case op:n=Ku;break;case ap:n=Wu;break;case cp:n=Gu;break;case lp:n=Ju;break;case dp:n=Zu;break;case up:n=Yu;break;case pp:n=Xu;break;case fp:n=Qu;break;case hp:n=ep;break;case gp:n=tp;break;case mp:n=np;break;case _p:n=rp;break;case yp:n=ip;break;case wp:n=sp;break}if(n)return new F({algorithm:Gr,parameters:q.serialize(new sn({namedCurve:n}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case Wl:return{name:ye,hash:{name:"SHA-1"}};case Gl:return{name:ye,hash:{name:"SHA-256"}};case Jl:return{name:ye,hash:{name:"SHA-384"}};case Zl:return{name:ye,hash:{name:"SHA-512"}};case Gr:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(q.parse(e.parameters,sn).namedCurve){case ku:return{name:ye,namedCurve:"P-256"};case Hi.SECP256K1:return{name:ye,namedCurve:"K-256"};case Su:return{name:ye,namedCurve:"P-384"};case Au:return{name:ye,namedCurve:"P-521"};case Ku:return{name:ye,namedCurve:op};case Wu:return{name:ye,namedCurve:ap};case Gu:return{name:ye,namedCurve:cp};case Ju:return{name:ye,namedCurve:lp};case Zu:return{name:ye,namedCurve:dp};case Yu:return{name:ye,namedCurve:up};case Xu:return{name:ye,namedCurve:pp};case Qu:return{name:ye,namedCurve:fp};case ep:return{name:ye,namedCurve:hp};case tp:return{name:ye,namedCurve:gp};case np:return{name:ye,namedCurve:mp};case rp:return{name:ye,namedCurve:_p};case ip:return{name:ye,namedCurve:yp};case sp:return{name:ye,namedCurve:wp}}}}return null}};Yr.SECP256K1="1.3.132.0.10";Yr=Hi=u([Fo()],Yr);Be.registerSingleton(xi,Yr);const Ng=Symbol("name"),jg=Symbol("value");class pe{constructor(e,n={},r=""){this[Ng]=e,this[jg]=r;for(const i in n)this[i]=n[i]}}pe.NAME=Ng;pe.VALUE=jg;class hv{static toTextObject(e){const n=new pe("Algorithm Identifier",{},un.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case Gr:{const r=new Yr().toWebAlgorithm(e);r&&"namedCurve"in r?n["Named Curve"]=r.namedCurve:n.Parameters=e.parameters;break}default:n.Parameters=e.parameters}return n}}class un{static toString(e){const n=this.items[e];return n||e}}un.items={[Bs]:"sha1",[_g]:"sha224",[Rs]:"sha256",[Ls]:"sha384",[Us]:"sha512",[Nn]:"rsaEncryption",[Os]:"sha1WithRSAEncryption",[Kw]:"sha224WithRSAEncryption",[Sc]:"sha256WithRSAEncryption",[Ps]:"sha384WithRSAEncryption",[Ts]:"sha512WithRSAEncryption",[Gr]:"ecPublicKey",[Wl]:"ecdsaWithSHA1",[hg]:"ecdsaWithSHA224",[Gl]:"ecdsaWithSHA256",[Jl]:"ecdsaWithSHA384",[Zl]:"ecdsaWithSHA512",[Nw]:"TLS WWW server authentication",[jw]:"TLS WWW client authentication",[$w]:"Code Signing",[Ow]:"E-mail Protection",[Pw]:"Time Stamping",[Tw]:"OCSP Signing",[Bw]:"Signed Data"};class Pn{static serialize(e){return this.serializeObj(e).join(`
142
+ `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,n=0){const r=[];let i=this.pad(n++),s="";const a=e[pe.VALUE];a&&(s=` ${a}`),r.push(`${i}${e[pe.NAME]}:${s}`),i=this.pad(n);for(const c in e){if(typeof c=="symbol")continue;const l=e[c],d=c?`${c}: `:"";if(typeof l=="string"||typeof l=="number"||typeof l=="boolean")r.push(`${i}${d}${l}`);else if(l instanceof Date)r.push(`${i}${d}${l.toUTCString()}`);else if(Array.isArray(l))for(const p of l)p[pe.NAME]=c,r.push(...this.serializeObj(p,n));else if(l instanceof pe)l[pe.NAME]=c,r.push(...this.serializeObj(l,n));else if(M.isBufferSource(l))c?(r.push(`${i}${d}`),r.push(...this.serializeBufferSource(l,n+1))):r.push(...this.serializeBufferSource(l,n));else if("toTextObject"in l){const p=l.toTextObject();p[pe.NAME]=c,r.push(...this.serializeObj(p,n))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return r}static serializeBufferSource(e,n=0){const r=this.pad(n),i=M.toUint8Array(e),s=[];for(let a=0;a<i.length;){const c=[];for(let l=0;l<16&&a<i.length;l++){l===8&&c.push("");const d=i[a++].toString(16).padStart(2,"0");c.push(d)}s.push(`${r}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}Pn.oidSerializer=un;Pn.algorithmSerializer=hv;class pn{constructor(...e){if(e.length===1){const n=e[0];this.rawData=q.serialize(n),this.onInit(n)}else{const n=q.parse(e[0],e[1]);this.rawData=M.toArrayBuffer(e[0]),this.onInit(n)}}equal(e){return e instanceof pn?Zf(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return q.toString(this.rawData);case"text":return Pn.serialize(this.toTextObject());case"hex":return J.ToHex(this.rawData);case"base64":return J.ToBase64(this.rawData);case"base64url":return J.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 pe(this.getTextName(),{},e)}}pn.NAME="ASN";class lt extends pn{constructor(...e){let n;M.isBufferSource(e[0])?n=M.toArrayBuffer(e[0]):n=q.serialize(new ot({extnID:e[0],critical:e[1],extnValue:new de(M.toArrayBuffer(e[2]))})),super(n,ot)}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[pe.NAME]===lt.NAME&&(e[pe.NAME]=un.toString(this.type)),e}}var $g;class Zt{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[$g]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(Zt.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(Zt.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=Zt.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(Zt.DEFAULT,e);return this}}$g=Symbol.toStringTag;Zt.DEFAULT="default";const $e=new Zt,gv=/^[0-2](?:\.[1-9][0-9]*)+$/;function mv(t){return new RegExp(gv).test(t)}class Og{constructor(e={}){this.items={};for(const n in e)this.register(n,e[n])}get(e){return this.items[e]||null}findId(e){return mv(e)?e:this.get(e)}register(e,n){this.items[e]=n,this.items[n]=e}}const Je=new Og;Je.register("CN","2.5.4.3");Je.register("L","2.5.4.7");Je.register("ST","2.5.4.8");Je.register("O","2.5.4.10");Je.register("OU","2.5.4.11");Je.register("C","2.5.4.6");Je.register("DC","0.9.2342.19200300.100.1.25");Je.register("E","1.2.840.113549.1.9.1");Je.register("G","2.5.4.42");Je.register("I","2.5.4.43");Je.register("SN","2.5.4.4");Je.register("T","2.5.4.12");function _v(t,e){return`\\${J.ToHex(J.FromUtf8String(e)).toUpperCase()}`}function yv(t){return t.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,_v)}class it{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 Og,this.asn=new xe;for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const i=n[r];this.extraNames.register(r,i)}typeof e=="string"?this.asn=this.fromString(e):e instanceof xe?this.asn=e:M.isBufferSource(e)?this.asn=q.parse(e,xe):this.asn=this.fromJSON(e)}getField(e){const n=this.extraNames.findId(e)||Je.findId(e),r=[];for(const i of this.asn)for(const s of i)s.type===n&&r.push(s.value.toString());return r}getName(e){return this.extraNames.get(e)||Je.get(e)}toString(){return this.asn.map(e=>e.map(n=>{const r=this.getName(n.type)||n.type,i=n.value.anyValue?`#${J.ToHex(n.value.anyValue)}`:yv(n.value.toString());return`${r}=${i}`}).join("+")).join(", ")}toJSON(){var e;const n=[];for(const r of this.asn){const i={};for(const s of r){const a=this.getName(s.type)||s.type;(e=i[a])!==null&&e!==void 0||(i[a]=[]),i[a].push(s.value.anyValue?`#${J.ToHex(s.value.anyValue)}`:s.value.toString())}n.push(i)}return n}fromString(e){const n=new xe,r=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,s=",";for(;i=r.exec(`${e},`);){let[,a,c]=i;const l=c[c.length-1];(l===","||l==="+")&&(c=c.slice(0,c.length-1),i[3]=l);const d=i[3];a=this.getTypeOid(a);const p=this.createAttribute(a,c);s==="+"?n[n.length-1].push(p):n.push(new nr([p])),s=d}return n}fromJSON(e){const n=new xe;for(const r of e){const i=new nr;for(const s in r){const a=this.getTypeOid(s),c=r[s];for(const l of c){const d=this.createAttribute(a,l);i.push(d)}}n.push(i)}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 r=new Ao({type:e});if(typeof n=="object")for(const i in n)switch(i){case"ia5String":r.value.ia5String=n[i];break;case"utf8String":r.value.utf8String=n[i];break;case"universalString":r.value.universalString=n[i];break;case"bmpString":r.value.bmpString=n[i];break;case"printableString":r.value.printableString=n[i];break}else if(n[0]==="#")r.value.anyValue=J.FromHex(n.slice(1));else{const i=this.processStringValue(n);e===this.getName("E")||e===this.getName("DC")?r.value.ia5String=i:it.isPrintableString(i)?r.value.printableString=i:r.value.utf8String=i}return r}processStringValue(e){const n=/"(.*?[^\\])?"/.exec(e);return n&&(e=n[1]),e.replace(/\\0a/ig,`
143
+ `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return q.serialize(this.asn)}async getThumbprint(...e){var n;let r,i="SHA-1";return e.length>=1&&!(!((n=e[0])===null||n===void 0)&&n.subtle)?(i=e[0]||i,r=e[1]||$e.get()):r=e[0]||$e.get(),await r.subtle.digest(i,this.toArrayBuffer())}}const Pg="Cannot initialize GeneralName from ASN.1 data.",vp=`${Pg} Unsupported string format in use.`,wv=`${Pg} Value doesn't match to GUID regular expression.`,bp=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,xp="1.3.6.1.4.1.311.25.1",kp="1.3.6.1.4.1.311.20.2.3",aa="dns",ca="dn",la="email",da="ip",ua="url",pa="guid",fa="upn",Ti="id";class Yt extends pn{constructor(...e){let n;if(e.length===2)switch(e[0]){case ca:{const r=new it(e[1]).toArrayBuffer(),i=q.parse(r,xe);n=new ie({directoryName:i});break}case aa:n=new ie({dNSName:e[1]});break;case la:n=new ie({rfc822Name:e[1]});break;case pa:{const r=new RegExp(bp,"i").exec(e[1]);if(!r)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=r.slice(1).map((s,a)=>a<3?J.ToHex(new Uint8Array(J.FromHex(s)).reverse()):s).join("");n=new ie({otherName:new Dr({typeId:xp,value:q.serialize(new de(J.FromHex(i)))})});break}case da:n=new ie({iPAddress:e[1]});break;case Ti:n=new ie({registeredID:e[1]});break;case fa:{n=new ie({otherName:new Dr({typeId:kp,value:q.serialize(Zh.toASN(e[1]))})});break}case ua:n=new ie({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else M.isBufferSource(e[0])?n=q.parse(e[0],ie):n=e[0];super(n)}onInit(e){if(e.dNSName!=null)this.type=aa,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=la,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=da,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=ua,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=Ti,this.value=e.registeredID;else if(e.directoryName!=null)this.type=ca,this.value=new it(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===xp){this.type=pa;const n=q.parse(e.otherName.value,de),r=new RegExp(bp,"i").exec(J.ToHex(n));if(!r)throw new Error(wv);this.value=r.slice(1).map((i,s)=>s<3?J.ToHex(new Uint8Array(J.FromHex(i)).reverse()):i).join("-")}else if(e.otherName.typeId===kp)this.type=fa,this.value=q.parse(e.otherName.value,Te).toString();else throw new Error(vp);else throw new Error(vp)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case ca:case aa:case pa:case da:case Ti:case fa:case ua:e=this.type.toUpperCase();break;case la:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let n=this.value;return this.type===Ti&&(n=un.toString(n)),new pe(e,void 0,n)}}class Xr extends pn{constructor(e){let n;if(e instanceof Me)n=e;else if(Array.isArray(e)){const r=[];for(const i of e)if(i instanceof ie)r.push(i);else{const s=q.parse(new Yt(i.type,i.value).rawData,ie);r.push(s)}n=new Me(r)}else if(M.isBufferSource(e))n=q.parse(e,Me);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(n)}onInit(e){const n=[];for(const r of e){let i=null;try{i=new Yt(r)}catch{continue}n.push(i)}this.items=n}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){const e=super.toTextObjectEmpty();for(const n of this.items){const r=n.toTextObject();let i=e[r[pe.NAME]];Array.isArray(i)||(i=[],e[r[pe.NAME]]=i),i.push(r)}return e}}Xr.NAME="GeneralNames";const Lr="-{5}",Qr="\\n",vv=`[^${Qr}]+`,bv=`${Lr}BEGIN (${vv}(?=${Lr}))${Lr}`,xv=`${Lr}END \\1${Lr}`,dr="\\n",kv=`[^:${Qr}]+`,Sv=`(?:[^${Qr}]+${dr}(?: +[^${Qr}]+${dr})*)`,Av="[a-zA-Z0-9=+/]+",zv=`(?:${Av}${dr})+`,Sp=`${bv}${dr}(?:((?:${kv}: ${Sv})+))?${dr}?(${zv})${xv}`;class et{static isPem(e){return typeof e=="string"&&new RegExp(Sp,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const n=new RegExp(Sp,"g"),r=[];let i=null;for(;i=n.exec(e);){const s=i[3].replace(new RegExp(`[${Qr}]+`,"g"),""),a={type:i[1],headers:[],rawData:J.FromBase64(s)},c=i[2];if(c){const l=c.split(new RegExp(dr,"g"));let d=null;for(const p of l){const[f,m]=p.split(/:(.*)/);if(m===void 0){if(!d)throw new Error("Cannot parse PEM string. Incorrect header value");d.value+=f.trim()}else d&&a.headers.push(d),d={key:f,value:m.trim()}}d&&a.headers.push(d)}r.push(a)}return r}static decode(e){return this.decodeWithHeaders(e).map(r=>r.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 r=new Array;return n?e.forEach(i=>{if(!M.isBufferSource(i))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");r.push(this.encodeStruct({type:n,rawData:M.toArrayBuffer(i)}))}):e.forEach(i=>{if(!("type"in i))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");r.push(this.encodeStruct(i))}),r.join(`
144
144
  `)}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 r=e.type.toLocaleUpperCase(),i=[];if(i.push(`-----BEGIN ${r}-----`),!((n=e.headers)===null||n===void 0)&&n.length){for(const d of e.headers)i.push(`${d.key}: ${d.value}`);i.push("")}const s=J.ToBase64(e.rawData);let a,c=0;const l=Array();for(;c<s.length&&(s.length-c<64?a=s.substring(c):(a=s.substring(c,c+64),c+=64),a.length!==0);)if(l.push(a),a.length<64)break;return i.push(...l),i.push(`-----END ${r}-----`),i.join(`
145
- `)}}et.CertificateTag="CERTIFICATE";et.CrlTag="CRL";et.CertificateRequestTag="CERTIFICATE REQUEST";et.PublicKeyTag="PUBLIC KEY";et.PrivateKeyTag="PRIVATE KEY";class Mt extends pn{static isAsnEncoded(e){return M.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(et.isPem(e))return et.decode(e)[0];if(J.isHex(e))return J.FromHex(e);if(J.isBase64(e))return J.FromBase64(e);if(J.isBase64Url(e))return J.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const n=J.ToBinary(e);return et.isPem(n)?et.decode(n)[0]:J.isHex(n)?J.FromHex(n):J.isBase64(n)?J.FromBase64(n):J.isBase64Url(n)?J.FromBase64Url(n):M.toArrayBuffer(e)}}constructor(...e){Mt.isAsnEncoded(e[0])?super(Mt.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return et.encode(this.rawData,this.tag);default:return super.toString(e)}}}class gt extends Mt{static async create(e,n=$e.get()){if(e instanceof gt)return e;if(Zt.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const r=await n.subtle.exportKey("spki",e);return new gt(r)}else{if(e.publicKey)return e.publicKey;if(M.isBufferSource(e))return new gt(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Mt.isAsnEncoded(e)?super(e,ht):super(e),this.tag=et.PublicKeyTag}async export(...e){let n,r=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,r=e[1]||r,n=e[2]||$e.get()):n=e[0]||$e.get();let s=this.rawData;const a=q.parse(this.rawData,ht);return a.algorithm.algorithm===Rr&&(s=Sv(a,s)),n.subtle.importKey("spki",s,i,!0,r)}onInit(e){const n=Be.resolve(On),r=this.algorithm=n.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case Nn:{const i=q.parse(e.subjectPublicKey,Yl),s=M.toUint8Array(i.modulus);r.publicExponent=M.toUint8Array(i.publicExponent),r.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var n;let r,i="SHA-1";return e.length>=1&&!(!((n=e[0])===null||n===void 0)&&n.subtle)?(i=e[0]||i,r=e[1]||$e.get()):r=e[0]||$e.get(),await r.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let n,r="SHA-1";e.length===1?typeof e[0]=="string"?(r=e[0],n=$e.get()):n=e[0]:e.length===2?(r=e[0],n=e[1]):n=$e.get();const i=q.parse(this.rawData,ht);return await n.subtle.digest(r,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),n=q.parse(this.rawData,ht);switch(e.Algorithm=Pn.serializeAlgorithm(n.algorithm),n.algorithm.algorithm){case Gr:e["EC Point"]=n.subjectPublicKey;break;case Nn:default:e["Raw Data"]=n.subjectPublicKey}return e}}function Sv(t,e){return t.algorithm=new F({algorithm:Nn,parameters:null}),e=q.serialize(t),e}class ei extends lt{static async create(e,n=!1,r=$e.get()){if("name"in e&&"serialNumber"in e)return new ei(e,n);const s=await(await gt.create(e,r)).getKeyIdentifier(r);return new ei(J.ToHex(s),n)}constructor(...e){if(M.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const n=new wn({keyIdentifier:new $l(J.FromHex(e[0]))});super(Ma,e[1],q.serialize(n))}else{const n=e[0],r=n.name instanceof Xr?q.parse(n.name.rawData,Me):n.name,i=new wn({authorityCertIssuer:r,authorityCertSerialNumber:J.FromHex(n.serialNumber)});super(Ma,e[1],q.serialize(i))}}onInit(e){super.onInit(e);const n=q.parse(e.extnValue,wn);n.keyIdentifier&&(this.keyId=J.ToHex(n.keyIdentifier)),(n.authorityCertIssuer||n.authorityCertSerialNumber)&&(this.certId={name:n.authorityCertIssuer||[],serialNumber:n.authorityCertSerialNumber?J.ToHex(n.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),n=q.parse(this.value,wn);return n.authorityCertIssuer&&(e["Authority Issuer"]=new Xr(n.authorityCertIssuer).toTextObject()),n.authorityCertSerialNumber&&(e["Authority Serial Number"]=n.authorityCertSerialNumber),n.keyIdentifier&&(e[""]=n.keyIdentifier),e}}ei.NAME="Authority Key Identifier";class td extends lt{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,gs);this.ca=n.cA,this.pathLength=n.pathLenConstraint}else{const n=new gs({cA:e[0],pathLenConstraint:e[1]});super(Yh,e[2],q.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}}td.NAME="Basic Constraints";var Ap;(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"})(Ap||(Ap={}));class nd extends lt{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,ws);this.usages=n.map(r=>r)}else{const n=new ws(e[0]);super(eg,e[1],q.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(n=>un.toString(n)).join(", "),e}}nd.NAME="Extended Key Usages";var Fs;(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"})(Fs||(Fs={}));class rd extends lt{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,oa);this.usages=n.toNumber()}else{const n=new oa(e[0]);super(tg,e[1],q.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=q.parse(this.value,oa);return e[""]=n.toJSON().join(", "),e}}rd.NAME="Key Usages";class ki extends lt{static async create(e,n=!1,r=$e.get()){const s=await(await gt.create(e,r)).getKeyIdentifier(r);return new ki(J.ToHex(s),n)}constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,Qt);this.keyId=J.ToHex(n)}else{const n=typeof e[0]=="string"?J.FromHex(e[0]):e[0],r=new Qt(n);super(sg,e[1],q.serialize(r)),this.keyId=J.ToHex(n)}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=q.parse(this.value,Qt);return e[""]=n,e}}ki.NAME="Subject Key Identifier";class Og extends lt{constructor(...e){M.isBufferSource(e[0])?super(e[0]):super(ig,e[1],new Xr(e[0]||[]).rawData)}onInit(e){super.onInit(e);const n=q.parse(e.extnValue,rc);this.names=new Xr(n)}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.names.toTextObject();for(const r in n)e[r]=n[r];return e}}Og.NAME="Subject Alternative Name";class dt{static register(e,n){this.items.set(e,n)}static create(e){const n=new lt(e),r=this.items.get(n.type);return r?new r(e):n}}dt.items=new Map;class Pg extends lt{constructor(...e){var n;if(M.isBufferSource(e[0])){super(e[0]);const r=q.parse(this.value,_s);this.policies=r.map(i=>i.policyIdentifier)}else{const r=e[0],i=(n=e[1])!==null&&n!==void 0?n:!1,s=new _s(r.map(a=>new Eo({policyIdentifier:a})));super(Xh,i,q.serialize(s)),this.policies=r}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(n=>new pe("",{},un.toString(n))),e}}Pg.NAME="Certificate Policies";dt.register(Xh,Pg);class Tg extends lt{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(a=>new _r({distributionPoint:new zn({fullName:[new ie({uniformResourceIdentifier:a})]})})),s=new Yn(i);super(Wa,e[1],q.serialize(s))}else{const r=new Yn(e[0]);super(Wa,e[1],q.serialize(r))}(n=this.distributionPoints)!==null&&n!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const n=q.parse(e.extnValue,Yn);this.distributionPoints=n}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(n=>{var r;const i={};return n.distributionPoint&&(i[""]=(r=n.distributionPoint.fullName)===null||r===void 0?void 0:r.map(s=>new Yt(s).toString()).join(", ")),n.reasons&&(i.Reasons=n.reasons.toString()),n.cRLIssuer&&(i["CRL Issuer"]=n.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}Tg.NAME="CRL Distribution Points";class Bg extends lt{constructor(...e){var n,r,i,s;if(M.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Gn){const a=new Gn(e[0]);super(qa,e[1],q.serialize(a))}else{const a=e[0],c=new Gn;Ri(c,a,cu,"ocsp"),Ri(c,a,lu,"caIssuers"),Ri(c,a,du,"timeStamping"),Ri(c,a,uu,"caRepository"),super(qa,e[1],q.serialize(c))}(n=this.ocsp)!==null&&n!==void 0||(this.ocsp=[]),(r=this.caIssuers)!==null&&r!==void 0||(this.caIssuers=[]),(i=this.timeStamping)!==null&&i!==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=[],q.parse(e.extnValue,Gn).forEach(r=>{switch(r.accessMethod){case cu:this.ocsp.push(new Yt(r.accessLocation));break;case lu:this.caIssuers.push(new Yt(r.accessLocation));break;case du:this.timeStamping.push(new Yt(r.accessLocation));break;case uu:this.caRepository.push(new Yt(r.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&Bi(e,"OCSP",this.ocsp),this.caIssuers.length&&Bi(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&Bi(e,"Time Stamping",this.timeStamping),this.caRepository.length&&Bi(e,"CA Repository",this.caRepository),e}}Bg.NAME="Authority Info Access";function Bi(t,e,n){if(n.length===1)t[e]=n[0].toTextObject();else{const r=new pe("");n.forEach((i,s)=>{const a=i.toTextObject(),c=`${a[pe.NAME]} ${s+1}`;let l=r[c];Array.isArray(l)||(l=[],r[c]=l),l.push(a)}),t[e]=r}}function Ri(t,e,n,r){const i=e[r];i&&(Array.isArray(i)?i:[i]).forEach(a=>{typeof a=="string"&&(a=new Yt("url",a)),t.push(new di({accessMethod:n,accessLocation:q.parse(a.rawData,ie)}))})}class Sr extends pn{constructor(...e){let n;if(M.isBufferSource(e[0]))n=M.toArrayBuffer(e[0]);else{const r=e[0],i=Array.isArray(e[1])?e[1].map(s=>M.toArrayBuffer(s)):[];n=q.serialize(new Ut({type:r,values:i}))}super(n,Ut)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(n=>new pe("",{"":n})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[pe.NAME]===Sr.NAME&&(e[pe.NAME]=un.toString(this.type)),e}}Sr.NAME="Attribute";class Rg extends Sr{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else{const r=new Hs({printableString:e[0]});super(Eg,[q.serialize(r)])}(n=this.password)!==null&&n!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const n=q.parse(this.values[0],Hs);this.password=n.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[pe.VALUE]=this.password,e}}Rg.NAME="Challenge Password";class id extends Sr{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else{const r=e[0],i=new nn;for(const s of r)i.push(q.parse(s.rawData,ot));super(ed,[q.serialize(i)])}(n=this.items)!==null&&n!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const n=q.parse(this.values[0],nn);this.items=n.map(r=>dt.create(q.serialize(r)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.items.map(r=>r.toTextObject());for(const r of n)e[r[pe.NAME]]=r;return e}}id.NAME="Extensions";class Zo{static register(e,n){this.items.set(e,n)}static create(e){const n=new Sr(e),r=this.items.get(n.type);return r?new r(e):n}}Zo.items=new Map;const Si="crypto.signatureFormatter";class Av{toAsnSignature(e,n){return M.toArrayBuffer(n)}toWebSignature(e,n){return M.toArrayBuffer(n)}}var Di;let Wc=Di=class{static createPssParams(e,n){const r=Di.getHashAlgorithm(e);return r?new $n({hashAlgorithm:r,maskGenAlgorithm:new F({algorithm:qo,parameters:q.serialize(r)}),saltLength:n}):null}static getHashAlgorithm(e){const n=Be.resolve(On);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:Os,parameters:null});case"sha-256":return new F({algorithm:Sc,parameters:null});case"sha-384":return new F({algorithm:Ps,parameters:null});case"sha-512":return new F({algorithm:Ts,parameters:null})}}else return new F({algorithm:Nn,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=Di.createPssParams(e.hash,e.saltLength);if(!n)throw new Error("Cannot create PSS parameters");return new F({algorithm:Rr,parameters:q.serialize(n)})}else return new F({algorithm:Rr,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case Nn:return{name:"RSASSA-PKCS1-v1_5"};case Os:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Sc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Ps:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Ts:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Rr:if(e.parameters){const n=q.parse(e.parameters,$n);return{name:"RSA-PSS",hash:Be.resolve(On).toWebAlgorithm(n.hashAlgorithm),saltLength:n.saltLength}}else return{name:"RSA-PSS"}}return null}};Wc=Di=u([Fo()],Wc);Be.registerSingleton(xi,Wc);let Gc=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new F({algorithm:Bs});case"sha-256":return new F({algorithm:Rs});case"sha-384":return new F({algorithm:Ls});case"sha-512":return new F({algorithm:Us})}return null}toWebAlgorithm(e){switch(e.algorithm){case Bs:return{name:"SHA-1"};case Rs:return{name:"SHA-256"};case Ls:return{name:"SHA-384"};case Us:return{name:"SHA-512"}}return null}};Gc=u([Fo()],Gc);Be.registerSingleton(xi,Gc);class st{addPadding(e,n){const r=M.toUint8Array(n),i=new Uint8Array(e);return i.set(r,e-r.length),i}removePadding(e,n=!1){let r=M.toUint8Array(e);for(let i=0;i<r.length;i++)if(r[i]){r=r.slice(i);break}if(n&&r[0]>127){const i=new Uint8Array(r.length+1);return i.set(r,1),i.buffer}return r.buffer}toAsnSignature(e,n){if(e.name==="ECDSA"){const r=e.namedCurve,i=st.namedCurveSize.get(r)||st.defaultNamedCurveSize,s=new $s,a=M.toUint8Array(n);return s.r=this.removePadding(a.slice(0,i),!0),s.s=this.removePadding(a.slice(i,i+i),!0),q.serialize(s)}return null}toWebSignature(e,n){if(e.name==="ECDSA"){const r=q.parse(n,$s),i=e.namedCurve,s=st.namedCurveSize.get(i)||st.defaultNamedCurveSize,a=this.addPadding(s,this.removePadding(r.r)),c=this.addPadding(s,this.removePadding(r.s));return Ly(a,c)}return null}}st.namedCurveSize=new Map;st.defaultNamedCurveSize=32;const ha="1.3.101.110",zp="1.3.101.111",ga="1.3.101.112",Ep="1.3.101.113";let Jc=class{toAsnAlgorithm(e){let n=null;switch(e.name.toLowerCase()){case"ed25519":n=ga;break;case"x25519":n=ha;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":n=ga;break;case"ed448":n=Ep;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":n=ha;break;case"x448":n=zp;break}}return n?new F({algorithm:n}):null}toWebAlgorithm(e){switch(e.algorithm){case ga:return{name:"Ed25519"};case Ep:return{name:"EdDSA",namedCurve:"Ed448"};case ha:return{name:"X25519"};case zp:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Jc=u([Fo()],Jc);Be.registerSingleton(xi,Jc);class zv extends Mt{constructor(e){Mt.isAsnEncoded(e)?super(e,Zr):super(e),this.tag=et.CertificateRequestTag}onInit(e){this.tbs=q.serialize(e.certificationRequestInfo),this.publicKey=new gt(e.certificationRequestInfo.subjectPKInfo);const n=Be.resolve(On);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>Zo.create(q.serialize(i)));const r=this.getAttribute(ed);this.extensions=[],r instanceof id&&(this.extensions=r.items),this.subjectName=new it(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=$e.get()){const n={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(n,["verify"],e),i=Be.resolveAll(Si).reverse();let s=null;for(const c of i)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,r,s,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),n=q.parse(this.rawData,Zr),r=n.certificationRequestInfo,i=new pe("",{Version:`${En[r.version]} (${r.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new pe("");for(const a of this.attributes){const c=a.toTextObject();s[c[pe.NAME]]=c}i.Attributes=s}return e.Data=i,e.Signature=new pe("",{Algorithm:Pn.serializeAlgorithm(n.signatureAlgorithm),"":n.signature}),e}}zv.NAME="PKCS#10 Certificate Request";class sd extends Mt{constructor(e){Mt.isAsnEncoded(e)?super(e,In):super(e),this.tag=et.CertificateTag}onInit(e){const n=e.tbsCertificate;this.tbs=q.serialize(n),this.serialNumber=J.ToHex(n.serialNumber),this.subjectName=new it(n.subject),this.subject=new it(n.subject).toString(),this.issuerName=new it(n.issuer),this.issuer=this.issuerName.toString();const r=Be.resolve(On);this.signatureAlgorithm=r.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const i=n.validity.notBefore.utcTime||n.validity.notBefore.generalTime;if(!i)throw new Error("Cannot get 'notBefore' value");this.notBefore=i;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(a=>dt.create(q.serialize(a)))),this.publicKey=new gt(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=$e.get()){let r,i;const s=e.publicKey;try{if(!s)r={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(r,["verify"],n);else if("publicKey"in s)r={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(r,["verify"],n);else if(s instanceof gt)r={...s.algorithm,...this.signatureAlgorithm},i=await s.export(r,["verify"],n);else if(M.isBufferSource(s)){const d=new gt(s);r={...d.algorithm,...this.signatureAlgorithm},i=await d.export(r,["verify"],n)}else r={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}const a=Be.resolveAll(Si).reverse();let c=null;for(const d of a)if(c=d.toWebSignature(r,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,i,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,r="SHA-1";return e[0]&&(e[0].subtle?n=e[0]:(r=e[0]||r,n=e[1])),n??(n=$e.get()),await n.subtle.digest(r,this.rawData)}async isSelfSigned(e=$e.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),n=q.parse(this.rawData,In),r=n.tbsCertificate,i=new pe("",{Version:`${En[r.version]} (${r.version})`,"Serial Number":r.serialNumber,"Signature Algorithm":Pn.serializeAlgorithm(r.signature),Issuer:this.issuer,Validity:new pe("",{"Not Before":r.validity.notBefore.getTime(),"Not After":r.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(r.issuerUniqueID&&(i["Issuer Unique ID"]=r.issuerUniqueID),r.subjectUniqueID&&(i["Subject Unique ID"]=r.subjectUniqueID),this.extensions.length){const s=new pe("");for(const a of this.extensions){const c=a.toTextObject();s[c[pe.NAME]]=c}i.Extensions=s}return e.Data=i,e.Signature=new pe("",{Algorithm:Pn.serializeAlgorithm(n.signatureAlgorithm),"":n.signatureValue}),e}}sd.NAME="Certificate";class Ev{static async createSelfSigned(e,n=$e.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=$e.get()){var r;let i;e.publicKey instanceof gt?i=e.publicKey.rawData:"publicKey"in e.publicKey?i=e.publicKey.publicKey.rawData:M.isBufferSource(e.publicKey)?i=e.publicKey:i=await n.subtle.exportKey("spki",e.publicKey);const s=e.serialNumber?M.toUint8Array(J.FromHex(e.serialNumber)):n.getRandomValues(new Uint8Array(16));s[0]>127&&(s[0]&=127),s.length>1&&s[0]===0&&(s[1]|=128);const a=e.notBefore||new Date,c=e.notAfter||new Date(a.getTime()+31536e6),l=new In({tbsCertificate:new nt({version:En.v3,serialNumber:s,validity:new ui({notBefore:a,notAfter:c}),extensions:new nn(((r=e.extensions)===null||r===void 0?void 0:r.map(v=>q.parse(v.rawData,ot)))||[]),subjectPublicKeyInfo:q.parse(i,ht)})});if(e.subject){const v=e.subject instanceof it?e.subject:new it(e.subject);l.tbsCertificate.subject=q.parse(v.toArrayBuffer(),xe)}if(e.issuer){const v=e.issuer instanceof it?e.issuer:new it(e.issuer);l.tbsCertificate.issuer=q.parse(v.toArrayBuffer(),xe)}const d={hash:"SHA-256"},p="signingKey"in e?{...d,...e.signingAlgorithm,...e.signingKey.algorithm}:{...d,...e.signingAlgorithm},f=Be.resolve(On);l.tbsCertificate.signature=l.signatureAlgorithm=f.toAsnAlgorithm(p);const m=q.serialize(l.tbsCertificate),w="signingKey"in e?await n.subtle.sign(p,e.signingKey,m):e.signature,h=Be.resolveAll(Si).reverse();let _=null;for(const v of h)if(_=v.toAsnSignature(p,w),_)break;if(!_)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return l.signatureValue=_,new sd(q.serialize(l))}}var Ip;(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"})(Ip||(Ip={}));dt.register(Yh,td);dt.register(eg,nd);dt.register(tg,rd);dt.register(sg,ki);dt.register(Ma,ei);dt.register(ig,Og);dt.register(Wa,Tg);dt.register(qa,Bg);Zo.register(Eg,Rg);Zo.register(ed,id);Be.registerSingleton(Si,Av);Be.registerSingleton(Si,st);st.namedCurveSize.set("P-256",32);st.namedCurveSize.set("K-256",32);st.namedCurveSize.set("P-384",48);st.namedCurveSize.set("P-521",66);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"]),r=ke(),i=Ca(new TextEncoder().encode(r)),s=await Ev.createSelfSigned({serialNumber:i,name:t.name,notBefore:new Date,notAfter:new Date(Date.now()+365*24*60*60*1e3),signingAlgorithm:e,keys:n,extensions:[new td(!0,2,!0),new nd(["1.3.6.1.5.5.7.3.1"],!0),new rd(Fs.keyCertSign|Fs.cRLSign,!0),await ki.create(n.publicKey)]}),a=await crypto.subtle.exportKey("pkcs8",n.privateKey),c=s.toString("pem"),l=await Cv(s),d=Ca(await s.getThumbprint()),p=Iv("PRIVATE",a);return{kid:s.serialNumber,cert:c,thumbprint:d,fingerprint:l,pkcs7:p}}function Iv(t,e){const n=L0.encode(new Uint8Array(e));let r=`-----BEGIN ${t} KEY-----\r
145
+ `)}}et.CertificateTag="CERTIFICATE";et.CrlTag="CRL";et.CertificateRequestTag="CERTIFICATE REQUEST";et.PublicKeyTag="PUBLIC KEY";et.PrivateKeyTag="PRIVATE KEY";class Mt extends pn{static isAsnEncoded(e){return M.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(et.isPem(e))return et.decode(e)[0];if(J.isHex(e))return J.FromHex(e);if(J.isBase64(e))return J.FromBase64(e);if(J.isBase64Url(e))return J.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const n=J.ToBinary(e);return et.isPem(n)?et.decode(n)[0]:J.isHex(n)?J.FromHex(n):J.isBase64(n)?J.FromBase64(n):J.isBase64Url(n)?J.FromBase64Url(n):M.toArrayBuffer(e)}}constructor(...e){Mt.isAsnEncoded(e[0])?super(Mt.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return et.encode(this.rawData,this.tag);default:return super.toString(e)}}}class gt extends Mt{static async create(e,n=$e.get()){if(e instanceof gt)return e;if(Zt.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const r=await n.subtle.exportKey("spki",e);return new gt(r)}else{if(e.publicKey)return e.publicKey;if(M.isBufferSource(e))return new gt(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Mt.isAsnEncoded(e)?super(e,ht):super(e),this.tag=et.PublicKeyTag}async export(...e){let n,r=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,r=e[1]||r,n=e[2]||$e.get()):n=e[0]||$e.get();let s=this.rawData;const a=q.parse(this.rawData,ht);return a.algorithm.algorithm===Rr&&(s=Ev(a,s)),n.subtle.importKey("spki",s,i,!0,r)}onInit(e){const n=Be.resolve(On),r=this.algorithm=n.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case Nn:{const i=q.parse(e.subjectPublicKey,Yl),s=M.toUint8Array(i.modulus);r.publicExponent=M.toUint8Array(i.publicExponent),r.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var n;let r,i="SHA-1";return e.length>=1&&!(!((n=e[0])===null||n===void 0)&&n.subtle)?(i=e[0]||i,r=e[1]||$e.get()):r=e[0]||$e.get(),await r.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let n,r="SHA-1";e.length===1?typeof e[0]=="string"?(r=e[0],n=$e.get()):n=e[0]:e.length===2?(r=e[0],n=e[1]):n=$e.get();const i=q.parse(this.rawData,ht);return await n.subtle.digest(r,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),n=q.parse(this.rawData,ht);switch(e.Algorithm=Pn.serializeAlgorithm(n.algorithm),n.algorithm.algorithm){case Gr:e["EC Point"]=n.subjectPublicKey;break;case Nn:default:e["Raw Data"]=n.subjectPublicKey}return e}}function Ev(t,e){return t.algorithm=new F({algorithm:Nn,parameters:null}),e=q.serialize(t),e}class ei extends lt{static async create(e,n=!1,r=$e.get()){if("name"in e&&"serialNumber"in e)return new ei(e,n);const s=await(await gt.create(e,r)).getKeyIdentifier(r);return new ei(J.ToHex(s),n)}constructor(...e){if(M.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const n=new wn({keyIdentifier:new $l(J.FromHex(e[0]))});super(Ma,e[1],q.serialize(n))}else{const n=e[0],r=n.name instanceof Xr?q.parse(n.name.rawData,Me):n.name,i=new wn({authorityCertIssuer:r,authorityCertSerialNumber:J.FromHex(n.serialNumber)});super(Ma,e[1],q.serialize(i))}}onInit(e){super.onInit(e);const n=q.parse(e.extnValue,wn);n.keyIdentifier&&(this.keyId=J.ToHex(n.keyIdentifier)),(n.authorityCertIssuer||n.authorityCertSerialNumber)&&(this.certId={name:n.authorityCertIssuer||[],serialNumber:n.authorityCertSerialNumber?J.ToHex(n.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),n=q.parse(this.value,wn);return n.authorityCertIssuer&&(e["Authority Issuer"]=new Xr(n.authorityCertIssuer).toTextObject()),n.authorityCertSerialNumber&&(e["Authority Serial Number"]=n.authorityCertSerialNumber),n.keyIdentifier&&(e[""]=n.keyIdentifier),e}}ei.NAME="Authority Key Identifier";class td extends lt{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,gs);this.ca=n.cA,this.pathLength=n.pathLenConstraint}else{const n=new gs({cA:e[0],pathLenConstraint:e[1]});super(Qh,e[2],q.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}}td.NAME="Basic Constraints";var Ap;(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"})(Ap||(Ap={}));class nd extends lt{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,ws);this.usages=n.map(r=>r)}else{const n=new ws(e[0]);super(ng,e[1],q.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(n=>un.toString(n)).join(", "),e}}nd.NAME="Extended Key Usages";var Fs;(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"})(Fs||(Fs={}));class rd extends lt{constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,oa);this.usages=n.toNumber()}else{const n=new oa(e[0]);super(rg,e[1],q.serialize(n)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=q.parse(this.value,oa);return e[""]=n.toJSON().join(", "),e}}rd.NAME="Key Usages";class ki extends lt{static async create(e,n=!1,r=$e.get()){const s=await(await gt.create(e,r)).getKeyIdentifier(r);return new ki(J.ToHex(s),n)}constructor(...e){if(M.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,Qt);this.keyId=J.ToHex(n)}else{const n=typeof e[0]=="string"?J.FromHex(e[0]):e[0],r=new Qt(n);super(ag,e[1],q.serialize(r)),this.keyId=J.ToHex(n)}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=q.parse(this.value,Qt);return e[""]=n,e}}ki.NAME="Subject Key Identifier";class Tg extends lt{constructor(...e){M.isBufferSource(e[0])?super(e[0]):super(og,e[1],new Xr(e[0]||[]).rawData)}onInit(e){super.onInit(e);const n=q.parse(e.extnValue,rc);this.names=new Xr(n)}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.names.toTextObject();for(const r in n)e[r]=n[r];return e}}Tg.NAME="Subject Alternative Name";class dt{static register(e,n){this.items.set(e,n)}static create(e){const n=new lt(e),r=this.items.get(n.type);return r?new r(e):n}}dt.items=new Map;class Bg extends lt{constructor(...e){var n;if(M.isBufferSource(e[0])){super(e[0]);const r=q.parse(this.value,_s);this.policies=r.map(i=>i.policyIdentifier)}else{const r=e[0],i=(n=e[1])!==null&&n!==void 0?n:!1,s=new _s(r.map(a=>new Eo({policyIdentifier:a})));super(eg,i,q.serialize(s)),this.policies=r}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(n=>new pe("",{},un.toString(n))),e}}Bg.NAME="Certificate Policies";dt.register(eg,Bg);class Rg extends lt{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(a=>new _r({distributionPoint:new zn({fullName:[new ie({uniformResourceIdentifier:a})]})})),s=new Yn(i);super(Wa,e[1],q.serialize(s))}else{const r=new Yn(e[0]);super(Wa,e[1],q.serialize(r))}(n=this.distributionPoints)!==null&&n!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const n=q.parse(e.extnValue,Yn);this.distributionPoints=n}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(n=>{var r;const i={};return n.distributionPoint&&(i[""]=(r=n.distributionPoint.fullName)===null||r===void 0?void 0:r.map(s=>new Yt(s).toString()).join(", ")),n.reasons&&(i.Reasons=n.reasons.toString()),n.cRLIssuer&&(i["CRL Issuer"]=n.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}Rg.NAME="CRL Distribution Points";class Lg extends lt{constructor(...e){var n,r,i,s;if(M.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Gn){const a=new Gn(e[0]);super(qa,e[1],q.serialize(a))}else{const a=e[0],c=new Gn;Ri(c,a,cu,"ocsp"),Ri(c,a,lu,"caIssuers"),Ri(c,a,du,"timeStamping"),Ri(c,a,uu,"caRepository"),super(qa,e[1],q.serialize(c))}(n=this.ocsp)!==null&&n!==void 0||(this.ocsp=[]),(r=this.caIssuers)!==null&&r!==void 0||(this.caIssuers=[]),(i=this.timeStamping)!==null&&i!==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=[],q.parse(e.extnValue,Gn).forEach(r=>{switch(r.accessMethod){case cu:this.ocsp.push(new Yt(r.accessLocation));break;case lu:this.caIssuers.push(new Yt(r.accessLocation));break;case du:this.timeStamping.push(new Yt(r.accessLocation));break;case uu:this.caRepository.push(new Yt(r.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&Bi(e,"OCSP",this.ocsp),this.caIssuers.length&&Bi(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&Bi(e,"Time Stamping",this.timeStamping),this.caRepository.length&&Bi(e,"CA Repository",this.caRepository),e}}Lg.NAME="Authority Info Access";function Bi(t,e,n){if(n.length===1)t[e]=n[0].toTextObject();else{const r=new pe("");n.forEach((i,s)=>{const a=i.toTextObject(),c=`${a[pe.NAME]} ${s+1}`;let l=r[c];Array.isArray(l)||(l=[],r[c]=l),l.push(a)}),t[e]=r}}function Ri(t,e,n,r){const i=e[r];i&&(Array.isArray(i)?i:[i]).forEach(a=>{typeof a=="string"&&(a=new Yt("url",a)),t.push(new di({accessMethod:n,accessLocation:q.parse(a.rawData,ie)}))})}class Sr extends pn{constructor(...e){let n;if(M.isBufferSource(e[0]))n=M.toArrayBuffer(e[0]);else{const r=e[0],i=Array.isArray(e[1])?e[1].map(s=>M.toArrayBuffer(s)):[];n=q.serialize(new Ut({type:r,values:i}))}super(n,Ut)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(n=>new pe("",{"":n})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[pe.NAME]===Sr.NAME&&(e[pe.NAME]=un.toString(this.type)),e}}Sr.NAME="Attribute";class Ug extends Sr{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else{const r=new Hs({printableString:e[0]});super(Cg,[q.serialize(r)])}(n=this.password)!==null&&n!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const n=q.parse(this.values[0],Hs);this.password=n.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[pe.VALUE]=this.password,e}}Ug.NAME="Challenge Password";class id extends Sr{constructor(...e){var n;if(M.isBufferSource(e[0]))super(e[0]);else{const r=e[0],i=new nn;for(const s of r)i.push(q.parse(s.rawData,ot));super(ed,[q.serialize(i)])}(n=this.items)!==null&&n!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const n=q.parse(this.values[0],nn);this.items=n.map(r=>dt.create(q.serialize(r)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),n=this.items.map(r=>r.toTextObject());for(const r of n)e[r[pe.NAME]]=r;return e}}id.NAME="Extensions";class Zo{static register(e,n){this.items.set(e,n)}static create(e){const n=new Sr(e),r=this.items.get(n.type);return r?new r(e):n}}Zo.items=new Map;const Si="crypto.signatureFormatter";class Iv{toAsnSignature(e,n){return M.toArrayBuffer(n)}toWebSignature(e,n){return M.toArrayBuffer(n)}}var Di;let Wc=Di=class{static createPssParams(e,n){const r=Di.getHashAlgorithm(e);return r?new $n({hashAlgorithm:r,maskGenAlgorithm:new F({algorithm:qo,parameters:q.serialize(r)}),saltLength:n}):null}static getHashAlgorithm(e){const n=Be.resolve(On);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:Os,parameters:null});case"sha-256":return new F({algorithm:Sc,parameters:null});case"sha-384":return new F({algorithm:Ps,parameters:null});case"sha-512":return new F({algorithm:Ts,parameters:null})}}else return new F({algorithm:Nn,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=Di.createPssParams(e.hash,e.saltLength);if(!n)throw new Error("Cannot create PSS parameters");return new F({algorithm:Rr,parameters:q.serialize(n)})}else return new F({algorithm:Rr,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case Nn:return{name:"RSASSA-PKCS1-v1_5"};case Os:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Sc:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Ps:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Ts:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Rr:if(e.parameters){const n=q.parse(e.parameters,$n);return{name:"RSA-PSS",hash:Be.resolve(On).toWebAlgorithm(n.hashAlgorithm),saltLength:n.saltLength}}else return{name:"RSA-PSS"}}return null}};Wc=Di=u([Fo()],Wc);Be.registerSingleton(xi,Wc);let Gc=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new F({algorithm:Bs});case"sha-256":return new F({algorithm:Rs});case"sha-384":return new F({algorithm:Ls});case"sha-512":return new F({algorithm:Us})}return null}toWebAlgorithm(e){switch(e.algorithm){case Bs:return{name:"SHA-1"};case Rs:return{name:"SHA-256"};case Ls:return{name:"SHA-384"};case Us:return{name:"SHA-512"}}return null}};Gc=u([Fo()],Gc);Be.registerSingleton(xi,Gc);class st{addPadding(e,n){const r=M.toUint8Array(n),i=new Uint8Array(e);return i.set(r,e-r.length),i}removePadding(e,n=!1){let r=M.toUint8Array(e);for(let i=0;i<r.length;i++)if(r[i]){r=r.slice(i);break}if(n&&r[0]>127){const i=new Uint8Array(r.length+1);return i.set(r,1),i.buffer}return r.buffer}toAsnSignature(e,n){if(e.name==="ECDSA"){const r=e.namedCurve,i=st.namedCurveSize.get(r)||st.defaultNamedCurveSize,s=new $s,a=M.toUint8Array(n);return s.r=this.removePadding(a.slice(0,i),!0),s.s=this.removePadding(a.slice(i,i+i),!0),q.serialize(s)}return null}toWebSignature(e,n){if(e.name==="ECDSA"){const r=q.parse(n,$s),i=e.namedCurve,s=st.namedCurveSize.get(i)||st.defaultNamedCurveSize,a=this.addPadding(s,this.removePadding(r.r)),c=this.addPadding(s,this.removePadding(r.s));return qy(a,c)}return null}}st.namedCurveSize=new Map;st.defaultNamedCurveSize=32;const ha="1.3.101.110",zp="1.3.101.111",ga="1.3.101.112",Ep="1.3.101.113";let Jc=class{toAsnAlgorithm(e){let n=null;switch(e.name.toLowerCase()){case"ed25519":n=ga;break;case"x25519":n=ha;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":n=ga;break;case"ed448":n=Ep;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":n=ha;break;case"x448":n=zp;break}}return n?new F({algorithm:n}):null}toWebAlgorithm(e){switch(e.algorithm){case ga:return{name:"Ed25519"};case Ep:return{name:"EdDSA",namedCurve:"Ed448"};case ha:return{name:"X25519"};case zp:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Jc=u([Fo()],Jc);Be.registerSingleton(xi,Jc);class Cv extends Mt{constructor(e){Mt.isAsnEncoded(e)?super(e,Zr):super(e),this.tag=et.CertificateRequestTag}onInit(e){this.tbs=q.serialize(e.certificationRequestInfo),this.publicKey=new gt(e.certificationRequestInfo.subjectPKInfo);const n=Be.resolve(On);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>Zo.create(q.serialize(i)));const r=this.getAttribute(ed);this.extensions=[],r instanceof id&&(this.extensions=r.items),this.subjectName=new it(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=$e.get()){const n={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(n,["verify"],e),i=Be.resolveAll(Si).reverse();let s=null;for(const c of i)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,r,s,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),n=q.parse(this.rawData,Zr),r=n.certificationRequestInfo,i=new pe("",{Version:`${En[r.version]} (${r.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new pe("");for(const a of this.attributes){const c=a.toTextObject();s[c[pe.NAME]]=c}i.Attributes=s}return e.Data=i,e.Signature=new pe("",{Algorithm:Pn.serializeAlgorithm(n.signatureAlgorithm),"":n.signature}),e}}Cv.NAME="PKCS#10 Certificate Request";class sd extends Mt{constructor(e){Mt.isAsnEncoded(e)?super(e,In):super(e),this.tag=et.CertificateTag}onInit(e){const n=e.tbsCertificate;this.tbs=q.serialize(n),this.serialNumber=J.ToHex(n.serialNumber),this.subjectName=new it(n.subject),this.subject=new it(n.subject).toString(),this.issuerName=new it(n.issuer),this.issuer=this.issuerName.toString();const r=Be.resolve(On);this.signatureAlgorithm=r.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const i=n.validity.notBefore.utcTime||n.validity.notBefore.generalTime;if(!i)throw new Error("Cannot get 'notBefore' value");this.notBefore=i;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(a=>dt.create(q.serialize(a)))),this.publicKey=new gt(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=$e.get()){let r,i;const s=e.publicKey;try{if(!s)r={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(r,["verify"],n);else if("publicKey"in s)r={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(r,["verify"],n);else if(s instanceof gt)r={...s.algorithm,...this.signatureAlgorithm},i=await s.export(r,["verify"],n);else if(M.isBufferSource(s)){const d=new gt(s);r={...d.algorithm,...this.signatureAlgorithm},i=await d.export(r,["verify"],n)}else r={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}const a=Be.resolveAll(Si).reverse();let c=null;for(const d of a)if(c=d.toWebSignature(r,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,i,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,r="SHA-1";return e[0]&&(e[0].subtle?n=e[0]:(r=e[0]||r,n=e[1])),n??(n=$e.get()),await n.subtle.digest(r,this.rawData)}async isSelfSigned(e=$e.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),n=q.parse(this.rawData,In),r=n.tbsCertificate,i=new pe("",{Version:`${En[r.version]} (${r.version})`,"Serial Number":r.serialNumber,"Signature Algorithm":Pn.serializeAlgorithm(r.signature),Issuer:this.issuer,Validity:new pe("",{"Not Before":r.validity.notBefore.getTime(),"Not After":r.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(r.issuerUniqueID&&(i["Issuer Unique ID"]=r.issuerUniqueID),r.subjectUniqueID&&(i["Subject Unique ID"]=r.subjectUniqueID),this.extensions.length){const s=new pe("");for(const a of this.extensions){const c=a.toTextObject();s[c[pe.NAME]]=c}i.Extensions=s}return e.Data=i,e.Signature=new pe("",{Algorithm:Pn.serializeAlgorithm(n.signatureAlgorithm),"":n.signatureValue}),e}}sd.NAME="Certificate";class Nv{static async createSelfSigned(e,n=$e.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=$e.get()){var r;let i;e.publicKey instanceof gt?i=e.publicKey.rawData:"publicKey"in e.publicKey?i=e.publicKey.publicKey.rawData:M.isBufferSource(e.publicKey)?i=e.publicKey:i=await n.subtle.exportKey("spki",e.publicKey);const s=e.serialNumber?M.toUint8Array(J.FromHex(e.serialNumber)):n.getRandomValues(new Uint8Array(16));s[0]>127&&(s[0]&=127),s.length>1&&s[0]===0&&(s[1]|=128);const a=e.notBefore||new Date,c=e.notAfter||new Date(a.getTime()+31536e6),l=new In({tbsCertificate:new nt({version:En.v3,serialNumber:s,validity:new ui({notBefore:a,notAfter:c}),extensions:new nn(((r=e.extensions)===null||r===void 0?void 0:r.map(v=>q.parse(v.rawData,ot)))||[]),subjectPublicKeyInfo:q.parse(i,ht)})});if(e.subject){const v=e.subject instanceof it?e.subject:new it(e.subject);l.tbsCertificate.subject=q.parse(v.toArrayBuffer(),xe)}if(e.issuer){const v=e.issuer instanceof it?e.issuer:new it(e.issuer);l.tbsCertificate.issuer=q.parse(v.toArrayBuffer(),xe)}const d={hash:"SHA-256"},p="signingKey"in e?{...d,...e.signingAlgorithm,...e.signingKey.algorithm}:{...d,...e.signingAlgorithm},f=Be.resolve(On);l.tbsCertificate.signature=l.signatureAlgorithm=f.toAsnAlgorithm(p);const m=q.serialize(l.tbsCertificate),w="signingKey"in e?await n.subtle.sign(p,e.signingKey,m):e.signature,h=Be.resolveAll(Si).reverse();let _=null;for(const v of h)if(_=v.toAsnSignature(p,w),_)break;if(!_)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return l.signatureValue=_,new sd(q.serialize(l))}}var Ip;(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"})(Ip||(Ip={}));dt.register(Qh,td);dt.register(ng,nd);dt.register(rg,rd);dt.register(ag,ki);dt.register(Ma,ei);dt.register(og,Tg);dt.register(Wa,Rg);dt.register(qa,Lg);Zo.register(Cg,Ug);Zo.register(ed,id);Be.registerSingleton(Si,Iv);Be.registerSingleton(Si,st);st.namedCurveSize.set("P-256",32);st.namedCurveSize.set("K-256",32);st.namedCurveSize.set("P-384",48);st.namedCurveSize.set("P-521",66);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"]),r=ke(),i=Ca(new TextEncoder().encode(r)),s=await Nv.createSelfSigned({serialNumber:i,name:t.name,notBefore:new Date,notAfter:new Date(Date.now()+365*24*60*60*1e3),signingAlgorithm:e,keys:n,extensions:[new td(!0,2,!0),new nd(["1.3.6.1.5.5.7.3.1"],!0),new rd(Fs.keyCertSign|Fs.cRLSign,!0),await ki.create(n.publicKey)]}),a=await crypto.subtle.exportKey("pkcs8",n.privateKey),c=s.toString("pem"),l=await $v(s),d=Ca(await s.getThumbprint()),p=jv("PRIVATE",a);return{kid:s.serialNumber,cert:c,thumbprint:d,fingerprint:l,pkcs7:p}}function jv(t,e){const n=q0.encode(new Uint8Array(e));let r=`-----BEGIN ${t} KEY-----\r
146
146
  `,i=0;for(;i<n.length;)i+64<=n.length?r+=n.substr(i,64)+`\r
147
147
  `:r+=n.substr(i)+`\r
148
148
  `,i+=64;return r+=`-----END ${t} KEY-----\r
149
- `,r}async function Cv(t){const e=await t.publicKey.export(),n=await crypto.subtle.exportKey("jwk",e),r=JSON.stringify(n,Object.keys(n).sort()),s=new TextEncoder().encode(r);return Ca(await $f(s))}const Nv=1e3*60*60*24,jv=new o.OpenAPIHono().openapi(o.createRoute({tags:["keys"],method:"get",path:"/signing",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.array(Ia)}},description:"List of keys"}}}),async t=>{const n=(await t.env.data.keys.list()).filter(r=>"cert"in r).map(r=>r);return t.json(n)}).openapi(o.createRoute({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({kid:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ia}},description:"The requested key"}}}),async t=>{const{kid:e}=t.req.valid("param"),r=(await t.env.data.keys.list()).find(i=>i.kid===e);if(!r)throw new I(404,{message:"Key not found"});return t.json(r)}).openapi(o.createRoute({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async t=>{const e=await t.env.data.keys.list();for await(const r of e)await t.env.data.keys.update(r.kid,{revoked_at:new Date(Date.now()+Nv).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(o.createRoute({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({kid:o.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 I(404,{message:"Key not found"});const r=await Zc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(r),t.text("OK")}),$v=new o.OpenAPIHono().openapi(o.createRoute({tags:["users"],method:"get",path:"/",request:{query:o.z.object({email:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:o.z.array(il)}},description:"List of users"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{email:n}=t.req.valid("query"),i=(await ml(t.env.data.users,e,n)).filter(s=>!s.linked_to);return t.json(i)}),Ov=an.extend({clients:o.z.array(mn)}),Pv=new o.OpenAPIHono().openapi(o.createRoute({tags:["clients"],method:"get",path:"/",request:{query:tn,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([Ov,o.z.array(mn)])}},description:"List of clients"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i,sort:s,q:a}=t.req.valid("query"),l=(await t.env.data.applications.list(e,{page:n,per_page:r,include_totals:i,sort:hr(s),q:a})).applications;return i?t.json({clients:l,start:0,limit:10,length:l.length}):t.json(l)}).openapi(o.createRoute({tags:["clients"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:mn}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=(await t.env.data.applications.list(e,{page:1,per_page:0,include_totals:!1})).applications.find(s=>s.id===n);if(!i)throw new I(404);return t.json(i)}).openapi(o.createRoute({tags:["clients"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.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 I(404,{message:"Application not found"});return t.text("OK")}).openapi(o.createRoute({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:o.z.object(is.shape).partial()}}},params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:mn}},description:"The update application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=t.req.valid("json");await t.env.data.applications.update(e,n,i);const s=await t.env.data.applications.get(e,n);if(!s)throw new I(404,{message:"Application not found"});return t.json(s)}).openapi(o.createRoute({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.object(is.shape)}}},headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:o.z.object(mn.shape)}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r={...n,id:n.id||ke(),client_secret:n.client_secret||ke()},i=await t.env.data.applications.create(e,r);return t.json(i,{status:201})});o.z.object({start:o.z.number(),limit:o.z.number(),length:o.z.number()});Ys.extend({email:o.z.string(),login_count:o.z.number(),multifactor:o.z.array(o.z.string()).optional(),last_ip:o.z.string().optional(),last_login:o.z.string().optional(),user_id:o.z.string()}).catchall(o.z.any());const Tv=an.extend({tenants:o.z.array(Jn)}),Bv=new o.OpenAPIHono().openapi(o.createRoute({tags:["tenants"],method:"get",path:"/",request:{query:tn},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:o.z.union([o.z.array(Jn),Tv])}},description:"List of tenants"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),a=await t.env.data.tenants.list({page:e,per_page:n,include_totals:r,sort:hr(i),q:s});return r?t.json(a):t.json(a.tenants)}).openapi(o.createRoute({tags:["tenants"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Jn}},description:"A tenant"}}}),async t=>{const{id:e}=t.req.valid("param"),n=await t.env.data.tenants.get(e);if(!n)throw new I(404);return t.json(n)}).openapi(o.createRoute({tags:["tenants"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.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(o.createRoute({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:o.z.object(os.shape).partial()}}},params:o.z.object({id:o.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(o.createRoute({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.object(os.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Jn}},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})}),Rv=an.extend({logs:o.z.array(cs)}),Lv=new o.OpenAPIHono().openapi(o.createRoute({tags:["logs"],method:"get",path:"/",request:{query:tn,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(cs),Rv])}},description:"List of log rows"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),{"tenant-id":a}=t.req.valid("header"),c=await t.env.data.logs.list(a,{page:e,per_page:n,include_totals:r,sort:hr(i),q:s});return r?t.json(c):t.json(c.logs)}).openapi(o.createRoute({tags:["logs"],method:"get",path:"/{id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:cs}},description:"A log entry"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.logs.get(e,n);if(!r)throw new I(404);return t.json(r)}),Uv=an.extend({hooks:o.z.array(Kn)}),Vv=new o.OpenAPIHono().openapi(o.createRoute({tags:["hooks"],method:"get",path:"/",request:{query:tn,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(Kn),Uv])}},description:"List of hooks"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i,sort:s,q:a}=t.req.valid("query"),c=await t.env.data.hooks.list(e,{page:n,per_page:r,include_totals:i,sort:hr(s),q:a});return i?t.json(c):t.json(c.hooks)}).openapi(o.createRoute({tags:["hooks"],method:"post",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(as.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Kn}},description:"The created hook"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.hooks.create(e,n);return t.json(r,{status:201})}).openapi(o.createRoute({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({hook_id:o.z.string()}),body:{content:{"application/json":{schema:o.z.object(as.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Kn.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"),r=t.req.valid("json");await t.env.data.hooks.update(e,n,r);const i=await t.env.data.hooks.get(e,n);if(!i)throw new I(404,{message:"Hook not found"});return t.json(i)}).openapi(o.createRoute({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({hook_id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Kn}},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"),r=await t.env.data.hooks.get(e,n);if(!r)throw new I(404,{message:"Hook not found"});return t.json(r)}).openapi(o.createRoute({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({hook_id:o.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 I(404,{message:"Hook not found"});return t.text("OK")}),qv=an.extend({connections:o.z.array(Jt)}),Mv=new o.OpenAPIHono().openapi(o.createRoute({tags:["connections"],method:"get",path:"/",request:{query:tn,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(Jt),qv])}},description:"List of connectionss"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i=!1,sort:s,q:a}=t.req.valid("query"),c=await t.env.data.connections.list(e,{page:n,per_page:r,include_totals:i,sort:hr(s),q:a});return i?t.json(c):t.json(c.connections)}).openapi(o.createRoute({tags:["connections"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Jt}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.connections.get(e,n);if(!r)throw new I(404);return t.json(r)}).openapi(o.createRoute({tags:["connections"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.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 I(404,{message:"Connection not found"});return t.text("OK")}).openapi(o.createRoute({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:o.z.object(ss.shape).partial()}}},params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Jt}},description:"The updated connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=t.req.valid("json");if(!await t.env.data.connections.update(e,n,r))throw new I(404,{message:"Connection not found"});const s=await t.env.data.connections.get(e,n);if(!s)throw new I(404,{message:"Connection not found"});return t.json(s)}).openapi(o.createRoute({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.object(ss.shape)}}},headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Jt}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.connections.create(e,n);return t.json(r,{status:201})}),Hv=new o.OpenAPIHono().openapi(o.createRoute({tags:["prompts"],method:"get",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ui}},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(Ui.parse({}))}).openapi(o.createRoute({tags:["prompts"],method:"patch",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(Ui.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"),r=await t.env.data.promptSettings.get(e);return Object.assign(r,n),await t.env.data.promptSettings.set(e,r),t.json(r)});let Cp=!1;function Lg(t){t.use(async(e,n)=>(Cp||(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"}}}}),Cp=!0),await n()))}o.z.object({alg:o.z.literal("RS256"),kty:o.z.literal("RSA"),use:o.z.literal("sig"),n:o.z.string(),e:o.z.string(),kid:o.z.string(),x5t:o.z.string(),x5c:o.z.array(o.z.string())});async function Dv(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 I(500,{message:`Failed to fetch jwks: ${e.message}`})}}async function Fv(t,e){const r=new TextEncoder().encode([e.raw.header,e.raw.payload].join(".")),i=new Uint8Array(Array.from(e.signature).map(l=>l.charCodeAt(0))),a=(await Dv(t.env)).find(l=>l.kid===e.header.kid);if(!a)return console.log("No matching kid found"),!1;const c=await crypto.subtle.importKey("jwk",a,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",c,i,r)}function Kv(t){const[e,n,r]=t.split(".");if(!e||!n||!r)return null;const i=JSON.parse(atob(e)),s=JSON.parse(atob(n)),a=atob(r.replace(/-/g,"+").replace(/_/g,"/"));return{header:i,payload:s,signature:a,raw:{header:e,payload:n,signature:r}}}function Ug(t){return async(e,n)=>{var i,s,a;const r=t.openAPIRegistry.definitions.find(c=>"route"in c&&c.route.path===e.req.path&&c.route.method.toUpperCase()===e.req.method);if(r&&"route"in r){const c=(s=(i=r.route.security)==null?void 0:i[0])==null?void 0:s.Bearer;if(!(c!=null&&c.length))return await n();const l=e.req.header("authorization")||"",[d,p]=l.split(" ");if((d==null?void 0:d.toLowerCase())!=="bearer"||!p)throw new I(401,{message:"Missing bearer token"});const f=Kv(p);if(!f||!await Fv(e,f))throw new I(403,{message:"Invalid JWT signature"});e.set("user_id",f.payload.sub),e.set("user",f.payload);const m=f.payload.permissions||[],w=((a=f.payload.scope)==null?void 0:a.split(" "))||[];if(c.length&&!(c.some(h=>m.includes(h))||c.some(h=>w.includes(h))))throw new I(403,{message:"Unauthorized"})}return await n()}}const Wv=new o.OpenAPIHono().openapi(o.createRoute({tags:["emails"],method:"get",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Vi}},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 I(404,{message:"Email provider not found"});return t.json(n)}).openapi(o.createRoute({tags:["emails"],method:"post",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(Vi.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(o.createRoute({tags:["emails"],method:"patch",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(Vi.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")}),Gv=new o.OpenAPIHono().openapi(o.createRoute({tags:["sessions"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Qs}},description:"A session"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.sessions.get(e,n);if(!r)throw new I(404);return t.json(r)}).openapi(o.createRoute({tags:["sessions"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.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 I(404,{message:"Session not found"});return t.text("OK")}).openapi(o.createRoute({tags:["sessions"],method:"post",path:"/{id}/revoke",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.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 I(404,{message:"Session not found"});return t.text("Session deletion request accepted.",{status:202})}),Jv=new o.OpenAPIHono().openapi(o.createRoute({tags:["refresh_tokens"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:cl}},description:"A session"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.refreshTokens.get(e,n);if(!r)throw new I(404);return t.json(r)}).openapi(o.createRoute({tags:["refresh_tokens"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.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 I(404,{message:"Session not found"});return t.text("OK")}),Zv=new o.OpenAPIHono().openapi(o.createRoute({tags:["custom-domains"],method:"get",path:"/",request:{query:tn,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.array(Gt)}},description:"List of custom domains"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.customDomains.list(e);return t.json(n)}).openapi(o.createRoute({tags:["custom-domains"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Gt}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.customDomains.get(e,n);if(!r)throw new I(404);return t.json(r)}).openapi(o.createRoute({tags:["custom-domains"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.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.customDomains.remove(e,n))throw new I(404,{message:"Custom domain not found"});return t.text("OK")}).openapi(o.createRoute({tags:["custom-domains"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:o.z.object(Gt.shape).partial()}}},params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Gt}},description:"The updated custom domain"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=t.req.valid("json");if(!await t.env.data.customDomains.update(e,n,r))throw new I(404);const s=await t.env.data.customDomains.get(e,n);if(!s)throw new I(404);return t.json(s)}).openapi(o.createRoute({tags:["custom-domains"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.object(ol.shape)}}},headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Gt}},description:"The created custom domain"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.customDomains.create(e,n);return t.json(r,{status:201})}).openapi(o.createRoute({tags:["custom-domains"],method:"post",path:"/{id}/verify",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Gt}},description:"The custom domain"}}}),async()=>{throw new I(501,{message:"Not implemented"})});async function od(t,e){const n=t.req.header("x-forwarded-host");if(n){const i=await t.env.data.customDomains.getByDomain(n);if(i)return t.set("tenant_id",i.tenant_id),t.set("custom_domain",n),await e()}const r=t.req.header("host");if(r){const i=r.split(".");if(i.length>1&&typeof i[0]=="string"){const s=i[0];await t.env.data.tenants.get(s)&&t.set("tenant_id",s)}}return await e()}function Yv(t){const e=new o.OpenAPIHono;e.use(cf({origin:r=>{var i;return r&&(i=t.allowedOrigins)!=null&&i.includes(r)?r:""},allowHeaders:["Tenant-Id","Content-Type","Content-Range","Auth0-Client","Authorization","Range","Upgrade-Insecure-Requests"],allowMethods:["POST","PUT","GET","DELETE","PATCH","OPTIONS"],exposeHeaders:["Content-Length","Content-Range"],maxAge:600,credentials:!0})),Lg(e),e.use(async(r,i)=>(r.env.data=io(r,t.dataAdapter),i())),e.use(od).use(Ug(e));const n=e.route("/branding",S0).route("/custom-domains",Zv).route("/email/providers",Wv).route("/users",Oy).route("/keys",jv).route("/users-by-email",$v).route("/clients",Pv).route("/tenants",Bv).route("/logs",Lv).route("/hooks",Vv).route("/connections",Mv).route("/prompts",Hv).route("/sessions",Gv).route("/refresh_tokens",Jv);return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"},security:[{oauth2:["openid","email","profile"]}]}),n}function Xv(t,e){Object.keys(e).forEach(n=>{const r=e[n];r!=null&&r.length&&t.searchParams.set(n,r)})}var Np;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Np||(Np={}));var jp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(jp||(jp={}));function Qv(t){return qg(t,eb,ti.Include)}function Vg(t){return qg(t,tb,ti.None)}function qg(t,e,n){let r="";for(let i=0;i<t.byteLength;i+=3){let s=0,a=0;for(let c=0;c<3&&i+c<t.byteLength;c++)s=s<<8|t[i+c],a+=8;for(let c=0;c<4;c++)a>=6?(r+=e[s>>a-6&63],a-=6):a>0?(r+=e[s<<6-a&63],a=0):n===ti.Include&&(r+="=")}return r}const eb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",tb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var ti;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(ti||(ti={}));var $p;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})($p||($p={}));class nb{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 r=0;for(let i=0;i<4;i++)r|=e[n+i]<<24-i*8;return r}uint64(e,n){if(e.byteLength<n+8)throw new TypeError("Insufficient bytes");let r=0n;for(let i=0;i<8;i++)r|=BigInt(e[n+i])<<BigInt(56-i*8);return r}putUint8(e,n,r){if(e.length<r+1)throw new TypeError("Not enough space");if(n<0||n>255)throw new TypeError("Invalid uint8 value");e[r]=n}putUint16(e,n,r){if(e.length<r+2)throw new TypeError("Not enough space");if(n<0||n>65535)throw new TypeError("Invalid uint16 value");e[r]=n>>8,e[r+1]=n&255}putUint32(e,n,r){if(e.length<r+4)throw new TypeError("Not enough space");if(n<0||n>4294967295)throw new TypeError("Invalid uint32 value");for(let i=0;i<4;i++)e[r+i]=n>>(3-i)*8&255}putUint64(e,n,r){if(e.length<r+8)throw new TypeError("Not enough space");if(n<0||n>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let i=0;i<8;i++)e[r+i]=Number(n>>BigInt((7-i)*8)&0xffn)}}const Op=new nb;function kt(t,e){return(t<<32-e|t>>>e)>>>0}function rb(t){const e=new ib;return e.update(t),e.digest()}class ib{constructor(){te(this,"blockSize",64);te(this,"size",32);te(this,"blocks",new Uint8Array(64));te(this,"currentBlockSize",0);te(this,"H",new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]));te(this,"l",0n);te(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 r=e.slice(0,64-this.currentBlockSize);this.blocks.set(r,this.currentBlockSize),this.process(),n+=r.byteLength,this.currentBlockSize=0}for(;n+64<=e.byteLength;){const r=e.slice(n,n+64);this.blocks.set(r),this.process(),n+=64}if(e.byteLength-n>0){const r=e.slice(n);this.blocks.set(r),this.currentBlockSize=r.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),Op.putUint64(this.blocks,this.l,this.blockSize-8),this.process();const e=new Uint8Array(32);for(let n=0;n<8;n++)Op.putUint32(e,this.H[n],n*4);return e}process(){for(let d=0;d<16;d++)this.w[d]=(this.blocks[d*4]<<24|this.blocks[d*4+1]<<16|this.blocks[d*4+2]<<8|this.blocks[d*4+3])>>>0;for(let d=16;d<64;d++){const p=(kt(this.w[d-2],17)^kt(this.w[d-2],19)^this.w[d-2]>>>10)>>>0,f=(kt(this.w[d-15],7)^kt(this.w[d-15],18)^this.w[d-15]>>>3)>>>0;this.w[d]=p+this.w[d-7]+f+this.w[d-16]|0}let e=this.H[0],n=this.H[1],r=this.H[2],i=this.H[3],s=this.H[4],a=this.H[5],c=this.H[6],l=this.H[7];for(let d=0;d<64;d++){const p=(kt(s,6)^kt(s,11)^kt(s,25))>>>0,f=(s&a^~s&c)>>>0,m=l+p+f+sb[d]+this.w[d]|0,w=(kt(e,2)^kt(e,13)^kt(e,22))>>>0,h=(e&n^e&r^n&r)>>>0,_=w+h|0;l=c,c=a,a=s,s=i+m|0,i=r,r=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]=r+this.H[2]|0,this.H[3]=i+this.H[3]|0,this.H[4]=s+this.H[4]|0,this.H[5]=a+this.H[5]|0,this.H[6]=c+this.H[6]|0,this.H[7]=l+this.H[7]|0}}const sb=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 ob{constructor(e){te(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 ab(t){const e=rb(new TextEncoder().encode(t));return Vg(e)}function cb(){const t=new Uint8Array(32);return crypto.getRandomValues(t),Vg(t)}function Ur(t,e){const n=new TextEncoder().encode(e.toString()),r=new Request(t,{method:"POST",body:n});return r.headers.set("Content-Type","application/x-www-form-urlencoded"),r.headers.set("Accept","application/json"),r.headers.set("User-Agent","arctic"),r.headers.set("Content-Length",n.byteLength.toString()),r}function ma(t,e){const n=new TextEncoder().encode(`${t}:${e}`);return Qv(n)}async function Ks(t){let e;try{e=await fetch(t)}catch(n){throw new Hg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new Fi(e.status)}if(typeof n!="object"||n===null)throw new Xn(e.status,n);let r;try{r=Mg(n)}catch{throw new Xn(e.status,n)}throw r}if(e.status===200){let n;try{n=await e.json()}catch{throw new Fi(e.status)}if(typeof n!="object"||n===null)throw new Xn(e.status,n);return new ob(n)}throw e.body!==null&&await e.body.cancel(),new Fi(e.status)}async function lb(t){let e;try{e=await fetch(t)}catch(n){throw new Hg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new Xn(e.status,null)}if(typeof n!="object"||n===null)throw new Xn(e.status,n);let r;try{r=Mg(n)}catch{throw new Xn(e.status,n)}throw r}if(e.status===200){e.body!==null&&await e.body.cancel();return}throw e.body!==null&&await e.body.cancel(),new Fi(e.status)}function Mg(t){let e;if("error"in t&&typeof t.error=="string")e=t.error;else throw new Error("Invalid error response");let n=null,r=null,i=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");r=t.error_uri}if("state"in t){if(typeof t.state!="string")throw new Error("Invalid data");i=t.state}return new db(e,n,r,i)}class Hg extends Error{constructor(e){super("Failed to send request",{cause:e})}}class db extends Error{constructor(n,r,i,s){super(`OAuth request error: ${n}`);te(this,"code");te(this,"description");te(this,"uri");te(this,"state");this.code=n,this.description=r,this.uri=i,this.state=s}}class Fi extends Error{constructor(n){super("Unexpected error response");te(this,"status");this.status=n}}class Xn extends Error{constructor(n,r){super("Unexpected error response body");te(this,"status");te(this,"data");this.status=n,this.data=r}}class ad{constructor(e,n,r){te(this,"clientId");te(this,"clientPassword");te(this,"redirectURI");this.clientId=e,this.clientPassword=n,this.redirectURI=r}createAuthorizationURL(e,n,r){const i=new URL(e);return i.searchParams.set("response_type","code"),i.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&i.searchParams.set("redirect_uri",this.redirectURI),i.searchParams.set("state",n),r.length>0&&i.searchParams.set("scope",r.join(" ")),i}createAuthorizationURLWithPKCE(e,n,r,i,s){const a=new URL(e);if(a.searchParams.set("response_type","code"),a.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&a.searchParams.set("redirect_uri",this.redirectURI),a.searchParams.set("state",n),r===ni.S256){const c=ab(i);a.searchParams.set("code_challenge_method","S256"),a.searchParams.set("code_challenge",c)}else r===ni.Plain&&(a.searchParams.set("code_challenge_method","plain"),a.searchParams.set("code_challenge",i));return s.length>0&&a.searchParams.set("scope",s.join(" ")),a}async validateAuthorizationCode(e,n,r){const i=new URLSearchParams;i.set("grant_type","authorization_code"),i.set("code",n),this.redirectURI!==null&&i.set("redirect_uri",this.redirectURI),r!==null&&i.set("code_verifier",r),this.clientPassword===null&&i.set("client_id",this.clientId);const s=Ur(e,i);if(this.clientPassword!==null){const c=ma(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await Ks(s)}async refreshAccessToken(e,n,r){const i=new URLSearchParams;i.set("grant_type","refresh_token"),i.set("refresh_token",n),this.clientPassword===null&&i.set("client_id",this.clientId),r.length>0&&i.set("scope",r.join(" "));const s=Ur(e,i);if(this.clientPassword!==null){const c=ma(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await Ks(s)}async revokeToken(e,n){const r=new URLSearchParams;r.set("token",n),this.clientPassword===null&&r.set("client_id",this.clientId);const i=Ur(e,r);if(this.clientPassword!==null){const s=ma(this.clientId,this.clientPassword);i.headers.set("Authorization",`Basic ${s}`)}await lb(i)}}var ni;(function(t){t[t.S256=0]="S256",t[t.Plain=1]="Plain"})(ni||(ni={}));var Pp;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Pp||(Pp={}));var Tp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(Tp||(Tp={}));function Vr(t){return ub(t,pb,Ws.None)}function ub(t,e,n){let r="";for(let i=0;i<t.byteLength;i+=3){let s=0,a=0;for(let c=0;c<3&&i+c<t.byteLength;c++)s=s<<8|t[i+c],a+=8;for(let c=0;c<4;c++)a>=6?(r+=e[s>>a-6&63],a-=6):a>0?(r+=e[s<<6-a&63],a=0):n===Ws.Include&&(r+="=")}return r}const pb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var Ws;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Ws||(Ws={}));var Bp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(Bp||(Bp={}));function fb(t,e,n){const r=Vr(new TextEncoder().encode(t)),i=Vr(new TextEncoder().encode(e)),s=Vr(n);return r+"."+i+"."+s}function hb(t,e){const n=Vr(new TextEncoder().encode(t)),r=Vr(new TextEncoder().encode(e)),i=n+"."+r;return new TextEncoder().encode(i)}const gb="https://appleid.apple.com/auth/authorize",mb="https://appleid.apple.com/auth/token";class Dg{constructor(e,n,r,i,s){te(this,"clientId");te(this,"teamId");te(this,"keyId");te(this,"pkcs8PrivateKey");te(this,"redirectURI");this.clientId=e,this.teamId=n,this.keyId=r,this.pkcs8PrivateKey=i,this.redirectURI=s}createAuthorizationURL(e,n){const r=new URL(gb);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",this.clientId),r.searchParams.set("state",e),n.length>0&&r.searchParams.set("scope",n.join(" ")),r.searchParams.set("redirect_uri",this.redirectURI),r}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 r=await this.createClientSecret();n.set("client_secret",r);const i=Ur(mb,n);return await Ks(i)}async createClientSecret(){const e=await crypto.subtle.importKey("pkcs8",this.pkcs8PrivateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),n=Math.floor(Date.now()/1e3),r=JSON.stringify({typ:"JWT",alg:"ES256",kid:this.keyId}),i=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,hb(r,i)));return fb(r,i,s)}}const _b="https://www.facebook.com/v16.0/dialog/oauth",yb="https://graph.facebook.com/v16.0/oauth/access_token";class Fg{constructor(e,n,r){te(this,"clientId");te(this,"clientSecret");te(this,"redirectURI");this.clientId=e,this.clientSecret=n,this.redirectURI=r}createAuthorizationURL(e,n){const r=new URL(_b);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",this.clientId),r.searchParams.set("state",e),n.length>0&&r.searchParams.set("scope",n.join(" ")),r.searchParams.set("redirect_uri",this.redirectURI),r}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 r=Ur(yb,n);return await Ks(r)}}const wb="https://accounts.google.com/o/oauth2/v2/auth",Rp="https://oauth2.googleapis.com/token",vb="https://oauth2.googleapis.com/revoke";let Kg=class{constructor(e,n,r){te(this,"client");this.client=new ad(e,n,r)}createAuthorizationURL(e,n,r){return this.client.createAuthorizationURLWithPKCE(wb,e,ni.S256,n,r)}async validateAuthorizationCode(e,n){return await this.client.validateAuthorizationCode(Rp,e,n)}async refreshAccessToken(e){return await this.client.refreshAccessToken(Rp,e,[])}async revokeToken(e){await this.client.revokeToken(vb,e)}};const Yo=o.z.object({iss:o.z.string().url(),sub:o.z.string(),aud:o.z.string(),exp:o.z.number(),email:o.z.string().optional(),given_name:o.z.string().optional(),family_name:o.z.string().optional(),name:o.z.string().optional(),iat:o.z.number(),auth_time:o.z.number().optional(),nonce:o.z.string().optional(),acr:o.z.string().optional(),amr:o.z.array(o.z.string()).optional(),azp:o.z.string().optional(),at_hash:o.z.string().optional(),c_hash:o.z.string().optional()}).passthrough();Yo.omit({iat:!0,auth_time:!0,nonce:!0,acr:!0,amr:!0,azp:!0,at_hash:!0,c_hash:!0});function bb(t){return t.ISSUER}function at(t){return t.UNIVERSAL_LOGIN_URL||`${t.ISSUER}u/`}function je(t){return t.OAUTH_API_URL||t.ISSUER}function Wg(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"),r=n.toString().replace(/-----BEGIN PRIVATE KEY-----|-----END PRIVATE KEY-----|\s/g,""),i=Uint8Array.from(Buffer.from(r,"base64"));return n.fill(0),{options:e,keyArray:i}}async function xb(t,e){var l,d;const{options:n,keyArray:r}=Wg(e),i=new Dg(n.client_id,n.team_id,n.kid,r,`${je(t.env)}callback`),s=ke(),a=await i.createAuthorizationURL(s,((l=n.scope)==null?void 0:l.split(" "))||["name","email"]);return(((d=n.scope)==null?void 0:d.split(" "))||["name","email"]).some(p=>["email","name"].includes(p))&&a.searchParams.set("response_mode","form_post"),{redirectUrl:a.href,code:s}}async function kb(t,e,n){const{options:r,keyArray:i}=Wg(e),a=await new Dg(r.client_id,r.team_id,r.kid,i,`${je(t.env)}callback`).validateAuthorizationCode(n),c=dl(a.idToken());if(!c)throw new Error("Invalid ID token");const l=Yo.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 Sb=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:xb,validateAuthorizationCodeAndGetUser:kb},Symbol.toStringTag,{value:"Module"}));async function Ab(t,e){var a;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const r=new Fg(n.client_id,n.client_secret,`${je(t.env)}callback`),i=ke();return{redirectUrl:r.createAuthorizationURL(i,((a=n.scope)==null?void 0:a.split(" "))||["email"]).href,code:i}}async function zb(t,e,n){const{options:r}=e;if(!(r!=null&&r.client_id)||!r.client_secret)throw new Error("Missing required authentication parameters");const s=await new Fg(r.client_id,r.client_secret,`${je(t.env)}callback`).validateAuthorizationCode(n),a=await fetch("https://graph.facebook.com/v16.0/me?fields=id,email,name",{headers:{Authorization:`Bearer ${s.accessToken()}`}});if(!a.ok)throw new Error("Failed to fetch user info");const c=await a.json();return t.set("log",`Userinfo: ${JSON.stringify(c)}`),{sub:c.id,email:c.email,name:c.name}}const Eb=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:Ab,validateAuthorizationCodeAndGetUser:zb},Symbol.toStringTag,{value:"Module"}));async function Ib(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 r=new Kg(n.client_id,n.client_secret,`${je(t.env)}callback`),i=ke(),s=cb();return{redirectUrl:r.createAuthorizationURL(i,s,((c=n.scope)==null?void 0:c.split(" "))??["email","profile"]).href,code:i,codeVerifier:s}}async function Cb(t,e,n,r){const{options:i}=e;if(!(i!=null&&i.client_id)||!i.client_secret||!r)throw new Error("Missing required authentication parameters");const a=await new Kg(i.client_id,i.client_secret,`${je(t.env)}callback`).validateAuthorizationCode(n,r),c=dl(a.idToken());if(!c)throw new Error("Invalid ID token");const l=Yo.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 Nb=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:Ib,validateAuthorizationCodeAndGetUser:Cb},Symbol.toStringTag,{value:"Module"}));async function jb(t,e){var a;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const r=new ad(n.client_id,n.client_secret,`${je(t.env)}callback`),i=ke(),s=r.createAuthorizationURL("https://api.vipps.no/access-management-1.0/access/oauth2/auth",i,((a=n.scope)==null?void 0:a.split(" "))||["openid","email","phoneNumber","name","address","birthDate"]);return s.searchParams.set("response_type","code"),s.searchParams.set("response_mode","query"),{redirectUrl:s.href,code:i}}async function $b(t,e,n){const{options:r}=e;if(!(r!=null&&r.client_id)||!r.client_secret)throw new Error("Missing required authentication parameters");const s=await new ad(r.client_id,r.client_secret,`${je(t.env)}callback`).validateAuthorizationCode("https://api.vipps.no/access-management-1.0/access/oauth2/token",n,null),a=dl(s.idToken());if(!a)throw new Error("Invalid ID token");const c=Yo.parse(a.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 I(400,{message:"Failed to get user from vipps"});return await l.json()}const Ob=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:jb,validateAuthorizationCodeAndGetUser:$b},Symbol.toStringTag,{value:"Module"}));function Gg(t,e){const n=t.env.STRATEGIES||{},i={apple:Sb,facebook:Eb,"google-oauth2":Nb,vipps:Ob,...n}[e];if(!i)throw new Error(`Strategy ${e} not found`);return i}async function Ai(t,e){const n=await t.data.clients.get(e);if(!n)throw new I(403,{message:"Client not found"});const r=t.DEFAULT_CLIENT_ID?await t.data.clients.get(t.DEFAULT_CLIENT_ID):void 0,i=await t.data.connections.list(n.tenant.id),s=t.DEFAULT_TENANT_ID?await t.data.connections.list(t.DEFAULT_TENANT_ID):{connections:[]},a=i.connections.map(c=>{var p;const l=(p=s.connections)==null?void 0:p.find(f=>f.name===c.name);if(!(l!=null&&l.options))return c;const d=Jt.parse({...l||{},...c});return d.options=sl.passthrough().parse({...l.options||{},...c.options}),d}).filter(c=>c);return{...n,web_origins:[...(r==null?void 0:r.web_origins)||[],...n.web_origins||[],`${at(t)}login`],allowed_logout_urls:[...(r==null?void 0:r.allowed_logout_urls)||[],...n.allowed_logout_urls||[],t.ISSUER],callbacks:[...(r==null?void 0:r.callbacks)||[],...n.callbacks||[],`${at(t)}info`],connections:a,tenant:{...(r==null?void 0:r.tenant)||{},...n.tenant}}}async function Pb(t,e,n,r){if(!r.state)throw new I(400,{message:"State not found"});const i=e.connections.find(l=>l.name===n);if(!i){t.set("client_id",e.id);const l=we(t,{type:ge.FAILED_LOGIN,description:"Connection not found"});throw await t.env.data.logs.create(e.tenant.id,l),new I(403,{message:"Connection Not Found"})}let s=await t.env.data.loginSessions.get(e.tenant.id,r.state);s||(s=await t.env.data.loginSessions.create(e.tenant.id,{expires_at:new Date(Date.now()+Qn*1e3).toISOString(),authParams:r,csrf_token:ke(),...Ht(t.req)}));const c=await Gg(t,i.strategy).getRedirect(t,i);return await t.env.data.codes.create(e.tenant.id,{login_id:s.id,code_id:c.code,code_type:"oauth2_state",connection_id:i.id,code_verifier:c.codeVerifier,expires_at:new Date(Date.now()+J0*1e3).toISOString()}),t.redirect(c.redirectUrl)}async function Lp(t,{code:e,state:n}){var h;const{env:r}=t,i=await r.data.codes.get(t.var.tenant_id||"",n,"oauth2_state");if(!i||!i.connection_id)throw new I(403,{message:"State not found"});const s=await r.data.loginSessions.get(t.var.tenant_id||"",i.login_id);if(!s)throw new I(403,{message:"Session not found"});const a=await Ai(r,s.authParams.client_id);t.set("client_id",a.id),t.set("tenant_id",a.tenant.id);const c=a.connections.find(_=>_.id===i.connection_id);if(!c){const _=we(t,{type:ge.FAILED_LOGIN,description:"Connection not found"});throw await r.data.logs.create(a.tenant.id,_),new I(403,{message:"Connection not found"})}if(t.set("connection",c.name),!s.authParams.redirect_uri){const _=we(t,{type:ge.FAILED_LOGIN,description:"Redirect URI not defined"});throw await r.data.logs.create(a.tenant.id,_),new I(403,{message:"Redirect URI not defined"})}const d=await Gg(t,c.strategy).validateAuthorizationCodeAndGetUser(t,c,e,i.code_verifier),{sub:p,...f}=d;t.set("user_id",p);const m=((h=d.email)==null?void 0:h.toLocaleLowerCase())||`${c.name}.${p}@${new URL(t.env.ISSUER).hostname}`;t.set("username",m);const w=await oo(t,{client:a,username:m,provider:c.strategy,connection:c.name,userId:p,profileData:f,isSocial:!0,ip:t.req.header("x-real-ip")});return ln(t,{client:a,authParams:s.authParams,loginSession:s,user:w})}async function Up(t,e,n,r,i,s){const a=await t.env.data.codes.get(t.var.tenant_id||"",e,"oauth2_state");if(!a)throw new I(400,{message:"State not found"});const c=await t.env.data.loginSessions.get(t.var.tenant_id,a.login_id);if(!c)throw new I(400,{message:"Login not found"});const{redirect_uri:l}=c.authParams;if(!l)throw new I(400,{message:"Redirect uri not found"});const d=we(t,{type:ge.FAILED_LOGIN,description:`Failed connection login: ${i} ${n}, ${r}`});zt(t,t.env.data.logs.create(t.var.tenant_id,d));const p=new URL(l);return Xv(p,{error:n,error_description:r,error_reason:s,error_code:i,state:c.authParams.state}),t.redirect(`${at(t.env)}login/identifier?state=${c.id}&error=${n}`)}const Tb=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string(),code:o.z.string().optional(),scope:o.z.string().optional(),hd:o.z.string().optional(),error:o.z.string().optional(),error_description:o.z.string().optional(),error_code:o.z.string().optional(),error_reason:o.z.string().optional()})},responses:{302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{state:e,code:n,error:r,error_description:i,error_code:s,error_reason:a}=t.req.valid("query");if(r)return Up(t,e,r,i,s,a);if(!n)throw new I(400,{message:"Code is required"});return Lp(t,{code:n,state:e})}).openapi(o.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({state:o.z.string(),code:o.z.string().optional(),scope:o.z.string().optional(),hd:o.z.string().optional(),error:o.z.string().optional(),error_description:o.z.string().optional(),error_code:o.z.string().optional(),error_reason:o.z.string().optional()})}}}},responses:{302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{state:e,code:n,error:r,error_description:i,error_code:s,error_reason:a}=t.req.valid("form");if(r)return Up(t,e,r,i,s,a);if(!n)throw new I(400,{message:"Code is required"});return Lp(t,{code:n,state:e})});function Jg(t,e=[],n={}){try{const r=new URL(t);return e.some(i=>{try{return Bb(r,new URL(i),n.allowPathWildcards)}catch{return!1}})}catch{return!1}}function Bb(t,e,n){if(t.protocol!==e.protocol)return!1;if(n&&e.pathname.includes("*")){const r=e.pathname.replace(/\*/g,".*").replace(/\//g,"\\/");if(!new RegExp(`^${r}$`).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 r=e.hostname.split(".").slice(1).join(".");return t.hostname.endsWith(r)}return t.hostname===e.hostname}const Rb=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:o.z.object({client_id:o.z.string(),returnTo:o.z.string().optional()}),header:o.z.object({cookie:o.z.string().optional()})},responses:{302:{description:"Log the user out"}}}),async t=>{const{client_id:e,returnTo:n}=t.req.valid("query"),r=await t.env.data.clients.get(e);if(!r)return t.text("OK");const i=await t.env.data.clients.get("DEFAULT_CLIENT");t.set("client_id",e),t.set("tenant_id",r.tenant.id);const s=n||t.req.header("referer");if(!s)return t.text("OK");if(!Jg(s,[...r.allowed_logout_urls||[],...(i==null?void 0:i.allowed_logout_urls)||[]],{allowPathWildcards:!0}))throw new I(400,{message:"Invalid redirect uri"});const a=t.req.header("cookie");if(a){const l=ds(r.tenant.id,a);if(l){const d=await t.env.data.sessions.get(r.tenant.id,l);if(d){const p=await t.env.data.users.get(r.tenant.id,d.user_id);p&&(t.set("user_id",p.user_id),t.set("connection",p.connection));const f=await t.env.data.refreshTokens.list(r.tenant.id,{q:`session_id=${l}`,page:0,per_page:100,include_totals:!1});await Promise.all(f.refresh_tokens.map(m=>t.env.data.refreshTokens.remove(r.tenant.id,m.id))),await t.env.data.sessions.update(r.tenant.id,l,{revoked_at:new Date().toISOString()})}}}const c=we(t,{type:ge.SUCCESS_LOGOUT,description:"User successfully logged out"});return await t.env.data.logs.create(r.tenant.id,c),new Response("Redirecting",{status:302,headers:{"set-cookie":e_(r.tenant.id,t.req.header("host")),location:s}})}),Vp=o.z.object({sub:o.z.string(),email:o.z.string().optional(),family_name:o.z.string().optional(),given_name:o.z.string().optional(),email_verified:o.z.boolean()}),Lb=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth2"],method:"get",path:"/",request:{},security:[{Bearer:["openid"]}],responses:{200:{content:{"application/json":{schema:Vp}},description:"Userinfo"}}}),async t=>{if(!t.var.user)throw new I(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 I(404,{message:"User not found"});return t.json(Vp.parse({...e,sub:e.user_id}))}),Ub=new o.OpenAPIHono().openapi(o.createRoute({tags:["well known"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:_f}},description:"List of tenants"}}}),async t=>{const e=await t.env.data.keys.list(),n=await Promise.all(e.map(async r=>{const s=await new sd(r.cert).publicKey.export(),a=await crypto.subtle.exportKey("jwk",s);return al.parse({...a,kid:r.kid})}));return t.json({keys:n},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${Oi}, stale-while-revalidate=${Oi*2}, stale-if-error=86400`}})}).openapi(o.createRoute({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Ea}},description:"List of tenants"}}}),async t=>{const e=Ea.parse({issuer:bb(t.env),authorization_endpoint:`${je(t.env)}authorize`,token_endpoint:`${je(t.env)}oauth/token`,device_authorization_endpoint:`${je(t.env)}oauth/device/code`,userinfo_endpoint:`${je(t.env)}userinfo`,mfa_challenge_endpoint:`${je(t.env)}mfa/challenge`,jwks_uri:`${je(t.env)}.well-known/jwks.json`,registration_endpoint:`${je(t.env)}oidc/register`,revocation_endpoint:`${je(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=${Oi}, stale-while-revalidate=${Oi*2}, stale-if-error=86400`}})});function Ki(t,e){if(!t||!e||t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t.charCodeAt(r)^e.charCodeAt(r);return n===0}const Zg=o.z.object({grant_type:o.z.literal("client_credentials"),scope:o.z.string().optional(),client_secret:o.z.string(),client_id:o.z.string(),audience:o.z.string().optional()});async function Vb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new I(403,{message:"Invalid client credentials"});if(n.client_secret&&!Ki(n.client_secret,e.client_secret))throw new I(403,{message:"Invalid client credentials"});const r={client_id:n.id,scope:e.scope,audience:e.audience},i=await ro(t,{authParams:r,client:n});return t.json(i)}const qb=o.z.object({grant_type:o.z.literal("authorization_code"),client_id:o.z.string(),code:o.z.string(),redirect_uri:o.z.string().optional(),client_secret:o.z.string().optional(),code_verifier:o.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 Mb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new I(403,{message:"Client not found"});const r=await t.env.data.codes.get(n.tenant.id,e.code,"authorization_code");if(!r||!r.user_id)throw new I(403,{message:"Invalid client credentials"});if(new Date(r.expires_at)<new Date)throw new I(403,{message:"Code expired"});if(r.used_at)throw new I(403,{message:"Code already used"});const i=await t.env.data.loginSessions.get(n.tenant.id,r.login_id);if(!i)throw new I(403,{message:"Invalid login"});if("client_secret"in e){const a=await t.env.data.clients.get("DEFAULT_CLIENT");if(!Ki(n.client_secret,e.client_secret)&&!Ki(a==null?void 0:a.client_secret,e.client_secret))throw new I(403,{message:"Invalid client credentials"})}else if("code_verifier"in e&&typeof e.code_verifier=="string"&&"code_challenge_method"in i.authParams&&typeof i.authParams.code_challenge_method=="string"){const a=await F0(e.code_verifier,i.authParams.code_challenge_method);if(!Ki(a,i.authParams.code_challenge||""))throw new I(403,{message:"Invalid client credentials"})}if(i.authParams.redirect_uri&&i.authParams.redirect_uri!==e.redirect_uri)throw new I(403,{message:"Invalid redirect uri"});const s=await t.env.data.users.get(n.tenant.id,r.user_id);if(!s)throw new I(403,{message:"User not found"});return await t.env.data.codes.used(n.tenant.id,e.code),ln(t,{user:s,client:n,loginSession:i,authParams:{...i.authParams,response_mode:Rt.WEB_MESSAGE}})}const Hb=o.z.object({grant_type:o.z.literal("refresh_token"),client_id:o.z.string(),redirect_uri:o.z.string().optional(),refresh_token:o.z.string()});async function Db(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new I(403,{message:"Client not found"});const r=await t.env.data.refreshTokens.get(n.tenant.id,e.refresh_token);if(r){if(r.expires_at&&new Date(r.expires_at)<new Date||r.idle_expires_at&&new Date(r.idle_expires_at)<new Date)throw new I(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Refresh token has expired"})})}else throw new I(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Invalid refresh token"})});const i=await t.env.data.users.get(n.tenant.id,r.user_id);if(!i)throw new I(403,{message:"User not found"});const s=r.resource_servers[0];if(r.idle_expires_at){const a=new Date(Date.now()+2592e6);await t.env.data.refreshTokens.update(n.tenant.id,r.id,{idle_expires_at:a.toISOString(),last_exchanged_at:new Date().toISOString(),device:{...r.device,last_ip:t.req.header["x-real-ip"]||"",last_user_agent:t.req.header["user-agent"]||""}})}return ln(t,{user:i,client:n,refreshToken:r.id,sessionId:r.session_id,authParams:{client_id:n.id,audience:s==null?void 0:s.audience,scope:s==null?void 0:s.scopes,response_mode:Rt.WEB_MESSAGE}})}function cd(t){return t.includes("@")?"email":"sms"}const Fb=o.z.object({client_id:o.z.string(),username:o.z.string().transform(t=>t.toLowerCase()),otp:o.z.string(),authParams:Mr.optional()});async function Yg(t,{client_id:e,username:n,otp:r,authParams:i}){const s=await t.env.data.clients.get(e);if(!s)throw new I(403,{message:"Client not found"});return ld(t,s,i||{client_id:e,response_type:It.TOKEN_ID_TOKEN,response_mode:Rt.WEB_MESSAGE},n,r)}async function ld(t,e,n,r,i,s,a){const{env:c}=t,l=await c.data.codes.get(e.tenant.id,i,"otp");if(!l)throw new I(400,{message:"Code not found or expired"});if(l.expires_at<new Date().toISOString())throw new I(400,{message:"Code expired"});if(l.used_at)throw new I(400,{message:"Code already used"});const d=cd(r),p=await c.data.loginSessions.get(e.tenant.id,l.login_id);if(!p||p.authParams.username!==r)throw new I(400,{message:"Code not found or expired"});const f=Ht(t.req);if(a&&p.ip!==f.ip)return t.redirect(`${at(t.env)}invalid-session?state=${p.id}`);const m=await oo(t,{client:e,username:r,provider:d,connection:d,isSocial:!1,ip:t.req.header("x-real-ip")});return await c.data.codes.used(e.tenant.id,i),ln(t,{user:m,client:e,loginSession:p,authParams:n,ticketAuth:s})}const qp=o.z.object({client_id:o.z.string().optional(),client_secret:o.z.string().optional()}),Kb=o.z.union([Zg.extend(qp.shape),o.z.object({grant_type:o.z.literal("authorization_code"),client_id:o.z.string(),code:o.z.string(),redirect_uri:o.z.string(),code_verifier:o.z.string().min(43).max(128)}),o.z.object({grant_type:o.z.literal("authorization_code"),code:o.z.string(),redirect_uri:o.z.string().optional(),...qp.shape}),o.z.object({grant_type:o.z.literal("refresh_token"),client_id:o.z.string(),refresh_token:o.z.string(),redirect_uri:o.z.string().optional()}),o.z.object({grant_type:o.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),client_id:o.z.string(),username:o.z.string(),otp:o.z.string(),realm:o.z.enum(["email","sms"])})]);function Wb(t){if(!t)return{};const[e,n]=t.split(" ");if((e==null?void 0:e.toLowerCase())==="basic"&&n){const[r,i]=atob(n).split(":");return{client_id:r,client_secret:i}}return{}}const Gb=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:Kb}}}},responses:{200:{content:{"application/json":{schema:kf}},description:"Tokens"}}}),async t=>{const e=t.req.valid("form"),n=Wb(t.req.header("Authorization")),r={...e,...n};if(!r.client_id)throw new I(400,{message:"client_id is required"});switch(t.set("client_id",r.client_id),e.grant_type){case Wn.AuthorizationCode:return Mb(t,qb.parse(r));case Wn.ClientCredential:return Vb(t,Zg.parse(r));case Wn.RefreshToken:return Db(t,Hb.parse(r));case Wn.OTP:return Yg(t,Fb.parse(r));default:throw new I(400,{message:"Not implemented"})}});var dd={exports:{}};const ud=[{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}],Xg=(t,e=ud,n="!\"#$%&'()*+,-./:;<=>?@[\\\\\\]^_`{|}~")=>{let r=t||"";e[0].minDiversity=0,e[0].minLength=0;const i=[{regex:"[a-z]",message:"lowercase"},{regex:"[A-Z]",message:"uppercase"},{regex:"[0-9]",message:"number"}];n&&i.push({regex:`[${n}]`,message:"symbol"});let s={};s.contains=i.filter(c=>new RegExp(`${c.regex}`).test(r)).map(c=>c.message),s.length=r.length;let a=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,a[0]),s};dd.exports={passwordStrength:Xg,defaultOptions:ud};var Jb=dd.exports.passwordStrength=Xg;dd.exports.defaultOptions=ud;function pd(t){return Jb(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 zi(t,e){var i;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 I(500,{message:"Email provider not found"});const r=(i=t.env.emailProviders)==null?void 0:i[n.name];if(!r)throw new I(500,{message:"Email provider not found"});await r({emailProvider:n,...e,from:n.default_from_address||`login@${t.env.ISSUER}`})}async function Zb(t,e){var a,c;if(!t.var.client_id)throw new I(500,{message:"Client not found"});const n=await Ai(t.env,t.var.client_id),r=n.connections.find(l=>l.strategy==="sms");if(!r)throw new I(500,{message:"SMS provider not found"});const i=((a=r.options)==null?void 0:a.provider)||"twilio",s=(c=t.env.smsProviders)==null?void 0:c[i];if(!s)throw new I(500,{message:"SMS provider not found"});await s({options:r.options,to:e.to,text:e.text,template:"auth-code",data:{code:e.code,tenantName:n.tenant.name,tenantId:n.tenant.id}})}async function Qg(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new I(500,{message:"Tenant not found"});const s=`${at(t.env)}reset-password?state=${r}&code=${n}`,a={vendorName:i.name,lng:i.language||"en"};await zi(t,{to:e,subject:re("reset_password_title",a),html:`Click here to reset your password: ${at(t.env)}reset-password?state=${r}&code=${n}`,template:"auth-password-reset",data:{vendorName:i.name,logo:i.logo||"",passwordResetUrl:s,supportUrl:i.support_url||"https://support.sesamy.com",buttonColor:i.primary_color||"#7d68f4",passwordResetTitle:re("password_reset_title",a),resetPasswordEmailClickToReset:re("reset_password_email_click_to_reset",a),resetPasswordEmailReset:re("reset_password_email_reset",a),supportInfo:re("support_info",a),contactUs:re("contact_us",a),copyright:re("copyright",a),tenantName:i.name,tenantId:i.id}})}async function em(t,{to:e,code:n}){const r=await t.env.data.tenants.get(t.var.tenant_id);if(!r)throw new I(500,{message:"Tenant not found"});const i=cd(e),s=new URL(at(t.env)),a={vendorName:r.name,vendorId:r.id,loginDomain:s.hostname,code:n,lng:r.language||"en"};i==="email"?await zi(t,{to:e,subject:re("code_email_subject",a),html:`Click here to validate your email: ${at(t.env)}validate-email`,template:"auth-code",data:{code:n,vendorName:r.name,logo:r.logo||"",supportUrl:r.support_url||"",buttonColor:r.primary_color||"",welcomeToYourAccount:re("welcome_to_your_account",a),linkEmailClickToLogin:re("link_email_click_to_login",a),linkEmailLogin:re("link_email_login",a),linkEmailOrEnterCode:re("link_email_or_enter_code",a),codeValid30Mins:re("code_valid_30_minutes",a),supportInfo:re("support_info",a),contactUs:re("contact_us",a),copyright:re("copyright",a)}}):i==="sms"&&await Zb(t,{to:e,text:re("sms_code_text",a),code:n});const c=we(t,{type:ge.CODE_LINK_SENT,description:e});zt(t,t.env.data.logs.create(r.id,c))}async function fd(t,{to:e,code:n,authParams:r}){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new I(500,{message:"Tenant not found"});if(!r.redirect_uri)throw new I(400,{message:"redirect_uri is required"});const s=cd(e),a=new URL(je(t.env));a.pathname="passwordless/verify_redirect",a.searchParams.set("verification_code",n),a.searchParams.set("connection",s),a.searchParams.set("client_id",r.client_id),a.searchParams.set("redirect_uri",r.redirect_uri),a.searchParams.set("email",e),r.response_type&&a.searchParams.set("response_type",r.response_type),r.scope&&a.searchParams.set("scope",r.scope),r.state&&a.searchParams.set("state",r.state),r.nonce&&a.searchParams.set("nonce",r.nonce),r.code_challenge&&a.searchParams.set("code_challenge",r.code_challenge),r.code_challenge_method&&a.searchParams.set("code_challenge_method",r.code_challenge_method),r.audience&&a.searchParams.set("audience",r.audience);const c={vendorName:i.name,code:n,lng:i.language||"en"};if(s!=="email")throw new I(400,{message:"Only email connections are supported for magic links"});await zi(t,{to:e,subject:re("code_email_subject",c),html:`Click here to validate your email: ${at(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:i.name,logo:i.logo||"",supportUrl:i.support_url||"",magicLink:a.toString(),buttonColor:i.primary_color||"",welcomeToYourAccount:re("welcome_to_your_account",c),linkEmailClickToLogin:re("link_email_click_to_login",c),linkEmailLogin:re("link_email_login",c),linkEmailOrEnterCode:re("link_email_or_enter_code",c),codeValid30Mins:re("code_valid_30_minutes",c),supportInfo:re("support_info",c),contactUs:re("contact_us",c),copyright:re("copyright",c)}});const l=we(t,{type:ge.CODE_LINK_SENT,description:e});zt(t,t.env.data.logs.create(i.id,l))}async function hd(t,e){const n=await t.env.data.tenants.get(t.var.tenant_id);if(!n)throw new I(500,{message:"Tenant not found"});if(!e.email)throw new I(400,{message:"User has no email"});const r={vendorName:n.name,lng:n.language||"en"};await zi(t,{to:e.email,subject:re("welcome_to_your_account",r),html:`Click here to validate your email: ${at(t.env)}validate-email`,template:"auth-verify-email",data:{vendorName:n.name,logo:n.logo||"",emailValidationUrl:`${at(t.env)}validate-email`,supportUrl:n.support_url||"https://support.sesamy.com",buttonColor:n.primary_color||"#7d68f4",welcomeToYourAccount:re("welcome_to_your_account",r),verifyEmailVerify:re("verify_email_verify",r),supportInfo:re("support_info",r),contactUs:re("contact_us",r),copyright:re("copyright",r)}})}async function Yb(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new I(500,{message:"Tenant not found"});const s={vendorName:i.name,lng:i.language||"en"},a=`${at(t.env)}signup?state=${r}&code=${n}`;await zi(t,{to:e,subject:re("register_password_account",s),html:`Click here to register: ${a}`,template:"auth-pre-signup-verification",data:{vendorName:i.name,logo:i.logo||"",signupUrl:a,setPassword:re("set_password",s),registerPasswordAccount:re("register_password_account",s),clickToSignUpDescription:re("click_to_sign_up_description",s),supportUrl:i.support_url||"https://support.sesamy.com",buttonColor:i.primary_color||"#7d68f4",welcomeToYourAccount:re("welcome_to_your_account",s),verifyEmailVerify:re("verify_email_verify",s),supportInfo:re("support_info",s),contactUs:re("contact_us",s),copyright:re("copyright",s)}})}const Xb=new o.OpenAPIHono().openapi(o.createRoute({tags:["dbconnections"],method:"post",path:"/signup",request:{body:{content:{"application/json":{schema:o.z.object({client_id:o.z.string(),connection:o.z.literal("Username-Password-Authentication"),email:o.z.string().transform(t=>t.toLowerCase()),password:o.z.string()})}}}},responses:{200:{content:{"application/json":{schema:o.z.object({_id:o.z.string(),email:o.z.string().optional(),email_verified:o.z.boolean(),app_metadata:o.z.object({}),user_metadata:o.z.object({})})}},description:"Created user"}}}),async t=>{const{email:e,password:n,client_id:r}=t.req.valid("json"),i=await t.env.data.clients.get(r);if(!i)throw new I(400,{message:"Client not found"});if(t.set("client_id",i.id),t.set("tenant_id",i.tenant.id),!pd(n))throw new I(400,{message:"Password does not meet the requirements"});if(await us({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username:e,provider:"auth2"}))throw new I(400,{message:"Invalid sign up"});const a=await t.env.data.users.create(i.tenant.id,{user_id:`auth2|${eo()}`,email:e,email_verified:!1,provider:"auth2",connection:"Username-Password-Authentication",is_social:!1});t.set("user_id",a.user_id),t.set("username",a.email),t.set("connection",a.connection);const c=await oi.hash(n,10);await t.env.data.passwords.create(i.tenant.id,{user_id:a.user_id,password:c,algorithm:"bcrypt"}),await hd(t,a);const l=we(t,{type:ge.SUCCESS_SIGNUP,description:"Successful signup"});return await t.env.data.logs.create(i.tenant.id,l),t.json({_id:a.user_id,email:a.email,email_verified:!1,app_metadata:{},user_metadata:{}})}).openapi(o.createRoute({tags:["dbconnections"],method:"post",path:"/change_password",request:{body:{content:{"application/json":{schema:o.z.object({client_id:o.z.string(),connection:o.z.literal("Username-Password-Authentication"),email:o.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"),r=await t.env.data.clients.get(n);if(!r)throw new I(400,{message:"Client not found"});if(t.set("client_id",r.id),t.set("tenant_id",r.tenant.id),!await fr({userAdapter:t.env.data.users,tenant_id:r.tenant.id,username: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},a=await t.env.data.loginSessions.create(r.tenant.id,{expires_at:new Date(Date.now()+Qn*1e3).toISOString(),authParams:s,csrf_token:ke(),...Ht(t.req)});return await Qg(t,e,a.id,a.authParams.state),t.html("If an account with that email exists, we've sent instructions to reset your password.")});function Tn(){const t="1234567890";let e="";for(let n=0;n<6;n+=1)e+=t[Math.floor(Math.random()*10)];return e.toString()}const Qb=new o.OpenAPIHono().openapi(o.createRoute({tags:["passwordless"],method:"post",path:"/start",request:{body:{content:{"application/json":{schema:o.z.union([o.z.object({connection:o.z.literal("email"),client_id:o.z.string(),email:o.z.string().transform(t=>t.toLowerCase()),send:o.z.enum(["link","code"]),authParams:Mr.omit({client_id:!0})}),o.z.object({client_id:o.z.string(),connection:o.z.literal("sms"),phone_number:o.z.string(),send:o.z.enum(["link","code"]),authParams:Mr.omit({client_id:!0})})])}}}},responses:{200:{description:"Status"}}}),async t=>{const e=t.req.valid("json"),{env:n}=t,{client_id:r,send:i,authParams:s,connection:a}=e,c=await t.env.data.clients.get(r);if(!c)throw new I(400,{message:"Client not found"});t.set("client_id",c.id),t.set("tenant_id",c.tenant.id);const l=a==="email"?e.email:e.phone_number,d=await n.data.loginSessions.create(c.tenant.id,{authParams:{...s,client_id:r,username:l},expires_at:new Date(Date.now()+Na).toISOString(),csrf_token:ke(),...Ht(t.req)}),p=await n.data.codes.create(c.tenant.id,{code_id:Tn(),code_type:"otp",login_id:d.id,expires_at:new Date(Date.now()+Na).toISOString()});return i==="link"?await fd(t,{to:l,code:p.code_id,authParams:{...s,client_id:r}}):await em(t,{to:l,code:p.code_id}),t.html("OK")}).openapi(o.createRoute({tags:["passwordless"],method:"get",path:"/verify_redirect",request:{query:o.z.object({scope:o.z.string(),response_type:o.z.nativeEnum(It),redirect_uri:o.z.string(),state:o.z.string(),nonce:o.z.string().optional(),verification_code:o.z.string(),connection:o.z.string(),client_id:o.z.string(),email:o.z.string().transform(t=>t.toLowerCase()),audience:o.z.string().optional()})},responses:{302:{description:"Status"}}}),async t=>{const{env:e}=t,{client_id:n,email:r,verification_code:i,redirect_uri:s,state:a,scope:c,audience:l,response_type:d,nonce:p}=t.req.valid("query"),f=await Ai(e,n);return t.set("client_id",f.id),t.set("tenant_id",f.tenant.id),t.set("connection","email"),ld(t,f,{client_id:n,redirect_uri:s,state:a,nonce:p,scope:c,audience:l,response_type:d},r,i,!1,!0)});class jr extends I{constructor(n,r){super(n,r);te(this,"_code");this._code=r==null?void 0:r.code}get code(){return this._code}}async function gd(t,e,n,r,i){const{env:s}=t,{username:a}=n;if(t.set("username",a),!a)throw new I(400,{message:"Username is required"});const c=await fr({userAdapter:t.env.data.users,tenant_id:e.tenant.id,username:a,provider:"auth2"});if(!c){const h=we(t,{type:ge.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid user"});throw zt(t,t.env.data.logs.create(e.tenant.id,h)),new jr(403,{message:"User not found",code:"USER_NOT_FOUND"})}const l=c.linked_to?await s.data.users.get(e.tenant.id,c.linked_to):c;if(!l)throw new jr(403,{message:"User not found",code:"USER_NOT_FOUND"});t.set("connection",c.connection),t.set("user_id",l.user_id);const d=await s.data.passwords.get(e.tenant.id,c.user_id);if(!(d&&await oi.compare(n.password,d.password))){const h=we(t,{type:ge.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});throw zt(t,t.env.data.logs.create(e.tenant.id,h)),new jr(403,{message:"Invalid password",code:"INVALID_PASSWORD"})}if((await s.data.logs.list(e.tenant.id,{page:0,per_page:10,include_totals:!1,q:`user_id:${l.user_id}`})).logs.filter(h=>h.type===ge.FAILED_LOGIN_INCORRECT_PASSWORD&&new Date(h.date)>new Date(Date.now()-1e3*60*5)).length>=3){const h=we(t,{type:ge.FAILED_LOGIN,description:"Too many failed login attempts"});throw zt(t,t.env.data.logs.create(e.tenant.id,h)),new jr(403,{message:"Too many failed login attempts",code:"TOO_MANY_FAILED_LOGINS"})}if(!c.email_verified&&e.email_validation==="enforced"){await hd(t,c);const h=we(t,{type:ge.FAILED_LOGIN,description:"Email not verified"});throw await t.env.data.logs.create(e.tenant.id,h),new jr(403,{message:"Email not verified",code:"EMAIL_NOT_VERIFIED"})}const w=we(t,{type:ge.SUCCESS_LOGIN,description:"Successful login",strategy_type:"Username-Password-Authentication",strategy:"Username-Password-Authentication"});return zt(t,t.env.data.logs.create(e.tenant.id,w)),ln(t,{client:e,authParams:n,user:l,ticketAuth:i,loginSession:r})}async function e1(t,e,n,r){await oo(t,{client:e,username:n,provider:"auth2",connection:"Username-Password-Authentication",isSocial:!1,ip:t.req.header("x-real-ip")});let i=Tn(),s=await t.env.data.codes.get(e.tenant.id,i,"password_reset");for(;s;)i=Tn(),s=await t.env.data.codes.get(e.tenant.id,i,"password_reset");const a=await t.env.data.loginSessions.create(e.tenant.id,{expires_at:new Date(Date.now()+X0).toISOString(),authParams:{client_id:e.id,username:n},csrf_token:ke(),...Ht(t.req)}),c=await t.env.data.codes.create(e.tenant.id,{code_id:i,code_type:"password_reset",login_id:a.id,expires_at:new Date(Date.now()+Y0).toISOString()});await Qg(t,n,c.code_id,r)}const t1=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.union([o.z.object({credential_type:o.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),otp:o.z.string(),client_id:o.z.string(),username:o.z.string().transform(t=>t.toLowerCase()),realm:o.z.enum(["email"]),scope:o.z.string().optional()}),o.z.object({credential_type:o.z.literal("http://auth0.com/oauth/grant-type/password-realm"),client_id:o.z.string(),username:o.z.string().transform(t=>t.toLowerCase()),password:o.z.string(),realm:o.z.enum(["Username-Password-Authentication"]),scope:o.z.string().optional()})])}}}},responses:{200:{description:"List of tenants"}}}),async t=>{const e=t.req.valid("json"),{client_id:n,username:r}=e;t.set("username",r);const i=await t.env.data.clients.get(n);if(!i)throw new I(400,{message:"Client not found"});t.set("client_id",n),t.set("tenant_id",i.tenant.id);const s=r.toLocaleLowerCase();if("otp"in e)return ld(t,i,{client_id:n,username:s},s,e.otp,!0);if("password"in e){const a=await t.env.data.loginSessions.create(i.tenant.id,{expires_at:new Date(Date.now()+Qn*1e3).toISOString(),authParams:{client_id:n,username:s},csrf_token:ke(),...Ht(t.req)});return gd(t,i,{username:s,password:e.password,client_id:n},a,!0)}else throw new I(400,{message:"Code or password required"})});function n1(t,e){var r,i,s;if(!t||e.length===0)return!1;const n=((r=_a(t))==null?void 0:r.host)??null;if(!n)return!1;for(const a of e){let c;if(a.startsWith("http://")||a.startsWith("https://")?c=((i=_a(a))==null?void 0:i.host)??null:c=((s=_a("https://"+a))==null?void 0:s.host)??null,n===c)return!0}return!1}function _a(t){try{return new URL(t)}catch{return null}}async function r1({ctx:t,session:e,client:n,authParams:r,connection:i,login_hint:s}){const a=await t.env.data.loginSessions.create(n.tenant.id,{expires_at:new Date(Date.now()+Qn*1e3).toISOString(),authParams:r,csrf_token:ke(),authorization_url:t.req.url,...Ht(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 ln(t,{client:n,loginSession:a,authParams:r,user:c,sessionId:e.id})}if(i==="email"&&s){const c=Tn();return await t.env.data.codes.create(n.tenant.id,{code_id:c,code_type:"otp",login_id:a.id,expires_at:new Date(Date.now()+Qn*1e3).toISOString()}),await fd(t,{code:c,to:s,authParams:r}),t.redirect(`/u/enter-code?state=${a.id}`)}return e?t.redirect(`/u/check-account?state=${a.id}`):t.redirect(`/u/login/identifier?state=${a.id}`)}function i1(t){if(t==="Username-Password-Authentication")return"auth2";if(t==="email")return"email";throw new I(403,{message:"Invalid realm"})}async function s1(t,e,n,r,i){var m;const{env:s}=t;t.set("connection",i);const a=await s.data.codes.get(e,n,"ticket");if(!a||a.used_at)throw new I(403,{message:"Ticket not found"});const c=await s.data.loginSessions.get(e,a.login_id);if(!c||!c.authParams.username)throw new I(403,{message:"Session not found"});const l=await s.data.clients.get(c.authParams.client_id);if(!l)throw new I(403,{message:"Client not found"});t.set("client_id",c.authParams.client_id),await s.data.codes.used(e,n);const d=i1(i);let p=await oo(t,{username:c.authParams.username,provider:d,client:l,connection:d==="auth2"?"Username-Password-Authentication":"email",isSocial:!1,ip:t.req.header("x-real-ip")});t.set("username",p.email||p.phone_number),t.set("user_id",p.user_id);const f=await Kf(t,{user:p,client:l,loginSession:c});return ln(t,{authParams:{scope:(m=c.authParams)==null?void 0:m.scope,...r},loginSession:c,sessionId:f.id,user:p,client:l})}async function Mp(t,e){return`<!DOCTYPE html>
149
+ `,r}async function $v(t){const e=await t.publicKey.export(),n=await crypto.subtle.exportKey("jwk",e),r=JSON.stringify(n,Object.keys(n).sort()),s=new TextEncoder().encode(r);return Ca(await Pf(s))}const Ov=1e3*60*60*24,Pv=new o.OpenAPIHono().openapi(o.createRoute({tags:["keys"],method:"get",path:"/signing",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.array(Ia)}},description:"List of keys"}}}),async t=>{const n=(await t.env.data.keys.list()).filter(r=>"cert"in r).map(r=>r);return t.json(n)}).openapi(o.createRoute({tags:["keys"],method:"get",path:"/signing/{kid}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({kid:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ia}},description:"The requested key"}}}),async t=>{const{kid:e}=t.req.valid("param"),r=(await t.env.data.keys.list()).find(i=>i.kid===e);if(!r)throw new I(404,{message:"Key not found"});return t.json(r)}).openapi(o.createRoute({tags:["keys"],method:"post",path:"/signing/rotate",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{description:"Status"}}}),async t=>{const e=await t.env.data.keys.list();for await(const r of e)await t.env.data.keys.update(r.kid,{revoked_at:new Date(Date.now()+Ov).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(o.createRoute({tags:["keys"],method:"put",path:"/signing/{kid}/revoke",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({kid:o.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 I(404,{message:"Key not found"});const r=await Zc({name:`CN=${t.env.ORGANIZATION_NAME}`});return await t.env.data.keys.create(r),t.text("OK")}),Tv=new o.OpenAPIHono().openapi(o.createRoute({tags:["users"],method:"get",path:"/",request:{query:o.z.object({email:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:o.z.array(il)}},description:"List of users"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{email:n}=t.req.valid("query"),i=(await ml(t.env.data.users,e,n)).filter(s=>!s.linked_to);return t.json(i)}),Bv=an.extend({clients:o.z.array(mn)}),Rv=new o.OpenAPIHono().openapi(o.createRoute({tags:["clients"],method:"get",path:"/",request:{query:tn,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([Bv,o.z.array(mn)])}},description:"List of clients"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i,sort:s,q:a}=t.req.valid("query"),l=(await t.env.data.applications.list(e,{page:n,per_page:r,include_totals:i,sort:hr(s),q:a})).applications;return i?t.json({clients:l,start:0,limit:10,length:l.length}):t.json(l)}).openapi(o.createRoute({tags:["clients"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:mn}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=(await t.env.data.applications.list(e,{page:1,per_page:0,include_totals:!1})).applications.find(s=>s.id===n);if(!i)throw new I(404);return t.json(i)}).openapi(o.createRoute({tags:["clients"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.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 I(404,{message:"Application not found"});return t.text("OK")}).openapi(o.createRoute({tags:["clients"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:o.z.object(is.shape).partial()}}},params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:mn}},description:"The update application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),i=t.req.valid("json");await t.env.data.applications.update(e,n,i);const s=await t.env.data.applications.get(e,n);if(!s)throw new I(404,{message:"Application not found"});return t.json(s)}).openapi(o.createRoute({tags:["clients"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.object(is.shape)}}},headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:o.z.object(mn.shape)}},description:"An application"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r={...n,id:n.id||ke(),client_secret:n.client_secret||ke()},i=await t.env.data.applications.create(e,r);return t.json(i,{status:201})});o.z.object({start:o.z.number(),limit:o.z.number(),length:o.z.number()});Ys.extend({email:o.z.string(),login_count:o.z.number(),multifactor:o.z.array(o.z.string()).optional(),last_ip:o.z.string().optional(),last_login:o.z.string().optional(),user_id:o.z.string()}).catchall(o.z.any());const Lv=an.extend({tenants:o.z.array(Jn)}),Uv=new o.OpenAPIHono().openapi(o.createRoute({tags:["tenants"],method:"get",path:"/",request:{query:tn},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:o.z.union([o.z.array(Jn),Lv])}},description:"List of tenants"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),a=await t.env.data.tenants.list({page:e,per_page:n,include_totals:r,sort:hr(i),q:s});return r?t.json(a):t.json(a.tenants)}).openapi(o.createRoute({tags:["tenants"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"tenant/json":{schema:Jn}},description:"A tenant"}}}),async t=>{const{id:e}=t.req.valid("param"),n=await t.env.data.tenants.get(e);if(!n)throw new I(404);return t.json(n)}).openapi(o.createRoute({tags:["tenants"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.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(o.createRoute({tags:["tenants"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:o.z.object(os.shape).partial()}}},params:o.z.object({id:o.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(o.createRoute({tags:["tenants"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.object(os.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"tenant/json":{schema:Jn}},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})}),Vv=an.extend({logs:o.z.array(cs)}),qv=new o.OpenAPIHono().openapi(o.createRoute({tags:["logs"],method:"get",path:"/",request:{query:tn,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(cs),Vv])}},description:"List of log rows"}}}),async t=>{const{page:e,per_page:n,include_totals:r,sort:i,q:s}=t.req.valid("query"),{"tenant-id":a}=t.req.valid("header"),c=await t.env.data.logs.list(a,{page:e,per_page:n,include_totals:r,sort:hr(i),q:s});return r?t.json(c):t.json(c.logs)}).openapi(o.createRoute({tags:["logs"],method:"get",path:"/{id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:cs}},description:"A log entry"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.logs.get(e,n);if(!r)throw new I(404);return t.json(r)}),Mv=an.extend({hooks:o.z.array(Kn)}),Hv=new o.OpenAPIHono().openapi(o.createRoute({tags:["hooks"],method:"get",path:"/",request:{query:tn,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(Kn),Mv])}},description:"List of hooks"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i,sort:s,q:a}=t.req.valid("query"),c=await t.env.data.hooks.list(e,{page:n,per_page:r,include_totals:i,sort:hr(s),q:a});return i?t.json(c):t.json(c.hooks)}).openapi(o.createRoute({tags:["hooks"],method:"post",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(as.shape)}}}},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Kn}},description:"The created hook"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.hooks.create(e,n);return t.json(r,{status:201})}).openapi(o.createRoute({tags:["hooks"],method:"patch",path:"/{hook_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({hook_id:o.z.string()}),body:{content:{"application/json":{schema:o.z.object(as.shape).omit({hook_id:!0}).partial()}}}},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Kn.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"),r=t.req.valid("json");await t.env.data.hooks.update(e,n,r);const i=await t.env.data.hooks.get(e,n);if(!i)throw new I(404,{message:"Hook not found"});return t.json(i)}).openapi(o.createRoute({tags:["hooks"],method:"get",path:"/{hook_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({hook_id:o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Kn}},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"),r=await t.env.data.hooks.get(e,n);if(!r)throw new I(404,{message:"Hook not found"});return t.json(r)}).openapi(o.createRoute({tags:["hooks"],method:"delete",path:"/{hook_id}",request:{headers:o.z.object({"tenant-id":o.z.string()}),params:o.z.object({hook_id:o.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 I(404,{message:"Hook not found"});return t.text("OK")}),Dv=an.extend({connections:o.z.array(Jt)}),Fv=new o.OpenAPIHono().openapi(o.createRoute({tags:["connections"],method:"get",path:"/",request:{query:tn,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.union([o.z.array(Jt),Dv])}},description:"List of connectionss"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{page:n,per_page:r,include_totals:i=!1,sort:s,q:a}=t.req.valid("query"),c=await t.env.data.connections.list(e,{page:n,per_page:r,include_totals:i,sort:hr(s),q:a});return i?t.json(c):t.json(c.connections)}).openapi(o.createRoute({tags:["connections"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Jt}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.connections.get(e,n);if(!r)throw new I(404);return t.json(r)}).openapi(o.createRoute({tags:["connections"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.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 I(404,{message:"Connection not found"});return t.text("OK")}).openapi(o.createRoute({tags:["connections"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:o.z.object(ss.shape).partial()}}},params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Jt}},description:"The updated connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=t.req.valid("json");if(!await t.env.data.connections.update(e,n,r))throw new I(404,{message:"Connection not found"});const s=await t.env.data.connections.get(e,n);if(!s)throw new I(404,{message:"Connection not found"});return t.json(s)}).openapi(o.createRoute({tags:["connections"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.object(ss.shape)}}},headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Jt}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.connections.create(e,n);return t.json(r,{status:201})}),Kv=new o.OpenAPIHono().openapi(o.createRoute({tags:["prompts"],method:"get",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Ui}},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(Ui.parse({}))}).openapi(o.createRoute({tags:["prompts"],method:"patch",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(Ui.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"),r=await t.env.data.promptSettings.get(e);return Object.assign(r,n),await t.env.data.promptSettings.set(e,r),t.json(r)});let Cp=!1;function Vg(t){t.use(async(e,n)=>(Cp||(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"}}}}),Cp=!0),await n()))}o.z.object({alg:o.z.literal("RS256"),kty:o.z.literal("RSA"),use:o.z.literal("sig"),n:o.z.string(),e:o.z.string(),kid:o.z.string(),x5t:o.z.string(),x5c:o.z.array(o.z.string())});async function Wv(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 I(500,{message:`Failed to fetch jwks: ${e.message}`})}}async function Gv(t,e){const r=new TextEncoder().encode([e.raw.header,e.raw.payload].join(".")),i=new Uint8Array(Array.from(e.signature).map(l=>l.charCodeAt(0))),a=(await Wv(t.env)).find(l=>l.kid===e.header.kid);if(!a)return console.log("No matching kid found"),!1;const c=await crypto.subtle.importKey("jwk",a,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",c,i,r)}function Jv(t){const[e,n,r]=t.split(".");if(!e||!n||!r)return null;const i=JSON.parse(atob(e)),s=JSON.parse(atob(n)),a=atob(r.replace(/-/g,"+").replace(/_/g,"/"));return{header:i,payload:s,signature:a,raw:{header:e,payload:n,signature:r}}}function qg(t){return async(e,n)=>{var i,s,a;const r=t.openAPIRegistry.definitions.find(c=>"route"in c&&c.route.path===e.req.path&&c.route.method.toUpperCase()===e.req.method);if(r&&"route"in r){const c=(s=(i=r.route.security)==null?void 0:i[0])==null?void 0:s.Bearer;if(!(c!=null&&c.length))return await n();const l=e.req.header("authorization")||"",[d,p]=l.split(" ");if((d==null?void 0:d.toLowerCase())!=="bearer"||!p)throw new I(401,{message:"Missing bearer token"});const f=Jv(p);if(!f||!await Gv(e,f))throw new I(403,{message:"Invalid JWT signature"});e.set("user_id",f.payload.sub),e.set("user",f.payload);const m=f.payload.permissions||[],w=((a=f.payload.scope)==null?void 0:a.split(" "))||[];if(c.length&&!(c.some(h=>m.includes(h))||c.some(h=>w.includes(h))))throw new I(403,{message:"Unauthorized"})}return await n()}}const Zv=new o.OpenAPIHono().openapi(o.createRoute({tags:["emails"],method:"get",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Vi}},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 I(404,{message:"Email provider not found"});return t.json(n)}).openapi(o.createRoute({tags:["emails"],method:"post",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(Vi.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(o.createRoute({tags:["emails"],method:"patch",path:"/",request:{headers:o.z.object({"tenant-id":o.z.string()}),body:{content:{"application/json":{schema:o.z.object(Vi.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")}),Yv=new o.OpenAPIHono().openapi(o.createRoute({tags:["sessions"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Qs}},description:"A session"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.sessions.get(e,n);if(!r)throw new I(404);return t.json(r)}).openapi(o.createRoute({tags:["sessions"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.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 I(404,{message:"Session not found"});return t.text("OK")}).openapi(o.createRoute({tags:["sessions"],method:"post",path:"/{id}/revoke",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.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 I(404,{message:"Session not found"});return t.text("Session deletion request accepted.",{status:202})}),Xv=new o.OpenAPIHono().openapi(o.createRoute({tags:["refresh_tokens"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:cl}},description:"A session"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.refreshTokens.get(e,n);if(!r)throw new I(404);return t.json(r)}).openapi(o.createRoute({tags:["refresh_tokens"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.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 I(404,{message:"Session not found"});return t.text("OK")}),Qv=new o.OpenAPIHono().openapi(o.createRoute({tags:["custom-domains"],method:"get",path:"/",request:{query:tn,headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:o.z.array(Gt)}},description:"List of custom domains"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=await t.env.data.customDomains.list(e);return t.json(n)}).openapi(o.createRoute({tags:["custom-domains"],method:"get",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:read"]}],responses:{200:{content:{"application/json":{schema:Gt}},description:"A connection"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=await t.env.data.customDomains.get(e,n);if(!r)throw new I(404);return t.json(r)}).openapi(o.createRoute({tags:["custom-domains"],method:"delete",path:"/{id}",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.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.customDomains.remove(e,n))throw new I(404,{message:"Custom domain not found"});return t.text("OK")}).openapi(o.createRoute({tags:["custom-domains"],method:"patch",path:"/{id}",request:{body:{content:{"application/json":{schema:o.z.object(Gt.shape).partial()}}},params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Gt}},description:"The updated custom domain"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),{id:n}=t.req.valid("param"),r=t.req.valid("json");if(!await t.env.data.customDomains.update(e,n,r))throw new I(404);const s=await t.env.data.customDomains.get(e,n);if(!s)throw new I(404);return t.json(s)}).openapi(o.createRoute({tags:["custom-domains"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.object(ol.shape)}}},headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{201:{content:{"application/json":{schema:Gt}},description:"The created custom domain"}}}),async t=>{const{"tenant-id":e}=t.req.valid("header"),n=t.req.valid("json"),r=await t.env.data.customDomains.create(e,n);return t.json(r,{status:201})}).openapi(o.createRoute({tags:["custom-domains"],method:"post",path:"/{id}/verify",request:{params:o.z.object({id:o.z.string()}),headers:o.z.object({"tenant-id":o.z.string()})},security:[{Bearer:["auth:write"]}],responses:{200:{content:{"application/json":{schema:Gt}},description:"The custom domain"}}}),async()=>{throw new I(501,{message:"Not implemented"})});async function od(t,e){const n=t.req.header("x-forwarded-host");if(n){const i=await t.env.data.customDomains.getByDomain(n);if(i)return t.set("tenant_id",i.tenant_id),t.set("custom_domain",n),await e()}const r=t.req.header("host");if(r){const i=r.split(".");if(i.length>1&&typeof i[0]=="string"){const s=i[0];await t.env.data.tenants.get(s)&&t.set("tenant_id",s)}}return await e()}function eb(t){const e=new o.OpenAPIHono;e.use(df({origin:r=>{var i;return r&&(i=t.allowedOrigins)!=null&&i.includes(r)?r:""},allowHeaders:["Tenant-Id","Content-Type","Content-Range","Auth0-Client","Authorization","Range","Upgrade-Insecure-Requests"],allowMethods:["POST","PUT","GET","DELETE","PATCH","OPTIONS"],exposeHeaders:["Content-Length","Content-Range"],maxAge:600,credentials:!0})),Vg(e),e.use(async(r,i)=>(r.env.data=io(r,t.dataAdapter),i())),e.use(od).use(qg(e));const n=e.route("/branding",E0).route("/custom-domains",Qv).route("/email/providers",Zv).route("/users",By).route("/keys",Pv).route("/users-by-email",Tv).route("/clients",Rv).route("/tenants",Uv).route("/logs",qv).route("/hooks",Hv).route("/connections",Fv).route("/prompts",Kv).route("/sessions",Yv).route("/refresh_tokens",Xv);return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Management api"},security:[{oauth2:["openid","email","profile"]}]}),n}function tb(t,e){Object.keys(e).forEach(n=>{const r=e[n];r!=null&&r.length&&t.searchParams.set(n,r)})}var Np;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Np||(Np={}));var jp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(jp||(jp={}));function nb(t){return Hg(t,rb,ti.Include)}function Mg(t){return Hg(t,ib,ti.None)}function Hg(t,e,n){let r="";for(let i=0;i<t.byteLength;i+=3){let s=0,a=0;for(let c=0;c<3&&i+c<t.byteLength;c++)s=s<<8|t[i+c],a+=8;for(let c=0;c<4;c++)a>=6?(r+=e[s>>a-6&63],a-=6):a>0?(r+=e[s<<6-a&63],a=0):n===ti.Include&&(r+="=")}return r}const rb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ib="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var ti;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(ti||(ti={}));var $p;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})($p||($p={}));class sb{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 r=0;for(let i=0;i<4;i++)r|=e[n+i]<<24-i*8;return r}uint64(e,n){if(e.byteLength<n+8)throw new TypeError("Insufficient bytes");let r=0n;for(let i=0;i<8;i++)r|=BigInt(e[n+i])<<BigInt(56-i*8);return r}putUint8(e,n,r){if(e.length<r+1)throw new TypeError("Not enough space");if(n<0||n>255)throw new TypeError("Invalid uint8 value");e[r]=n}putUint16(e,n,r){if(e.length<r+2)throw new TypeError("Not enough space");if(n<0||n>65535)throw new TypeError("Invalid uint16 value");e[r]=n>>8,e[r+1]=n&255}putUint32(e,n,r){if(e.length<r+4)throw new TypeError("Not enough space");if(n<0||n>4294967295)throw new TypeError("Invalid uint32 value");for(let i=0;i<4;i++)e[r+i]=n>>(3-i)*8&255}putUint64(e,n,r){if(e.length<r+8)throw new TypeError("Not enough space");if(n<0||n>18446744073709551615n)throw new TypeError("Invalid uint64 value");for(let i=0;i<8;i++)e[r+i]=Number(n>>BigInt((7-i)*8)&0xffn)}}const Op=new sb;function kt(t,e){return(t<<32-e|t>>>e)>>>0}function ob(t){const e=new ab;return e.update(t),e.digest()}class ab{constructor(){te(this,"blockSize",64);te(this,"size",32);te(this,"blocks",new Uint8Array(64));te(this,"currentBlockSize",0);te(this,"H",new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]));te(this,"l",0n);te(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 r=e.slice(0,64-this.currentBlockSize);this.blocks.set(r,this.currentBlockSize),this.process(),n+=r.byteLength,this.currentBlockSize=0}for(;n+64<=e.byteLength;){const r=e.slice(n,n+64);this.blocks.set(r),this.process(),n+=64}if(e.byteLength-n>0){const r=e.slice(n);this.blocks.set(r),this.currentBlockSize=r.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),Op.putUint64(this.blocks,this.l,this.blockSize-8),this.process();const e=new Uint8Array(32);for(let n=0;n<8;n++)Op.putUint32(e,this.H[n],n*4);return e}process(){for(let d=0;d<16;d++)this.w[d]=(this.blocks[d*4]<<24|this.blocks[d*4+1]<<16|this.blocks[d*4+2]<<8|this.blocks[d*4+3])>>>0;for(let d=16;d<64;d++){const p=(kt(this.w[d-2],17)^kt(this.w[d-2],19)^this.w[d-2]>>>10)>>>0,f=(kt(this.w[d-15],7)^kt(this.w[d-15],18)^this.w[d-15]>>>3)>>>0;this.w[d]=p+this.w[d-7]+f+this.w[d-16]|0}let e=this.H[0],n=this.H[1],r=this.H[2],i=this.H[3],s=this.H[4],a=this.H[5],c=this.H[6],l=this.H[7];for(let d=0;d<64;d++){const p=(kt(s,6)^kt(s,11)^kt(s,25))>>>0,f=(s&a^~s&c)>>>0,m=l+p+f+cb[d]+this.w[d]|0,w=(kt(e,2)^kt(e,13)^kt(e,22))>>>0,h=(e&n^e&r^n&r)>>>0,_=w+h|0;l=c,c=a,a=s,s=i+m|0,i=r,r=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]=r+this.H[2]|0,this.H[3]=i+this.H[3]|0,this.H[4]=s+this.H[4]|0,this.H[5]=a+this.H[5]|0,this.H[6]=c+this.H[6]|0,this.H[7]=l+this.H[7]|0}}const cb=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 lb{constructor(e){te(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 db(t){const e=ob(new TextEncoder().encode(t));return Mg(e)}function ub(){const t=new Uint8Array(32);return crypto.getRandomValues(t),Mg(t)}function Ur(t,e){const n=new TextEncoder().encode(e.toString()),r=new Request(t,{method:"POST",body:n});return r.headers.set("Content-Type","application/x-www-form-urlencoded"),r.headers.set("Accept","application/json"),r.headers.set("User-Agent","arctic"),r.headers.set("Content-Length",n.byteLength.toString()),r}function ma(t,e){const n=new TextEncoder().encode(`${t}:${e}`);return nb(n)}async function Ks(t){let e;try{e=await fetch(t)}catch(n){throw new Fg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new Fi(e.status)}if(typeof n!="object"||n===null)throw new Xn(e.status,n);let r;try{r=Dg(n)}catch{throw new Xn(e.status,n)}throw r}if(e.status===200){let n;try{n=await e.json()}catch{throw new Fi(e.status)}if(typeof n!="object"||n===null)throw new Xn(e.status,n);return new lb(n)}throw e.body!==null&&await e.body.cancel(),new Fi(e.status)}async function pb(t){let e;try{e=await fetch(t)}catch(n){throw new Fg(n)}if(e.status===400||e.status===401){let n;try{n=await e.json()}catch{throw new Xn(e.status,null)}if(typeof n!="object"||n===null)throw new Xn(e.status,n);let r;try{r=Dg(n)}catch{throw new Xn(e.status,n)}throw r}if(e.status===200){e.body!==null&&await e.body.cancel();return}throw e.body!==null&&await e.body.cancel(),new Fi(e.status)}function Dg(t){let e;if("error"in t&&typeof t.error=="string")e=t.error;else throw new Error("Invalid error response");let n=null,r=null,i=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");r=t.error_uri}if("state"in t){if(typeof t.state!="string")throw new Error("Invalid data");i=t.state}return new fb(e,n,r,i)}class Fg extends Error{constructor(e){super("Failed to send request",{cause:e})}}class fb extends Error{constructor(n,r,i,s){super(`OAuth request error: ${n}`);te(this,"code");te(this,"description");te(this,"uri");te(this,"state");this.code=n,this.description=r,this.uri=i,this.state=s}}class Fi extends Error{constructor(n){super("Unexpected error response");te(this,"status");this.status=n}}class Xn extends Error{constructor(n,r){super("Unexpected error response body");te(this,"status");te(this,"data");this.status=n,this.data=r}}class ad{constructor(e,n,r){te(this,"clientId");te(this,"clientPassword");te(this,"redirectURI");this.clientId=e,this.clientPassword=n,this.redirectURI=r}createAuthorizationURL(e,n,r){const i=new URL(e);return i.searchParams.set("response_type","code"),i.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&i.searchParams.set("redirect_uri",this.redirectURI),i.searchParams.set("state",n),r.length>0&&i.searchParams.set("scope",r.join(" ")),i}createAuthorizationURLWithPKCE(e,n,r,i,s){const a=new URL(e);if(a.searchParams.set("response_type","code"),a.searchParams.set("client_id",this.clientId),this.redirectURI!==null&&a.searchParams.set("redirect_uri",this.redirectURI),a.searchParams.set("state",n),r===ni.S256){const c=db(i);a.searchParams.set("code_challenge_method","S256"),a.searchParams.set("code_challenge",c)}else r===ni.Plain&&(a.searchParams.set("code_challenge_method","plain"),a.searchParams.set("code_challenge",i));return s.length>0&&a.searchParams.set("scope",s.join(" ")),a}async validateAuthorizationCode(e,n,r){const i=new URLSearchParams;i.set("grant_type","authorization_code"),i.set("code",n),this.redirectURI!==null&&i.set("redirect_uri",this.redirectURI),r!==null&&i.set("code_verifier",r),this.clientPassword===null&&i.set("client_id",this.clientId);const s=Ur(e,i);if(this.clientPassword!==null){const c=ma(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await Ks(s)}async refreshAccessToken(e,n,r){const i=new URLSearchParams;i.set("grant_type","refresh_token"),i.set("refresh_token",n),this.clientPassword===null&&i.set("client_id",this.clientId),r.length>0&&i.set("scope",r.join(" "));const s=Ur(e,i);if(this.clientPassword!==null){const c=ma(this.clientId,this.clientPassword);s.headers.set("Authorization",`Basic ${c}`)}return await Ks(s)}async revokeToken(e,n){const r=new URLSearchParams;r.set("token",n),this.clientPassword===null&&r.set("client_id",this.clientId);const i=Ur(e,r);if(this.clientPassword!==null){const s=ma(this.clientId,this.clientPassword);i.headers.set("Authorization",`Basic ${s}`)}await pb(i)}}var ni;(function(t){t[t.S256=0]="S256",t[t.Plain=1]="Plain"})(ni||(ni={}));var Pp;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Pp||(Pp={}));var Tp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(Tp||(Tp={}));function Vr(t){return hb(t,gb,Ws.None)}function hb(t,e,n){let r="";for(let i=0;i<t.byteLength;i+=3){let s=0,a=0;for(let c=0;c<3&&i+c<t.byteLength;c++)s=s<<8|t[i+c],a+=8;for(let c=0;c<4;c++)a>=6?(r+=e[s>>a-6&63],a-=6):a>0?(r+=e[s<<6-a&63],a=0):n===Ws.Include&&(r+="=")}return r}const gb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";var Ws;(function(t){t[t.Include=0]="Include",t[t.None=1]="None"})(Ws||(Ws={}));var Bp;(function(t){t[t.Required=0]="Required",t[t.Ignore=1]="Ignore"})(Bp||(Bp={}));function mb(t,e,n){const r=Vr(new TextEncoder().encode(t)),i=Vr(new TextEncoder().encode(e)),s=Vr(n);return r+"."+i+"."+s}function _b(t,e){const n=Vr(new TextEncoder().encode(t)),r=Vr(new TextEncoder().encode(e)),i=n+"."+r;return new TextEncoder().encode(i)}const yb="https://appleid.apple.com/auth/authorize",wb="https://appleid.apple.com/auth/token";class Kg{constructor(e,n,r,i,s){te(this,"clientId");te(this,"teamId");te(this,"keyId");te(this,"pkcs8PrivateKey");te(this,"redirectURI");this.clientId=e,this.teamId=n,this.keyId=r,this.pkcs8PrivateKey=i,this.redirectURI=s}createAuthorizationURL(e,n){const r=new URL(yb);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",this.clientId),r.searchParams.set("state",e),n.length>0&&r.searchParams.set("scope",n.join(" ")),r.searchParams.set("redirect_uri",this.redirectURI),r}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 r=await this.createClientSecret();n.set("client_secret",r);const i=Ur(wb,n);return await Ks(i)}async createClientSecret(){const e=await crypto.subtle.importKey("pkcs8",this.pkcs8PrivateKey,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),n=Math.floor(Date.now()/1e3),r=JSON.stringify({typ:"JWT",alg:"ES256",kid:this.keyId}),i=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,_b(r,i)));return mb(r,i,s)}}const vb="https://www.facebook.com/v16.0/dialog/oauth",bb="https://graph.facebook.com/v16.0/oauth/access_token";class Wg{constructor(e,n,r){te(this,"clientId");te(this,"clientSecret");te(this,"redirectURI");this.clientId=e,this.clientSecret=n,this.redirectURI=r}createAuthorizationURL(e,n){const r=new URL(vb);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",this.clientId),r.searchParams.set("state",e),n.length>0&&r.searchParams.set("scope",n.join(" ")),r.searchParams.set("redirect_uri",this.redirectURI),r}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 r=Ur(bb,n);return await Ks(r)}}const xb="https://accounts.google.com/o/oauth2/v2/auth",Rp="https://oauth2.googleapis.com/token",kb="https://oauth2.googleapis.com/revoke";let Gg=class{constructor(e,n,r){te(this,"client");this.client=new ad(e,n,r)}createAuthorizationURL(e,n,r){return this.client.createAuthorizationURLWithPKCE(xb,e,ni.S256,n,r)}async validateAuthorizationCode(e,n){return await this.client.validateAuthorizationCode(Rp,e,n)}async refreshAccessToken(e){return await this.client.refreshAccessToken(Rp,e,[])}async revokeToken(e){await this.client.revokeToken(kb,e)}};const Yo=o.z.object({iss:o.z.string().url(),sub:o.z.string(),aud:o.z.string(),exp:o.z.number(),email:o.z.string().optional(),given_name:o.z.string().optional(),family_name:o.z.string().optional(),name:o.z.string().optional(),iat:o.z.number(),auth_time:o.z.number().optional(),nonce:o.z.string().optional(),acr:o.z.string().optional(),amr:o.z.array(o.z.string()).optional(),azp:o.z.string().optional(),at_hash:o.z.string().optional(),c_hash:o.z.string().optional()}).passthrough();Yo.omit({iat:!0,auth_time:!0,nonce:!0,acr:!0,amr:!0,azp:!0,at_hash:!0,c_hash:!0});function Sb(t){return t.ISSUER}function at(t){return t.UNIVERSAL_LOGIN_URL||`${t.ISSUER}u/`}function je(t){return t.OAUTH_API_URL||t.ISSUER}function Jg(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"),r=n.toString().replace(/-----BEGIN PRIVATE KEY-----|-----END PRIVATE KEY-----|\s/g,""),i=Uint8Array.from(Buffer.from(r,"base64"));return n.fill(0),{options:e,keyArray:i}}async function Ab(t,e){var l,d;const{options:n,keyArray:r}=Jg(e),i=new Kg(n.client_id,n.team_id,n.kid,r,`${je(t.env)}callback`),s=ke(),a=await i.createAuthorizationURL(s,((l=n.scope)==null?void 0:l.split(" "))||["name","email"]);return(((d=n.scope)==null?void 0:d.split(" "))||["name","email"]).some(p=>["email","name"].includes(p))&&a.searchParams.set("response_mode","form_post"),{redirectUrl:a.href,code:s}}async function zb(t,e,n){const{options:r,keyArray:i}=Jg(e),a=await new Kg(r.client_id,r.team_id,r.kid,i,`${je(t.env)}callback`).validateAuthorizationCode(n),c=dl(a.idToken());if(!c)throw new Error("Invalid ID token");const l=Yo.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 Eb=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:Ab,validateAuthorizationCodeAndGetUser:zb},Symbol.toStringTag,{value:"Module"}));async function Ib(t,e){var a;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const r=new Wg(n.client_id,n.client_secret,`${je(t.env)}callback`),i=ke();return{redirectUrl:r.createAuthorizationURL(i,((a=n.scope)==null?void 0:a.split(" "))||["email"]).href,code:i}}async function Cb(t,e,n){const{options:r}=e;if(!(r!=null&&r.client_id)||!r.client_secret)throw new Error("Missing required authentication parameters");const s=await new Wg(r.client_id,r.client_secret,`${je(t.env)}callback`).validateAuthorizationCode(n),a=await fetch("https://graph.facebook.com/v16.0/me?fields=id,email,name",{headers:{Authorization:`Bearer ${s.accessToken()}`}});if(!a.ok)throw new Error("Failed to fetch user info");const c=await a.json();return t.set("log",`Userinfo: ${JSON.stringify(c)}`),{sub:c.id,email:c.email,name:c.name}}const Nb=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:Ib,validateAuthorizationCodeAndGetUser:Cb},Symbol.toStringTag,{value:"Module"}));async function jb(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 r=new Gg(n.client_id,n.client_secret,`${je(t.env)}callback`),i=ke(),s=ub();return{redirectUrl:r.createAuthorizationURL(i,s,((c=n.scope)==null?void 0:c.split(" "))??["email","profile"]).href,code:i,codeVerifier:s}}async function $b(t,e,n,r){const{options:i}=e;if(!(i!=null&&i.client_id)||!i.client_secret||!r)throw new Error("Missing required authentication parameters");const a=await new Gg(i.client_id,i.client_secret,`${je(t.env)}callback`).validateAuthorizationCode(n,r),c=dl(a.idToken());if(!c)throw new Error("Invalid ID token");const l=Yo.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 Ob=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:jb,validateAuthorizationCodeAndGetUser:$b},Symbol.toStringTag,{value:"Module"}));async function Pb(t,e){var a;const{options:n}=e;if(!(n!=null&&n.client_id)||!n.client_secret)throw new Error("Missing required authentication parameters");const r=new ad(n.client_id,n.client_secret,`${je(t.env)}callback`),i=ke(),s=r.createAuthorizationURL("https://api.vipps.no/access-management-1.0/access/oauth2/auth",i,((a=n.scope)==null?void 0:a.split(" "))||["openid","email","phoneNumber","name","address","birthDate"]);return s.searchParams.set("response_type","code"),s.searchParams.set("response_mode","query"),{redirectUrl:s.href,code:i}}async function Tb(t,e,n){const{options:r}=e;if(!(r!=null&&r.client_id)||!r.client_secret)throw new Error("Missing required authentication parameters");const s=await new ad(r.client_id,r.client_secret,`${je(t.env)}callback`).validateAuthorizationCode("https://api.vipps.no/access-management-1.0/access/oauth2/token",n,null),a=dl(s.idToken());if(!a)throw new Error("Invalid ID token");const c=Yo.parse(a.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 I(400,{message:"Failed to get user from vipps"});return await l.json()}const Bb=Object.freeze(Object.defineProperty({__proto__:null,getRedirect:Pb,validateAuthorizationCodeAndGetUser:Tb},Symbol.toStringTag,{value:"Module"}));function Zg(t,e){const n=t.env.STRATEGIES||{},i={apple:Eb,facebook:Nb,"google-oauth2":Ob,vipps:Bb,...n}[e];if(!i)throw new Error(`Strategy ${e} not found`);return i}async function Ai(t,e){const n=await t.data.clients.get(e);if(!n)throw new I(403,{message:"Client not found"});const r=t.DEFAULT_CLIENT_ID?await t.data.clients.get(t.DEFAULT_CLIENT_ID):void 0,i=await t.data.connections.list(n.tenant.id),s=t.DEFAULT_TENANT_ID?await t.data.connections.list(t.DEFAULT_TENANT_ID):{connections:[]},a=i.connections.map(c=>{var p;const l=(p=s.connections)==null?void 0:p.find(f=>f.name===c.name);if(!(l!=null&&l.options))return c;const d=Jt.parse({...l||{},...c});return d.options=sl.passthrough().parse({...l.options||{},...c.options}),d}).filter(c=>c);return{...n,web_origins:[...(r==null?void 0:r.web_origins)||[],...n.web_origins||[],`${at(t)}login`],allowed_logout_urls:[...(r==null?void 0:r.allowed_logout_urls)||[],...n.allowed_logout_urls||[],t.ISSUER],callbacks:[...(r==null?void 0:r.callbacks)||[],...n.callbacks||[],`${at(t)}info`],connections:a,tenant:{...(r==null?void 0:r.tenant)||{},...n.tenant}}}async function Rb(t,e,n,r){if(!r.state)throw new I(400,{message:"State not found"});const i=e.connections.find(l=>l.name===n);if(!i){t.set("client_id",e.id);const l=we(t,{type:ge.FAILED_LOGIN,description:"Connection not found"});throw await t.env.data.logs.create(e.tenant.id,l),new I(403,{message:"Connection Not Found"})}let s=await t.env.data.loginSessions.get(e.tenant.id,r.state);s||(s=await t.env.data.loginSessions.create(e.tenant.id,{expires_at:new Date(Date.now()+Qn*1e3).toISOString(),authParams:r,csrf_token:ke(),...Ht(t.req)}));const c=await Zg(t,i.strategy).getRedirect(t,i);return await t.env.data.codes.create(e.tenant.id,{login_id:s.id,code_id:c.code,code_type:"oauth2_state",connection_id:i.id,code_verifier:c.codeVerifier,expires_at:new Date(Date.now()+X0*1e3).toISOString()}),t.redirect(c.redirectUrl)}async function Lp(t,{code:e,state:n}){var h;const{env:r}=t,i=await r.data.codes.get(t.var.tenant_id||"",n,"oauth2_state");if(!i||!i.connection_id)throw new I(403,{message:"State not found"});const s=await r.data.loginSessions.get(t.var.tenant_id||"",i.login_id);if(!s)throw new I(403,{message:"Session not found"});if(s.authorization_url){const _=new URL(s.authorization_url).hostname,v=t.req.header("host")||"";if(_!==v&&_){const S=new URL(`https://${_}/callback`);return S.searchParams.set("state",n),S.searchParams.set("code",e),new Response("Redirecting",{status:307,headers:{location:S.toString()}})}}const a=await Ai(r,s.authParams.client_id);t.set("client_id",a.id),t.set("tenant_id",a.tenant.id);const c=a.connections.find(_=>_.id===i.connection_id);if(!c){const _=we(t,{type:ge.FAILED_LOGIN,description:"Connection not found"});throw await r.data.logs.create(a.tenant.id,_),new I(403,{message:"Connection not found"})}if(t.set("connection",c.name),!s.authParams.redirect_uri){const _=we(t,{type:ge.FAILED_LOGIN,description:"Redirect URI not defined"});throw await r.data.logs.create(a.tenant.id,_),new I(403,{message:"Redirect URI not defined"})}const d=await Zg(t,c.strategy).validateAuthorizationCodeAndGetUser(t,c,e,i.code_verifier),{sub:p,...f}=d;t.set("user_id",p);const m=((h=d.email)==null?void 0:h.toLocaleLowerCase())||`${c.name}.${p}@${new URL(t.env.ISSUER).hostname}`;t.set("username",m);const w=await oo(t,{client:a,username:m,provider:c.strategy,connection:c.name,userId:p,profileData:f,isSocial:!0,ip:t.req.header("x-real-ip")});return ln(t,{client:a,authParams:s.authParams,loginSession:s,user:w})}async function Up(t,e,n,r,i,s){const a=await t.env.data.codes.get(t.var.tenant_id||"",e,"oauth2_state");if(!a)throw new I(400,{message:"State not found"});const c=await t.env.data.loginSessions.get(t.var.tenant_id,a.login_id);if(!c)throw new I(400,{message:"Login not found"});const{redirect_uri:l}=c.authParams;if(!l)throw new I(400,{message:"Redirect uri not found"});const d=we(t,{type:ge.FAILED_LOGIN,description:`Failed connection login: ${i} ${n}, ${r}`});zt(t,t.env.data.logs.create(t.var.tenant_id,d));const p=new URL(l);return tb(p,{error:n,error_description:r,error_reason:s,error_code:i,state:c.authParams.state}),t.redirect(`${at(t.env)}login/identifier?state=${c.id}&error=${n}`)}const Lb=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string(),code:o.z.string().optional(),scope:o.z.string().optional(),hd:o.z.string().optional(),error:o.z.string().optional(),error_description:o.z.string().optional(),error_code:o.z.string().optional(),error_reason:o.z.string().optional()})},responses:{302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{state:e,code:n,error:r,error_description:i,error_code:s,error_reason:a}=t.req.valid("query");if(r)return Up(t,e,r,i,s,a);if(!n)throw new I(400,{message:"Code is required"});return Lp(t,{code:n,state:e})}).openapi(o.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({state:o.z.string(),code:o.z.string().optional(),scope:o.z.string().optional(),hd:o.z.string().optional(),error:o.z.string().optional(),error_description:o.z.string().optional(),error_code:o.z.string().optional(),error_reason:o.z.string().optional()})}}}},responses:{302:{description:"Redirect to the client's redirect uri"}}}),async t=>{const{state:e,code:n,error:r,error_description:i,error_code:s,error_reason:a}=t.req.valid("form");if(r)return Up(t,e,r,i,s,a);if(!n)throw new I(400,{message:"Code is required"});return Lp(t,{code:n,state:e})});function Yg(t,e=[],n={}){try{const r=new URL(t);return e.some(i=>{try{return Ub(r,new URL(i),n.allowPathWildcards)}catch{return!1}})}catch{return!1}}function Ub(t,e,n){if(t.protocol!==e.protocol)return!1;if(n&&e.pathname.includes("*")){const r=e.pathname.replace(/\*/g,".*").replace(/\//g,"\\/");if(!new RegExp(`^${r}$`).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 r=e.hostname.split(".").slice(1).join(".");return t.hostname.endsWith(r)}return t.hostname===e.hostname}const Vb=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth2"],method:"get",path:"/",request:{query:o.z.object({client_id:o.z.string(),returnTo:o.z.string().optional()}),header:o.z.object({cookie:o.z.string().optional()})},responses:{302:{description:"Log the user out"}}}),async t=>{const{client_id:e,returnTo:n}=t.req.valid("query"),r=await t.env.data.clients.get(e);if(!r)return t.text("OK");const i=await t.env.data.clients.get("DEFAULT_CLIENT");t.set("client_id",e),t.set("tenant_id",r.tenant.id);const s=n||t.req.header("referer");if(!s)return t.text("OK");if(!Yg(s,[...r.allowed_logout_urls||[],...(i==null?void 0:i.allowed_logout_urls)||[]],{allowPathWildcards:!0}))throw new I(400,{message:"Invalid redirect uri"});const a=t.req.header("cookie");if(a){const l=ds(r.tenant.id,a);if(l){const d=await t.env.data.sessions.get(r.tenant.id,l);if(d){const p=await t.env.data.users.get(r.tenant.id,d.user_id);p&&(t.set("user_id",p.user_id),t.set("connection",p.connection));const f=await t.env.data.refreshTokens.list(r.tenant.id,{q:`session_id=${l}`,page:0,per_page:100,include_totals:!1});await Promise.all(f.refresh_tokens.map(m=>t.env.data.refreshTokens.remove(r.tenant.id,m.id))),await t.env.data.sessions.update(r.tenant.id,l,{revoked_at:new Date().toISOString()})}}}const c=we(t,{type:ge.SUCCESS_LOGOUT,description:"User successfully logged out"});return await t.env.data.logs.create(r.tenant.id,c),new Response("Redirecting",{status:302,headers:{"set-cookie":r_(r.tenant.id,t.req.header("host")),location:s}})}),Vp=o.z.object({sub:o.z.string(),email:o.z.string().optional(),family_name:o.z.string().optional(),given_name:o.z.string().optional(),email_verified:o.z.boolean()}),qb=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth2"],method:"get",path:"/",request:{},security:[{Bearer:["openid"]}],responses:{200:{content:{"application/json":{schema:Vp}},description:"Userinfo"}}}),async t=>{if(!t.var.user)throw new I(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 I(404,{message:"User not found"});return t.json(Vp.parse({...e,sub:e.user_id}))}),Mb=new o.OpenAPIHono().openapi(o.createRoute({tags:["well known"],method:"get",path:"/jwks.json",request:{},responses:{200:{content:{"application/json":{schema:wf}},description:"List of tenants"}}}),async t=>{const e=await t.env.data.keys.list(),n=await Promise.all(e.map(async r=>{const s=await new sd(r.cert).publicKey.export(),a=await crypto.subtle.exportKey("jwk",s);return al.parse({...a,kid:r.kid})}));return t.json({keys:n},{headers:{"access-control-allow-origin":"*","access-control-allow-method":"GET","cache-control":`public, max-age=${Oi}, stale-while-revalidate=${Oi*2}, stale-if-error=86400`}})}).openapi(o.createRoute({tags:["well known"],method:"get",path:"/openid-configuration",request:{},responses:{200:{content:{"application/json":{schema:Ea}},description:"List of tenants"}}}),async t=>{const e=Ea.parse({issuer:Sb(t.env),authorization_endpoint:`${je(t.env)}authorize`,token_endpoint:`${je(t.env)}oauth/token`,device_authorization_endpoint:`${je(t.env)}oauth/device/code`,userinfo_endpoint:`${je(t.env)}userinfo`,mfa_challenge_endpoint:`${je(t.env)}mfa/challenge`,jwks_uri:`${je(t.env)}.well-known/jwks.json`,registration_endpoint:`${je(t.env)}oidc/register`,revocation_endpoint:`${je(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=${Oi}, stale-while-revalidate=${Oi*2}, stale-if-error=86400`}})});function Ki(t,e){if(!t||!e||t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t.charCodeAt(r)^e.charCodeAt(r);return n===0}const Xg=o.z.object({grant_type:o.z.literal("client_credentials"),scope:o.z.string().optional(),client_secret:o.z.string(),client_id:o.z.string(),audience:o.z.string().optional()});async function Hb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new I(403,{message:"Invalid client credentials"});if(n.client_secret&&!Ki(n.client_secret,e.client_secret))throw new I(403,{message:"Invalid client credentials"});const r={client_id:n.id,scope:e.scope,audience:e.audience},i=await ro(t,{authParams:r,client:n});return t.json(i)}const Db=o.z.object({grant_type:o.z.literal("authorization_code"),client_id:o.z.string(),code:o.z.string(),redirect_uri:o.z.string().optional(),client_secret:o.z.string().optional(),code_verifier:o.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 Fb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new I(403,{message:"Client not found"});const r=await t.env.data.codes.get(n.tenant.id,e.code,"authorization_code");if(!r||!r.user_id)throw new I(403,{message:"Invalid client credentials"});if(new Date(r.expires_at)<new Date)throw new I(403,{message:"Code expired"});if(r.used_at)throw new I(403,{message:"Code already used"});const i=await t.env.data.loginSessions.get(n.tenant.id,r.login_id);if(!i)throw new I(403,{message:"Invalid login"});if("client_secret"in e){const a=await t.env.data.clients.get("DEFAULT_CLIENT");if(!Ki(n.client_secret,e.client_secret)&&!Ki(a==null?void 0:a.client_secret,e.client_secret))throw new I(403,{message:"Invalid client credentials"})}else if("code_verifier"in e&&typeof e.code_verifier=="string"&&"code_challenge_method"in i.authParams&&typeof i.authParams.code_challenge_method=="string"){const a=await G0(e.code_verifier,i.authParams.code_challenge_method);if(!Ki(a,i.authParams.code_challenge||""))throw new I(403,{message:"Invalid client credentials"})}if(i.authParams.redirect_uri&&i.authParams.redirect_uri!==e.redirect_uri)throw new I(403,{message:"Invalid redirect uri"});const s=await t.env.data.users.get(n.tenant.id,r.user_id);if(!s)throw new I(403,{message:"User not found"});return await t.env.data.codes.used(n.tenant.id,e.code),ln(t,{user:s,client:n,loginSession:i,authParams:{...i.authParams,response_mode:Rt.WEB_MESSAGE}})}const Kb=o.z.object({grant_type:o.z.literal("refresh_token"),client_id:o.z.string(),redirect_uri:o.z.string().optional(),refresh_token:o.z.string()});async function Wb(t,e){const n=await t.env.data.clients.get(e.client_id);if(!n)throw new I(403,{message:"Client not found"});const r=await t.env.data.refreshTokens.get(n.tenant.id,e.refresh_token);if(r){if(r.expires_at&&new Date(r.expires_at)<new Date||r.idle_expires_at&&new Date(r.idle_expires_at)<new Date)throw new I(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Refresh token has expired"})})}else throw new I(403,{message:JSON.stringify({error:"invalid_grant",error_description:"Invalid refresh token"})});const i=await t.env.data.users.get(n.tenant.id,r.user_id);if(!i)throw new I(403,{message:"User not found"});const s=r.resource_servers[0];if(r.idle_expires_at){const a=new Date(Date.now()+2592e6);await t.env.data.refreshTokens.update(n.tenant.id,r.id,{idle_expires_at:a.toISOString(),last_exchanged_at:new Date().toISOString(),device:{...r.device,last_ip:t.req.header["x-real-ip"]||"",last_user_agent:t.req.header["user-agent"]||""}})}return ln(t,{user:i,client:n,refreshToken:r.id,sessionId:r.session_id,authParams:{client_id:n.id,audience:s==null?void 0:s.audience,scope:s==null?void 0:s.scopes,response_mode:Rt.WEB_MESSAGE}})}function cd(t){return t.includes("@")?"email":"sms"}const Gb=o.z.object({client_id:o.z.string(),username:o.z.string().transform(t=>t.toLowerCase()),otp:o.z.string(),authParams:Mr.optional()});async function Qg(t,{client_id:e,username:n,otp:r,authParams:i}){const s=await t.env.data.clients.get(e);if(!s)throw new I(403,{message:"Client not found"});return ld(t,s,i||{client_id:e,response_type:It.TOKEN_ID_TOKEN,response_mode:Rt.WEB_MESSAGE},n,r)}async function ld(t,e,n,r,i,s,a){const{env:c}=t,l=await c.data.codes.get(e.tenant.id,i,"otp");if(!l)throw new I(400,{message:"Code not found or expired"});if(l.expires_at<new Date().toISOString())throw new I(400,{message:"Code expired"});if(l.used_at)throw new I(400,{message:"Code already used"});const d=cd(r),p=await c.data.loginSessions.get(e.tenant.id,l.login_id);if(!p||p.authParams.username!==r)throw new I(400,{message:"Code not found or expired"});const f=Ht(t.req);if(a&&p.ip!==f.ip)return t.redirect(`${at(t.env)}invalid-session?state=${p.id}`);const m=await oo(t,{client:e,username:r,provider:d,connection:d,isSocial:!1,ip:t.req.header("x-real-ip")});return await c.data.codes.used(e.tenant.id,i),ln(t,{user:m,client:e,loginSession:p,authParams:n,ticketAuth:s})}const qp=o.z.object({client_id:o.z.string().optional(),client_secret:o.z.string().optional()}),Jb=o.z.union([Xg.extend(qp.shape),o.z.object({grant_type:o.z.literal("authorization_code"),client_id:o.z.string(),code:o.z.string(),redirect_uri:o.z.string(),code_verifier:o.z.string().min(43).max(128)}),o.z.object({grant_type:o.z.literal("authorization_code"),code:o.z.string(),redirect_uri:o.z.string().optional(),...qp.shape}),o.z.object({grant_type:o.z.literal("refresh_token"),client_id:o.z.string(),refresh_token:o.z.string(),redirect_uri:o.z.string().optional()}),o.z.object({grant_type:o.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),client_id:o.z.string(),username:o.z.string(),otp:o.z.string(),realm:o.z.enum(["email","sms"])})]);function Zb(t){if(!t)return{};const[e,n]=t.split(" ");if((e==null?void 0:e.toLowerCase())==="basic"&&n){const[r,i]=atob(n).split(":");return{client_id:r,client_secret:i}}return{}}const Yb=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth2"],method:"post",path:"/",request:{body:{content:{"application/x-www-form-urlencoded":{schema:Jb}}}},responses:{200:{content:{"application/json":{schema:Af}},description:"Tokens"}}}),async t=>{const e=t.req.valid("form"),n=Zb(t.req.header("Authorization")),r={...e,...n};if(!r.client_id)throw new I(400,{message:"client_id is required"});switch(t.set("client_id",r.client_id),e.grant_type){case Wn.AuthorizationCode:return Fb(t,Db.parse(r));case Wn.ClientCredential:return Hb(t,Xg.parse(r));case Wn.RefreshToken:return Wb(t,Kb.parse(r));case Wn.OTP:return Qg(t,Gb.parse(r));default:throw new I(400,{message:"Not implemented"})}});var dd={exports:{}};const ud=[{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}],em=(t,e=ud,n="!\"#$%&'()*+,-./:;<=>?@[\\\\\\]^_`{|}~")=>{let r=t||"";e[0].minDiversity=0,e[0].minLength=0;const i=[{regex:"[a-z]",message:"lowercase"},{regex:"[A-Z]",message:"uppercase"},{regex:"[0-9]",message:"number"}];n&&i.push({regex:`[${n}]`,message:"symbol"});let s={};s.contains=i.filter(c=>new RegExp(`${c.regex}`).test(r)).map(c=>c.message),s.length=r.length;let a=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,a[0]),s};dd.exports={passwordStrength:em,defaultOptions:ud};var Xb=dd.exports.passwordStrength=em;dd.exports.defaultOptions=ud;function pd(t){return Xb(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 zi(t,e){var i;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 I(500,{message:"Email provider not found"});const r=(i=t.env.emailProviders)==null?void 0:i[n.name];if(!r)throw new I(500,{message:"Email provider not found"});await r({emailProvider:n,...e,from:n.default_from_address||`login@${t.env.ISSUER}`})}async function Qb(t,e){var a,c;if(!t.var.client_id)throw new I(500,{message:"Client not found"});const n=await Ai(t.env,t.var.client_id),r=n.connections.find(l=>l.strategy==="sms");if(!r)throw new I(500,{message:"SMS provider not found"});const i=((a=r.options)==null?void 0:a.provider)||"twilio",s=(c=t.env.smsProviders)==null?void 0:c[i];if(!s)throw new I(500,{message:"SMS provider not found"});await s({options:r.options,to:e.to,text:e.text,template:"auth-code",data:{code:e.code,tenantName:n.tenant.name,tenantId:n.tenant.id}})}async function tm(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new I(500,{message:"Tenant not found"});const s=`${at(t.env)}reset-password?state=${r}&code=${n}`,a={vendorName:i.name,lng:i.language||"en"};await zi(t,{to:e,subject:re("reset_password_title",a),html:`Click here to reset your password: ${at(t.env)}reset-password?state=${r}&code=${n}`,template:"auth-password-reset",data:{vendorName:i.name,logo:i.logo||"",passwordResetUrl:s,supportUrl:i.support_url||"https://support.sesamy.com",buttonColor:i.primary_color||"#7d68f4",passwordResetTitle:re("password_reset_title",a),resetPasswordEmailClickToReset:re("reset_password_email_click_to_reset",a),resetPasswordEmailReset:re("reset_password_email_reset",a),supportInfo:re("support_info",a),contactUs:re("contact_us",a),copyright:re("copyright",a),tenantName:i.name,tenantId:i.id}})}async function nm(t,{to:e,code:n}){const r=await t.env.data.tenants.get(t.var.tenant_id);if(!r)throw new I(500,{message:"Tenant not found"});const i=cd(e),s=new URL(at(t.env)),a={vendorName:r.name,vendorId:r.id,loginDomain:s.hostname,code:n,lng:r.language||"en"};i==="email"?await zi(t,{to:e,subject:re("code_email_subject",a),html:`Click here to validate your email: ${at(t.env)}validate-email`,template:"auth-code",data:{code:n,vendorName:r.name,logo:r.logo||"",supportUrl:r.support_url||"",buttonColor:r.primary_color||"",welcomeToYourAccount:re("welcome_to_your_account",a),linkEmailClickToLogin:re("link_email_click_to_login",a),linkEmailLogin:re("link_email_login",a),linkEmailOrEnterCode:re("link_email_or_enter_code",a),codeValid30Mins:re("code_valid_30_minutes",a),supportInfo:re("support_info",a),contactUs:re("contact_us",a),copyright:re("copyright",a)}}):i==="sms"&&await Qb(t,{to:e,text:re("sms_code_text",a),code:n});const c=we(t,{type:ge.CODE_LINK_SENT,description:e});zt(t,t.env.data.logs.create(r.id,c))}async function fd(t,{to:e,code:n,authParams:r}){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new I(500,{message:"Tenant not found"});if(!r.redirect_uri)throw new I(400,{message:"redirect_uri is required"});const s=cd(e),a=new URL(je(t.env));a.pathname="passwordless/verify_redirect",a.searchParams.set("verification_code",n),a.searchParams.set("connection",s),a.searchParams.set("client_id",r.client_id),a.searchParams.set("redirect_uri",r.redirect_uri),a.searchParams.set("email",e),r.response_type&&a.searchParams.set("response_type",r.response_type),r.scope&&a.searchParams.set("scope",r.scope),r.state&&a.searchParams.set("state",r.state),r.nonce&&a.searchParams.set("nonce",r.nonce),r.code_challenge&&a.searchParams.set("code_challenge",r.code_challenge),r.code_challenge_method&&a.searchParams.set("code_challenge_method",r.code_challenge_method),r.audience&&a.searchParams.set("audience",r.audience);const c={vendorName:i.name,code:n,lng:i.language||"en"};if(s!=="email")throw new I(400,{message:"Only email connections are supported for magic links"});await zi(t,{to:e,subject:re("code_email_subject",c),html:`Click here to validate your email: ${at(t.env)}validate-email`,template:"auth-link",data:{code:n,vendorName:i.name,logo:i.logo||"",supportUrl:i.support_url||"",magicLink:a.toString(),buttonColor:i.primary_color||"",welcomeToYourAccount:re("welcome_to_your_account",c),linkEmailClickToLogin:re("link_email_click_to_login",c),linkEmailLogin:re("link_email_login",c),linkEmailOrEnterCode:re("link_email_or_enter_code",c),codeValid30Mins:re("code_valid_30_minutes",c),supportInfo:re("support_info",c),contactUs:re("contact_us",c),copyright:re("copyright",c)}});const l=we(t,{type:ge.CODE_LINK_SENT,description:e});zt(t,t.env.data.logs.create(i.id,l))}async function hd(t,e){const n=await t.env.data.tenants.get(t.var.tenant_id);if(!n)throw new I(500,{message:"Tenant not found"});if(!e.email)throw new I(400,{message:"User has no email"});const r={vendorName:n.name,lng:n.language||"en"};await zi(t,{to:e.email,subject:re("welcome_to_your_account",r),html:`Click here to validate your email: ${at(t.env)}validate-email`,template:"auth-verify-email",data:{vendorName:n.name,logo:n.logo||"",emailValidationUrl:`${at(t.env)}validate-email`,supportUrl:n.support_url||"https://support.sesamy.com",buttonColor:n.primary_color||"#7d68f4",welcomeToYourAccount:re("welcome_to_your_account",r),verifyEmailVerify:re("verify_email_verify",r),supportInfo:re("support_info",r),contactUs:re("contact_us",r),copyright:re("copyright",r)}})}async function e1(t,e,n,r){const i=await t.env.data.tenants.get(t.var.tenant_id);if(!i)throw new I(500,{message:"Tenant not found"});const s={vendorName:i.name,lng:i.language||"en"},a=`${at(t.env)}signup?state=${r}&code=${n}`;await zi(t,{to:e,subject:re("register_password_account",s),html:`Click here to register: ${a}`,template:"auth-pre-signup-verification",data:{vendorName:i.name,logo:i.logo||"",signupUrl:a,setPassword:re("set_password",s),registerPasswordAccount:re("register_password_account",s),clickToSignUpDescription:re("click_to_sign_up_description",s),supportUrl:i.support_url||"https://support.sesamy.com",buttonColor:i.primary_color||"#7d68f4",welcomeToYourAccount:re("welcome_to_your_account",s),verifyEmailVerify:re("verify_email_verify",s),supportInfo:re("support_info",s),contactUs:re("contact_us",s),copyright:re("copyright",s)}})}const t1=new o.OpenAPIHono().openapi(o.createRoute({tags:["dbconnections"],method:"post",path:"/signup",request:{body:{content:{"application/json":{schema:o.z.object({client_id:o.z.string(),connection:o.z.literal("Username-Password-Authentication"),email:o.z.string().transform(t=>t.toLowerCase()),password:o.z.string()})}}}},responses:{200:{content:{"application/json":{schema:o.z.object({_id:o.z.string(),email:o.z.string().optional(),email_verified:o.z.boolean(),app_metadata:o.z.object({}),user_metadata:o.z.object({})})}},description:"Created user"}}}),async t=>{const{email:e,password:n,client_id:r}=t.req.valid("json"),i=await t.env.data.clients.get(r);if(!i)throw new I(400,{message:"Client not found"});if(t.set("client_id",i.id),t.set("tenant_id",i.tenant.id),!pd(n))throw new I(400,{message:"Password does not meet the requirements"});if(await us({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username:e,provider:"auth2"}))throw new I(400,{message:"Invalid sign up"});const a=await t.env.data.users.create(i.tenant.id,{user_id:`auth2|${eo()}`,email:e,email_verified:!1,provider:"auth2",connection:"Username-Password-Authentication",is_social:!1});t.set("user_id",a.user_id),t.set("username",a.email),t.set("connection",a.connection);const c=await oi.hash(n,10);await t.env.data.passwords.create(i.tenant.id,{user_id:a.user_id,password:c,algorithm:"bcrypt"}),await hd(t,a);const l=we(t,{type:ge.SUCCESS_SIGNUP,description:"Successful signup"});return await t.env.data.logs.create(i.tenant.id,l),t.json({_id:a.user_id,email:a.email,email_verified:!1,app_metadata:{},user_metadata:{}})}).openapi(o.createRoute({tags:["dbconnections"],method:"post",path:"/change_password",request:{body:{content:{"application/json":{schema:o.z.object({client_id:o.z.string(),connection:o.z.literal("Username-Password-Authentication"),email:o.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"),r=await t.env.data.clients.get(n);if(!r)throw new I(400,{message:"Client not found"});if(t.set("client_id",r.id),t.set("tenant_id",r.tenant.id),!await fr({userAdapter:t.env.data.users,tenant_id:r.tenant.id,username: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},a=await t.env.data.loginSessions.create(r.tenant.id,{expires_at:new Date(Date.now()+Qn*1e3).toISOString(),authParams:s,csrf_token:ke(),...Ht(t.req)});return await tm(t,e,a.id,a.authParams.state),t.html("If an account with that email exists, we've sent instructions to reset your password.")});function Tn(){const t="1234567890";let e="";for(let n=0;n<6;n+=1)e+=t[Math.floor(Math.random()*10)];return e.toString()}const n1=new o.OpenAPIHono().openapi(o.createRoute({tags:["passwordless"],method:"post",path:"/start",request:{body:{content:{"application/json":{schema:o.z.union([o.z.object({connection:o.z.literal("email"),client_id:o.z.string(),email:o.z.string().transform(t=>t.toLowerCase()),send:o.z.enum(["link","code"]),authParams:Mr.omit({client_id:!0})}),o.z.object({client_id:o.z.string(),connection:o.z.literal("sms"),phone_number:o.z.string(),send:o.z.enum(["link","code"]),authParams:Mr.omit({client_id:!0})})])}}}},responses:{200:{description:"Status"}}}),async t=>{const e=t.req.valid("json"),{env:n}=t,{client_id:r,send:i,authParams:s,connection:a}=e,c=await t.env.data.clients.get(r);if(!c)throw new I(400,{message:"Client not found"});t.set("client_id",c.id),t.set("tenant_id",c.tenant.id);const l=a==="email"?e.email:e.phone_number,d=await n.data.loginSessions.create(c.tenant.id,{authParams:{...s,client_id:r,username:l},expires_at:new Date(Date.now()+Na).toISOString(),csrf_token:ke(),...Ht(t.req)}),p=await n.data.codes.create(c.tenant.id,{code_id:Tn(),code_type:"otp",login_id:d.id,expires_at:new Date(Date.now()+Na).toISOString()});return i==="link"?await fd(t,{to:l,code:p.code_id,authParams:{...s,client_id:r}}):await nm(t,{to:l,code:p.code_id}),t.html("OK")}).openapi(o.createRoute({tags:["passwordless"],method:"get",path:"/verify_redirect",request:{query:o.z.object({scope:o.z.string(),response_type:o.z.nativeEnum(It),redirect_uri:o.z.string(),state:o.z.string(),nonce:o.z.string().optional(),verification_code:o.z.string(),connection:o.z.string(),client_id:o.z.string(),email:o.z.string().transform(t=>t.toLowerCase()),audience:o.z.string().optional()})},responses:{302:{description:"Status"}}}),async t=>{const{env:e}=t,{client_id:n,email:r,verification_code:i,redirect_uri:s,state:a,scope:c,audience:l,response_type:d,nonce:p}=t.req.valid("query"),f=await Ai(e,n);return t.set("client_id",f.id),t.set("tenant_id",f.tenant.id),t.set("connection","email"),ld(t,f,{client_id:n,redirect_uri:s,state:a,nonce:p,scope:c,audience:l,response_type:d},r,i,!1,!0)});class jr extends I{constructor(n,r){super(n,r);te(this,"_code");this._code=r==null?void 0:r.code}get code(){return this._code}}async function gd(t,e,n,r,i){const{env:s}=t,{username:a}=n;if(t.set("username",a),!a)throw new I(400,{message:"Username is required"});const c=await fr({userAdapter:t.env.data.users,tenant_id:e.tenant.id,username:a,provider:"auth2"});if(!c){const h=we(t,{type:ge.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid user"});throw zt(t,t.env.data.logs.create(e.tenant.id,h)),new jr(403,{message:"User not found",code:"USER_NOT_FOUND"})}const l=c.linked_to?await s.data.users.get(e.tenant.id,c.linked_to):c;if(!l)throw new jr(403,{message:"User not found",code:"USER_NOT_FOUND"});t.set("connection",c.connection),t.set("user_id",l.user_id);const d=await s.data.passwords.get(e.tenant.id,c.user_id);if(!(d&&await oi.compare(n.password,d.password))){const h=we(t,{type:ge.FAILED_LOGIN_INCORRECT_PASSWORD,description:"Invalid password"});throw zt(t,t.env.data.logs.create(e.tenant.id,h)),new jr(403,{message:"Invalid password",code:"INVALID_PASSWORD"})}if((await s.data.logs.list(e.tenant.id,{page:0,per_page:10,include_totals:!1,q:`user_id:${l.user_id}`})).logs.filter(h=>h.type===ge.FAILED_LOGIN_INCORRECT_PASSWORD&&new Date(h.date)>new Date(Date.now()-1e3*60*5)).length>=3){const h=we(t,{type:ge.FAILED_LOGIN,description:"Too many failed login attempts"});throw zt(t,t.env.data.logs.create(e.tenant.id,h)),new jr(403,{message:"Too many failed login attempts",code:"TOO_MANY_FAILED_LOGINS"})}if(!c.email_verified&&e.email_validation==="enforced"){await hd(t,c);const h=we(t,{type:ge.FAILED_LOGIN,description:"Email not verified"});throw await t.env.data.logs.create(e.tenant.id,h),new jr(403,{message:"Email not verified",code:"EMAIL_NOT_VERIFIED"})}const w=we(t,{type:ge.SUCCESS_LOGIN,description:"Successful login",strategy_type:"Username-Password-Authentication",strategy:"Username-Password-Authentication"});return zt(t,t.env.data.logs.create(e.tenant.id,w)),ln(t,{client:e,authParams:n,user:l,ticketAuth:i,loginSession:r})}async function r1(t,e,n,r){await oo(t,{client:e,username:n,provider:"auth2",connection:"Username-Password-Authentication",isSocial:!1,ip:t.req.header("x-real-ip")});let i=Tn(),s=await t.env.data.codes.get(e.tenant.id,i,"password_reset");for(;s;)i=Tn(),s=await t.env.data.codes.get(e.tenant.id,i,"password_reset");const a=await t.env.data.loginSessions.create(e.tenant.id,{expires_at:new Date(Date.now()+t_).toISOString(),authParams:{client_id:e.id,username:n},csrf_token:ke(),...Ht(t.req)}),c=await t.env.data.codes.create(e.tenant.id,{code_id:i,code_type:"password_reset",login_id:a.id,expires_at:new Date(Date.now()+e_).toISOString()});await tm(t,n,c.code_id,r)}const i1=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth"],method:"post",path:"/",request:{body:{content:{"application/json":{schema:o.z.union([o.z.object({credential_type:o.z.literal("http://auth0.com/oauth/grant-type/passwordless/otp"),otp:o.z.string(),client_id:o.z.string(),username:o.z.string().transform(t=>t.toLowerCase()),realm:o.z.enum(["email"]),scope:o.z.string().optional()}),o.z.object({credential_type:o.z.literal("http://auth0.com/oauth/grant-type/password-realm"),client_id:o.z.string(),username:o.z.string().transform(t=>t.toLowerCase()),password:o.z.string(),realm:o.z.enum(["Username-Password-Authentication"]),scope:o.z.string().optional()})])}}}},responses:{200:{description:"List of tenants"}}}),async t=>{const e=t.req.valid("json"),{client_id:n,username:r}=e;t.set("username",r);const i=await t.env.data.clients.get(n);if(!i)throw new I(400,{message:"Client not found"});t.set("client_id",n),t.set("tenant_id",i.tenant.id);const s=r.toLocaleLowerCase();if("otp"in e)return ld(t,i,{client_id:n,username:s},s,e.otp,!0);if("password"in e){const a=await t.env.data.loginSessions.create(i.tenant.id,{expires_at:new Date(Date.now()+Qn*1e3).toISOString(),authParams:{client_id:n,username:s},csrf_token:ke(),...Ht(t.req)});return gd(t,i,{username:s,password:e.password,client_id:n},a,!0)}else throw new I(400,{message:"Code or password required"})});function s1(t,e){var r,i,s;if(!t||e.length===0)return!1;const n=((r=_a(t))==null?void 0:r.host)??null;if(!n)return!1;for(const a of e){let c;if(a.startsWith("http://")||a.startsWith("https://")?c=((i=_a(a))==null?void 0:i.host)??null:c=((s=_a("https://"+a))==null?void 0:s.host)??null,n===c)return!0}return!1}function _a(t){try{return new URL(t)}catch{return null}}async function o1({ctx:t,session:e,client:n,authParams:r,connection:i,login_hint:s}){const a=new URL(t.req.url);t.var.custom_domain&&(a.hostname=t.var.custom_domain);const c=await t.env.data.loginSessions.create(n.tenant.id,{expires_at:new Date(Date.now()+Qn*1e3).toISOString(),authParams:r,csrf_token:ke(),authorization_url:a.toString(),...Ht(t.req)});if(e&&s){const l=await t.env.data.users.get(n.tenant.id,e.user_id);if((l==null?void 0:l.email)===s)return ln(t,{client:n,loginSession:c,authParams:r,user:l,sessionId:e.id})}if(i==="email"&&s){const l=Tn();return await t.env.data.codes.create(n.tenant.id,{code_id:l,code_type:"otp",login_id:c.id,expires_at:new Date(Date.now()+Qn*1e3).toISOString()}),await fd(t,{code:l,to:s,authParams:r}),t.redirect(`/u/enter-code?state=${c.id}`)}return e?t.redirect(`/u/check-account?state=${c.id}`):t.redirect(`/u/login/identifier?state=${c.id}`)}function a1(t){if(t==="Username-Password-Authentication")return"auth2";if(t==="email")return"email";throw new I(403,{message:"Invalid realm"})}async function c1(t,e,n,r,i){var m;const{env:s}=t;t.set("connection",i);const a=await s.data.codes.get(e,n,"ticket");if(!a||a.used_at)throw new I(403,{message:"Ticket not found"});const c=await s.data.loginSessions.get(e,a.login_id);if(!c||!c.authParams.username)throw new I(403,{message:"Session not found"});const l=await s.data.clients.get(c.authParams.client_id);if(!l)throw new I(403,{message:"Client not found"});t.set("client_id",c.authParams.client_id),await s.data.codes.used(e,n);const d=a1(i);let p=await oo(t,{username:c.authParams.username,provider:d,client:l,connection:d==="auth2"?"Username-Password-Authentication":"email",isSocial:!1,ip:t.req.header("x-real-ip")});t.set("username",p.email||p.phone_number),t.set("user_id",p.user_id);const f=await Gf(t,{user:p,client:l,loginSession:c});return ln(t,{authParams:{scope:(m=c.authParams)==null?void 0:m.scope,...r},loginSession:c,sessionId:f.id,user:p,client:l})}async function Mp(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 o1({ctx:t,client:e,session:n,redirect_uri:r,state:i,nonce:s,code_challenge_method:a,code_challenge:c,audience:l,scope:d,response_type:p}){const{env:f}=t,m=new URL(r),w=`${m.protocol}//${m.host}`;async function h(ce="Login required"){const le=we(t,{type:ge.FAILED_SILENT_AUTH,description:ce});return await t.env.data.logs.create(e.tenant.id,le),t.html(Mp(w,JSON.stringify({error:"login_required",error_description:ce,state:i})))}if(!n||(n==null?void 0:n.expires_at)&&new Date(n.expires_at)<new Date||(n==null?void 0:n.idle_expires_at)&&new Date(n.idle_expires_at)<new Date)return h();t.set("user_id",n.user_id);const v=await f.data.users.get(e.tenant.id,n.user_id);if(!v)return console.error("User not found",n.user_id),h("User not found");t.set("username",v.email),t.set("connection",v.connection);const S={client:e,authParams:{client_id:e.id,audience:l,code_challenge_method:a,code_challenge:c,scope:d,state:i,nonce:s,response_type:p},user:v,session_id:n.id},C=p===It.CODE?await Ff(t,S):await ro(t,S);await f.data.sessions.update(e.tenant.id,n.id,{used_at:new Date().toISOString(),last_interaction_at:new Date().toISOString(),device:{...n.device,last_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||""},idle_expires_at:n.idle_expires_at?new Date(Date.now()+to*1e3).toISOString():void 0});const O=we(t,{type:ge.SUCCESS_SILENT_AUTH,description:"Successful silent authentication"});await t.env.data.logs.create(e.tenant.id,O);const L=new Headers;L.set("Server-Timing","cf-nel=0; no-cloudflare-insights=1");const Q=Rf(e.tenant.id,n.id,t.req.header("host"));return L.set("set-cookie",Q),t.html(Mp(w,JSON.stringify(C)),{headers:L})}const a1=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth"],method:"get",path:"/",request:{query:o.z.object({client_id:o.z.string(),vendor_id:o.z.string().optional(),redirect_uri:o.z.string(),scope:o.z.string().optional(),state:o.z.string(),prompt:o.z.string().optional(),response_mode:o.z.nativeEnum(Rt).optional(),response_type:o.z.nativeEnum(It).optional(),audience:o.z.string().optional(),connection:o.z.string().optional(),nonce:o.z.string().optional(),max_age:o.z.string().optional(),login_ticket:o.z.string().optional(),code_challenge_method:o.z.nativeEnum(Xs).optional(),code_challenge:o.z.string().optional(),realm:o.z.string().optional(),auth0Client:o.z.string().optional(),organization:o.z.string().optional(),login_hint:o.z.string().optional(),screen_hint:o.z.string().openapi({example:"signup",description:'Optional hint for the screen to show, like "signup" or "login".'}).optional(),ui_locales:o.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:r,redirect_uri:i,scope:s,state:a,audience:c,nonce:l,connection:d,response_type:p,response_mode:f,code_challenge:m,code_challenge_method:w,prompt:h,login_ticket:_,realm:v,auth0Client:S,login_hint:C,ui_locales:O,organization:L}=t.req.valid("query");t.set("log","authorize");const Q=await Ai(e,n);t.set("client_id",Q.id),t.set("tenant_id",Q.tenant.id);const ce={redirect_uri:i,scope:s,state:a,client_id:n,vendor_id:r,audience:c,nonce:l,prompt:h,response_type:p,response_mode:f,code_challenge:m,code_challenge_method:w,username:C,ui_locales:O,organization:L},le=t.req.header("origin");if(le&&!n1(le,Q.web_origins||[]))throw new I(403,{message:`Origin ${le} not allowed`});if(ce.redirect_uri&&!Jg(ce.redirect_uri,Q.callbacks||[],{allowPathWildcards:!0}))throw new I(400,{message:`Invalid redirect URI - ${ce.redirect_uri}`});const De=ds(Q.tenant.id,t.req.header("cookie")),Ve=De?await e.data.sessions.get(Q.tenant.id,De):void 0,Re=Ve&&!Ve.revoked_at?Ve:void 0;if(h=="none"){if(!p)throw new I(400,{message:"Missing response_type"});return o1({ctx:t,session:Re||void 0,redirect_uri:i,state:a,response_type:p,client:Q,nonce:l,code_challenge_method:w,code_challenge:m,audience:c,scope:s})}return d&&d!=="email"?Pb(t,Q,d,ce):_?s1(t,Q.tenant.id,_,ce,v):r1({ctx:t,client:Q,auth0Client:S,authParams:ce,session:Re||void 0,connection:d,login_hint:C})});function c1(t){const e=new o.OpenAPIHono;e.use(async(r,i)=>(r.env.data=io(r,t.dataAdapter),i())),e.use("/oauth/token",cf({origin:r=>r||"",allowHeaders:["Tenant-Id","Content-Type","Auth0-Client","Upgrade-Insecure-Requests"],allowMethods:["POST"],maxAge:600})),e.use(od).use(Ug(e));const n=e.route("/v2/logout",Rb).route("/userinfo",Lb).route("/.well-known",Ub).route("/oauth/token",Gb).route("/dbconnections",Xb).route("/passwordless",Qb).route("/co/authenticate",t1).route("/authorize",a1).route("/callback",Tb);return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth API"},security:[{oauth2:["openid","email","profile"]}]}),Lg(n),n}var l1={Stringify:1,BeforeStream:2,Stream:3},mt=(t,e)=>{const n=new String(t);return n.isEscaped=!0,n.callbacks=e,n},d1=/[&<>'"]/,tm=async(t,e)=>{let n="";e||(e=[]);const r=await Promise.all(t);for(let i=r.length-1;n+=r[i],i--,!(i<0);i--){let s=r[i];typeof s=="object"&&e.push(...s.callbacks||[]);const a=s.isEscaped;if(s=await(typeof s=="object"?s.toString():s),typeof s=="object"&&e.push(...s.callbacks||[]),s.isEscaped??a)n+=s;else{const c=[n];en(s,c),n=c[0]}}return mt(n,e)},en=(t,e)=>{const n=t.search(d1);if(n===-1){e[0]+=t;return}let r,i,s=0;for(i=n;i<t.length;i++){switch(t.charCodeAt(i)){case 34:r="&quot;";break;case 39:r="&#39;";break;case 38:r="&amp;";break;case 60:r="&lt;";break;case 62:r="&gt;";break;default:continue}e[0]+=t.substring(s,i)+r,s=i+1}e[0]+=t.substring(s,i)},nm=t=>{const e=t.callbacks;if(!(e!=null&&e.length))return t;const n=[t],r={};return e.forEach(i=>i({phase:l1.Stringify,buffer:n,context:r})),n[0]},u1=(t,...e)=>{const n=[""];for(let r=0,i=t.length-1;r<i;r++){n[0]+=t[r];const s=Array.isArray(e[r])?e[r].flat(1/0):[e[r]];for(let a=0,c=s.length;a<c;a++){const l=s[a];if(typeof l=="string")en(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 d=l.toString();d instanceof Promise?n.unshift("",d):n[0]+=d}else l instanceof Promise?n.unshift("",l):en(l.toString(),n)}}}return n[0]+=t[t.length-1],n.length===1?"callbacks"in n?mt(nm(mt(n[0],n.callbacks))):mt(n[0]):tm(n,n.callbacks)},md=Symbol("RENDERER"),Yc=Symbol("ERROR_HANDLER"),Ae=Symbol("STASH"),rm=Symbol("INTERNAL"),p1=Symbol("MEMO"),Gs=Symbol("PERMALINK"),Hp=t=>(t[rm]=!0,t),im=t=>({value:e,children:n})=>{if(!n)return;const r={children:[{tag:Hp(()=>{t.push(e)}),props:{}}]};Array.isArray(n)?r.children.push(...n.flat()):r.children.push(n),r.children.push({tag:Hp(()=>{t.pop()}),props:{}});const i={tag:"",props:r,type:""};return i[Yc]=s=>{throw t.pop(),s},i},sm=t=>{const e=[t],n=im(e);return n.values=e,n.Provider=n,ur.push(n),n},ur=[],f1=t=>{const e=[t],n=r=>{e.push(r.value);let i;try{i=r.children?(Array.isArray(r.children)?new lm("",{},r.children):r.children).toString():""}finally{e.pop()}return i instanceof Promise?i.then(s=>mt(s,s.callbacks)):mt(i)};return n.values=e,n.Provider=n,n[md]=im(e),ur.push(n),n},Ar=t=>t.values.at(-1),Wi={title:[],script:["src"],style:["data-href"],link:["href"],meta:["name","httpEquiv","charset","itemProp"]},Xc={},Gi="data-precedence",Ei=t=>Array.isArray(t)?t:[t],Dp=new WeakMap,Fp=(t,e,n,r)=>({buffer:i,context:s})=>{if(!i)return;const a=Dp.get(s)||{};Dp.set(s,a);const c=a[t]||(a[t]=[]);let l=!1;const d=Wi[t];if(d.length>0){e:for(const[,p]of c)for(const f of d)if(((p==null?void 0:p[f])??null)===(n==null?void 0:n[f])){l=!0;break e}}if(l?i[0]=i[0].replaceAll(e,""):d.length>0?c.push([e,n,r]):c.unshift([e,n,r]),i[0].indexOf("</head>")!==-1){let p;if(r===void 0)p=c.map(([f])=>f);else{const f=[];p=c.map(([m,,w])=>{let h=f.indexOf(w);return h===-1&&(f.push(w),h=f.length-1),[m,h]}).sort((m,w)=>m[1]-w[1]).map(([m])=>m)}p.forEach(f=>{i[0]=i[0].replaceAll(f,"")}),i[0]=i[0].replace(/(?=<\/head>)/,p.join(""))}},Ii=(t,e,n)=>mt(new _t(t,n,Ei(e??[])).toString()),Ci=(t,e,n,r)=>{if("itemProp"in n)return Ii(t,e,n);let{precedence:i,blocking:s,...a}=n;i=r?i??"":void 0,r&&(a[Gi]=i);const c=new _t(t,a,Ei(e||[])).toString();return c instanceof Promise?c.then(l=>mt(c,[...l.callbacks||[],Fp(t,l,a,i)])):mt(c,[Fp(t,c,a,i)])},h1=({children:t,...e})=>{const n=_d();if(n){const r=Ar(n);if(r==="svg"||r==="head")return new _t("title",e,Ei(t??[]))}return Ci("title",t,e,!1)},g1=({children:t,...e})=>{const n=_d();return["src","async"].some(r=>!e[r])||n&&Ar(n)==="head"?Ii("script",t,e):Ci("script",t,e,!1)},m1=({children:t,...e})=>["href","precedence"].every(n=>n in e)?(e["data-href"]=e.href,delete e.href,Ci("style",t,e,!0)):Ii("style",t,e),_1=({children:t,...e})=>["onLoad","onError"].some(n=>n in e)||e.rel==="stylesheet"&&(!("precedence"in e)||"disabled"in e)?Ii("link",t,e):Ci("link",t,e,"precedence"in e),y1=({children:t,...e})=>{const n=_d();return n&&Ar(n)==="head"?Ii("meta",t,e):Ci("meta",t,e,!1)},om=(t,{children:e,...n})=>new _t(t,n,Ei(e??[])),w1=t=>(typeof t.action=="function"&&(t.action=Gs in t.action?t.action[Gs]:void 0),om("form",t)),am=(t,e)=>(typeof e.formAction=="function"&&(e.formAction=Gs in e.formAction?e.formAction[Gs]:void 0),om(t,e)),v1=t=>am("input",t),b1=t=>am("button",t);const ya=Object.freeze(Object.defineProperty({__proto__:null,button:b1,form:w1,input:v1,link:_1,meta:y1,script:g1,style:m1,title:h1},Symbol.toStringTag,{value:"Module"}));var x1=new Map([["className","class"],["htmlFor","for"],["crossOrigin","crossorigin"],["httpEquiv","http-equiv"],["itemProp","itemprop"],["fetchPriority","fetchpriority"],["noModule","nomodule"],["formAction","formaction"]]),Js=t=>x1.get(t)||t,cm=(t,e)=>{for(const[n,r]of Object.entries(t)){const i=n[0]==="-"||!/[A-Z]/.test(n)?n:n.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);e(i,r==null?null:typeof r=="number"?i.match(/^(?:a|border-im|column(?:-c|s)|flex(?:$|-[^b])|grid-(?:ar|[^a])|font-w|li|or|sca|st|ta|wido|z)|ty$/)?`${r}`:`${r}px`:r)}},ri=void 0,_d=()=>ri,k1=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,S1=["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],A1=["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"],yd=(t,e)=>{for(let n=0,r=t.length;n<r;n++){const i=t[n];if(typeof i=="string")en(i,e);else{if(typeof i=="boolean"||i===null||i===void 0)continue;i instanceof _t?i.toStringToBuffer(e):typeof i=="number"||i.isEscaped?e[0]+=i:i instanceof Promise?e.unshift("",i):yd(i,e)}}},_t=class{constructor(t,e,n){te(this,"tag");te(this,"props");te(this,"key");te(this,"children");te(this,"isEscaped",!0);te(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(([r,i])=>{r.values.push(i)});try{this.toStringToBuffer(t)}finally{(n=this.localContexts)==null||n.forEach(([r])=>{r.values.pop()})}return t.length===1?"callbacks"in t?nm(mt(t[0],t.callbacks)).toString():t[0]:tm(t,t.callbacks)}toStringToBuffer(t){const e=this.tag,n=this.props;let{children:r}=this;t[0]+=`<${e}`;const i=ri&&Ar(ri)==="svg"?s=>k1(Js(s)):s=>Js(s);for(let[s,a]of Object.entries(n))if(s=i(s),s!=="children"){if(s==="style"&&typeof a=="object"){let c="";cm(a,(l,d)=>{d!=null&&(c+=`${c?";":""}${l}:${d}`)}),t[0]+=' style="',en(c,t),t[0]+='"'}else if(typeof a=="string")t[0]+=` ${s}="`,en(a,t),t[0]+='"';else if(a!=null)if(typeof a=="number"||a.isEscaped)t[0]+=` ${s}="${a}"`;else if(typeof a=="boolean"&&A1.includes(s))a&&(t[0]+=` ${s}=""`);else if(s==="dangerouslySetInnerHTML"){if(r.length>0)throw"Can only set one of `children` or `props.dangerouslySetInnerHTML`.";r=[mt(a.__html)]}else if(a instanceof Promise)t[0]+=` ${s}="`,t.unshift('"',a);else if(typeof a=="function"){if(!s.startsWith("on"))throw`Invalid prop '${s}' of type 'function' supplied to '${e}'.`}else t[0]+=` ${s}="`,en(a.toString(),t),t[0]+='"'}if(S1.includes(e)&&r.length===0){t[0]+="/>";return}t[0]+=">",yd(r,t),t[0]+=`</${e}>`}},wa=class extends _t{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(ur.length===0)t.unshift("",n);else{const r=ur.map(i=>[i,i.values.at(-1)]);t.unshift("",n.then(i=>(i instanceof _t&&(i.localContexts=r),i)))}else n instanceof _t?n.toStringToBuffer(t):typeof n=="number"||n.isEscaped?(t[0]+=n,n.callbacks&&(t.callbacks||(t.callbacks=[]),t.callbacks.push(...n.callbacks))):en(n,t)}},lm=class extends _t{toStringToBuffer(t){yd(this.children,t)}},z1=(t,e,...n)=>{e??(e={}),n.length&&(e.children=n.length===1?n[0]:n);const r=e.key;delete e.key;const i=Ji(t,e,n);return i.key=r,i},Kp=!1,Ji=(t,e,n)=>{if(!Kp){for(const r in Xc)ya[r][md]=Xc[r];Kp=!0}return typeof t=="function"?new wa(t,e,n):ya[t]?new wa(ya[t],e,n):t==="svg"||t==="head"?(ri||(ri=f1("")),new _t(t,e,[new wa(ri,{value:t},n)])):new _t(t,e,n)},dm=({children:t})=>new lm("",{children:t},Array.isArray(t)?t:t?[t]:[]),E1=(t,e,...n)=>z1(t.tag,{...t.props,...e},...n);function y(t,e,n){let r;if(!e||!("children"in e))r=Ji(t,e,[]);else{const i=e.children;r=Array.isArray(i)?Ji(t,e,i):Ji(t,e,[i])}return r.key=n,r}const Wp={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 wd(t,e,n){if(!n&&!e)return Wp;const r=n||e;try{const i=await fetch(`${t.API_URL}/profile/vendors/${r}/style`);if(!i.ok)throw new Error("Failed to fetch vendor settings");const s=await i.json();return ff.parse(s)}catch(i){return console.error(i),Wp}}async function Ee(t,e,n=!1){var d;const{env:r}=t,i=await r.data.loginSessions.get(t.var.tenant_id||"",e);if(i)i.session_id;else throw new I(400,{message:"Login session not found"});t.set("loginSession",i);const s=await Ai(r,i.authParams.client_id);t.set("client_id",s.id),t.set("tenant_id",s.tenant.id);const a=await r.data.tenants.get(s.tenant.id);if(a){if(i.session_id&&!n)throw new I(400,{message:"Login session closed"})}else throw new I(400,{message:"Tenant not found"});const c=await wd(r,s.id,i.authParams.vendor_id),l=(d=i.authParams.ui_locales)==null?void 0:d.split(" ").map(p=>p.split("-")[0]).find(p=>{if(Array.isArray(T.options.supportedLngs))return T.options.supportedLngs.includes(p)});return await T.changeLanguage(l||a.language||"sv"),{vendorSettings:{...c,termsAndConditionsUrl:s.id==="fokus-app"?"https://www.fokus.se/kopvillkor-app/":c.termsAndConditionsUrl},client:s,tenant:a,loginSession:i}}async function I1(t,e,n,r){if(r!==void 0)return r==="password";const i=await so({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:n});if(i){const a=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:${ge.SUCCESS_LOGIN} user_id:${i.user_id}`}),[c]=a.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 um=({vendorSettings:t})=>t!=null&&t.logoUrl?y("div",{className:"flex h-9 items-center",children:y("img",{src:t.logoUrl,className:"max-h-full",alt:"Vendor logo"})}):y(dm,{}),pm=({vendorSettings:t})=>{const{termsAndConditionsUrl:e}=t;return y("div",{className:"mt-8",children:e&&y("div",{className:"text-xs text-gray-300",children:[T.t("agree_to")," ",y("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noreferrer",children:T.t("terms")})]})})};var fm={exports:{}};/*!
192
+ </html>`}async function l1({ctx:t,client:e,session:n,redirect_uri:r,state:i,nonce:s,code_challenge_method:a,code_challenge:c,audience:l,scope:d,response_type:p}){const{env:f}=t,m=new URL(r),w=`${m.protocol}//${m.host}`;async function h(ce="Login required"){const le=we(t,{type:ge.FAILED_SILENT_AUTH,description:ce});return await t.env.data.logs.create(e.tenant.id,le),t.html(Mp(w,JSON.stringify({error:"login_required",error_description:ce,state:i})))}if(!n||(n==null?void 0:n.expires_at)&&new Date(n.expires_at)<new Date||(n==null?void 0:n.idle_expires_at)&&new Date(n.idle_expires_at)<new Date)return h();t.set("user_id",n.user_id);const v=await f.data.users.get(e.tenant.id,n.user_id);if(!v)return console.error("User not found",n.user_id),h("User not found");t.set("username",v.email),t.set("connection",v.connection);const S={client:e,authParams:{client_id:e.id,audience:l,code_challenge_method:a,code_challenge:c,scope:d,state:i,nonce:s,response_type:p},user:v,session_id:n.id},C=p===It.CODE?await Wf(t,S):await ro(t,S);await f.data.sessions.update(e.tenant.id,n.id,{used_at:new Date().toISOString(),last_interaction_at:new Date().toISOString(),device:{...n.device,last_ip:t.req.header("x-real-ip")||"",last_user_agent:t.req.header("user-agent")||""},idle_expires_at:n.idle_expires_at?new Date(Date.now()+to*1e3).toISOString():void 0});const O=we(t,{type:ge.SUCCESS_SILENT_AUTH,description:"Successful silent authentication"});await t.env.data.logs.create(e.tenant.id,O);const L=new Headers;L.set("Server-Timing","cf-nel=0; no-cloudflare-insights=1");const Q=Uf(e.tenant.id,n.id,t.req.header("host"));return L.set("set-cookie",Q),t.html(Mp(w,JSON.stringify(C)),{headers:L})}const d1=new o.OpenAPIHono().openapi(o.createRoute({tags:["oauth"],method:"get",path:"/",request:{query:o.z.object({client_id:o.z.string(),vendor_id:o.z.string().optional(),redirect_uri:o.z.string(),scope:o.z.string().optional(),state:o.z.string(),prompt:o.z.string().optional(),response_mode:o.z.nativeEnum(Rt).optional(),response_type:o.z.nativeEnum(It).optional(),audience:o.z.string().optional(),connection:o.z.string().optional(),nonce:o.z.string().optional(),max_age:o.z.string().optional(),login_ticket:o.z.string().optional(),code_challenge_method:o.z.nativeEnum(Xs).optional(),code_challenge:o.z.string().optional(),realm:o.z.string().optional(),auth0Client:o.z.string().optional(),organization:o.z.string().optional(),login_hint:o.z.string().optional(),screen_hint:o.z.string().openapi({example:"signup",description:'Optional hint for the screen to show, like "signup" or "login".'}).optional(),ui_locales:o.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:r,redirect_uri:i,scope:s,state:a,audience:c,nonce:l,connection:d,response_type:p,response_mode:f,code_challenge:m,code_challenge_method:w,prompt:h,login_ticket:_,realm:v,auth0Client:S,login_hint:C,ui_locales:O,organization:L}=t.req.valid("query");t.set("log","authorize");const Q=await Ai(e,n);t.set("client_id",Q.id),t.set("tenant_id",Q.tenant.id);const ce={redirect_uri:i,scope:s,state:a,client_id:n,vendor_id:r,audience:c,nonce:l,prompt:h,response_type:p,response_mode:f,code_challenge:m,code_challenge_method:w,username:C,ui_locales:O,organization:L},le=t.req.header("origin");if(le&&!s1(le,Q.web_origins||[]))throw new I(403,{message:`Origin ${le} not allowed`});if(ce.redirect_uri&&!Yg(ce.redirect_uri,Q.callbacks||[],{allowPathWildcards:!0}))throw new I(400,{message:`Invalid redirect URI - ${ce.redirect_uri}`});const De=ds(Q.tenant.id,t.req.header("cookie")),Ve=De?await e.data.sessions.get(Q.tenant.id,De):void 0,Re=Ve&&!Ve.revoked_at?Ve:void 0;if(h=="none"){if(!p)throw new I(400,{message:"Missing response_type"});return l1({ctx:t,session:Re||void 0,redirect_uri:i,state:a,response_type:p,client:Q,nonce:l,code_challenge_method:w,code_challenge:m,audience:c,scope:s})}return d&&d!=="email"?Rb(t,Q,d,ce):_?c1(t,Q.tenant.id,_,ce,v):o1({ctx:t,client:Q,auth0Client:S,authParams:ce,session:Re||void 0,connection:d,login_hint:C})});function u1(t){const e=new o.OpenAPIHono;e.use(async(r,i)=>(r.env.data=io(r,t.dataAdapter),i())),e.use("/oauth/token",df({origin:r=>r||"",allowHeaders:["Tenant-Id","Content-Type","Auth0-Client","Upgrade-Insecure-Requests"],allowMethods:["POST"],maxAge:600})),e.use(od).use(qg(e));const n=e.route("/v2/logout",Vb).route("/userinfo",qb).route("/.well-known",Mb).route("/oauth/token",Yb).route("/dbconnections",t1).route("/passwordless",n1).route("/co/authenticate",i1).route("/authorize",d1).route("/callback",Lb);return n.doc("/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Oauth API"},security:[{oauth2:["openid","email","profile"]}]}),Vg(n),n}var p1={Stringify:1,BeforeStream:2,Stream:3},mt=(t,e)=>{const n=new String(t);return n.isEscaped=!0,n.callbacks=e,n},f1=/[&<>'"]/,rm=async(t,e)=>{let n="";e||(e=[]);const r=await Promise.all(t);for(let i=r.length-1;n+=r[i],i--,!(i<0);i--){let s=r[i];typeof s=="object"&&e.push(...s.callbacks||[]);const a=s.isEscaped;if(s=await(typeof s=="object"?s.toString():s),typeof s=="object"&&e.push(...s.callbacks||[]),s.isEscaped??a)n+=s;else{const c=[n];en(s,c),n=c[0]}}return mt(n,e)},en=(t,e)=>{const n=t.search(f1);if(n===-1){e[0]+=t;return}let r,i,s=0;for(i=n;i<t.length;i++){switch(t.charCodeAt(i)){case 34:r="&quot;";break;case 39:r="&#39;";break;case 38:r="&amp;";break;case 60:r="&lt;";break;case 62:r="&gt;";break;default:continue}e[0]+=t.substring(s,i)+r,s=i+1}e[0]+=t.substring(s,i)},im=t=>{const e=t.callbacks;if(!(e!=null&&e.length))return t;const n=[t],r={};return e.forEach(i=>i({phase:p1.Stringify,buffer:n,context:r})),n[0]},sm=(t,...e)=>{const n=[""];for(let r=0,i=t.length-1;r<i;r++){n[0]+=t[r];const s=Array.isArray(e[r])?e[r].flat(1/0):[e[r]];for(let a=0,c=s.length;a<c;a++){const l=s[a];if(typeof l=="string")en(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 d=l.toString();d instanceof Promise?n.unshift("",d):n[0]+=d}else l instanceof Promise?n.unshift("",l):en(l.toString(),n)}}}return n[0]+=t[t.length-1],n.length===1?"callbacks"in n?mt(im(mt(n[0],n.callbacks))):mt(n[0]):rm(n,n.callbacks)},md=Symbol("RENDERER"),Yc=Symbol("ERROR_HANDLER"),Ae=Symbol("STASH"),om=Symbol("INTERNAL"),h1=Symbol("MEMO"),Gs=Symbol("PERMALINK"),Hp=t=>(t[om]=!0,t),am=t=>({value:e,children:n})=>{if(!n)return;const r={children:[{tag:Hp(()=>{t.push(e)}),props:{}}]};Array.isArray(n)?r.children.push(...n.flat()):r.children.push(n),r.children.push({tag:Hp(()=>{t.pop()}),props:{}});const i={tag:"",props:r,type:""};return i[Yc]=s=>{throw t.pop(),s},i},cm=t=>{const e=[t],n=am(e);return n.values=e,n.Provider=n,ur.push(n),n},ur=[],g1=t=>{const e=[t],n=r=>{e.push(r.value);let i;try{i=r.children?(Array.isArray(r.children)?new pm("",{},r.children):r.children).toString():""}finally{e.pop()}return i instanceof Promise?i.then(s=>mt(s,s.callbacks)):mt(i)};return n.values=e,n.Provider=n,n[md]=am(e),ur.push(n),n},Ar=t=>t.values.at(-1),Wi={title:[],script:["src"],style:["data-href"],link:["href"],meta:["name","httpEquiv","charset","itemProp"]},Xc={},Gi="data-precedence",Ei=t=>Array.isArray(t)?t:[t],Dp=new WeakMap,Fp=(t,e,n,r)=>({buffer:i,context:s})=>{if(!i)return;const a=Dp.get(s)||{};Dp.set(s,a);const c=a[t]||(a[t]=[]);let l=!1;const d=Wi[t];if(d.length>0){e:for(const[,p]of c)for(const f of d)if(((p==null?void 0:p[f])??null)===(n==null?void 0:n[f])){l=!0;break e}}if(l?i[0]=i[0].replaceAll(e,""):d.length>0?c.push([e,n,r]):c.unshift([e,n,r]),i[0].indexOf("</head>")!==-1){let p;if(r===void 0)p=c.map(([f])=>f);else{const f=[];p=c.map(([m,,w])=>{let h=f.indexOf(w);return h===-1&&(f.push(w),h=f.length-1),[m,h]}).sort((m,w)=>m[1]-w[1]).map(([m])=>m)}p.forEach(f=>{i[0]=i[0].replaceAll(f,"")}),i[0]=i[0].replace(/(?=<\/head>)/,p.join(""))}},Ii=(t,e,n)=>mt(new _t(t,n,Ei(e??[])).toString()),Ci=(t,e,n,r)=>{if("itemProp"in n)return Ii(t,e,n);let{precedence:i,blocking:s,...a}=n;i=r?i??"":void 0,r&&(a[Gi]=i);const c=new _t(t,a,Ei(e||[])).toString();return c instanceof Promise?c.then(l=>mt(c,[...l.callbacks||[],Fp(t,l,a,i)])):mt(c,[Fp(t,c,a,i)])},m1=({children:t,...e})=>{const n=_d();if(n){const r=Ar(n);if(r==="svg"||r==="head")return new _t("title",e,Ei(t??[]))}return Ci("title",t,e,!1)},_1=({children:t,...e})=>{const n=_d();return["src","async"].some(r=>!e[r])||n&&Ar(n)==="head"?Ii("script",t,e):Ci("script",t,e,!1)},y1=({children:t,...e})=>["href","precedence"].every(n=>n in e)?(e["data-href"]=e.href,delete e.href,Ci("style",t,e,!0)):Ii("style",t,e),w1=({children:t,...e})=>["onLoad","onError"].some(n=>n in e)||e.rel==="stylesheet"&&(!("precedence"in e)||"disabled"in e)?Ii("link",t,e):Ci("link",t,e,"precedence"in e),v1=({children:t,...e})=>{const n=_d();return n&&Ar(n)==="head"?Ii("meta",t,e):Ci("meta",t,e,!1)},lm=(t,{children:e,...n})=>new _t(t,n,Ei(e??[])),b1=t=>(typeof t.action=="function"&&(t.action=Gs in t.action?t.action[Gs]:void 0),lm("form",t)),dm=(t,e)=>(typeof e.formAction=="function"&&(e.formAction=Gs in e.formAction?e.formAction[Gs]:void 0),lm(t,e)),x1=t=>dm("input",t),k1=t=>dm("button",t);const ya=Object.freeze(Object.defineProperty({__proto__:null,button:k1,form:b1,input:x1,link:w1,meta:v1,script:_1,style:y1,title:m1},Symbol.toStringTag,{value:"Module"}));var S1=new Map([["className","class"],["htmlFor","for"],["crossOrigin","crossorigin"],["httpEquiv","http-equiv"],["itemProp","itemprop"],["fetchPriority","fetchpriority"],["noModule","nomodule"],["formAction","formaction"]]),Js=t=>S1.get(t)||t,um=(t,e)=>{for(const[n,r]of Object.entries(t)){const i=n[0]==="-"||!/[A-Z]/.test(n)?n:n.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`);e(i,r==null?null:typeof r=="number"?i.match(/^(?:a|border-im|column(?:-c|s)|flex(?:$|-[^b])|grid-(?:ar|[^a])|font-w|li|or|sca|st|ta|wido|z)|ty$/)?`${r}`:`${r}px`:r)}},ri=void 0,_d=()=>ri,A1=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,z1=["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],E1=["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"],yd=(t,e)=>{for(let n=0,r=t.length;n<r;n++){const i=t[n];if(typeof i=="string")en(i,e);else{if(typeof i=="boolean"||i===null||i===void 0)continue;i instanceof _t?i.toStringToBuffer(e):typeof i=="number"||i.isEscaped?e[0]+=i:i instanceof Promise?e.unshift("",i):yd(i,e)}}},_t=class{constructor(t,e,n){te(this,"tag");te(this,"props");te(this,"key");te(this,"children");te(this,"isEscaped",!0);te(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(([r,i])=>{r.values.push(i)});try{this.toStringToBuffer(t)}finally{(n=this.localContexts)==null||n.forEach(([r])=>{r.values.pop()})}return t.length===1?"callbacks"in t?im(mt(t[0],t.callbacks)).toString():t[0]:rm(t,t.callbacks)}toStringToBuffer(t){const e=this.tag,n=this.props;let{children:r}=this;t[0]+=`<${e}`;const i=ri&&Ar(ri)==="svg"?s=>A1(Js(s)):s=>Js(s);for(let[s,a]of Object.entries(n))if(s=i(s),s!=="children"){if(s==="style"&&typeof a=="object"){let c="";um(a,(l,d)=>{d!=null&&(c+=`${c?";":""}${l}:${d}`)}),t[0]+=' style="',en(c,t),t[0]+='"'}else if(typeof a=="string")t[0]+=` ${s}="`,en(a,t),t[0]+='"';else if(a!=null)if(typeof a=="number"||a.isEscaped)t[0]+=` ${s}="${a}"`;else if(typeof a=="boolean"&&E1.includes(s))a&&(t[0]+=` ${s}=""`);else if(s==="dangerouslySetInnerHTML"){if(r.length>0)throw"Can only set one of `children` or `props.dangerouslySetInnerHTML`.";r=[mt(a.__html)]}else if(a instanceof Promise)t[0]+=` ${s}="`,t.unshift('"',a);else if(typeof a=="function"){if(!s.startsWith("on"))throw`Invalid prop '${s}' of type 'function' supplied to '${e}'.`}else t[0]+=` ${s}="`,en(a.toString(),t),t[0]+='"'}if(z1.includes(e)&&r.length===0){t[0]+="/>";return}t[0]+=">",yd(r,t),t[0]+=`</${e}>`}},wa=class extends _t{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(ur.length===0)t.unshift("",n);else{const r=ur.map(i=>[i,i.values.at(-1)]);t.unshift("",n.then(i=>(i instanceof _t&&(i.localContexts=r),i)))}else n instanceof _t?n.toStringToBuffer(t):typeof n=="number"||n.isEscaped?(t[0]+=n,n.callbacks&&(t.callbacks||(t.callbacks=[]),t.callbacks.push(...n.callbacks))):en(n,t)}},pm=class extends _t{toStringToBuffer(t){yd(this.children,t)}},I1=(t,e,...n)=>{e??(e={}),n.length&&(e.children=n.length===1?n[0]:n);const r=e.key;delete e.key;const i=Ji(t,e,n);return i.key=r,i},Kp=!1,Ji=(t,e,n)=>{if(!Kp){for(const r in Xc)ya[r][md]=Xc[r];Kp=!0}return typeof t=="function"?new wa(t,e,n):ya[t]?new wa(ya[t],e,n):t==="svg"||t==="head"?(ri||(ri=g1("")),new _t(t,e,[new wa(ri,{value:t},n)])):new _t(t,e,n)},fm=({children:t})=>new pm("",{children:t},Array.isArray(t)?t:t?[t]:[]),C1=(t,e,...n)=>I1(t.tag,{...t.props,...e},...n);function y(t,e,n){let r;if(!e||!("children"in e))r=Ji(t,e,[]);else{const i=e.children;r=Array.isArray(i)?Ji(t,e,i):Ji(t,e,[i])}return r.key=n,r}const Wp={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 wd(t,e,n){if(!n&&!e)return Wp;const r=n||e;try{const i=await fetch(`${t.API_URL}/profile/vendors/${r}/style`);if(!i.ok)throw new Error("Failed to fetch vendor settings");const s=await i.json();return gf.parse(s)}catch(i){return console.error(i),Wp}}async function Ee(t,e,n=!1){var d;const{env:r}=t,i=await r.data.loginSessions.get(t.var.tenant_id||"",e);if(i)i.session_id;else throw new I(400,{message:"Login session not found"});t.set("loginSession",i);const s=await Ai(r,i.authParams.client_id);t.set("client_id",s.id),t.set("tenant_id",s.tenant.id);const a=await r.data.tenants.get(s.tenant.id);if(a){if(i.session_id&&!n)throw new I(400,{message:"Login session closed"})}else throw new I(400,{message:"Tenant not found"});const c=await wd(r,s.id,i.authParams.vendor_id),l=(d=i.authParams.ui_locales)==null?void 0:d.split(" ").map(p=>p.split("-")[0]).find(p=>{if(Array.isArray(T.options.supportedLngs))return T.options.supportedLngs.includes(p)});return await T.changeLanguage(l||a.language||"sv"),{vendorSettings:{...c,termsAndConditionsUrl:s.id==="fokus-app"?"https://www.fokus.se/kopvillkor-app/":c.termsAndConditionsUrl},client:s,tenant:a,loginSession:i}}async function N1(t,e,n,r){if(r!==void 0)return r==="password";const i=await so({userAdapter:t.env.data.users,tenant_id:e.tenant.id,email:n});if(i){const a=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:${ge.SUCCESS_LOGIN} user_id:${i.user_id}`}),[c]=a.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 hm=({vendorSettings:t})=>t!=null&&t.logoUrl?y("div",{className:"flex h-9 items-center",children:y("img",{src:t.logoUrl,className:"max-h-full",alt:"Vendor logo"})}):y(fm,{}),gm=({vendorSettings:t})=>{const{termsAndConditionsUrl:e}=t;return y("div",{className:"mt-8",children:e&&y("div",{className:"text-xs text-gray-300",children:[T.t("agree_to")," ",y("a",{href:e,className:"text-primary hover:underline",target:"_blank",rel:"noreferrer",children:T.t("terms")})]})})};var mm={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="",a=0;a<arguments.length;a++){var c=arguments[a];c&&(s=i(s,r(c)))}return s}function r(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 a="";for(var c in s)e.call(s,c)&&s[c]&&(a=i(a,c));return a}function i(s,a){return a?s?s+" "+a:s+a:s}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(fm);var C1=fm.exports;const on=Nf(C1),N1=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",Ge=({name:t,size:e,className:n=""})=>{const r=N1(e);return y("span",{className:on(`uicon-${t}`,n,r)})};var Gp=Object.freeze,j1=Object.defineProperty,$1=(t,e)=>Gp(j1(t,"raw",{value:Gp(t.slice())})),Jp;const O1=t=>{const{style:e}=t;return`
196
+ */(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",a=0;a<arguments.length;a++){var c=arguments[a];c&&(s=i(s,r(c)))}return s}function r(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 a="";for(var c in s)e.call(s,c)&&s[c]&&(a=i(a,c));return a}function i(s,a){return a?s?s+" "+a:s+a:s}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(mm);var j1=mm.exports;const on=$f(j1),$1=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",Ge=({name:t,size:e,className:n=""})=>{const r=$1(e);return y("span",{className:on(`uicon-${t}`,n,r)})};var Gp=Object.freeze,O1=Object.defineProperty,P1=(t,e)=>Gp(O1(t,"raw",{value:Gp(t.slice())})),Jp;const T1=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
- `},P1="https://assets.sesamy.com/images/login-bg.jpg",Ue=({title:t,children:e,vendorSettings:n})=>{const r={backgroundImage:`url(${(n==null?void 0:n.loginBackgroundImage)||P1})`};return y("html",{lang:"en",children:[y("head",{children:[y("title",{children:t}),y("meta",{charset:"UTF-8"}),y("meta",{name:"robots",content:"noindex, follow"}),y("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Regular.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),y("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Medium.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),y("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Bold.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),y("link",{rel:"stylesheet",href:"/u/css/tailwind.css"}),y("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"}),y("style",{children:O1(n)}),y("meta",{name:"theme-color",content:"#000000"})]}),y("body",{children:y("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:r,children:y("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:y("div",{className:"column-left w-full sm:w-auto",children:[y("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:[y("div",{className:"mb-16",children:y(um,{vendorSettings:n})}),y("div",{className:"flex flex-1 flex-col",children:[e,y(pm,{vendorSettings:n})]})]}),y("div",{className:"flex w-full items-center px-6 pb-8 pt-4 justify-between",children:[y("div",{className:"flex justify-center leading-[0]",children:y("a",{href:"https://sesamy.com",target:"_blank",rel:"noreferrer",children:y(Ge,{name:"sesamy",className:"text-xl text-white"})})}),y("div",{className:"flex justify-center space-x-2 text-xs text-white sm:justify-normal md:text-xs",children:n.supportUrl&&y("a",{className:"text-xs text-white hover:underline md:text-xs",href:n.supportUrl,target:"_blank",rel:"noopener noreferrer",children:T.t("contact_support")})})]})]})})})}),u1(Jp||(Jp=$1([`
202
+ `},B1="https://assets.sesamy.com/images/login-bg.jpg",Ue=({title:t,children:e,vendorSettings:n})=>{const r={backgroundImage:`url(${(n==null?void 0:n.loginBackgroundImage)||B1})`};return y("html",{lang:"en",children:[y("head",{children:[y("title",{children:t}),y("meta",{charset:"UTF-8"}),y("meta",{name:"robots",content:"noindex, follow"}),y("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Regular.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),y("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Medium.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),y("link",{rel:"preload",href:"https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Bold.woff2",as:"font",type:"font/woff2",crossOrigin:"anonymous"}),y("link",{rel:"stylesheet",href:"/u/css/tailwind.css"}),y("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"}),y("style",{children:T1(n)}),y("meta",{name:"theme-color",content:"#000000"})]}),y("body",{children:y("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:r,children:y("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:y("div",{className:"column-left w-full sm:w-auto",children:[y("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:[y("div",{className:"mb-16",children:y(hm,{vendorSettings:n})}),y("div",{className:"flex flex-1 flex-col",children:[e,y(gm,{vendorSettings:n})]})]}),y("div",{className:"flex w-full items-center px-6 pb-8 pt-4 justify-between",children:[y("div",{className:"flex justify-center leading-[0]",children:y("a",{href:"https://sesamy.com",target:"_blank",rel:"noreferrer",children:y(Ge,{name:"sesamy",className:"text-xl text-white"})})}),y("div",{className:"flex justify-center space-x-2 text-xs text-white sm:justify-normal md:text-xs",children:n.supportUrl&&y("a",{className:"text-xs text-white hover:underline md:text-xs",href:n.supportUrl,target:"_blank",rel:"noopener noreferrer",children:T.t("contact_support")})})]})]})})})}),sm(Jp||(Jp=P1([`
203
203
  <script>
204
204
  // Add loading class to submit button on form submission
205
205
  var form = document.getElementById("form");
@@ -213,7 +213,11 @@ PERFORMANCE OF THIS SOFTWARE.
213
213
  submitBtn.classList.remove("is-loading");
214
214
  }
215
215
  });
216
-
216
+ <\/script>
217
+ `])))]})},Un=({children:t})=>y("div",{className:"mb-2 text-sm text-red",children:t}),R1=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",_m=({size:t})=>{const e=R1(t);return y("div",{className:"relative inline-block leading-[0]",children:[y(Ge,{className:on("text-gray-200 dark:text-[#201a41]",{[e]:e}),name:"spinner-circle"}),y(Ge,{className:on("absolute inset-0 animate-spin text-primary",{[e]:e}),name:"spinner-inner"})]})},Ze=({children:t,className:e,Component:n="button",variant:r="primary",href:i,disabled:s,isLoading:a,id:c})=>{const l=n==="a"?{href:i}:{};return y(n,{class:on("btn relative w-full rounded-lg text-center",{"px-4 py-5":r!=="custom","bg-primary text-textOnPrimary hover:bg-primaryHover":r==="primary","border border-gray-300 bg-white text-black":r==="secondary","pointer-events-none cursor-not-allowed opacity-40":s,"is-loading":a},"focus:outline-none focus:ring",e),type:"submit",disabled:s,id:c,...l,children:[y("span",{className:"btn-label flex items-center justify-center space-x-2",children:t}),y("div",{className:"btn-spinner absolute left-0 top-0 flex h-full w-full items-center justify-center",children:y(_m,{size:"medium"})})]})},$r=({connection:t,text:e,icon:n=null,canResize:r=!1,loginSession:i})=>{const s=new URLSearchParams({client_id:i.authParams.client_id,connection:t});i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.redirect_uri&&s.set("redirect_uri",i.authParams.redirect_uri),i.authParams.scope&&s.set("scope",i.authParams.scope),i.authParams.nonce&&s.set("nonce",i.authParams.nonce),i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.state&&s.set("state",i.id);const a=`/authorize?${s.toString()}`;return y(Ze,{className:on("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":r,"px-10 py-3":!r}),variant:"custom","aria-label":e,Component:"a",href:a,children:[n||"",y("div",{className:on("text-left text-black dark:text-white sm:text-base",{"hidden sm:inline short:hidden":r}),children:e})]})},ym=({...t})=>y("svg",{width:"45",height:"45",viewBox:"0 0 45 45",xmlns:"http://www.w3.org/2000/svg",...t,children:[y("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"}),y("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"}),y("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"}),y("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"})]}),Wt=({children:t,className:e})=>y("form",{id:"form",method:"post",className:e,children:t}),wm=({...t})=>y("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:[y("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"}),y("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
218
+ 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
219
+ 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`})]}),Qc=({error:t,vendorSettings:e,loginSession:n,email:r,client:i})=>{const s=i.connections.map(({strategy:S})=>S),a=s.includes("email")||s.includes("Username-Password-Authentication"),c=s.includes("sms"),l=s.includes("facebook"),d=s.includes("google-oauth2"),p=s.includes("apple"),f=s.includes("vipps"),m=l||d||p||f,w=a||c;let h="text",_="username",v=T.t("email_or_phone_placeholder","Email or Phone Number");return a&&!c?(h="email",v=T.t("email_placeholder","Email address")):!a&&c&&(h="tel",v=T.t("phone_placeholder","Phone number")),y(Ue,{title:T.t("welcome"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("welcome")}),y("div",{className:"mb-8 text-gray-300",children:T.t("login_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[w&&y(Wt,{className:"mb-7",children:[y("input",{type:h,name:_,placeholder:v,className:on("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:r||""}),t&&y(Un,{children:t}),y(Ze,{className:"sm:mt-4 !text-base",children:[y("span",{children:T.t("continue")}),y(Ge,{className:"text-xs",name:"arrow-right"})]})]}),w&&m&&y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:T.t("continue_social_login")})]}),y("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:[l&&y($r,{connection:"facebook",text:T.t("continue_with",{provider:"Facebook"}),canResize:!0,icon:y(Ge,{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"}),loginSession:n}),d&&y($r,{connection:"google-oauth2",text:T.t("continue_with",{provider:"Google"}),canResize:!0,icon:y(ym,{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"}),loginSession:n}),p&&y($r,{connection:"apple",text:T.t("continue_with",{provider:"Apple"}),canResize:!0,icon:y(Ge,{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"}),loginSession:n}),f&&y($r,{connection:"vipps",text:T.t("continue_with",{provider:"Vipps"}),canResize:!0,icon:y(wm,{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"}),loginSession:n})]})]})]})},L1=["Auth0.swift"];function U1(t){if(!t)return"code";const e=atob(t),n=JSON.parse(e);return L1.includes(n.name)?"code":"link"}const V1=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),impersonation:o.z.string().optional()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r,client:i}=await Ee(t,e);return t.html(y(Qc,{vendorSettings:n,loginSession:r,client:i,email:r.authParams.username}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({username:o.z.string().transform(t=>t.toLowerCase()),login_selection:o.z.enum(["code","password"]).optional()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),r=t.req.valid("form");t.set("body",r),t.set("username",r.username);const{client:i,loginSession:s,vendorSettings:a}=await Ee(t,n);t.set("client_id",i.id);const c=r.username,l=await so({userAdapter:e.data.users,tenant_id:i.tenant.id,email:c});if(l&&t.set("user_id",l.user_id),!l)try{await Py(t,i,t.env.data,r.username)}catch{const w=we(t,{type:ge.FAILED_SIGNUP,description:"Public signup is disabled"});return await t.env.data.logs.create(i.tenant.id,w),t.html(y(Qc,{vendorSettings:a,loginSession:s,error:T.t("user_account_does_not_exist"),email:r.username,client:i}),400)}if(s.authParams.username=r.username,await e.data.loginSessions.update(i.tenant.id,s.id,s),await N1(t,i,r.username,r.login_selection))return t.redirect(`/u/enter-password?state=${n}`);let d=Tn(),p=await e.data.codes.get(i.tenant.id,d,"otp");for(;p;)d=Tn(),p=await e.data.codes.get(i.tenant.id,d,"otp");const f=await t.env.data.codes.create(i.tenant.id,{code_id:d,code_type:"otp",login_id:s.id,expires_at:new Date(Date.now()+Na).toISOString()});return U1(s.auth0Client)==="link"&&!r.username.includes("online.no")?await fd(t,{to:r.username,code:f.code_id,authParams:s.authParams}):await nm(t,{to:r.username,code:f.code_id}),t.redirect(`/u/enter-code?state=${n}`)}),yt=t=>y("a",{className:"block text-primary hover:text-primaryHover text-center",href:`/u/login/identifier?state=${t.state}`,children:T.t("go_back")});var ii="_hp",q1={Change:"Input",DoubleClick:"DblClick"},M1={svg:"2000/svg",math:"1998/Math/MathML"},si=[],el=new WeakMap,pr=void 0,H1=()=>pr,Ot=t=>"t"in t,va={onClick:["click",!1]},Zp=t=>{if(!t.startsWith("on"))return;if(va[t])return va[t];const e=t.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);if(e){const[,n,r]=e;return va[t]=[(q1[n]||n).toLowerCase(),!!r]}},Yp=(t,e)=>pr&&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,D1=(t,e,n)=>{var r;e||(e={});for(let i in e){const s=e[i];if(i!=="children"&&(!n||n[i]!==s)){i=Js(i);const a=Zp(i);if(a){if((n==null?void 0:n[i])!==s&&(n&&t.removeEventListener(a[0],n[i],a[1]),s!=null)){if(typeof s!="function")throw new Error(`Event handler for "${i}" is not a function`);t.addEventListener(a[0],s,a[1])}}else if(i==="dangerouslySetInnerHTML"&&s)t.innerHTML=s.__html;else if(i==="ref"){let c;typeof s=="function"?c=s(t)||(()=>s(null)):s&&"current"in s&&(s.current=t,c=()=>s.current=null),el.set(t,c)}else if(i==="style"){const c=t.style;typeof s=="string"?c.cssText=s:(c.cssText="",s!=null&&um(s,c.setProperty.bind(c)))}else{if(i==="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(i==="checked"&&t.nodeName==="INPUT"||i==="selected"&&t.nodeName==="OPTION")&&(t[i]=s);const c=Yp(t,i);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 i in n){const s=n[i];if(i!=="children"&&!(i in e)){i=Js(i);const a=Zp(i);a?t.removeEventListener(a[0],s,a[1]):i==="ref"?(r=el.get(t))==null||r():t.removeAttribute(Yp(t,i))}}},F1=(t,e)=>{e[Ae][0]=0,si.push([t,e]);const n=e.tag[md]||e.tag,r=n.defaultProps?{...n.defaultProps,...e.props}:e.props;try{return[n.call(null,r)]}finally{si.pop()}},vm=(t,e,n,r,i)=>{var s,a;(s=t.vR)!=null&&s.length&&(r.push(...t.vR),delete t.vR),typeof t.tag=="function"&&((a=t[Ae][1][Sm])==null||a.forEach(c=>i.push(c))),t.vC.forEach(c=>{var l;if(Ot(c))n.push(c);else if(typeof c.tag=="function"||c.tag===""){c.c=e;const d=n.length;if(vm(c,e,n,r,i),c.s){for(let p=d;p<n.length;p++)n[p].s=!0;c.s=!1}}else n.push(c),(l=c.vR)!=null&&l.length&&(r.push(...c.vR),delete c.vR)})},K1=t=>{for(;;t=t.tag===ii||!t.vC||!t.pP?t.nN:t.vC[0]){if(!t)return null;if(t.tag!==ii&&t.e)return t.e}},bm=t=>{var e,n,r,i,s,a;Ot(t)||((n=(e=t[Ae])==null?void 0:e[1][Sm])==null||n.forEach(c=>{var l;return(l=c[2])==null?void 0:l.call(c)}),(r=el.get(t.e))==null||r(),t.p===2&&((i=t.vC)==null||i.forEach(c=>c.p=2)),(s=t.vC)==null||s.forEach(bm)),t.p||((a=t.e)==null||a.remove(),delete t.e),typeof t.tag=="function"&&(Or.delete(t),Zi.delete(t),delete t[Ae][3],t.a=!0)},xm=(t,e,n)=>{t.c=e,km(t,e,n)},Xp=(t,e)=>{if(e){for(let n=0,r=t.length;n<r;n++)if(t[n]===e)return n}},Qp=Symbol(),km=(t,e,n)=>{var d;const r=[],i=[],s=[];vm(t,e,r,i,s),i.forEach(bm);const a=n?void 0:e.childNodes;let c,l=null;if(n)c=-1;else if(!a.length)c=0;else{const p=Xp(a,K1(t.nN));p!==void 0?(l=a[p],c=p):c=Xp(a,(d=r.find(f=>f.tag!==ii&&f.e))==null?void 0:d.e)??-1,c===-1&&(n=!0)}for(let p=0,f=r.length;p<f;p++,c++){const m=r[p];let w;if(m.s&&m.e)w=m.e,m.s=!1;else{const h=n||!m.e;Ot(m)?(m.e&&m.d&&(m.e.textContent=m.t),m.d=!1,w=m.e||(m.e=document.createTextNode(m.t))):(w=m.e||(m.e=m.n?document.createElementNS(m.n,m.tag):document.createElement(m.tag)),D1(w,m.props,m.pP),km(m,w,h))}m.tag===ii?c--:n?w.parentNode||e.appendChild(w):a[c]!==w&&a[c-1]!==w&&(a[c+1]===w?e.appendChild(a[c]):e.insertBefore(w,l||a[c]||null))}if(t.pP&&delete t.pP,s.length){const p=[],f=[];s.forEach(([,m,,w,h])=>{m&&p.push(m),w&&f.push(w),h==null||h()}),p.forEach(m=>m()),f.length&&requestAnimationFrame(()=>{f.forEach(m=>m())})}},Zi=new WeakMap,tl=(t,e,n)=>{var s,a,c,l,d,p;const r=!n&&e.pC;n&&(e.pC||(e.pC=e.vC));let i;try{n||(n=typeof e.tag=="function"?F1(t,e):Ei(e.props.children)),((s=n[0])==null?void 0:s.tag)===""&&n[0][Yc]&&(i=n[0][Yc],t[5].push([t,i,e]));const f=r?[...e.pC]:e.vC?[...e.vC]:void 0,m=[];let w;for(let h=0;h<n.length;h++){Array.isArray(n[h])&&n.splice(h,1,...n[h].flat());let _=W1(n[h]);if(_){typeof _.tag=="function"&&!_.tag[om]&&(ur.length>0&&(_[Ae][2]=ur.map(S=>[S,S.values.at(-1)])),(a=t[5])!=null&&a.length&&(_[Ae][3]=t[5].at(-1)));let v;if(f&&f.length){const S=f.findIndex(Ot(_)?C=>Ot(C):_.key!==void 0?C=>C.key===_.key&&C.tag===_.tag:C=>C.tag===_.tag);S!==-1&&(v=f[S],f.splice(S,1))}if(v)if(Ot(_))v.t!==_.t&&(v.t=_.t,v.d=!0),_=v;else{const S=v.pP=v.props;v.props=_.props,v.f||(v.f=_.f||e.f),typeof _.tag=="function"&&(v[Ae][2]=_[Ae][2]||[],v[Ae][3]=_[Ae][3],!v.f&&((v.o||v)===_.o||(l=(c=v.tag)[h1])!=null&&l.call(c,S,v.props))&&(v.s=!0)),_=v}else if(!Ot(_)&&pr){const S=Ar(pr);S&&(_.n=S)}if(!Ot(_)&&!_.s&&(tl(t,_),delete _.f),m.push(_),w&&!w.s&&!_.s)for(let S=w;S&&!Ot(S);S=(d=S.vC)==null?void 0:d.at(-1))S.nN=_;w=_}}e.vR=r?[...e.vC,...f||[]]:f||[],e.vC=m,r&&delete e.pC}catch(f){if(e.f=!0,f===Qp){if(i)return;throw f}const[m,w,h]=((p=e[Ae])==null?void 0:p[3])||[];if(w){const _=()=>Yi([0,!1,t[2]],h),v=Zi.get(h)||[];v.push(_),Zi.set(h,v);const S=w(f,()=>{const C=Zi.get(h);if(C){const O=C.indexOf(_);if(O!==-1)return C.splice(O,1),_()}});if(S){if(t[0]===1)t[1]=!0;else if(tl(t,h,[S]),(w.length===1||t!==m)&&h.c){xm(h,h.c,!1);return}throw Qp}}throw f}finally{i&&t[5].pop()}},W1=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[Ae]=[0,[]];else{const e=M1[t.tag];e&&(pr||(pr=cm("")),t.props.children=[{tag:pr,props:{value:t.n=`http://www.w3.org/${e}`,children:t.props.children}}])}return t}},ef=(t,e)=>{var n,r;(n=e[Ae][2])==null||n.forEach(([i,s])=>{i.values.push(s)});try{tl(t,e,void 0)}catch{return}if(e.a){delete e.a;return}(r=e[Ae][2])==null||r.forEach(([i])=>{i.values.pop()}),(t[0]!==1||!t[1])&&xm(e,e.c,!1)},Or=new WeakMap,tf=[],Yi=async(t,e)=>{t[5]||(t[5]=[]);const n=Or.get(e);n&&n[0](void 0);let r;const i=new Promise(s=>r=s);if(Or.set(e,[r,()=>{t[2]?t[2](t,e,s=>{ef(s,e)}).then(()=>r(e)):(ef(t,e),r(e))}]),tf.length)tf.at(-1).add(e);else{await Promise.resolve();const s=Or.get(e);s&&(Or.delete(e),s[1]())}return i},G1=(t,e,n)=>({tag:ii,props:{children:t},key:n,e,p:1}),ba=0,Sm=1,xa=2,ka=3,Sa=new WeakMap,Am=(t,e)=>!t||!e||t.length!==e.length||e.some((n,r)=>n!==t[r]),J1=void 0,nf=[],Z1=t=>{var a;const e=()=>typeof t=="function"?t():t,n=si.at(-1);if(!n)return[e(),()=>{}];const[,r]=n,i=(a=r[Ae][1])[ba]||(a[ba]=[]),s=r[Ae][0]++;return i[s]||(i[s]=[e(),c=>{const l=J1,d=i[s];if(typeof c=="function"&&(c=c(d[0])),!Object.is(c,d[0]))if(d[0]=c,nf.length){const[p,f]=nf.at(-1);Promise.all([p===3?r:Yi([p,!1,l],r),f]).then(([m])=>{if(!m||!(p===2||p===3))return;const w=m.vC;requestAnimationFrame(()=>{setTimeout(()=>{w===m.vC&&Yi([p===3?1:0,!1,l],m)})})})}else Yi([0,!1,l],r)}])},vd=(t,e)=>{var c;const n=si.at(-1);if(!n)return t;const[,r]=n,i=(c=r[Ae][1])[xa]||(c[xa]=[]),s=r[Ae][0]++,a=i[s];return Am(a==null?void 0:a[1],e)?i[s]=[t,e]:t=i[s][0],t},Y1=t=>{const e=Sa.get(t);if(e){if(e.length===2)throw e[1];return e[0]}throw t.then(n=>Sa.set(t,[n]),n=>Sa.set(t,[void 0,n])),t},X1=(t,e)=>{var c;const n=si.at(-1);if(!n)return t();const[,r]=n,i=(c=r[Ae][1])[ka]||(c[ka]=[]),s=r[Ae][0]++,a=i[s];return Am(a==null?void 0:a[1],e)&&(i[s]=[t(),e]),i[s][0]},Q1=cm({pending:!1,data:null,method:null,action:null}),rf=new Set,ex=t=>{rf.add(t),t.finally(()=>rf.delete(t))},bd=(t,e)=>X1(()=>n=>{let r;t&&(typeof t=="function"?r=t(n)||(()=>{t(null)}):t&&"current"in t&&(t.current=n,r=()=>{t.current=null}));const i=e(n);return()=>{i==null||i(),r==null||r()}},[t]),Hn=Object.create(null),Li=Object.create(null),Ni=(t,e,n,r,i)=>{if(e!=null&&e.itemProp)return{tag:t,props:e,type:t,ref:e.ref};const s=document.head;let{onLoad:a,onError:c,precedence:l,blocking:d,...p}=e,f=null,m=!1;const w=Wi[t];let h;if(w.length>0){const C=s.querySelectorAll(t);e:for(const O of C)for(const L of Wi[t])if(O.getAttribute(L)===e[L]){f=O;break e}if(!f){const O=w.reduce((L,Q)=>e[Q]===void 0?L:`${L}-${Q}-${e[Q]}`,t);m=!Li[O],f=Li[O]||(Li[O]=(()=>{const L=document.createElement(t);for(const Q of w)e[Q]!==void 0&&L.setAttribute(Q,e[Q]),e.rel&&L.setAttribute("rel",e.rel);return L})())}}else h=s.querySelectorAll(t);l=r?l??"":void 0,r&&(p[Gi]=l);const _=vd(C=>{if(w.length>0){let O=!1;for(const L of s.querySelectorAll(t)){if(O&&L.getAttribute(Gi)!==l){s.insertBefore(C,L);return}L.getAttribute(Gi)===l&&(O=!0)}s.appendChild(C)}else if(h){let O=!1;for(const L of h)if(L===C){O=!0;break}O||s.insertBefore(C,s.contains(h[0])?h[0]:s.querySelector(t)),h=void 0}},[l]),v=bd(e.ref,C=>{var Q;const O=w[0];if(n===2&&(C.innerHTML=""),(m||h)&&_(C),!c&&!a)return;let L=Hn[Q=C.getAttribute(O)]||(Hn[Q]=new Promise((ce,le)=>{C.addEventListener("load",ce),C.addEventListener("error",le)}));a&&(L=L.then(a)),c&&(L=L.catch(c)),L.catch(()=>{})});if(i&&d==="render"){const C=Wi[t][0];if(e[C]){const O=e[C],L=Hn[O]||(Hn[O]=new Promise((Q,ce)=>{_(f),f.addEventListener("load",Q),f.addEventListener("error",ce)}));Y1(L)}}const S={tag:t,type:t,props:{...p,ref:v},ref:v};return S.p=n,f&&(S.e=f),G1(S,s)},tx=t=>{const e=H1(),n=e&&Ar(e);return n!=null&&n.endsWith("svg")?{tag:"title",props:t,type:"title",ref:t.ref}:Ni("title",t,void 0,!1,!1)},nx=t=>!t||["src","async"].some(e=>!t[e])?{tag:"script",props:t,type:"script",ref:t.ref}:Ni("script",t,1,!1,!0),rx=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,Ni("style",t,2,!0,!0)),ix=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}:Ni("link",t,1,"precedence"in t,!0),sx=t=>Ni("meta",t,void 0,!1,!1),zm=Symbol(),ox=t=>{const{action:e,...n}=t;typeof e!="function"&&(n.action=e);const[r,i]=Z1([null,!1]),s=vd(async d=>{const p=d.isTrusted?e:d.detail[zm];if(typeof p!="function")return;d.preventDefault();const f=new FormData(d.target);i([f,!0]);const m=p(f);m instanceof Promise&&(ex(m),await m),i([null,!0])},[]),a=bd(t.ref,d=>(d.addEventListener("submit",s),()=>{d.removeEventListener("submit",s)})),[c,l]=r;return r[1]=!1,{tag:Q1,props:{value:{pending:c!==null,data:c,method:c?"post":null,action:c?e:null},children:{tag:"form",props:{...n,ref:a},type:"form",ref:a}},f:l}},Em=(t,{formAction:e,...n})=>{if(typeof e=="function"){const r=vd(i=>{i.preventDefault(),i.currentTarget.form.dispatchEvent(new CustomEvent("submit",{detail:{[zm]:e}}))},[]);n.ref=bd(n.ref,i=>(i.addEventListener("click",r),()=>{i.removeEventListener("click",r)}))}return{tag:t,props:n,type:t,ref:n.ref}},ax=t=>Em("input",t),cx=t=>Em("button",t);Object.assign(Xc,{title:tx,script:nx,style:rx,link:ix,meta:sx,form:ox,input:ax,button:cx});new TextEncoder;const Xo=t=>{const{i18nKey:e,values:n,components:r}=t,i=T.t(e,n),s=/<(\d+)>(.*?)<\/\d+>/g,a=[];let c=0,l;for(;(l=s.exec(i))!==null;){const[,d,p]=l,f=i.substring(c,l.index);f&&a.push(f);const m=parseInt(d,10);a.push(C1(r[m],{},p)),c=s.lastIndex}return c<i.length&&a.push(i.substring(c)),y(fm,{children:a})},sf=6,nl=({error:t,vendorSettings:e,email:n,state:r,client:i,hasPasswordLogin:s})=>{const a=new URLSearchParams({state:r}),l=i.connections.map(({name:d})=>d).includes("auth2");return y(Ue,{title:T.t("verify_your_email"),vendorSettings:e,children:[y("div",{className:"mb-4 text-2xl font-medium",children:T.t("verify_your_email")}),y("div",{className:"mb-8 text-gray-300",children:y(Xo,{i18nKey:"we_sent_a_code_to",components:[y("span",{className:"text-black dark:text-white"},"span")],values:{email:n}})}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Wt,{className:"pt-2",children:[y("input",{autoFocus:!0,type:"text",pattern:"[0-9]*",maxLength:sf,inputMode:"numeric",name:"code",placeholder:"******",className:on("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:sf,required:!0,id:"code-input"}),t&&y(Un,{children:t}),y(Ze,{className:"sm:mt-4 !text-base",children:[y("span",{children:T.t("login")}),y(Ge,{className:"text-xs",name:"arrow-right"})]}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Ge,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:T.t("sent_code_spam")})]}),l&&y("div",{className:"text-center mb-12",children:[y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:T.t("or")})]}),y(Ze,{Component:"a",href:`/u/${s?"enter-password":"pre-signup"}?${a.toString()}`,variant:"secondary",className:"block",children:T.t("enter_your_password_btn")})]})]}),y(yt,{state:r})]})]})},lx=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r,client:i}=await Ee(t,e);if(!r.authParams.username)throw new I(400,{message:"Username not found in state"});const s=await us({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username:r.authParams.username,provider:"auth2"});return t.html(y(nl,{vendorSettings:n,email:r.authParams.username,state:e,client:i,hasPasswordLogin:!!s}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({code:o.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{code:n}=t.req.valid("form"),{loginSession:r,client:i,vendorSettings:s}=await Ee(t,e);if(t.set("client_id",i.id),!r.authParams.username)throw new I(400,{message:"Username not found in state"});try{return await Qg(t,{client_id:i.id,authParams:r.authParams,username:r.authParams.username,otp:n})}catch(a){const c=a,l=await us({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username:r.authParams.username,provider:"auth2"});return t.html(y(nl,{vendorSettings:s,email:r.authParams.username,state:e,client:i,error:c.message,hasPasswordLogin:!!l}),400)}}),Im=t=>{const{vendorSettings:e,state:n}=t;return y(Ue,{title:T.t("unverified_email"),vendorSettings:e,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:[y("p",{className:"mb-8 text-gray-300 text-lg",children:T.t("unverified_email")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Ge,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:T.t("sent_code_spam")})]}),y(yt,{state:n})]}),y(yt,{state:n})]})},dx=({width:t=22,height:e=17})=>y("svg",{width:t,height:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 576 512",children:y("path",{fill:"currentColor",d:"M288 32c-80.8 0-145.5 36.8-192.6 80.6C48.6 156 17.3 208 2.5 243.7c-3.3 7.9-3.3 16.7 0 24.6C17.3 304 48.6 356 95.4 399.4 142.5 443.2 207.2 480 288 480s145.5-36.8 192.6-80.6c46.8-43.5 78.1-95.4 93-131.1 3.3-7.9 3.3-16.7 0-24.6-14.9-35.7-46.2-87.7-93-131.1C433.5 68.8 368.8 32 288 32M144 256a144 144 0 1 1 288 0 144 144 0 1 1-288 0m144-64c0 35.3-28.7 64-64 64-7.1 0-13.9-1.2-20.3-3.3-5.5-1.8-11.9 1.6-11.7 7.4.3 6.9 1.3 13.8 3.2 20.7 13.7 51.2 66.4 81.6 117.6 67.9s81.6-66.4 67.9-117.6c-11.1-41.5-47.8-69.4-88.6-71.1-5.8-.2-9.2 6.1-7.4 11.7 2.1 6.4 3.3 13.2 3.3 20.3"})}),ux=({width:t=23,height:e=18})=>y("svg",{width:t,height:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 512",children:y("path",{fill:"currentColor",d:"M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2s-6.3 25.5 4.1 33.7l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7l-105.2-82.4c39.6-40.6 66.4-86.1 79.9-118.4 3.3-7.9 3.3-16.7 0-24.6-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8zm184.3 144.4c25.5-23.3 59.6-37.5 96.9-37.5 79.5 0 144 64.5 144 144 0 24.9-6.3 48.3-17.4 68.7L408 294.5c8.4-19.3 10.6-41.4 4.8-63.3-11.1-41.5-47.8-69.4-88.6-71.1-5.8-.2-9.2 6.1-7.4 11.7 2.1 6.4 3.3 13.2 3.3 20.3 0 10.2-2.4 19.8-6.6 28.3l-90.3-70.8zM373 389.9c-16.4 6.5-34.3 10.1-53 10.1-79.5 0-144-64.5-144-144 0-6.9.5-13.6 1.4-20.2l-94.3-74.3c-22.8 29.7-39.1 59.3-48.6 82.2-3.3 7.9-3.3 16.7 0 24.6 14.9 35.7 46.2 87.7 93 131.1 47 43.8 111.7 80.6 192.5 80.6 47.8 0 89.9-12.9 126.2-32.5z"})}),rl=({name:t,placeholder:e=T.t("password")})=>y("div",{className:"password-input relative mb-2",children:[y("input",{type:"password",name:t,placeholder:e,className:"w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0}),y("button",{type:"button","aria-label":T.t("show_password"),title:T.t("show_password"),className:"show-password-toggle-show absolute right-0 top-0 w-10 h-full rounded-r-lg text-gray-400 column hover:bg-black/5",children:y(dx,{})}),y("button",{type:"button","aria-label":T.t("hide_password"),title:T.t("hide_password"),className:"show-password-toggle-hide !hidden absolute right-0 top-0 w-10 h-full rounded-r-lg text-gray-400 column hover:bg-black/5",children:y(ux,{})})]});var of=Object.freeze,px=Object.defineProperty,fx=(t,e)=>of(px(t,"raw",{value:of(t.slice())})),af;const Xi=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t,s=new URLSearchParams({state:i});return y(Ue,{title:T.t("enter_password"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("enter_password")}),y("div",{className:"mb-6 text-gray-300",children:T.t("enter_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Wt,{className:"mb-7",children:[y("input",{type:"text",name:"username",placeholder:T.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",value:r}),y(rl,{name:"password"}),e&&y(Un,{children:e}),y(Ze,{className:"sm:mt-4 !text-base",children:[y("span",{children:T.t("login")}),y(Ge,{className:"text-xs",name:"arrow-right"})]})]}),y("a",{href:`/u/forgot-password?${s.toString()}`,className:"text-primary hover:underline mb-4",children:T.t("forgot_password_link")}),y("div",{className:"text-center mb-12",children:[y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:T.t("or")})]}),y("form",{method:"post",action:`/u/login/identifier?${s.toString()}`,children:[y("input",{type:"hidden",name:"login_selection",value:"code"}),y("input",{type:"hidden",name:"username",value:r}),y(Ze,{variant:"secondary",className:"block",children:T.t("enter_a_code_btn")})]})]}),y(yt,{state:i})]}),sm(af||(af=fx([`
220
+ <script>
217
221
  // Show password toggle
218
222
  var passwordInputs = document.querySelectorAll(".password-input");
219
223
  passwordInputs.forEach(function (wrapper) {
@@ -236,37 +240,35 @@ PERFORMANCE OF THIS SOFTWARE.
236
240
  });
237
241
  });
238
242
  <\/script>
239
- `])))]})},Un=({children:t})=>y("div",{className:"mb-2 text-sm text-red",children:t}),T1=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",hm=({size:t})=>{const e=T1(t);return y("div",{className:"relative inline-block leading-[0]",children:[y(Ge,{className:on("text-gray-200 dark:text-[#201a41]",{[e]:e}),name:"spinner-circle"}),y(Ge,{className:on("absolute inset-0 animate-spin text-primary",{[e]:e}),name:"spinner-inner"})]})},Ze=({children:t,className:e,Component:n="button",variant:r="primary",href:i,disabled:s,isLoading:a,id:c})=>{const l=n==="a"?{href:i}:{};return y(n,{class:on("btn relative w-full rounded-lg text-center",{"px-4 py-5":r!=="custom","bg-primary text-textOnPrimary hover:bg-primaryHover":r==="primary","border border-gray-300 bg-white text-black":r==="secondary","pointer-events-none cursor-not-allowed opacity-40":s,"is-loading":a},"focus:outline-none focus:ring",e),type:"submit",disabled:s,id:c,...l,children:[y("span",{className:"btn-label flex items-center justify-center space-x-2",children:t}),y("div",{className:"btn-spinner absolute left-0 top-0 flex h-full w-full items-center justify-center",children:y(hm,{size:"medium"})})]})},$r=({connection:t,text:e,icon:n=null,canResize:r=!1,loginSession:i})=>{const s=new URLSearchParams({client_id:i.authParams.client_id,connection:t});i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.redirect_uri&&s.set("redirect_uri",i.authParams.redirect_uri),i.authParams.scope&&s.set("scope",i.authParams.scope),i.authParams.nonce&&s.set("nonce",i.authParams.nonce),i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.state&&s.set("state",i.id);const a=`/authorize?${s.toString()}`;return y(Ze,{className:on("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":r,"px-10 py-3":!r}),variant:"custom","aria-label":e,Component:"a",href:a,children:[n||"",y("div",{className:on("text-left text-black dark:text-white sm:text-base",{"hidden sm:inline short:hidden":r}),children:e})]})},gm=({...t})=>y("svg",{width:"45",height:"45",viewBox:"0 0 45 45",xmlns:"http://www.w3.org/2000/svg",...t,children:[y("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"}),y("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"}),y("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"}),y("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"})]}),Wt=({children:t,className:e})=>y("form",{id:"form",method:"post",className:e,children:t}),mm=({...t})=>y("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:[y("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"}),y("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
240
- 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
241
- 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`})]}),Qc=({error:t,vendorSettings:e,loginSession:n,email:r,client:i})=>{const s=i.connections.map(({strategy:S})=>S),a=s.includes("email")||s.includes("Username-Password-Authentication"),c=s.includes("sms"),l=s.includes("facebook"),d=s.includes("google-oauth2"),p=s.includes("apple"),f=s.includes("vipps"),m=l||d||p||f,w=a||c;let h="text",_="username",v=T.t("email_or_phone_placeholder","Email or Phone Number");return a&&!c?(h="email",v=T.t("email_placeholder","Email address")):!a&&c&&(h="tel",v=T.t("phone_placeholder","Phone number")),y(Ue,{title:T.t("welcome"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("welcome")}),y("div",{className:"mb-8 text-gray-300",children:T.t("login_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[w&&y(Wt,{className:"mb-7",children:[y("input",{type:h,name:_,placeholder:v,className:on("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:r||""}),t&&y(Un,{children:t}),y(Ze,{className:"sm:mt-4 !text-base",children:[y("span",{children:T.t("continue")}),y(Ge,{className:"text-xs",name:"arrow-right"})]})]}),w&&m&&y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:T.t("continue_social_login")})]}),y("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:[l&&y($r,{connection:"facebook",text:T.t("continue_with",{provider:"Facebook"}),canResize:!0,icon:y(Ge,{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"}),loginSession:n}),d&&y($r,{connection:"google-oauth2",text:T.t("continue_with",{provider:"Google"}),canResize:!0,icon:y(gm,{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"}),loginSession:n}),p&&y($r,{connection:"apple",text:T.t("continue_with",{provider:"Apple"}),canResize:!0,icon:y(Ge,{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"}),loginSession:n}),f&&y($r,{connection:"vipps",text:T.t("continue_with",{provider:"Vipps"}),canResize:!0,icon:y(mm,{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"}),loginSession:n})]})]})]})},B1=["Auth0.swift"];function R1(t){if(!t)return"code";const e=atob(t),n=JSON.parse(e);return B1.includes(n.name)?"code":"link"}const L1=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),impersonation:o.z.string().optional()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r,client:i}=await Ee(t,e);return t.html(y(Qc,{vendorSettings:n,loginSession:r,client:i,email:r.authParams.username}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({username:o.z.string().transform(t=>t.toLowerCase()),login_selection:o.z.enum(["code","password"]).optional()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),r=t.req.valid("form");t.set("body",r),t.set("username",r.username);const{client:i,loginSession:s,vendorSettings:a}=await Ee(t,n);t.set("client_id",i.id);const c=r.username,l=await so({userAdapter:e.data.users,tenant_id:i.tenant.id,email:c});if(l&&t.set("user_id",l.user_id),!l)try{await jy(t,i,t.env.data,r.username)}catch{const w=we(t,{type:ge.FAILED_SIGNUP,description:"Public signup is disabled"});return await t.env.data.logs.create(i.tenant.id,w),t.html(y(Qc,{vendorSettings:a,loginSession:s,error:T.t("user_account_does_not_exist"),email:r.username,client:i}),400)}if(s.authParams.username=r.username,await e.data.loginSessions.update(i.tenant.id,s.id,s),await I1(t,i,r.username,r.login_selection))return t.redirect(`/u/enter-password?state=${n}`);let d=Tn(),p=await e.data.codes.get(i.tenant.id,d,"otp");for(;p;)d=Tn(),p=await e.data.codes.get(i.tenant.id,d,"otp");const f=await t.env.data.codes.create(i.tenant.id,{code_id:d,code_type:"otp",login_id:s.id,expires_at:new Date(Date.now()+Na).toISOString()});return R1(s.auth0Client)==="link"&&!r.username.includes("online.no")?await fd(t,{to:r.username,code:f.code_id,authParams:s.authParams}):await em(t,{to:r.username,code:f.code_id}),t.redirect(`/u/enter-code?state=${n}`)}),yt=t=>y("a",{className:"block text-primary hover:text-primaryHover text-center",href:`/u/login/identifier?state=${t.state}`,children:T.t("go_back")});var ii="_hp",U1={Change:"Input",DoubleClick:"DblClick"},V1={svg:"2000/svg",math:"1998/Math/MathML"},si=[],el=new WeakMap,pr=void 0,q1=()=>pr,Ot=t=>"t"in t,va={onClick:["click",!1]},Zp=t=>{if(!t.startsWith("on"))return;if(va[t])return va[t];const e=t.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);if(e){const[,n,r]=e;return va[t]=[(U1[n]||n).toLowerCase(),!!r]}},Yp=(t,e)=>pr&&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,M1=(t,e,n)=>{var r;e||(e={});for(let i in e){const s=e[i];if(i!=="children"&&(!n||n[i]!==s)){i=Js(i);const a=Zp(i);if(a){if((n==null?void 0:n[i])!==s&&(n&&t.removeEventListener(a[0],n[i],a[1]),s!=null)){if(typeof s!="function")throw new Error(`Event handler for "${i}" is not a function`);t.addEventListener(a[0],s,a[1])}}else if(i==="dangerouslySetInnerHTML"&&s)t.innerHTML=s.__html;else if(i==="ref"){let c;typeof s=="function"?c=s(t)||(()=>s(null)):s&&"current"in s&&(s.current=t,c=()=>s.current=null),el.set(t,c)}else if(i==="style"){const c=t.style;typeof s=="string"?c.cssText=s:(c.cssText="",s!=null&&cm(s,c.setProperty.bind(c)))}else{if(i==="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(i==="checked"&&t.nodeName==="INPUT"||i==="selected"&&t.nodeName==="OPTION")&&(t[i]=s);const c=Yp(t,i);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 i in n){const s=n[i];if(i!=="children"&&!(i in e)){i=Js(i);const a=Zp(i);a?t.removeEventListener(a[0],s,a[1]):i==="ref"?(r=el.get(t))==null||r():t.removeAttribute(Yp(t,i))}}},H1=(t,e)=>{e[Ae][0]=0,si.push([t,e]);const n=e.tag[md]||e.tag,r=n.defaultProps?{...n.defaultProps,...e.props}:e.props;try{return[n.call(null,r)]}finally{si.pop()}},_m=(t,e,n,r,i)=>{var s,a;(s=t.vR)!=null&&s.length&&(r.push(...t.vR),delete t.vR),typeof t.tag=="function"&&((a=t[Ae][1][bm])==null||a.forEach(c=>i.push(c))),t.vC.forEach(c=>{var l;if(Ot(c))n.push(c);else if(typeof c.tag=="function"||c.tag===""){c.c=e;const d=n.length;if(_m(c,e,n,r,i),c.s){for(let p=d;p<n.length;p++)n[p].s=!0;c.s=!1}}else n.push(c),(l=c.vR)!=null&&l.length&&(r.push(...c.vR),delete c.vR)})},D1=t=>{for(;;t=t.tag===ii||!t.vC||!t.pP?t.nN:t.vC[0]){if(!t)return null;if(t.tag!==ii&&t.e)return t.e}},ym=t=>{var e,n,r,i,s,a;Ot(t)||((n=(e=t[Ae])==null?void 0:e[1][bm])==null||n.forEach(c=>{var l;return(l=c[2])==null?void 0:l.call(c)}),(r=el.get(t.e))==null||r(),t.p===2&&((i=t.vC)==null||i.forEach(c=>c.p=2)),(s=t.vC)==null||s.forEach(ym)),t.p||((a=t.e)==null||a.remove(),delete t.e),typeof t.tag=="function"&&(Or.delete(t),Zi.delete(t),delete t[Ae][3],t.a=!0)},wm=(t,e,n)=>{t.c=e,vm(t,e,n)},Xp=(t,e)=>{if(e){for(let n=0,r=t.length;n<r;n++)if(t[n]===e)return n}},Qp=Symbol(),vm=(t,e,n)=>{var d;const r=[],i=[],s=[];_m(t,e,r,i,s),i.forEach(ym);const a=n?void 0:e.childNodes;let c,l=null;if(n)c=-1;else if(!a.length)c=0;else{const p=Xp(a,D1(t.nN));p!==void 0?(l=a[p],c=p):c=Xp(a,(d=r.find(f=>f.tag!==ii&&f.e))==null?void 0:d.e)??-1,c===-1&&(n=!0)}for(let p=0,f=r.length;p<f;p++,c++){const m=r[p];let w;if(m.s&&m.e)w=m.e,m.s=!1;else{const h=n||!m.e;Ot(m)?(m.e&&m.d&&(m.e.textContent=m.t),m.d=!1,w=m.e||(m.e=document.createTextNode(m.t))):(w=m.e||(m.e=m.n?document.createElementNS(m.n,m.tag):document.createElement(m.tag)),M1(w,m.props,m.pP),vm(m,w,h))}m.tag===ii?c--:n?w.parentNode||e.appendChild(w):a[c]!==w&&a[c-1]!==w&&(a[c+1]===w?e.appendChild(a[c]):e.insertBefore(w,l||a[c]||null))}if(t.pP&&delete t.pP,s.length){const p=[],f=[];s.forEach(([,m,,w,h])=>{m&&p.push(m),w&&f.push(w),h==null||h()}),p.forEach(m=>m()),f.length&&requestAnimationFrame(()=>{f.forEach(m=>m())})}},Zi=new WeakMap,tl=(t,e,n)=>{var s,a,c,l,d,p;const r=!n&&e.pC;n&&(e.pC||(e.pC=e.vC));let i;try{n||(n=typeof e.tag=="function"?H1(t,e):Ei(e.props.children)),((s=n[0])==null?void 0:s.tag)===""&&n[0][Yc]&&(i=n[0][Yc],t[5].push([t,i,e]));const f=r?[...e.pC]:e.vC?[...e.vC]:void 0,m=[];let w;for(let h=0;h<n.length;h++){Array.isArray(n[h])&&n.splice(h,1,...n[h].flat());let _=F1(n[h]);if(_){typeof _.tag=="function"&&!_.tag[rm]&&(ur.length>0&&(_[Ae][2]=ur.map(S=>[S,S.values.at(-1)])),(a=t[5])!=null&&a.length&&(_[Ae][3]=t[5].at(-1)));let v;if(f&&f.length){const S=f.findIndex(Ot(_)?C=>Ot(C):_.key!==void 0?C=>C.key===_.key&&C.tag===_.tag:C=>C.tag===_.tag);S!==-1&&(v=f[S],f.splice(S,1))}if(v)if(Ot(_))v.t!==_.t&&(v.t=_.t,v.d=!0),_=v;else{const S=v.pP=v.props;v.props=_.props,v.f||(v.f=_.f||e.f),typeof _.tag=="function"&&(v[Ae][2]=_[Ae][2]||[],v[Ae][3]=_[Ae][3],!v.f&&((v.o||v)===_.o||(l=(c=v.tag)[p1])!=null&&l.call(c,S,v.props))&&(v.s=!0)),_=v}else if(!Ot(_)&&pr){const S=Ar(pr);S&&(_.n=S)}if(!Ot(_)&&!_.s&&(tl(t,_),delete _.f),m.push(_),w&&!w.s&&!_.s)for(let S=w;S&&!Ot(S);S=(d=S.vC)==null?void 0:d.at(-1))S.nN=_;w=_}}e.vR=r?[...e.vC,...f||[]]:f||[],e.vC=m,r&&delete e.pC}catch(f){if(e.f=!0,f===Qp){if(i)return;throw f}const[m,w,h]=((p=e[Ae])==null?void 0:p[3])||[];if(w){const _=()=>Yi([0,!1,t[2]],h),v=Zi.get(h)||[];v.push(_),Zi.set(h,v);const S=w(f,()=>{const C=Zi.get(h);if(C){const O=C.indexOf(_);if(O!==-1)return C.splice(O,1),_()}});if(S){if(t[0]===1)t[1]=!0;else if(tl(t,h,[S]),(w.length===1||t!==m)&&h.c){wm(h,h.c,!1);return}throw Qp}}throw f}finally{i&&t[5].pop()}},F1=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[Ae]=[0,[]];else{const e=V1[t.tag];e&&(pr||(pr=sm("")),t.props.children=[{tag:pr,props:{value:t.n=`http://www.w3.org/${e}`,children:t.props.children}}])}return t}},ef=(t,e)=>{var n,r;(n=e[Ae][2])==null||n.forEach(([i,s])=>{i.values.push(s)});try{tl(t,e,void 0)}catch{return}if(e.a){delete e.a;return}(r=e[Ae][2])==null||r.forEach(([i])=>{i.values.pop()}),(t[0]!==1||!t[1])&&wm(e,e.c,!1)},Or=new WeakMap,tf=[],Yi=async(t,e)=>{t[5]||(t[5]=[]);const n=Or.get(e);n&&n[0](void 0);let r;const i=new Promise(s=>r=s);if(Or.set(e,[r,()=>{t[2]?t[2](t,e,s=>{ef(s,e)}).then(()=>r(e)):(ef(t,e),r(e))}]),tf.length)tf.at(-1).add(e);else{await Promise.resolve();const s=Or.get(e);s&&(Or.delete(e),s[1]())}return i},K1=(t,e,n)=>({tag:ii,props:{children:t},key:n,e,p:1}),ba=0,bm=1,xa=2,ka=3,Sa=new WeakMap,xm=(t,e)=>!t||!e||t.length!==e.length||e.some((n,r)=>n!==t[r]),W1=void 0,nf=[],G1=t=>{var a;const e=()=>typeof t=="function"?t():t,n=si.at(-1);if(!n)return[e(),()=>{}];const[,r]=n,i=(a=r[Ae][1])[ba]||(a[ba]=[]),s=r[Ae][0]++;return i[s]||(i[s]=[e(),c=>{const l=W1,d=i[s];if(typeof c=="function"&&(c=c(d[0])),!Object.is(c,d[0]))if(d[0]=c,nf.length){const[p,f]=nf.at(-1);Promise.all([p===3?r:Yi([p,!1,l],r),f]).then(([m])=>{if(!m||!(p===2||p===3))return;const w=m.vC;requestAnimationFrame(()=>{setTimeout(()=>{w===m.vC&&Yi([p===3?1:0,!1,l],m)})})})}else Yi([0,!1,l],r)}])},vd=(t,e)=>{var c;const n=si.at(-1);if(!n)return t;const[,r]=n,i=(c=r[Ae][1])[xa]||(c[xa]=[]),s=r[Ae][0]++,a=i[s];return xm(a==null?void 0:a[1],e)?i[s]=[t,e]:t=i[s][0],t},J1=t=>{const e=Sa.get(t);if(e){if(e.length===2)throw e[1];return e[0]}throw t.then(n=>Sa.set(t,[n]),n=>Sa.set(t,[void 0,n])),t},Z1=(t,e)=>{var c;const n=si.at(-1);if(!n)return t();const[,r]=n,i=(c=r[Ae][1])[ka]||(c[ka]=[]),s=r[Ae][0]++,a=i[s];return xm(a==null?void 0:a[1],e)&&(i[s]=[t(),e]),i[s][0]},Y1=sm({pending:!1,data:null,method:null,action:null}),rf=new Set,X1=t=>{rf.add(t),t.finally(()=>rf.delete(t))},bd=(t,e)=>Z1(()=>n=>{let r;t&&(typeof t=="function"?r=t(n)||(()=>{t(null)}):t&&"current"in t&&(t.current=n,r=()=>{t.current=null}));const i=e(n);return()=>{i==null||i(),r==null||r()}},[t]),Hn=Object.create(null),Li=Object.create(null),Ni=(t,e,n,r,i)=>{if(e!=null&&e.itemProp)return{tag:t,props:e,type:t,ref:e.ref};const s=document.head;let{onLoad:a,onError:c,precedence:l,blocking:d,...p}=e,f=null,m=!1;const w=Wi[t];let h;if(w.length>0){const C=s.querySelectorAll(t);e:for(const O of C)for(const L of Wi[t])if(O.getAttribute(L)===e[L]){f=O;break e}if(!f){const O=w.reduce((L,Q)=>e[Q]===void 0?L:`${L}-${Q}-${e[Q]}`,t);m=!Li[O],f=Li[O]||(Li[O]=(()=>{const L=document.createElement(t);for(const Q of w)e[Q]!==void 0&&L.setAttribute(Q,e[Q]),e.rel&&L.setAttribute("rel",e.rel);return L})())}}else h=s.querySelectorAll(t);l=r?l??"":void 0,r&&(p[Gi]=l);const _=vd(C=>{if(w.length>0){let O=!1;for(const L of s.querySelectorAll(t)){if(O&&L.getAttribute(Gi)!==l){s.insertBefore(C,L);return}L.getAttribute(Gi)===l&&(O=!0)}s.appendChild(C)}else if(h){let O=!1;for(const L of h)if(L===C){O=!0;break}O||s.insertBefore(C,s.contains(h[0])?h[0]:s.querySelector(t)),h=void 0}},[l]),v=bd(e.ref,C=>{var Q;const O=w[0];if(n===2&&(C.innerHTML=""),(m||h)&&_(C),!c&&!a)return;let L=Hn[Q=C.getAttribute(O)]||(Hn[Q]=new Promise((ce,le)=>{C.addEventListener("load",ce),C.addEventListener("error",le)}));a&&(L=L.then(a)),c&&(L=L.catch(c)),L.catch(()=>{})});if(i&&d==="render"){const C=Wi[t][0];if(e[C]){const O=e[C],L=Hn[O]||(Hn[O]=new Promise((Q,ce)=>{_(f),f.addEventListener("load",Q),f.addEventListener("error",ce)}));J1(L)}}const S={tag:t,type:t,props:{...p,ref:v},ref:v};return S.p=n,f&&(S.e=f),K1(S,s)},Q1=t=>{const e=q1(),n=e&&Ar(e);return n!=null&&n.endsWith("svg")?{tag:"title",props:t,type:"title",ref:t.ref}:Ni("title",t,void 0,!1,!1)},ex=t=>!t||["src","async"].some(e=>!t[e])?{tag:"script",props:t,type:"script",ref:t.ref}:Ni("script",t,1,!1,!0),tx=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,Ni("style",t,2,!0,!0)),nx=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}:Ni("link",t,1,"precedence"in t,!0),rx=t=>Ni("meta",t,void 0,!1,!1),km=Symbol(),ix=t=>{const{action:e,...n}=t;typeof e!="function"&&(n.action=e);const[r,i]=G1([null,!1]),s=vd(async d=>{const p=d.isTrusted?e:d.detail[km];if(typeof p!="function")return;d.preventDefault();const f=new FormData(d.target);i([f,!0]);const m=p(f);m instanceof Promise&&(X1(m),await m),i([null,!0])},[]),a=bd(t.ref,d=>(d.addEventListener("submit",s),()=>{d.removeEventListener("submit",s)})),[c,l]=r;return r[1]=!1,{tag:Y1,props:{value:{pending:c!==null,data:c,method:c?"post":null,action:c?e:null},children:{tag:"form",props:{...n,ref:a},type:"form",ref:a}},f:l}},Sm=(t,{formAction:e,...n})=>{if(typeof e=="function"){const r=vd(i=>{i.preventDefault(),i.currentTarget.form.dispatchEvent(new CustomEvent("submit",{detail:{[km]:e}}))},[]);n.ref=bd(n.ref,i=>(i.addEventListener("click",r),()=>{i.removeEventListener("click",r)}))}return{tag:t,props:n,type:t,ref:n.ref}},sx=t=>Sm("input",t),ox=t=>Sm("button",t);Object.assign(Xc,{title:Q1,script:ex,style:tx,link:nx,meta:rx,form:ix,input:sx,button:ox});new TextEncoder;const Xo=t=>{const{i18nKey:e,values:n,components:r}=t,i=T.t(e,n),s=/<(\d+)>(.*?)<\/\d+>/g,a=[];let c=0,l;for(;(l=s.exec(i))!==null;){const[,d,p]=l,f=i.substring(c,l.index);f&&a.push(f);const m=parseInt(d,10);a.push(E1(r[m],{},p)),c=s.lastIndex}return c<i.length&&a.push(i.substring(c)),y(dm,{children:a})},sf=6,nl=({error:t,vendorSettings:e,email:n,state:r,client:i,hasPasswordLogin:s})=>{const a=new URLSearchParams({state:r}),l=i.connections.map(({name:d})=>d).includes("auth2");return y(Ue,{title:T.t("verify_your_email"),vendorSettings:e,children:[y("div",{className:"mb-4 text-2xl font-medium",children:T.t("verify_your_email")}),y("div",{className:"mb-8 text-gray-300",children:y(Xo,{i18nKey:"we_sent_a_code_to",components:[y("span",{className:"text-black dark:text-white"},"span")],values:{email:n}})}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Wt,{className:"pt-2",children:[y("input",{autoFocus:!0,type:"text",pattern:"[0-9]*",maxLength:sf,inputMode:"numeric",name:"code",placeholder:"******",className:on("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:sf,required:!0,id:"code-input"}),t&&y(Un,{children:t}),y(Ze,{className:"sm:mt-4 !text-base",children:[y("span",{children:T.t("login")}),y(Ge,{className:"text-xs",name:"arrow-right"})]}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Ge,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:T.t("sent_code_spam")})]}),l&&y("div",{className:"text-center mb-12",children:[y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:T.t("or")})]}),y(Ze,{Component:"a",href:`/u/${s?"enter-password":"pre-signup"}?${a.toString()}`,variant:"secondary",className:"block",children:T.t("enter_your_password_btn")})]})]}),y(yt,{state:r})]})]})},ax=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r,client:i}=await Ee(t,e);if(!r.authParams.username)throw new I(400,{message:"Username not found in state"});const s=await us({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username:r.authParams.username,provider:"auth2"});return t.html(y(nl,{vendorSettings:n,email:r.authParams.username,state:e,client:i,hasPasswordLogin:!!s}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({code:o.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{code:n}=t.req.valid("form"),{loginSession:r,client:i,vendorSettings:s}=await Ee(t,e);if(t.set("client_id",i.id),!r.authParams.username)throw new I(400,{message:"Username not found in state"});try{return await Yg(t,{client_id:i.id,authParams:r.authParams,username:r.authParams.username,otp:n})}catch(a){const c=a,l=await us({userAdapter:t.env.data.users,tenant_id:i.tenant.id,username:r.authParams.username,provider:"auth2"});return t.html(y(nl,{vendorSettings:s,email:r.authParams.username,state:e,client:i,error:c.message,hasPasswordLogin:!!l}),400)}}),Am=t=>{const{vendorSettings:e,state:n}=t;return y(Ue,{title:T.t("unverified_email"),vendorSettings:e,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:[y("p",{className:"mb-8 text-gray-300 text-lg",children:T.t("unverified_email")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Ge,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:T.t("sent_code_spam")})]}),y(yt,{state:n})]}),y(yt,{state:n})]})},cx=({width:t=22,height:e=17})=>y("svg",{width:t,height:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 576 512",children:y("path",{fill:"currentColor",d:"M288 32c-80.8 0-145.5 36.8-192.6 80.6C48.6 156 17.3 208 2.5 243.7c-3.3 7.9-3.3 16.7 0 24.6C17.3 304 48.6 356 95.4 399.4 142.5 443.2 207.2 480 288 480s145.5-36.8 192.6-80.6c46.8-43.5 78.1-95.4 93-131.1 3.3-7.9 3.3-16.7 0-24.6-14.9-35.7-46.2-87.7-93-131.1C433.5 68.8 368.8 32 288 32M144 256a144 144 0 1 1 288 0 144 144 0 1 1-288 0m144-64c0 35.3-28.7 64-64 64-7.1 0-13.9-1.2-20.3-3.3-5.5-1.8-11.9 1.6-11.7 7.4.3 6.9 1.3 13.8 3.2 20.7 13.7 51.2 66.4 81.6 117.6 67.9s81.6-66.4 67.9-117.6c-11.1-41.5-47.8-69.4-88.6-71.1-5.8-.2-9.2 6.1-7.4 11.7 2.1 6.4 3.3 13.2 3.3 20.3"})}),lx=({width:t=23,height:e=18})=>y("svg",{width:t,height:e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 512",children:y("path",{fill:"currentColor",d:"M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2s-6.3 25.5 4.1 33.7l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7l-105.2-82.4c39.6-40.6 66.4-86.1 79.9-118.4 3.3-7.9 3.3-16.7 0-24.6-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8zm184.3 144.4c25.5-23.3 59.6-37.5 96.9-37.5 79.5 0 144 64.5 144 144 0 24.9-6.3 48.3-17.4 68.7L408 294.5c8.4-19.3 10.6-41.4 4.8-63.3-11.1-41.5-47.8-69.4-88.6-71.1-5.8-.2-9.2 6.1-7.4 11.7 2.1 6.4 3.3 13.2 3.3 20.3 0 10.2-2.4 19.8-6.6 28.3l-90.3-70.8zM373 389.9c-16.4 6.5-34.3 10.1-53 10.1-79.5 0-144-64.5-144-144 0-6.9.5-13.6 1.4-20.2l-94.3-74.3c-22.8 29.7-39.1 59.3-48.6 82.2-3.3 7.9-3.3 16.7 0 24.6 14.9 35.7 46.2 87.7 93 131.1 47 43.8 111.7 80.6 192.5 80.6 47.8 0 89.9-12.9 126.2-32.5z"})}),rl=({name:t,placeholder:e=T.t("password")})=>y("div",{className:"password-input relative mb-2",children:[y("input",{type:"password",name:t,placeholder:e,className:"w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0}),y("button",{type:"button","aria-label":T.t("show_password"),title:T.t("show_password"),className:"show-password-toggle-show absolute right-0 top-0 w-10 h-full rounded-r-lg text-gray-400 column hover:bg-black/5",children:y(cx,{})}),y("button",{type:"button","aria-label":T.t("hide_password"),title:T.t("hide_password"),className:"show-password-toggle-hide !hidden absolute right-0 top-0 w-10 h-full rounded-r-lg text-gray-400 column hover:bg-black/5",children:y(lx,{})})]}),Xi=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t,s=new URLSearchParams({state:i});return y(Ue,{title:T.t("enter_password"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("enter_password")}),y("div",{className:"mb-6 text-gray-300",children:T.t("enter_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Wt,{className:"mb-7",children:[y("input",{type:"text",name:"username",placeholder:T.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",value:r}),y(rl,{name:"password"}),e&&y(Un,{children:e}),y(Ze,{className:"sm:mt-4 !text-base",children:[y("span",{children:T.t("login")}),y(Ge,{className:"text-xs",name:"arrow-right"})]})]}),y("a",{href:`/u/forgot-password?${s.toString()}`,className:"text-primary hover:underline mb-4",children:T.t("forgot_password_link")}),y("div",{className:"text-center mb-12",children:[y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:T.t("or")})]}),y("form",{method:"post",action:`/u/login/identifier?${s.toString()}`,children:[y("input",{type:"hidden",name:"login_selection",value:"code"}),y("input",{type:"hidden",name:"username",value:r}),y(Ze,{variant:"secondary",className:"block",children:T.t("enter_a_code_btn")})]})]}),y(yt,{state:i})]})]})},dx=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,client:r,loginSession:i}=await Ee(t,e);if(!i.authParams.username)throw new I(400,{message:"Username required"});return t.html(y(Xi,{vendorSettings:n,email:i.authParams.username,state:e,client:r}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({password:o.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),n=t.req.valid("form"),{password:r}=n,{vendorSettings:i,client:s,loginSession:a}=await Ee(t,e),{username:c}=a.authParams;if(!c)throw new I(400,{message:"Username required"});try{return await gd(t,s,{...a.authParams,password:r},a)}catch(l){const d=l;return d.code==="INVALID_PASSWORD"||d.code==="USER_NOT_FOUND"?t.html(y(Xi,{vendorSettings:i,email:c,error:T.t("invalid_password"),state:e,client:s}),400):d.code==="EMAIL_NOT_VERIFIED"?t.html(y(Am,{vendorSettings:i,state:e}),400):t.html(y(Xi,{vendorSettings:i,email:c,error:d.message,state:e,client:s}),400)}}),Dn=t=>{const{state:e,error:n,vendorSettings:r,email:i,code:s}=t;return y(Ue,{title:T.t("create_account_title"),vendorSettings:r,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("create_account_title")}),y("div",{className:"mb-6 text-gray-300",children:T.t("create_account_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Wt,{children:[y("input",{type:"hidden",name:"code",value:s}),y("input",{type:"email",name:"username",placeholder:T.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0,value:i,disabled:!!i}),y("input",{type:"password",name:"password",placeholder:T.t("enter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),y("input",{type:"password",name:"re-enter-password",placeholder:T.t("reenter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),n&&y(Un,{children:n}),y(Ze,{className:"sm:mt-4 !text-base",children:T.t("continue")})]}),y(yt,{state:e})]})]})},Qo=t=>{const{message:e,vendorSettings:n,pageTitle:r,state:i}=t;return y(Ue,{title:"Login",vendorSettings:n,children:[r?y("div",{className:"mb-6 text-gray-300",children:r}):"",y("div",{className:"flex flex-1 flex-col justify-center",children:e}),i?y(yt,{state:i}):""]})},ux=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().optional().openapi({description:"The code parameter from an email verification link"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e,code:n}=t.req.valid("query"),{vendorSettings:r,loginSession:i}=await Ee(t,e),{username:s}=i.authParams;if(!s)throw new I(400,{message:"Username required"});return n?t.html(y(Dn,{state:e,vendorSettings:r,email:s,code:n})):t.html(y(Dn,{state:e,vendorSettings:r,email:s}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({password:o.z.string(),"re-enter-password":o.z.string(),code:o.z.string().optional()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),n=t.req.valid("form"),{env:r}=t,{vendorSettings:i,client:s,loginSession:a}=await Ee(t,e),c="Username-Password-Authentication";t.set("client_id",s.id),t.set("connection",c);const{username:l}=a.authParams;if(!l)throw new I(400,{message:"Username required"});if(n.password!==n["re-enter-password"])return t.html(y(Dn,{state:e,code:n.code,vendorSettings:i,error:T.t("create_account_passwords_didnt_match"),email:a.authParams.username}),400);if(!pd(n.password))return t.html(y(Dn,{state:e,code:n.code,vendorSettings:i,error:T.t("create_account_weak_password"),email:a.authParams.username}),400);const d=n.code?await r.data.codes.get(s.tenant.id,n.code,"email_verification"):void 0,p=d?await r.data.loginSessions.get(s.tenant.id,d.login_id):void 0;try{if(await fr({userAdapter:t.env.data.users,tenant_id:s.tenant.id,username:l,provider:"auth2"}))throw new I(400,{message:"Invalid sign up"});const m=(p==null?void 0:p.authParams.username)===l,w=await Wf(t).users.create(s.tenant.id,{user_id:`auth2|${eo()}`,email:l,email_verified:m,provider:"auth2",connection:c,is_social:!1});return await r.data.passwords.create(s.tenant.id,{user_id:w.user_id,password:await oi.hash(n.password,10),algorithm:"bcrypt"}),m?await gd(t,s,{...a.authParams,password:n.password},a):(await hd(t,w),t.html(y(Qo,{message:T.t("validate_email_body"),pageTitle:T.t("validate_email_title"),vendorSettings:i,state:e})))}catch(f){const m=await wd(r,s.id,a.authParams.vendor_id),w=f;return t.html(y(Dn,{state:e,vendorSettings:m,error:w.message,email:l}),400)}}),Fn=t=>{const{error:e,vendorSettings:n,email:r}=t;return y(Ue,{title:T.t("reset_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("reset_password_title")}),y("div",{className:"mb-6 text-gray-300",children:`${T.t("reset_password_description")} ${r}`}),y("div",{className:"flex flex-1 flex-col justify-center",children:y(Wt,{children:[y(rl,{name:"password",placeholder:T.t("enter_new_password_placeholder")}),y(rl,{name:"re-enter-password",placeholder:T.t("reenter_new_password_placeholder")}),e&&y(Un,{children:e}),y(Ze,{className:"sm:mt-4 !text-base",children:T.t("reset_password_cta")})]})})]})},px=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().openapi({description:"The code parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ee(t,e);if(!r.authParams.username)throw new I(400,{message:"Username required"});return t.html(y(Fn,{vendorSettings:n,email:r.authParams.username}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().openapi({description:"The code parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({password:o.z.string(),"re-enter-password":o.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e,code:n}=t.req.valid("query"),{password:r,"re-enter-password":i}=t.req.valid("form"),{env:s}=t,{vendorSettings:a,client:c,loginSession:l}=await Ee(t,e);if(!l.authParams.username)throw new I(400,{message:"Username required"});if(r!==i)return t.html(y(Fn,{error:T.t("create_account_passwords_didnt_match"),vendorSettings:a,email:l.authParams.username}),400);if(!pd(r))return t.html(y(Fn,{error:T.t("create_account_weak_password"),vendorSettings:a,email:l.authParams.username}),400);const d=await fr({userAdapter:s.data.users,tenant_id:c.tenant.id,username:l.authParams.username,provider:"auth2"});if(!d)throw new I(400,{message:"User not found"});try{if(!await s.data.codes.get(c.tenant.id,n,"password_reset"))return t.html(y(Fn,{error:"Code not found or expired",vendorSettings:a,email:l.authParams.username}),400);const f={user_id:d.user_id,password:await oi.hash(r,10),algorithm:"bcrypt"};await s.data.passwords.get(c.tenant.id,d.user_id)?await s.data.passwords.update(c.tenant.id,f):await s.data.passwords.create(c.tenant.id,f),d.email_verified||await s.data.users.update(c.tenant.id,d.user_id,{email_verified:!0})}catch{return t.html(y(Fn,{error:"The password could not be reset",vendorSettings:a,email:l.authParams.username}),400)}return t.html(y(Qo,{message:T.t("password_has_been_reset"),vendorSettings:a,state:e}))}),zm=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t;return y(Ue,{title:T.t("forgot_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("forgot_password_title")}),y("div",{className:"mb-6 text-gray-300",children:T.t("forgot_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Wt,{className:"pt-2",children:[y("input",{type:"email",name:"username",placeholder:T.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",value:r,disabled:!!r}),e&&y(Un,{children:e}),y(Ze,{className:"sm:mt-4 !text-base",children:T.t("forgot_password_cta")})]}),y(yt,{state:i})]})]})},Em=t=>{const{vendorSettings:e,state:n}=t;return y(Ue,{title:"Login",vendorSettings:e,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{children:T.t("forgot_password_email_sent")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Ge,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:T.t("sent_code_spam")})]})]}),y(yt,{state:n})]})},fx=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ee(t,e);return t.html(y(zm,{vendorSettings:n,state:e,email:r.authParams.username}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,client:r,loginSession:i}=await Ee(t,e);return await e1(t,r,i.authParams.username,i.id),t.html(y(Em,{vendorSettings:n,state:e}))}),Im=({vendorSettings:t,state:e,user:n})=>y(Ue,{title:re("check_email_title"),vendorSettings:t,children:y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{className:"mb-8 text-gray-700 dark:text-gray-300",children:[y(Xo,{i18nKey:"currently_logged_in_as",components:[y("span",{className:"font-semibold text-gray-900 dark:text-white"},"span")],values:{email:n.email||""}}),y("br",{}),re("continue_with_sso_provider_headline")]}),y("div",{className:"space-y-6",children:[y(Wt,{children:y(Ze,{className:"!text-base",children:y("span",{children:T.t("yes_continue_with_existing_account")})})}),y("a",{className:"block text-center text-primary hover:text-primaryHover focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 dark:focus:ring-offset-gray-900",href:`/u/login/identifier?state=${encodeURIComponent(e)}`,children:T.t("no_use_another")})]})]})}),hx=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),{vendorSettings:r,client:i}=await Ee(t,n),s=ds(i.tenant.id,t.req.header("cookie")),a=s?await e.data.sessions.get(i.tenant.id,s):null;if(!a)return t.redirect(`/u/login/identifier?state=${n}`);const c=await e.data.users.get(i.tenant.id,a.user_id);return c?t.html(y(Im,{vendorSettings:r,state:n,user:c})):t.redirect(`/u/login/identifier?state=${n}`)}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{302:{description:"Redirect"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),{loginSession:r,client:i}=await Ee(t,n),s=ds(i.tenant.id,t.req.header("cookie")),a=s?await e.data.sessions.get(i.tenant.id,s):null;if(!a)return t.redirect(`/u/login/identifier?state=${n}`);const c=await e.data.users.get(i.tenant.id,a.user_id);return c?ln(t,{user:c,authParams:r.authParams,client:i,loginSession:r}):t.redirect(`/u/login/identifier?state=${n}`)}),Cm=t=>{const{vendorSettings:e,email:n,state:r}=t;return y(Ue,{title:T.t("create_password_account_title"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("create_password_account_title")}),y("div",{className:"mb-6 text-gray-300",children:T.t("enter_email_for_verification_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:y(Wt,{className:"pt-2",children:[y("input",{type:"email",name:"username",placeholder:T.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0,value:n,disabled:!0}),y(Ze,{className:"sm:mt-4 !text-base",children:T.t("send")})]})}),y(yt,{state:r})]})},gx=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ee(t,e),{username:i}=r.authParams;if(!i)throw new I(400,{message:"Username required"});return t.html(y(Cm,{state:e,vendorSettings:n,email:i}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{loginSession:n,client:r}=await Ee(t,e),{username:i}=n.authParams;if(!i)throw new I(400,{message:"Username required"});const s=await t.env.data.codes.create(r.tenant.id,{code_id:Tn(),code_type:"email_verification",login_id:n.id,expires_at:new Date(Date.now()+W0).toISOString()});return await Yb(t,i,s.code_id,n.id),t.redirect(`/u/pre-signup-sent?state=${e}`)}),Nm=t=>{const{redirectUrl:e,vendorSettings:n}=t;return y(Ue,{title:T.t("invalid_session_title"),vendorSettings:n,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:T.t("invalid_session_body")}),y("div",{className:"flex flex-1 flex-col justify-center",children:e&&y("a",{className:"block text-primary hover:text-primaryHover text-center",href:e,children:T.t("go_back")})})]})},mx=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ee(t,e);let i;return r.authParams.redirect_uri&&r.authParams.state&&(i=new URL(r.authParams.redirect_uri),i.searchParams.set("state",r.authParams.state),i.searchParams.set("error","invalid_session"),i.searchParams.set("error_description",r.authParams.username||"")),t.html(y(Nm,{redirectUrl:i==null?void 0:i.href,vendorSettings:n}))}),_x=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().openapi({description:"The code parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const e=await wd(t.env),{state:n}=t.req.valid("query");return t.html(y(Qo,{message:"Not implemented",pageTitle:"User info",vendorSettings:e,state:n}))}),jm=({vendorSettings:t,state:e})=>{const n=new URLSearchParams({state:e});return y(Ue,{title:T.t("email_validated"),vendorSettings:t,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("email_validated")}),y("div",{className:"flex flex-1 flex-col justify-center mb-7",children:y(Ze,{Component:"a",href:`/u/enter-password?${n}`,className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:T.t("email_validated_cta")}),y(Ge,{className:"text-xs",name:"arrow-right"})]})})})]})},yx=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().openapi({description:"The code parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{var m;const{state:e,code:n}=t.req.valid("query"),{env:r}=t,{client:i,loginSession:s,vendorSettings:a}=await Ee(t,e),{username:c}=s.authParams;if(!c)throw new I(400,{message:"Username not found in state"});const l=await fr({userAdapter:r.data.users,tenant_id:i.tenant.id,username:c,provider:"auth2"});if(!l)throw new I(500,{message:"No user found"});if(!await r.data.codes.get(i.tenant.id,n,"email_verification"))throw new I(400,{message:"Code not found or expired"});await r.data.users.update(i.tenant.id,l.user_id,{email_verified:!0});const f=(await ml(r.data.users,i.tenant.id,c)).filter(w=>w.provider!=="auth2");if(f.length>0){const w=f.filter(h=>!h.linked_to);w.length>1&&console.error("More than one primary user found for email",c),w.length===0&&console.error("No primary user found for email",c),w.length===1&&await r.data.users.update(i.tenant.id,l.user_id,{linked_to:(m=w[0])==null?void 0:m.user_id})}return t.html(y(jm,{vendorSettings:a,state:e}))}),$m=t=>{const{vendorSettings:e,email:n,state:r}=t;return y(Ue,{title:T.t("email_verification_for_signup_sent_title"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("email_verification_for_signup_sent_title")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{className:"mb-6 text-gray-300",children:y(Xo,{i18nKey:"email_verification_for_signup_sent_description",components:[y("span",{className:"text-black dark:text-white"},"span")],values:{email:n}})}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Ge,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:T.t("sent_code_spam")})]})]}),y(yt,{state:r})]})},wx=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ee(t,e),{username:i}=r.authParams;if(!i)throw new I(400,{message:"Username required"});return t.html(y($m,{vendorSettings:n,state:e,email:i}))}),xd=`
243
+ `])))]})},hx=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,client:r,loginSession:i}=await Ee(t,e);if(!i.authParams.username)throw new I(400,{message:"Username required"});return t.html(y(Xi,{vendorSettings:n,email:i.authParams.username,state:e,client:r}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({password:o.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),n=t.req.valid("form"),{password:r}=n,{vendorSettings:i,client:s,loginSession:a}=await Ee(t,e),{username:c}=a.authParams;if(!c)throw new I(400,{message:"Username required"});try{return await gd(t,s,{...a.authParams,password:r},a)}catch(l){const d=l;return d.code==="INVALID_PASSWORD"||d.code==="USER_NOT_FOUND"?t.html(y(Xi,{vendorSettings:i,email:c,error:T.t("invalid_password"),state:e,client:s}),400):d.code==="EMAIL_NOT_VERIFIED"?t.html(y(Im,{vendorSettings:i,state:e}),400):t.html(y(Xi,{vendorSettings:i,email:c,error:d.message,state:e,client:s}),400)}}),Dn=t=>{const{state:e,error:n,vendorSettings:r,email:i,code:s}=t;return y(Ue,{title:T.t("create_account_title"),vendorSettings:r,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("create_account_title")}),y("div",{className:"mb-6 text-gray-300",children:T.t("create_account_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Wt,{children:[y("input",{type:"hidden",name:"code",value:s}),y("input",{type:"email",name:"username",placeholder:T.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0,value:i,disabled:!!i}),y("input",{type:"password",name:"password",placeholder:T.t("enter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),y("input",{type:"password",name:"re-enter-password",placeholder:T.t("reenter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),n&&y(Un,{children:n}),y(Ze,{className:"sm:mt-4 !text-base",children:T.t("continue")})]}),y(yt,{state:e})]})]})},Qo=t=>{const{message:e,vendorSettings:n,pageTitle:r,state:i}=t;return y(Ue,{title:"Login",vendorSettings:n,children:[r?y("div",{className:"mb-6 text-gray-300",children:r}):"",y("div",{className:"flex flex-1 flex-col justify-center",children:e}),i?y(yt,{state:i}):""]})},gx=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().optional().openapi({description:"The code parameter from an email verification link"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e,code:n}=t.req.valid("query"),{vendorSettings:r,loginSession:i}=await Ee(t,e),{username:s}=i.authParams;if(!s)throw new I(400,{message:"Username required"});return n?t.html(y(Dn,{state:e,vendorSettings:r,email:s,code:n})):t.html(y(Dn,{state:e,vendorSettings:r,email:s}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({password:o.z.string(),"re-enter-password":o.z.string(),code:o.z.string().optional()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),n=t.req.valid("form"),{env:r}=t,{vendorSettings:i,client:s,loginSession:a}=await Ee(t,e),c="Username-Password-Authentication";t.set("client_id",s.id),t.set("connection",c);const{username:l}=a.authParams;if(!l)throw new I(400,{message:"Username required"});if(n.password!==n["re-enter-password"])return t.html(y(Dn,{state:e,code:n.code,vendorSettings:i,error:T.t("create_account_passwords_didnt_match"),email:a.authParams.username}),400);if(!pd(n.password))return t.html(y(Dn,{state:e,code:n.code,vendorSettings:i,error:T.t("create_account_weak_password"),email:a.authParams.username}),400);const d=n.code?await r.data.codes.get(s.tenant.id,n.code,"email_verification"):void 0,p=d?await r.data.loginSessions.get(s.tenant.id,d.login_id):void 0;try{if(await fr({userAdapter:t.env.data.users,tenant_id:s.tenant.id,username:l,provider:"auth2"}))throw new I(400,{message:"Invalid sign up"});const m=(p==null?void 0:p.authParams.username)===l,w=await Jf(t).users.create(s.tenant.id,{user_id:`auth2|${eo()}`,email:l,email_verified:m,provider:"auth2",connection:c,is_social:!1});return await r.data.passwords.create(s.tenant.id,{user_id:w.user_id,password:await oi.hash(n.password,10),algorithm:"bcrypt"}),m?await gd(t,s,{...a.authParams,password:n.password},a):(await hd(t,w),t.html(y(Qo,{message:T.t("validate_email_body"),pageTitle:T.t("validate_email_title"),vendorSettings:i,state:e})))}catch(f){const m=await wd(r,s.id,a.authParams.vendor_id),w=f;return t.html(y(Dn,{state:e,vendorSettings:m,error:w.message,email:l}),400)}}),Fn=t=>{const{error:e,vendorSettings:n,email:r}=t;return y(Ue,{title:T.t("reset_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("reset_password_title")}),y("div",{className:"mb-6 text-gray-300",children:`${T.t("reset_password_description")} ${r}`}),y("div",{className:"flex flex-1 flex-col justify-center",children:y(Wt,{children:[y(rl,{name:"password",placeholder:T.t("enter_new_password_placeholder")}),y(rl,{name:"re-enter-password",placeholder:T.t("reenter_new_password_placeholder")}),e&&y(Un,{children:e}),y(Ze,{className:"sm:mt-4 !text-base",children:T.t("reset_password_cta")})]})})]})},mx=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().openapi({description:"The code parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ee(t,e);if(!r.authParams.username)throw new I(400,{message:"Username required"});return t.html(y(Fn,{vendorSettings:n,email:r.authParams.username}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().openapi({description:"The code parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:o.z.object({password:o.z.string(),"re-enter-password":o.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e,code:n}=t.req.valid("query"),{password:r,"re-enter-password":i}=t.req.valid("form"),{env:s}=t,{vendorSettings:a,client:c,loginSession:l}=await Ee(t,e);if(!l.authParams.username)throw new I(400,{message:"Username required"});if(r!==i)return t.html(y(Fn,{error:T.t("create_account_passwords_didnt_match"),vendorSettings:a,email:l.authParams.username}),400);if(!pd(r))return t.html(y(Fn,{error:T.t("create_account_weak_password"),vendorSettings:a,email:l.authParams.username}),400);const d=await fr({userAdapter:s.data.users,tenant_id:c.tenant.id,username:l.authParams.username,provider:"auth2"});if(!d)throw new I(400,{message:"User not found"});try{if(!await s.data.codes.get(c.tenant.id,n,"password_reset"))return t.html(y(Fn,{error:"Code not found or expired",vendorSettings:a,email:l.authParams.username}),400);const f={user_id:d.user_id,password:await oi.hash(r,10),algorithm:"bcrypt"};await s.data.passwords.get(c.tenant.id,d.user_id)?await s.data.passwords.update(c.tenant.id,f):await s.data.passwords.create(c.tenant.id,f),d.email_verified||await s.data.users.update(c.tenant.id,d.user_id,{email_verified:!0})}catch{return t.html(y(Fn,{error:"The password could not be reset",vendorSettings:a,email:l.authParams.username}),400)}return t.html(y(Qo,{message:T.t("password_has_been_reset"),vendorSettings:a,state:e}))}),Cm=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t;return y(Ue,{title:T.t("forgot_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("forgot_password_title")}),y("div",{className:"mb-6 text-gray-300",children:T.t("forgot_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Wt,{className:"pt-2",children:[y("input",{type:"email",name:"username",placeholder:T.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",value:r,disabled:!!r}),e&&y(Un,{children:e}),y(Ze,{className:"sm:mt-4 !text-base",children:T.t("forgot_password_cta")})]}),y(yt,{state:i})]})]})},Nm=t=>{const{vendorSettings:e,state:n}=t;return y(Ue,{title:"Login",vendorSettings:e,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{children:T.t("forgot_password_email_sent")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Ge,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:T.t("sent_code_spam")})]})]}),y(yt,{state:n})]})},_x=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ee(t,e);return t.html(y(Cm,{vendorSettings:n,state:e,email:r.authParams.username}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,client:r,loginSession:i}=await Ee(t,e);return await r1(t,r,i.authParams.username,i.id),t.html(y(Nm,{vendorSettings:n,state:e}))}),jm=({vendorSettings:t,state:e,user:n})=>y(Ue,{title:re("check_email_title"),vendorSettings:t,children:y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{className:"mb-8 text-gray-700 dark:text-gray-300",children:[y(Xo,{i18nKey:"currently_logged_in_as",components:[y("span",{className:"font-semibold text-gray-900 dark:text-white"},"span")],values:{email:n.email||""}}),y("br",{}),re("continue_with_sso_provider_headline")]}),y("div",{className:"space-y-6",children:[y(Wt,{children:y(Ze,{className:"!text-base",children:y("span",{children:T.t("yes_continue_with_existing_account")})})}),y("a",{className:"block text-center text-primary hover:text-primaryHover focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 dark:focus:ring-offset-gray-900",href:`/u/login/identifier?state=${encodeURIComponent(e)}`,children:T.t("no_use_another")})]})]})}),yx=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),{vendorSettings:r,client:i}=await Ee(t,n),s=ds(i.tenant.id,t.req.header("cookie")),a=s?await e.data.sessions.get(i.tenant.id,s):null;if(!a)return t.redirect(`/u/login/identifier?state=${n}`);const c=await e.data.users.get(i.tenant.id,a.user_id);return c?t.html(y(jm,{vendorSettings:r,state:n,user:c})):t.redirect(`/u/login/identifier?state=${n}`)}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{302:{description:"Redirect"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),{loginSession:r,client:i}=await Ee(t,n),s=ds(i.tenant.id,t.req.header("cookie")),a=s?await e.data.sessions.get(i.tenant.id,s):null;if(!a)return t.redirect(`/u/login/identifier?state=${n}`);const c=await e.data.users.get(i.tenant.id,a.user_id);return c?ln(t,{user:c,authParams:r.authParams,client:i,loginSession:r}):t.redirect(`/u/login/identifier?state=${n}`)}),$m=t=>{const{vendorSettings:e,email:n,state:r}=t;return y(Ue,{title:T.t("create_password_account_title"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("create_password_account_title")}),y("div",{className:"mb-6 text-gray-300",children:T.t("enter_email_for_verification_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:y(Wt,{className:"pt-2",children:[y("input",{type:"email",name:"username",placeholder:T.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0,value:n,disabled:!0}),y(Ze,{className:"sm:mt-4 !text-base",children:T.t("send")})]})}),y(yt,{state:r})]})},wx=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ee(t,e),{username:i}=r.authParams;if(!i)throw new I(400,{message:"Username required"});return t.html(y($m,{state:e,vendorSettings:n,email:i}))}).openapi(o.createRoute({tags:["login"],method:"post",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{loginSession:n,client:r}=await Ee(t,e),{username:i}=n.authParams;if(!i)throw new I(400,{message:"Username required"});const s=await t.env.data.codes.create(r.tenant.id,{code_id:Tn(),code_type:"email_verification",login_id:n.id,expires_at:new Date(Date.now()+Z0).toISOString()});return await e1(t,i,s.code_id,n.id),t.redirect(`/u/pre-signup-sent?state=${e}`)}),Om=t=>{const{redirectUrl:e,vendorSettings:n}=t;return y(Ue,{title:T.t("invalid_session_title"),vendorSettings:n,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:T.t("invalid_session_body")}),y("div",{className:"flex flex-1 flex-col justify-center",children:e&&y("a",{className:"block text-primary hover:text-primaryHover text-center",href:e,children:T.t("go_back")})})]})},vx=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ee(t,e);let i;return r.authParams.redirect_uri&&r.authParams.state&&(i=new URL(r.authParams.redirect_uri),i.searchParams.set("state",r.authParams.state),i.searchParams.set("error","invalid_session"),i.searchParams.set("error_description",r.authParams.username||"")),t.html(y(Om,{redirectUrl:i==null?void 0:i.href,vendorSettings:n}))}),bx=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().openapi({description:"The code parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const e=await wd(t.env),{state:n}=t.req.valid("query");return t.html(y(Qo,{message:"Not implemented",pageTitle:"User info",vendorSettings:e,state:n}))}),Pm=({vendorSettings:t,state:e})=>{const n=new URLSearchParams({state:e});return y(Ue,{title:T.t("email_validated"),vendorSettings:t,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("email_validated")}),y("div",{className:"flex flex-1 flex-col justify-center mb-7",children:y(Ze,{Component:"a",href:`/u/enter-password?${n}`,className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:T.t("email_validated_cta")}),y(Ge,{className:"text-xs",name:"arrow-right"})]})})})]})},xx=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"}),code:o.z.string().openapi({description:"The code parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{var m;const{state:e,code:n}=t.req.valid("query"),{env:r}=t,{client:i,loginSession:s,vendorSettings:a}=await Ee(t,e),{username:c}=s.authParams;if(!c)throw new I(400,{message:"Username not found in state"});const l=await fr({userAdapter:r.data.users,tenant_id:i.tenant.id,username:c,provider:"auth2"});if(!l)throw new I(500,{message:"No user found"});if(!await r.data.codes.get(i.tenant.id,n,"email_verification"))throw new I(400,{message:"Code not found or expired"});await r.data.users.update(i.tenant.id,l.user_id,{email_verified:!0});const f=(await ml(r.data.users,i.tenant.id,c)).filter(w=>w.provider!=="auth2");if(f.length>0){const w=f.filter(h=>!h.linked_to);w.length>1&&console.error("More than one primary user found for email",c),w.length===0&&console.error("No primary user found for email",c),w.length===1&&await r.data.users.update(i.tenant.id,l.user_id,{linked_to:(m=w[0])==null?void 0:m.user_id})}return t.html(y(Pm,{vendorSettings:a,state:e}))}),Tm=t=>{const{vendorSettings:e,email:n,state:r}=t;return y(Ue,{title:T.t("email_verification_for_signup_sent_title"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:T.t("email_verification_for_signup_sent_title")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{className:"mb-6 text-gray-300",children:y(Xo,{i18nKey:"email_verification_for_signup_sent_description",components:[y("span",{className:"text-black dark:text-white"},"span")],values:{email:n}})}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(Ge,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:T.t("sent_code_spam")})]})]}),y(yt,{state:r})]})},kx=new o.OpenAPIHono().openapi(o.createRoute({tags:["login"],method:"get",path:"/",request:{query:o.z.object({state:o.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ee(t,e),{username:i}=r.authParams;if(!i)throw new I(400,{message:"Username required"});return t.html(y(Tm,{vendorSettings:n,state:e,email:i}))}),xd=`
242
244
  @font-face{font-display:swap;font-family:KHTeka;font-style:normal;font-weight:400;src:url(https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Regular.woff2) format("woff2")}@font-face{font-display:swap;font-family:KHTeka;font-style:normal;font-weight:500;src:url(https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Medium.woff2) format("woff2")}@font-face{font-display:swap;font-family:KHTeka;font-style:normal;font-weight:600;src:url(https://assets.sesamy.com/fonts/khteka/WOFF2/KHTeka-Bold.woff2) format("woff2")}@font-face{font-family:uicon;src:url(https://login2.sesamy.com/_next/static/media/uicon.0b00e08a.woff2)}[class*=" uicon-"],[class^=uicon-]{font-family:uicon!important;font-size:inherit;font-style:normal;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}.uicon-apple:before{content:"\\ea01"}.uicon-arrow-down:before{content:"\\ea02"}.uicon-arrow-left:before{content:"\\ea03"}.uicon-arrow-right:before{content:"\\ea04"}.uicon-arrow-up:before{content:"\\ea05"}.uicon-facebook:before{content:"\\ea06"}.uicon-google:before{content:"\\ea07"}.uicon-info-bubble:before{content:"\\ea08"}.uicon-info:before{content:"\\ea09"}.uicon-sesamy:before{content:"\\ea0a"}.uicon-spinner-circle:before{content:"\\ea0b"}.uicon-spinner-inner:before{content:"\\ea0c"}
243
245
 
244
- /*! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #bfbcd7;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:KHTeka,Helvetica Neue,HelveticaNeue,TeX Gyre Heros,TeXGyreHeros,FreeSans,Nimbus Sans L,Liberation Sans,Arimo,Helvetica,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#4b4a58;opacity:1}input::placeholder,textarea::placeholder{color:#4b4a58;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]{display:none}body,html{height:100%}body{--tw-bg-opacity:1;background-color:rgb(248 249 251/var(--tw-bg-opacity));font-size:1rem;letter-spacing:.0125rem;line-height:120%;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (min-width:1280px){body{font-size:1.125rem;line-height:120%}}:is(.dark body){--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}button,input,optgroup,select,textarea{font-size:.875rem;letter-spacing:.0125rem;line-height:120%}@media (min-width:1280px){button,input,optgroup,select,textarea{font-size:1rem;line-height:120%}}h1{font-size:1.5rem;font-weight:500;line-height:120%}@media (min-width:1280px){h1{font-size:2rem;line-height:120%}}@media (min-width:640px){h1{font-size:3rem;letter-spacing:-.0625rem;line-height:100%}}@media (min-width:1280px){h1{font-size:3.5rem;letter-spacing:-.0625rem;line-height:100%}}h2{font-size:1.25rem;font-weight:500;line-height:120%}@media (min-width:1280px){h2{font-size:1.5rem;line-height:120%}}@media (min-width:640px){h2{font-size:2rem;letter-spacing:0;line-height:120%}}@media (min-width:1280px){h2{font-size:3rem;letter-spacing:-.0625rem;line-height:100%}}h3{font-size:1.125rem;font-weight:500;line-height:120%}@media (min-width:1280px){h3{font-size:1.25rem;line-height:120%}}@media (min-width:640px){h3{font-size:1.5rem;line-height:120%}}@media (min-width:1280px){h3{font-size:2rem;line-height:120%}}h4{font-size:1rem;font-weight:500;line-height:120%}@media (min-width:1280px){h4{font-size:1.125rem;line-height:120%}}@media (min-width:640px){h4{font-size:1.125rem;line-height:120%}}@media (min-width:1280px){h4{font-size:1.5rem;line-height:120%}}h5{font-size:.875rem;font-weight:500;line-height:120%}@media (min-width:1280px){h5{font-size:1rem;line-height:120%}}@media (min-width:640px){h5{font-size:1rem;line-height:120%}}@media (min-width:1280px){h5{font-size:1.125rem;line-height:120%}}h6{font-size:.75rem;font-weight:500;line-height:135%}@media (min-width:1280px){h6{font-size:.875rem;line-height:120%}}@media (min-width:640px){h6{font-size:.875rem;line-height:120%}}@media (min-width:1280px){h6{font-size:1rem;line-height:120%}}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.pointer-events-none{pointer-events:none}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.left-0{left:0}.right-0{right:0}.top-0{top:0}.top-1\\/2{top:50%}.my-4{margin-bottom:1rem;margin-top:1rem}.mb-12{margin-bottom:3rem}.mb-16{margin-bottom:4rem}.mb-2{margin-bottom:.5rem}.mb-4{margin-bottom:1rem}.mb-5{margin-bottom:1.25rem}.mb-6{margin-bottom:1.5rem}.mb-7{margin-bottom:1.75rem}.mb-8{margin-bottom:2rem}.mt-8{margin-top:2rem}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.\\!hidden{display:none!important}.hidden{display:none}.h-5{height:1.25rem}.h-9{height:2.25rem}.h-full{height:100%}.max-h-full{max-height:100%}.min-h-\\[calc\\(100vh-83px\\)\\]{min-height:calc(100vh - 83px)}.min-h-full{min-height:100%}.w-10{width:2.5rem}.w-5{width:1.25rem}.w-\\[calc\\(100\\%-theme\\(space\\.2\\)-theme\\(space\\.2\\)\\)\\]{width:calc(100% - 1rem)}.w-full{width:100%}.max-w-\\[1295px\\]{max-width:1295px}.flex-1{flex:1 1 0%}@keyframes spin{to{transform:rotate(1turn)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.flex-col{flex-direction:column}.\\!flex-nowrap{flex-wrap:nowrap!important}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(1rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(1rem*var(--tw-space-x-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.overflow-hidden{overflow:hidden}.rounded-2xl{border-radius:1.25rem}.rounded-lg{border-radius:.625rem}.rounded-r-lg{border-bottom-right-radius:.625rem;border-top-right-radius:.625rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-gray-100{--tw-border-opacity:1;border-color:rgb(248 249 251/var(--tw-border-opacity))}.border-gray-200{--tw-border-opacity:1;border-color:rgb(191 188 215/var(--tw-border-opacity))}.border-gray-300{--tw-border-opacity:1;border-color:rgb(136 134 159/var(--tw-border-opacity))}.border-gray-500{--tw-border-opacity:1;border-color:rgb(59 57 70/var(--tw-border-opacity))}.border-red{--tw-border-opacity:1;border-color:rgb(252 90 90/var(--tw-border-opacity))}.bg-gray-100{--tw-bg-opacity:1;background-color:rgb(248 249 251/var(--tw-bg-opacity))}.bg-primary{background-color:var(--primary-color)}.bg-primaryHover{background-color:var(--primary-hover)}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.bg-cover{background-size:cover}.bg-center{background-position:50%}.px-0{padding-left:0;padding-right:0}.px-10{padding-left:2.5rem;padding-right:2.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-10{padding-bottom:2.5rem;padding-top:2.5rem}.py-2{padding-bottom:.5rem;padding-top:.5rem}.py-3{padding-bottom:.75rem;padding-top:.75rem}.py-5{padding-bottom:1.25rem;padding-top:1.25rem}.pb-2{padding-bottom:.5rem}.pb-8{padding-bottom:2rem}.pt-2{padding-top:.5rem}.pt-2\\.5{padding-top:.625rem}.pt-4{padding-top:1rem}.text-left{text-align:left}.text-center{text-align:center}.indent-\\[5px\\]{text-indent:5px}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.\\!text-base{font-size:1rem!important;line-height:120%!important}.text-2xl{font-size:1.5rem;line-height:120%}.text-3xl{font-size:2rem;line-height:120%}.text-base{font-size:1rem;line-height:120%}.text-lg{font-size:1.125rem;line-height:120%}.text-sm{font-size:.875rem;line-height:120%}.text-xl{font-size:1.25rem;line-height:120%}.text-xs{font-size:.75rem;line-height:135%}.font-medium{font-weight:500}.font-semibold{font-weight:600}.leading-\\[0\\]{line-height:0}.text-\\[\\#1196F5\\]{--tw-text-opacity:1;color:rgb(17 150 245/var(--tw-text-opacity))}.text-\\[\\#B2B2B2\\]{--tw-text-opacity:1;color:rgb(178 178 178/var(--tw-text-opacity))}.text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity))}.text-gray-200{--tw-text-opacity:1;color:rgb(191 188 215/var(--tw-text-opacity))}.text-gray-300{--tw-text-opacity:1;color:rgb(136 134 159/var(--tw-text-opacity))}.text-gray-400{--tw-text-opacity:1;color:rgb(75 74 88/var(--tw-text-opacity))}.text-gray-700{--tw-text-opacity:1;color:rgb(30 30 39/var(--tw-text-opacity))}.text-gray-900{--tw-text-opacity:1;color:rgb(8 8 14/var(--tw-text-opacity))}.text-primary{color:var(--primary-color)}.text-red{--tw-text-opacity:1;color:rgb(252 90 90/var(--tw-text-opacity))}.text-textOnPrimary{color:var(--text-on-primary)}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.opacity-40{opacity:.4}.row-up-left{align-content:flex-start;justify-content:flex-start}.row,.row-up-left{display:flex;flex-direction:row;flex-wrap:wrap}.row{align-content:center;align-items:center;justify-content:center}.column-left{align-items:flex-start}.column,.column-left{display:flex;flex-direction:column;justify-content:center}.column{align-items:center}@media (min-width:1280px){.text-5xl{font-size:5.125rem;letter-spacing:-.125rem;line-height:100%}.text-4xl{font-size:3.5rem}.text-3xl,.text-4xl{letter-spacing:-.0625rem;line-height:100%}.text-3xl{font-size:3rem}.text-2xl{font-size:2rem}.text-2xl,.text-xl{line-height:120%}.text-xl{font-size:1.5rem}.text-lg{font-size:1.25rem}.text-base,.text-lg{line-height:120%}.text-base{font-size:1.125rem}.text-sm{font-size:1rem}.text-sm,.text-xs{line-height:120%}.text-xs{font-size:.875rem}}:root{--primary-color:#7d68f4;--primary-hover:#7e69f4;--text-on-primary:#fff}svg{transform:translate3d(var(--tw-translate-x),var(--tw-translate-y),0) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}*,:after,:before{text-underline-offset:4px}input[type=number],input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;-moz-appearance:textfield!important}.btn.is-loading{cursor:not-allowed;opacity:.4;pointer-events:none}.btn .btn-spinner,.btn.is-loading .btn-label{opacity:0;visibility:hidden}.btn.is-loading .btn-spinner{opacity:1;visibility:visible}[class*=" uicon-"],[class^=uicon-]{letter-spacing:0;line-height:100%}.placeholder\\:text-gray-300::-moz-placeholder{--tw-text-opacity:1;color:rgb(136 134 159/var(--tw-text-opacity))}.placeholder\\:text-gray-300::placeholder{--tw-text-opacity:1;color:rgb(136 134 159/var(--tw-text-opacity))}.hover\\:bg-black\\/5:hover{background-color:rgba(0,0,0,.05)}.hover\\:bg-gray-100:hover{--tw-bg-opacity:1;background-color:rgb(248 249 251/var(--tw-bg-opacity))}.hover\\:bg-primaryHover:hover{background-color:var(--primary-hover)}.hover\\:text-primaryHover:hover{color:var(--primary-hover)}.hover\\:underline:hover{text-decoration-line:underline}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:ring:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.focus\\:ring-2:focus,.focus\\:ring:focus{box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.focus\\:ring-primary:focus{--tw-ring-color:var(--primary-color)}.focus\\:ring-offset-2:focus{--tw-ring-offset-width:2px}:is(.dark .dark\\:border-gray-400){--tw-border-opacity:1;border-color:rgb(75 74 88/var(--tw-border-opacity))}:is(.dark .dark\\:border-gray-500){--tw-border-opacity:1;border-color:rgb(59 57 70/var(--tw-border-opacity))}:is(.dark .dark\\:border-gray-600){--tw-border-opacity:1;border-color:rgb(40 40 52/var(--tw-border-opacity))}:is(.dark .dark\\:bg-black){--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity))}:is(.dark .dark\\:bg-gray-600){--tw-bg-opacity:1;background-color:rgb(40 40 52/var(--tw-bg-opacity))}:is(.dark .dark\\:bg-gray-800){--tw-bg-opacity:1;background-color:rgb(20 20 26/var(--tw-bg-opacity))}:is(.dark .dark\\:text-\\[\\#201a41\\]){--tw-text-opacity:1;color:rgb(32 26 65/var(--tw-text-opacity))}:is(.dark .dark\\:text-gray-300){--tw-text-opacity:1;color:rgb(136 134 159/var(--tw-text-opacity))}:is(.dark .dark\\:text-white){--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}:is(.dark .dark\\:hover\\:bg-black\\/90:hover){background-color:rgba(0,0,0,.9)}:is(.dark .dark\\:focus\\:ring-offset-gray-900:focus){--tw-ring-offset-color:#08080e}@media (min-width:640px){.sm\\:absolute{position:absolute}.sm\\:left-4{left:1rem}.sm\\:top-1\\/2{top:50%}.sm\\:mt-4{margin-top:1rem}.sm\\:inline{display:inline}.sm\\:h-6{height:1.5rem}.sm\\:min-h-\\[700px\\]{min-height:700px}.sm\\:w-6{width:1.5rem}.sm\\:w-\\[calc\\(100\\%-theme\\(space\\.16\\)-theme\\(space\\.16\\)\\)\\]{width:calc(100% - 8rem)}.sm\\:w-auto{width:auto}.sm\\:max-w-md{max-width:28rem}.sm\\:-translate-y-1\\/2{--tw-translate-y:-50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.sm\\:flex-col{flex-direction:column}.sm\\:justify-normal{justify-content:normal}.sm\\:space-x-0>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(0px*(1 - var(--tw-space-x-reverse)));margin-right:calc(0px*var(--tw-space-x-reverse))}.sm\\:space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.sm\\:bg-fixed{background-attachment:fixed}.sm\\:bg-left-top{background-position:0 0}.sm\\:px-10{padding-left:2.5rem;padding-right:2.5rem}.sm\\:px-14{padding-left:3.5rem;padding-right:3.5rem}.sm\\:py-14{padding-bottom:3.5rem;padding-top:3.5rem}.sm\\:py-4{padding-bottom:1rem;padding-top:1rem}.sm\\:pt-16{padding-top:4rem}.sm\\:text-2xl{font-size:1.5rem;line-height:120%}.sm\\:text-base{font-size:1rem;line-height:120%}}@media (min-width:1280px){.md\\:min-w-\\[448px\\]{min-width:448px}.md\\:text-3xl{font-size:2rem;line-height:120%}.md\\:text-base{font-size:1rem;line-height:120%}.md\\:text-sm{font-size:.875rem;line-height:120%}.md\\:text-xs{font-size:.75rem;line-height:135%}}@media (max-height:900px) and (min-width:640px){.short\\:static{position:static}.short\\:left-auto{left:auto}.short\\:top-auto{top:auto}.short\\:hidden{display:none}.short\\:h-5{height:1.25rem}.short\\:min-h-\\[558px\\]{min-height:558px}.short\\:w-5{width:1.25rem}.short\\:translate-y-0{--tw-translate-y:0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.short\\:flex-row{flex-direction:row}.short\\:space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(1rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(1rem*var(--tw-space-x-reverse))}.short\\:space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(0px*var(--tw-space-y-reverse));margin-top:calc(0px*(1 - var(--tw-space-y-reverse)))}.short\\:px-0{padding-left:0;padding-right:0}.short\\:py-3{padding-bottom:.75rem;padding-top:.75rem}.short\\:text-xl{font-size:1.25rem;line-height:120%}}`;function vx(){if(typeof document<"u"){const t=document.createElement("style");t.innerHTML=xd,t.setAttribute("data-authhero-tailwind",""),document.head.appendChild(t)}}function bx(t){const e=new o.OpenAPIHono;e.use(od).use(async(r,i)=>(r.env.data=io(r,t.dataAdapter),i())),e.get("/css/tailwind.css",async r=>{const i=xd;return r.text(i,200,{"content-type":"text/css; charset=utf-8"})});const n=e.route("/info",_x).route("/check-account",hx).route("/login/identifier",L1).route("/enter-code",ax).route("/enter-password",dx).route("/invalid-session",mx).route("/pre-signup",gx).route("/pre-signup-sent",wx).route("/reset-password",px).route("/forgot-password",fx).route("/validate-email",yx).route("/signup",ux);return n.doc("/u/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Universal login"}}),n}const xx="Account detected",kx="We have detected that you have already created an account through",Sx="By signing in, you agree to our",Ax="and",zx="Callback URL mismatch",Ex="The provided redirect_uri is not in the list of allowed callback URLs.",Ix="continue with user",Cx="Please click the button to create a new password account.",Nx="Enter the code at {{vendorName}} to complete the login",jx="Welcome to {{vendorName}}! {{code}} is the login code",$x="Welcome to {{vendorName}}! {{code}} is the login code",Ox="The code is valid for 30 minutes",Px="Confirm password",Tx="Need Help?",Bx="Contact us",Rx="or continue with social account",Lx="Continue with {{provider}}",Ux="Would you like to continue with your existing account?",Vx="Copyright © 2023 SESAMY. All rights reserved.",qx="©2023 Sesamy",Mx="Choose a password with a mix of uppercase and lowercase letters, numbers, and symbols.",Hx="Please enter a valid email address.",Dx="The passwords didn't match. Try again.",Fx="Choose password",Kx="Password must be at least 8 characters long and contain at least one lowercase letter, one uppercase letter, one number and one symbol.",Wx="Create new account",Gx="Sign up with password",Jx="You are currently logged in as <0>{{email}}</0>",Zx="Email",Yx="Email or Phone Number",Xx="Email address",Qx="Your email address has been validated",ek="Now enter your password to login again",tk="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.",nk="Email verification sent",rk="Enter a code",ik="We'll send you a verification link to ensure you own this email address.",sk="Enter new password",ok="Enter password",ak="Enter your email address and password to login.",ck="Enter your password",lk="The magic link has expired. Please click on the button below to receive a new link in your inbox.",dk="Hey! We updated our login experience. <0>Click here to learn more about it.</0>",uk="Send password reset email",pk="Click the button below and we’ll send instructions on how to reset your password.",fk="Password reset email sent",hk="Forgot password?",gk="Forgot password?",mk="Go back",_k="Hide password",yk="Invalid password",wk=`The link is no longer valid.
246
+ /*! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #bfbcd7;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:KHTeka,Helvetica Neue,HelveticaNeue,TeX Gyre Heros,TeXGyreHeros,FreeSans,Nimbus Sans L,Liberation Sans,Arimo,Helvetica,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#4b4a58;opacity:1}input::placeholder,textarea::placeholder{color:#4b4a58;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]{display:none}body,html{height:100%}body{--tw-bg-opacity:1;background-color:rgb(248 249 251/var(--tw-bg-opacity));font-size:1rem;letter-spacing:.0125rem;line-height:120%;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}@media (min-width:1280px){body{font-size:1.125rem;line-height:120%}}:is(.dark body){--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}button,input,optgroup,select,textarea{font-size:.875rem;letter-spacing:.0125rem;line-height:120%}@media (min-width:1280px){button,input,optgroup,select,textarea{font-size:1rem;line-height:120%}}h1{font-size:1.5rem;font-weight:500;line-height:120%}@media (min-width:1280px){h1{font-size:2rem;line-height:120%}}@media (min-width:640px){h1{font-size:3rem;letter-spacing:-.0625rem;line-height:100%}}@media (min-width:1280px){h1{font-size:3.5rem;letter-spacing:-.0625rem;line-height:100%}}h2{font-size:1.25rem;font-weight:500;line-height:120%}@media (min-width:1280px){h2{font-size:1.5rem;line-height:120%}}@media (min-width:640px){h2{font-size:2rem;letter-spacing:0;line-height:120%}}@media (min-width:1280px){h2{font-size:3rem;letter-spacing:-.0625rem;line-height:100%}}h3{font-size:1.125rem;font-weight:500;line-height:120%}@media (min-width:1280px){h3{font-size:1.25rem;line-height:120%}}@media (min-width:640px){h3{font-size:1.5rem;line-height:120%}}@media (min-width:1280px){h3{font-size:2rem;line-height:120%}}h4{font-size:1rem;font-weight:500;line-height:120%}@media (min-width:1280px){h4{font-size:1.125rem;line-height:120%}}@media (min-width:640px){h4{font-size:1.125rem;line-height:120%}}@media (min-width:1280px){h4{font-size:1.5rem;line-height:120%}}h5{font-size:.875rem;font-weight:500;line-height:120%}@media (min-width:1280px){h5{font-size:1rem;line-height:120%}}@media (min-width:640px){h5{font-size:1rem;line-height:120%}}@media (min-width:1280px){h5{font-size:1.125rem;line-height:120%}}h6{font-size:.75rem;font-weight:500;line-height:135%}@media (min-width:1280px){h6{font-size:.875rem;line-height:120%}}@media (min-width:640px){h6{font-size:.875rem;line-height:120%}}@media (min-width:1280px){h6{font-size:1rem;line-height:120%}}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.pointer-events-none{pointer-events:none}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.left-0{left:0}.right-0{right:0}.top-0{top:0}.top-1\\/2{top:50%}.my-4{margin-bottom:1rem;margin-top:1rem}.mb-12{margin-bottom:3rem}.mb-16{margin-bottom:4rem}.mb-2{margin-bottom:.5rem}.mb-4{margin-bottom:1rem}.mb-5{margin-bottom:1.25rem}.mb-6{margin-bottom:1.5rem}.mb-7{margin-bottom:1.75rem}.mb-8{margin-bottom:2rem}.mt-8{margin-top:2rem}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.\\!hidden{display:none!important}.hidden{display:none}.h-5{height:1.25rem}.h-9{height:2.25rem}.h-full{height:100%}.max-h-full{max-height:100%}.min-h-\\[calc\\(100vh-83px\\)\\]{min-height:calc(100vh - 83px)}.min-h-full{min-height:100%}.w-10{width:2.5rem}.w-5{width:1.25rem}.w-\\[calc\\(100\\%-theme\\(space\\.2\\)-theme\\(space\\.2\\)\\)\\]{width:calc(100% - 1rem)}.w-full{width:100%}.max-w-\\[1295px\\]{max-width:1295px}.flex-1{flex:1 1 0%}@keyframes spin{to{transform:rotate(1turn)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.flex-col{flex-direction:column}.\\!flex-nowrap{flex-wrap:nowrap!important}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(1rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(1rem*var(--tw-space-x-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.overflow-hidden{overflow:hidden}.rounded-2xl{border-radius:1.25rem}.rounded-lg{border-radius:.625rem}.rounded-r-lg{border-bottom-right-radius:.625rem;border-top-right-radius:.625rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-gray-100{--tw-border-opacity:1;border-color:rgb(248 249 251/var(--tw-border-opacity))}.border-gray-200{--tw-border-opacity:1;border-color:rgb(191 188 215/var(--tw-border-opacity))}.border-gray-300{--tw-border-opacity:1;border-color:rgb(136 134 159/var(--tw-border-opacity))}.border-gray-500{--tw-border-opacity:1;border-color:rgb(59 57 70/var(--tw-border-opacity))}.border-red{--tw-border-opacity:1;border-color:rgb(252 90 90/var(--tw-border-opacity))}.bg-gray-100{--tw-bg-opacity:1;background-color:rgb(248 249 251/var(--tw-bg-opacity))}.bg-primary{background-color:var(--primary-color)}.bg-primaryHover{background-color:var(--primary-hover)}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.bg-cover{background-size:cover}.bg-center{background-position:50%}.px-0{padding-left:0;padding-right:0}.px-10{padding-left:2.5rem;padding-right:2.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-10{padding-bottom:2.5rem;padding-top:2.5rem}.py-2{padding-bottom:.5rem;padding-top:.5rem}.py-3{padding-bottom:.75rem;padding-top:.75rem}.py-5{padding-bottom:1.25rem;padding-top:1.25rem}.pb-2{padding-bottom:.5rem}.pb-8{padding-bottom:2rem}.pt-2{padding-top:.5rem}.pt-2\\.5{padding-top:.625rem}.pt-4{padding-top:1rem}.text-left{text-align:left}.text-center{text-align:center}.indent-\\[5px\\]{text-indent:5px}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.\\!text-base{font-size:1rem!important;line-height:120%!important}.text-2xl{font-size:1.5rem;line-height:120%}.text-3xl{font-size:2rem;line-height:120%}.text-base{font-size:1rem;line-height:120%}.text-lg{font-size:1.125rem;line-height:120%}.text-sm{font-size:.875rem;line-height:120%}.text-xl{font-size:1.25rem;line-height:120%}.text-xs{font-size:.75rem;line-height:135%}.font-medium{font-weight:500}.font-semibold{font-weight:600}.leading-\\[0\\]{line-height:0}.text-\\[\\#1196F5\\]{--tw-text-opacity:1;color:rgb(17 150 245/var(--tw-text-opacity))}.text-\\[\\#B2B2B2\\]{--tw-text-opacity:1;color:rgb(178 178 178/var(--tw-text-opacity))}.text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity))}.text-gray-200{--tw-text-opacity:1;color:rgb(191 188 215/var(--tw-text-opacity))}.text-gray-300{--tw-text-opacity:1;color:rgb(136 134 159/var(--tw-text-opacity))}.text-gray-400{--tw-text-opacity:1;color:rgb(75 74 88/var(--tw-text-opacity))}.text-gray-700{--tw-text-opacity:1;color:rgb(30 30 39/var(--tw-text-opacity))}.text-gray-900{--tw-text-opacity:1;color:rgb(8 8 14/var(--tw-text-opacity))}.text-primary{color:var(--primary-color)}.text-red{--tw-text-opacity:1;color:rgb(252 90 90/var(--tw-text-opacity))}.text-textOnPrimary{color:var(--text-on-primary)}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.opacity-40{opacity:.4}.row-up-left{align-content:flex-start;justify-content:flex-start}.row,.row-up-left{display:flex;flex-direction:row;flex-wrap:wrap}.row{align-content:center;align-items:center;justify-content:center}.column-left{align-items:flex-start}.column,.column-left{display:flex;flex-direction:column;justify-content:center}.column{align-items:center}@media (min-width:1280px){.text-5xl{font-size:5.125rem;letter-spacing:-.125rem;line-height:100%}.text-4xl{font-size:3.5rem}.text-3xl,.text-4xl{letter-spacing:-.0625rem;line-height:100%}.text-3xl{font-size:3rem}.text-2xl{font-size:2rem}.text-2xl,.text-xl{line-height:120%}.text-xl{font-size:1.5rem}.text-lg{font-size:1.25rem}.text-base,.text-lg{line-height:120%}.text-base{font-size:1.125rem}.text-sm{font-size:1rem}.text-sm,.text-xs{line-height:120%}.text-xs{font-size:.875rem}}:root{--primary-color:#7d68f4;--primary-hover:#7e69f4;--text-on-primary:#fff}svg{transform:translate3d(var(--tw-translate-x),var(--tw-translate-y),0) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}*,:after,:before{text-underline-offset:4px}input[type=number],input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;-moz-appearance:textfield!important}.btn.is-loading{cursor:not-allowed;opacity:.4;pointer-events:none}.btn .btn-spinner,.btn.is-loading .btn-label{opacity:0;visibility:hidden}.btn.is-loading .btn-spinner{opacity:1;visibility:visible}[class*=" uicon-"],[class^=uicon-]{letter-spacing:0;line-height:100%}.placeholder\\:text-gray-300::-moz-placeholder{--tw-text-opacity:1;color:rgb(136 134 159/var(--tw-text-opacity))}.placeholder\\:text-gray-300::placeholder{--tw-text-opacity:1;color:rgb(136 134 159/var(--tw-text-opacity))}.hover\\:bg-black\\/5:hover{background-color:rgba(0,0,0,.05)}.hover\\:bg-gray-100:hover{--tw-bg-opacity:1;background-color:rgb(248 249 251/var(--tw-bg-opacity))}.hover\\:bg-primaryHover:hover{background-color:var(--primary-hover)}.hover\\:text-primaryHover:hover{color:var(--primary-hover)}.hover\\:underline:hover{text-decoration-line:underline}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:ring:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.focus\\:ring-2:focus,.focus\\:ring:focus{box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.focus\\:ring-primary:focus{--tw-ring-color:var(--primary-color)}.focus\\:ring-offset-2:focus{--tw-ring-offset-width:2px}:is(.dark .dark\\:border-gray-400){--tw-border-opacity:1;border-color:rgb(75 74 88/var(--tw-border-opacity))}:is(.dark .dark\\:border-gray-500){--tw-border-opacity:1;border-color:rgb(59 57 70/var(--tw-border-opacity))}:is(.dark .dark\\:border-gray-600){--tw-border-opacity:1;border-color:rgb(40 40 52/var(--tw-border-opacity))}:is(.dark .dark\\:bg-black){--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity))}:is(.dark .dark\\:bg-gray-600){--tw-bg-opacity:1;background-color:rgb(40 40 52/var(--tw-bg-opacity))}:is(.dark .dark\\:bg-gray-800){--tw-bg-opacity:1;background-color:rgb(20 20 26/var(--tw-bg-opacity))}:is(.dark .dark\\:text-\\[\\#201a41\\]){--tw-text-opacity:1;color:rgb(32 26 65/var(--tw-text-opacity))}:is(.dark .dark\\:text-gray-300){--tw-text-opacity:1;color:rgb(136 134 159/var(--tw-text-opacity))}:is(.dark .dark\\:text-white){--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}:is(.dark .dark\\:hover\\:bg-black\\/90:hover){background-color:rgba(0,0,0,.9)}:is(.dark .dark\\:focus\\:ring-offset-gray-900:focus){--tw-ring-offset-color:#08080e}@media (min-width:640px){.sm\\:absolute{position:absolute}.sm\\:left-4{left:1rem}.sm\\:top-1\\/2{top:50%}.sm\\:mt-4{margin-top:1rem}.sm\\:inline{display:inline}.sm\\:h-6{height:1.5rem}.sm\\:min-h-\\[700px\\]{min-height:700px}.sm\\:w-6{width:1.5rem}.sm\\:w-\\[calc\\(100\\%-theme\\(space\\.16\\)-theme\\(space\\.16\\)\\)\\]{width:calc(100% - 8rem)}.sm\\:w-auto{width:auto}.sm\\:max-w-md{max-width:28rem}.sm\\:-translate-y-1\\/2{--tw-translate-y:-50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.sm\\:flex-col{flex-direction:column}.sm\\:justify-normal{justify-content:normal}.sm\\:space-x-0>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(0px*(1 - var(--tw-space-x-reverse)));margin-right:calc(0px*var(--tw-space-x-reverse))}.sm\\:space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.sm\\:bg-fixed{background-attachment:fixed}.sm\\:bg-left-top{background-position:0 0}.sm\\:px-10{padding-left:2.5rem;padding-right:2.5rem}.sm\\:px-14{padding-left:3.5rem;padding-right:3.5rem}.sm\\:py-14{padding-bottom:3.5rem;padding-top:3.5rem}.sm\\:py-4{padding-bottom:1rem;padding-top:1rem}.sm\\:pt-16{padding-top:4rem}.sm\\:text-2xl{font-size:1.5rem;line-height:120%}.sm\\:text-base{font-size:1rem;line-height:120%}}@media (min-width:1280px){.md\\:min-w-\\[448px\\]{min-width:448px}.md\\:text-3xl{font-size:2rem;line-height:120%}.md\\:text-base{font-size:1rem;line-height:120%}.md\\:text-sm{font-size:.875rem;line-height:120%}.md\\:text-xs{font-size:.75rem;line-height:135%}}@media (max-height:900px) and (min-width:640px){.short\\:static{position:static}.short\\:left-auto{left:auto}.short\\:top-auto{top:auto}.short\\:hidden{display:none}.short\\:h-5{height:1.25rem}.short\\:min-h-\\[558px\\]{min-height:558px}.short\\:w-5{width:1.25rem}.short\\:translate-y-0{--tw-translate-y:0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.short\\:flex-row{flex-direction:row}.short\\:space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(1rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(1rem*var(--tw-space-x-reverse))}.short\\:space-y-0>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(0px*var(--tw-space-y-reverse));margin-top:calc(0px*(1 - var(--tw-space-y-reverse)))}.short\\:px-0{padding-left:0;padding-right:0}.short\\:py-3{padding-bottom:.75rem;padding-top:.75rem}.short\\:text-xl{font-size:1.25rem;line-height:120%}}`;function Sx(){if(typeof document<"u"){const t=document.createElement("style");t.innerHTML=xd,t.setAttribute("data-authhero-tailwind",""),document.head.appendChild(t)}}function Ax(t){const e=new o.OpenAPIHono;e.use(od).use(async(r,i)=>(r.env.data=io(r,t.dataAdapter),i())),e.get("/css/tailwind.css",async r=>{const i=xd;return r.text(i,200,{"content-type":"text/css; charset=utf-8"})});const n=e.route("/info",bx).route("/check-account",yx).route("/login/identifier",V1).route("/enter-code",lx).route("/enter-password",hx).route("/invalid-session",vx).route("/pre-signup",wx).route("/pre-signup-sent",kx).route("/reset-password",mx).route("/forgot-password",_x).route("/validate-email",xx).route("/signup",gx);return n.doc("/u/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Universal login"}}),n}const zx="Account detected",Ex="We have detected that you have already created an account through",Ix="By signing in, you agree to our",Cx="and",Nx="Callback URL mismatch",jx="The provided redirect_uri is not in the list of allowed callback URLs.",$x="continue with user",Ox="Please click the button to create a new password account.",Px="Enter the code at {{vendorName}} to complete the login",Tx="Welcome to {{vendorName}}! {{code}} is the login code",Bx="Welcome to {{vendorName}}! {{code}} is the login code",Rx="The code is valid for 30 minutes",Lx="Confirm password",Ux="Need Help?",Vx="Contact us",qx="or continue with social account",Mx="Continue with {{provider}}",Hx="Would you like to continue with your existing account?",Dx="Copyright © 2023 SESAMY. All rights reserved.",Fx="©2023 Sesamy",Kx="Choose a password with a mix of uppercase and lowercase letters, numbers, and symbols.",Wx="Please enter a valid email address.",Gx="The passwords didn't match. Try again.",Jx="Choose password",Zx="Password must be at least 8 characters long and contain at least one lowercase letter, one uppercase letter, one number and one symbol.",Yx="Create new account",Xx="Sign up with password",Qx="You are currently logged in as <0>{{email}}</0>",ek="Email",tk="Email or Phone Number",nk="Email address",rk="Your email address has been validated",ik="Now enter your password to login again",sk="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.",ok="Email verification sent",ak="Enter a code",ck="We'll send you a verification link to ensure you own this email address.",lk="Enter new password",dk="Enter password",uk="Enter your email address and password to login.",pk="Enter your password",fk="The magic link has expired. Please click on the button below to receive a new link in your inbox.",hk="Hey! We updated our login experience. <0>Click here to learn more about it.</0>",gk="Send password reset email",mk="Click the button below and we’ll send instructions on how to reset your password.",_k="Password reset email sent",yk="Forgot password?",wk="Forgot password?",vk="Go back",bk="Hide password",xk="Invalid password",kk=`The link is no longer valid.
245
247
 
246
248
  Please make sure to open the login link in the same browser you started the login with.
247
249
 
248
- You can click the link below to start a new login.`,vk="Invalid link",bk="Click the button to log in",xk="Login",kk="Or enter the code at {{vendorName}} to complete the login.",Sk="Enter your email address to unlock this show on {{service}}",Ak="Link your account with {{service}}",zk="You are logged in as",Ek="Login",Ik="Enter your email address to sign in.",Ck="Enter your email address and we will send you a login code.",Nk="Enter your email address and we will send you a login link.",jk="Log out",$k="No, I want to use another account",Ok="or",Pk="Password",Tk="The password has been reset",Bk="Success",Rk="Change password for your {{vendorName}} account",Lk="Change password for your {{vendorName}} account",Uk="Phone number",Vk="Privacy Policy",qk="Redirecting",Mk="Confirm password",Hk="Register a new password",Dk="Resend code",Fk="Change password",Kk="Enter your new password below for the email account: ",Wk="Click the button to reset your password",Gk="Click the button to reset your password",Jk="Reset your password",Zk="Change password for your {{vendorName}} account",Yk="Reset password",Xk="Send",Qk="Send me a new magic link",e2="Remember to check your spam folder if the email did not arrive.",t2="Set password",n2="Show password",r2="Sign in",i2="Signup",s2="Sign up successful",o2="{{code}} is your login code for {{vendorName}}",a2="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.",c2="Go to Spotify's Content Access page",l2=`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.`,d2="Step 1: Unlink Your Spotify Account",u2="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.",p2="Step 2: Relink Your Spotify Account to Sesamy",f2="Oops! Your Spotify Account Is Already Linked",h2="If you have questions or need assistance, you can contact our support team",g2="Terms and Conditions",m2="Your email address needs validating. We have sent a new email to your inbox",_2="User account does not exist",y2="User account does not exist",w2="We could not find a user with the provided email address. Please, try again.",v2="Try again.",b2="Validate code",x2="Check your inbox for email validation instructions.",k2="Signed up",S2="Click the button to verify your email address",A2="Validate your email address",z2="Validate your email address",E2="Verify account",I2="Verify your email",C2="Welcome",N2="Welcome to your {{vendorName}} account!",j2="Please check your email at <0>{{email}}</0> and enter the six-digit code that we've sent you.",$2="Continue with this account",O2="Yes, continue with {{text}}",P2="Yes, continue with existing account",T2={account_detected:xx,account_with_sso_provider:kx,agree_to:Sx,and:Ax,callback_url_mismatch:zx,callback_url_not_allowed:Ex,check_email_title:Ix,click_to_sign_up_description:Cx,code_email_enter_code:Nx,code_email_subject:jx,code_email_title:$x,code_valid_30_minutes:Ox,confirm_password:Px,contact_support:Tx,contact_us:Bx,continue:"Continue",continue_social_login:Rx,continue_with:Lx,continue_with_sso_provider_headline:Ux,copyright:Vx,copyright_sesamy:qx,create_account_description:Mx,create_account_email_invalid:Hx,create_account_passwords_didnt_match:Dx,create_account_title:Fx,create_account_weak_password:Kx,create_new_account_link:Wx,create_password_account_title:Gx,currently_logged_in_as:Jx,email:Zx,email_or_phone_placeholder:Yx,email_placeholder:Xx,email_validated:Qx,email_validated_cta:ek,email_verification_for_signup_sent_description:tk,email_verification_for_signup_sent_title:nk,enter_a_code_btn:rk,enter_email_for_verification_description:ik,enter_new_password_placeholder:sk,enter_password:ok,enter_password_description:ak,enter_your_password_btn:ck,expired_code:lk,fokus_info_message:dk,forgot_password_cta:uk,forgot_password_description:pk,forgot_password_email_sent:fk,forgot_password_link:hk,forgot_password_title:gk,go_back:mk,hide_password:_k,"invalid-email":"Invalid email",invalid_password:yk,invalid_session_body:wk,invalid_session_title:vk,link_email_click_to_login:bk,link_email_login:xk,link_email_or_enter_code:kk,link_page_body:Sk,link_page_headline:Ak,logged_in_as:zk,login:Ek,login_description:Ik,login_description_code:Ck,login_description_link:Nk,logout:jk,no_use_another:$k,or:Ok,password:Pk,password_has_been_reset:Tk,password_has_been_reset_title:Bk,password_reset_subject:Rk,password_reset_title:Lk,phone_placeholder:Uk,privacy_policy:Vk,redirecting:qk,reenter_new_password_placeholder:Mk,register_password_account:Hk,resend_code:Dk,reset_password_cta:Fk,reset_password_description:Kk,reset_password_email_click_to_reset:Wk,reset_password_email_cta:Gk,reset_password_email_reset:Jk,reset_password_subject:Zk,reset_password_title:Yk,send:Xk,send_me_a_new_magic_link:Qk,sent_code_spam:e2,"Server error: Invalid code":"Invalid code",set_password:t2,show_password:n2,sign_in:r2,signup:i2,signup_success:s2,sms_code_text:o2,spotify_already_linked_body:a2,spotify_already_linked_cta:c2,spotify_already_linked_step1_body:l2,spotify_already_linked_step1_title:d2,spotify_already_linked_step2_body:u2,spotify_already_linked_step2_title:p2,spotify_already_linked_title:f2,support_info:h2,terms:g2,unverified_email:m2,user_account_does_not_exist:_2,user_not_found:y2,user_not_found_body:w2,user_not_found_cta:v2,validate_code:b2,validate_email_body:x2,validate_email_title:k2,verify_email_click_to_verify:S2,verify_email_subject:A2,verify_email_title:z2,verify_email_verify:E2,verify_your_email:I2,welcome:C2,welcome_to_your_account:N2,we_sent_a_code_to:j2,"Wrong email or verification code":{"":"Wrong email or verification code."},yes_continue:$2,yes_continue_with:O2,yes_continue_with_existing_account:P2},B2="Account rilevato",R2="Abbiamo rilevato che l'utente ha già creato un account tramite",L2="Effettuando l'accesso, l'utente accetta la nostra",U2="e",V2="Mancata corrispondenza dell'URL di callback",q2="Il redirect_uri fornito non è nell'elenco degli URL di callback consentiti.",M2="continuare con l'utente",H2="Fare clic sul pulsante per creare un nuovo account con password.",D2="Inserite il codice all'indirizzo {{vendorName}} per completare il login.",F2="Benvenuti su {{vendorName}}! {{code}} è il codice di accesso",K2="Benvenuti su {{vendorName}}! {{code}} è il codice di accesso",W2="Il codice è valido per 30 minuti",G2="Confermare la password",J2="Avete bisogno di aiuto?",Z2="Contattateci",Y2="o continuare con il conto sociale",X2="Continua con {{provider}}",Q2="Desidera continuare a utilizzare l'account esistente?",eS="Copyright © 2023 SESAMY. Tutti i diritti riservati.",tS="©2023 Sesamy",nS="Scegliete una password con un mix di lettere maiuscole e minuscole, numeri e simboli.",rS="Inserire un indirizzo e-mail valido.",iS="Le password non corrispondono. Riprovare.",sS="Scegliere la password",oS="La password deve essere lunga almeno 8 caratteri e contenere almeno una lettera minuscola, una lettera maiuscola, un numero e un simbolo.",aS="Creare un nuovo account",cS="Iscriviti con la password",lS="Attualmente si è connessi come <0>{{email}}</0>",dS="Email",uS="Indirizzo e-mail o numero di telefono",pS="Indirizzo e-mail",fS="Il tuo indirizzo e-mail è stato convalidato",hS="Ora inserire la password per accedere nuovamente",gS="È 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.",mS="Email di verifica inviata",_S="Inserire un codice",yS="Vi invieremo un link di verifica per assicurarvi di possedere questo indirizzo e-mail.",wS="Inserire la nuova password",vS="Inserire la password",bS="Inserire l'indirizzo e-mail e la password per accedere.",xS="Inserire la password",kS="Il link magico è scaduto. Cliccate sul pulsante sottostante per ricevere un nuovo link nella vostra casella di posta elettronica.",SS="Abbiamo aggiornato la nostra esperienza di accesso. <0>Clicca qui per saperne di più.</0>",AS="Inviare l'e-mail di reimpostazione della password",zS="Fare clic sul pulsante sottostante per ricevere le istruzioni su come reimpostare la password.",ES="Email di reimpostazione della password inviata",IS="Hai dimenticato la password?",CS="Hai dimenticato la password?",NS="Torna indietro",jS="Nascondere la password",$S="Password non valida",OS=`Il link non è più valido.
250
+ You can click the link below to start a new login.`,Sk="Invalid link",Ak="Click the button to log in",zk="Login",Ek="Or enter the code at {{vendorName}} to complete the login.",Ik="Enter your email address to unlock this show on {{service}}",Ck="Link your account with {{service}}",Nk="You are logged in as",jk="Login",$k="Enter your email address to sign in.",Ok="Enter your email address and we will send you a login code.",Pk="Enter your email address and we will send you a login link.",Tk="Log out",Bk="No, I want to use another account",Rk="or",Lk="Password",Uk="The password has been reset",Vk="Success",qk="Change password for your {{vendorName}} account",Mk="Change password for your {{vendorName}} account",Hk="Phone number",Dk="Privacy Policy",Fk="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",e2="Change password for your {{vendorName}} account",t2="Reset password",n2="Send",r2="Send me a new magic link",i2="Remember to check your spam folder if the email did not arrive.",s2="Set password",o2="Show password",a2="Sign in",c2="Signup",l2="Sign up successful",d2="{{code}} is your login code for {{vendorName}}",u2="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.",p2="Go to Spotify's Content Access page",f2=`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.`,h2="Step 1: Unlink Your Spotify Account",g2="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.",m2="Step 2: Relink Your Spotify Account to Sesamy",_2="Oops! Your Spotify Account Is Already Linked",y2="If you have questions or need assistance, you can contact our support team",w2="Terms and Conditions",v2="Your email address needs validating. We have sent a new email to your inbox",b2="User account does not exist",x2="User account does not exist",k2="We could not find a user with the provided email address. Please, try again.",S2="Try again.",A2="Validate code",z2="Check your inbox for email validation instructions.",E2="Signed up",I2="Click the button to verify your email address",C2="Validate your email address",N2="Validate your email address",j2="Verify account",$2="Verify your email",O2="Welcome",P2="Welcome to your {{vendorName}} account!",T2="Please check your email at <0>{{email}}</0> and enter the six-digit code that we've sent you.",B2="Continue with this account",R2="Yes, continue with {{text}}",L2="Yes, continue with existing account",U2={account_detected:zx,account_with_sso_provider:Ex,agree_to:Ix,and:Cx,callback_url_mismatch:Nx,callback_url_not_allowed:jx,check_email_title:$x,click_to_sign_up_description:Ox,code_email_enter_code:Px,code_email_subject:Tx,code_email_title:Bx,code_valid_30_minutes:Rx,confirm_password:Lx,contact_support:Ux,contact_us:Vx,continue:"Continue",continue_social_login:qx,continue_with:Mx,continue_with_sso_provider_headline:Hx,copyright:Dx,copyright_sesamy:Fx,create_account_description:Kx,create_account_email_invalid:Wx,create_account_passwords_didnt_match:Gx,create_account_title:Jx,create_account_weak_password:Zx,create_new_account_link:Yx,create_password_account_title:Xx,currently_logged_in_as:Qx,email:ek,email_or_phone_placeholder:tk,email_placeholder:nk,email_validated:rk,email_validated_cta:ik,email_verification_for_signup_sent_description:sk,email_verification_for_signup_sent_title:ok,enter_a_code_btn:ak,enter_email_for_verification_description:ck,enter_new_password_placeholder:lk,enter_password:dk,enter_password_description:uk,enter_your_password_btn:pk,expired_code:fk,fokus_info_message:hk,forgot_password_cta:gk,forgot_password_description:mk,forgot_password_email_sent:_k,forgot_password_link:yk,forgot_password_title:wk,go_back:vk,hide_password:bk,"invalid-email":"Invalid email",invalid_password:xk,invalid_session_body:kk,invalid_session_title:Sk,link_email_click_to_login:Ak,link_email_login:zk,link_email_or_enter_code:Ek,link_page_body:Ik,link_page_headline:Ck,logged_in_as:Nk,login:jk,login_description:$k,login_description_code:Ok,login_description_link:Pk,logout:Tk,no_use_another:Bk,or:Rk,password:Lk,password_has_been_reset:Uk,password_has_been_reset_title:Vk,password_reset_subject:qk,password_reset_title:Mk,phone_placeholder:Hk,privacy_policy:Dk,redirecting:Fk,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:e2,reset_password_title:t2,send:n2,send_me_a_new_magic_link:r2,sent_code_spam:i2,"Server error: Invalid code":"Invalid code",set_password:s2,show_password:o2,sign_in:a2,signup:c2,signup_success:l2,sms_code_text:d2,spotify_already_linked_body:u2,spotify_already_linked_cta:p2,spotify_already_linked_step1_body:f2,spotify_already_linked_step1_title:h2,spotify_already_linked_step2_body:g2,spotify_already_linked_step2_title:m2,spotify_already_linked_title:_2,support_info:y2,terms:w2,unverified_email:v2,user_account_does_not_exist:b2,user_not_found:x2,user_not_found_body:k2,user_not_found_cta:S2,validate_code:A2,validate_email_body:z2,validate_email_title:E2,verify_email_click_to_verify:I2,verify_email_subject:C2,verify_email_title:N2,verify_email_verify:j2,verify_your_email:$2,welcome:O2,welcome_to_your_account:P2,we_sent_a_code_to:T2,"Wrong email or verification code":{"":"Wrong email or verification code."},yes_continue:B2,yes_continue_with:R2,yes_continue_with_existing_account:L2},V2="Account rilevato",q2="Abbiamo rilevato che l'utente ha già creato un account tramite",M2="Effettuando l'accesso, l'utente accetta la nostra",H2="e",D2="Mancata corrispondenza dell'URL di callback",F2="Il redirect_uri fornito non è nell'elenco degli URL di callback consentiti.",K2="continuare con l'utente",W2="Fare clic sul pulsante per creare un nuovo account con password.",G2="Inserite il codice all'indirizzo {{vendorName}} per completare il login.",J2="Benvenuti su {{vendorName}}! {{code}} è il codice di accesso",Z2="Benvenuti su {{vendorName}}! {{code}} è il codice di accesso",Y2="Il codice è valido per 30 minuti",X2="Confermare la password",Q2="Avete bisogno di aiuto?",eS="Contattateci",tS="o continuare con il conto sociale",nS="Continua con {{provider}}",rS="Desidera continuare a utilizzare l'account esistente?",iS="Copyright © 2023 SESAMY. Tutti i diritti riservati.",sS="©2023 Sesamy",oS="Scegliete una password con un mix di lettere maiuscole e minuscole, numeri e simboli.",aS="Inserire un indirizzo e-mail valido.",cS="Le password non corrispondono. Riprovare.",lS="Scegliere la password",dS="La password deve essere lunga almeno 8 caratteri e contenere almeno una lettera minuscola, una lettera maiuscola, un numero e un simbolo.",uS="Creare un nuovo account",pS="Iscriviti con la password",fS="Attualmente si è connessi come <0>{{email}}</0>",hS="Email",gS="Indirizzo e-mail o numero di telefono",mS="Indirizzo e-mail",_S="Il tuo indirizzo e-mail è stato convalidato",yS="Ora inserire la password per accedere nuovamente",wS="È 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.",vS="Email di verifica inviata",bS="Inserire un codice",xS="Vi invieremo un link di verifica per assicurarvi di possedere questo indirizzo e-mail.",kS="Inserire la nuova password",SS="Inserire la password",AS="Inserire l'indirizzo e-mail e la password per accedere.",zS="Inserire la password",ES="Il link magico è scaduto. Cliccate sul pulsante sottostante per ricevere un nuovo link nella vostra casella di posta elettronica.",IS="Abbiamo aggiornato la nostra esperienza di accesso. <0>Clicca qui per saperne di più.</0>",CS="Inviare l'e-mail di reimpostazione della password",NS="Fare clic sul pulsante sottostante per ricevere le istruzioni su come reimpostare la password.",jS="Email di reimpostazione della password inviata",$S="Hai dimenticato la password?",OS="Hai dimenticato la password?",PS="Torna indietro",TS="Nascondere la password",BS="Password non valida",RS=`Il link non è più valido.
249
251
 
250
252
  Assicuratevi di aprire il link di accesso con lo stesso browser con cui avete iniziato l'accesso.
251
253
 
252
- Potete fare clic sul link sottostante per iniziare un nuovo accesso.`,PS="Collegamento non valido",TS="Fare clic sul pulsante per accedere",BS="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",qS="Accesso",MS="Inserire l'indirizzo e-mail per accedere.",HS="Inserite il vostro indirizzo e-mail e vi invieremo un codice di accesso.",DS="Inserite il vostro indirizzo e-mail e vi invieremo un link di accesso.",FS="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="Numero di telefono",eA="Informativa sulla privacy",tA="Reindirizzamento",nA="Confermare la password",rA="Registrazione di una nuova password",iA="Reinvio del codice",sA="Modifica della password",oA="Immettere di seguito la nuova password per l'account e-mail: ",aA="Fare clic sul pulsante per reimpostare la password",cA="Fare clic sul pulsante per reimpostare la password",lA="Reimpostare la password",dA="Modifica della password dell'account {{vendorName}} ",uA="Reimpostare la password",pA="Inviare",fA="Inviami un nuovo link magico",hA="Ricordate di controllare la cartella spam se l'e-mail non è arrivata.",gA="Impostare la password",mA="Mostra password",_A="Accedi",yA="Iscriviti",wA="Iscriviti con successo",vA="{{code}} è il codice di accesso per {{vendorName}}",bA="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.",xA="Vai alla pagina di accesso ai contenuti di Spotify",kA=`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.`,SA="Passo 1: Disconnettere l'account Spotify",AA="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.",zA="Passo 2: ricollegare l'account Spotify a Sesamy",EA="Ops! Il tuo account Spotify è già collegato",IA="Se avete domande o bisogno di assistenza, potete contattare il nostro team di supporto",CA="Termini e condizioni",NA="Il tuo indirizzo e-mail deve essere convalidato. Abbiamo inviato una nuova e-mail alla tua casella di posta.",jA="L'account utente non esiste",$A="L'account utente non esiste",OA="Non è stato possibile trovare un utente con l'indirizzo e-mail fornito. Si prega di riprovare.",PA="Riprova.",TA="Convalida del codice",BA="Controllate la vostra casella di posta per le istruzioni di convalida dell'e-mail.",RA="Iscritta",LA="Fare clic sul pulsante per verificare l'indirizzo e-mail",UA="Convalidare l'indirizzo e-mail",VA="Convalidare l'indirizzo e-mail",qA="Verifica dell'account",MA="Verificare l'e-mail",HA="Benvenuti",DA="Benvenuto nel tuo account {{vendorName}}!",FA="Controllate la vostra e-mail all'indirizzo <0>{{email}}</0> e inserisca il codice a sei cifre che le abbiamo inviato.",KA="Continuare con questo account",WA="Sì, continuare con {{text}}",GA="Sì, continuare con l'account esistente",JA={account_detected:B2,account_with_sso_provider:R2,agree_to:L2,and:U2,callback_url_mismatch:V2,callback_url_not_allowed:q2,check_email_title:M2,click_to_sign_up_description:H2,code_email_enter_code:D2,code_email_subject:F2,code_email_title:K2,code_valid_30_minutes:W2,confirm_password:G2,contact_support:J2,contact_us:Z2,continue:"Continua",continue_social_login:Y2,continue_with:X2,continue_with_sso_provider_headline:Q2,copyright:eS,copyright_sesamy:tS,create_account_description:nS,create_account_email_invalid:rS,create_account_passwords_didnt_match:iS,create_account_title:sS,create_account_weak_password:oS,create_new_account_link:aS,create_password_account_title:cS,currently_logged_in_as:lS,email:dS,email_or_phone_placeholder:uS,email_placeholder:pS,email_validated:fS,email_validated_cta:hS,email_verification_for_signup_sent_description:gS,email_verification_for_signup_sent_title:mS,enter_a_code_btn:_S,enter_email_for_verification_description:yS,enter_new_password_placeholder:wS,enter_password:vS,enter_password_description:bS,enter_your_password_btn:xS,expired_code:kS,fokus_info_message:SS,forgot_password_cta:AS,forgot_password_description:zS,forgot_password_email_sent:ES,forgot_password_link:IS,forgot_password_title:CS,go_back:NS,hide_password:jS,"invalid-email":"Email non valida",invalid_password:$S,invalid_session_body:OS,invalid_session_title:PS,link_email_click_to_login:TS,link_email_login:BS,link_email_or_enter_code:RS,link_page_body:LS,link_page_headline:US,logged_in_as:VS,login:qS,login_description:MS,login_description_code:HS,login_description_link:DS,logout:FS,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,phone_placeholder:QS,privacy_policy:eA,redirecting:tA,reenter_new_password_placeholder:nA,register_password_account:rA,resend_code:iA,reset_password_cta:sA,reset_password_description:oA,reset_password_email_click_to_reset:aA,reset_password_email_cta:cA,reset_password_email_reset:lA,reset_password_subject:dA,reset_password_title:uA,send:pA,send_me_a_new_magic_link:fA,sent_code_spam:hA,"Server error: Invalid code":"Codice non valido",set_password:gA,show_password:mA,sign_in:_A,signup:yA,signup_success:wA,sms_code_text:vA,spotify_already_linked_body:bA,spotify_already_linked_cta:xA,spotify_already_linked_step1_body:kA,spotify_already_linked_step1_title:SA,spotify_already_linked_step2_body:AA,spotify_already_linked_step2_title:zA,spotify_already_linked_title:EA,support_info:IA,terms:CA,unverified_email:NA,user_account_does_not_exist:jA,user_not_found:$A,user_not_found_body:OA,user_not_found_cta:PA,validate_code:TA,validate_email_body:BA,validate_email_title:RA,verify_email_click_to_verify:LA,verify_email_subject:UA,verify_email_title:VA,verify_email_verify:qA,verify_your_email:MA,welcome:HA,welcome_to_your_account:DA,we_sent_a_code_to:FA,"Wrong email or verification code":{"":"Email o codice di verifica errati."},yes_continue:KA,yes_continue_with:WA,yes_continue_with_existing_account:GA},ZA="Konto oppdaget",YA="Vi har oppdaget at du allerede har opprettet en konto gjennom",XA="Ved å logge på godtar du våre",QA="og",e4="Callback-URLen samsvarer ikke",t4="Den oppgitte redirect_uri er ikke på listen over tillatte tilbakeringings-URLer.",n4="fortsett med bruker",r4="Klikk på knappen for å opprette en ny passordkonto.",i4="Skriv inn koden på {{vendorName}} for å fullføre påloggingen",s4="Velkommen til {{vendorName}} ! {{code}} er påloggingskoden",o4="Velkommen til {{vendorName}}! {{code}} er påloggingskoden",a4="Koden er gyldig i 30 minutter",c4="Bekreft passord",l4="Trenger hjelp?",d4="Kontakt oss",u4="eller fortsett med sosial konto",p4="Fortsett med {{provider}}",f4="Vil du fortsette med din eksisterende konto?",h4="Opphavsrett © 2023 SESAMY. Alle rettigheter forbeholdt.",g4="©2023 Sesamy",m4="Velg et passord med en blanding av store og små bokstaver, tall og symboler.",_4="Vennligst skriv inn en gyldig e-postadresse.",y4="Passordene stemte ikke overens. Prøv igjen.",w4="Velg passord",v4="Passordet må være på minst 8 tegn og inneholde minst én liten bokstav, én stor bokstav, ett tall og ett symbol.",b4="Opprett ny konto",x4="Registrer deg med passord",k4="Du er logget på som <0> {{email}}</0>",S4="E-post",A4="E-post eller telefonnummer",z4="E-postadresse",E4="E-postadressen din har blitt validert",I4="Skriv nå inn passordet ditt for å logge inn igjen",C4="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.",N4="E-postbekreftelse sendt",j4="Angi en kode",$4="Vi sender deg en bekreftelseskobling for å sikre at du eier denne e-postadressen.",O4="Skriv inn nytt passord",P4="Oppgi passord",T4="Skriv inn e-postadressen og passordet ditt for å logge inn.",B4="Skriv inn passordet ditt",R4="Den magiske lenken er utløpt. Vennligst klikk på knappen nedenfor for å motta en ny lenke i innboksen din.",L4="Hei! Vi oppdaterte påloggingsopplevelsen vår. <0>Klikk her for å lære mer om det.</0>",U4="Send e-post om tilbakestilling av passord",V4="Klikk på knappen nedenfor, så sender vi deg instruksjoner om hvordan du tilbakestiller passordet ditt.",q4="E-post om tilbakestilling av passord sendt",M4="Har du glemt passordet?",H4="Har du glemt passordet?",D4="Gå tilbake",F4="Skjul passord",K4="Ugyldig passord",W4=`Lenken er ikke lenger gyldig.
254
+ Potete fare clic sul link sottostante per iniziare un nuovo accesso.`,LS="Collegamento non valido",US="Fare clic sul pulsante per accedere",VS="Accedi",qS="Oppure inserire il codice all'indirizzo {{vendorName}} per completare il login.",MS="Inserisci il tuo indirizzo e-mail per sbloccare questo spettacolo su {{service}}",HS="Collegate il vostro account con {{service}}",DS="L'utente ha effettuato l'accesso come",FS="Accesso",KS="Inserire l'indirizzo e-mail per accedere.",WS="Inserite il vostro indirizzo e-mail e vi invieremo un codice di accesso.",GS="Inserite il vostro indirizzo e-mail e vi invieremo un link di accesso.",JS="Disconnettersi",ZS="No, voglio usare un altro account",YS="o",XS="Password",QS="La password è stata reimpostata",eA="Il successo",tA="Modifica della password dell'account {{vendorName}}",nA="Modifica della password dell'account {{vendorName}} ",rA="Numero di telefono",iA="Informativa sulla privacy",sA="Reindirizzamento",oA="Confermare la password",aA="Registrazione di una nuova password",cA="Reinvio del codice",lA="Modifica della password",dA="Immettere di seguito la nuova password per l'account e-mail: ",uA="Fare clic sul pulsante per reimpostare la password",pA="Fare clic sul pulsante per reimpostare la password",fA="Reimpostare la password",hA="Modifica della password dell'account {{vendorName}} ",gA="Reimpostare la password",mA="Inviare",_A="Inviami un nuovo link magico",yA="Ricordate di controllare la cartella spam se l'e-mail non è arrivata.",wA="Impostare la password",vA="Mostra password",bA="Accedi",xA="Iscriviti",kA="Iscriviti con successo",SA="{{code}} è il codice di accesso per {{vendorName}}",AA="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.",zA="Vai alla pagina di accesso ai contenuti di Spotify",EA=`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.`,IA="Passo 1: Disconnettere l'account Spotify",CA="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.",NA="Passo 2: ricollegare l'account Spotify a Sesamy",jA="Ops! Il tuo account Spotify è già collegato",$A="Se avete domande o bisogno di assistenza, potete contattare il nostro team di supporto",OA="Termini e condizioni",PA="Il tuo indirizzo e-mail deve essere convalidato. Abbiamo inviato una nuova e-mail alla tua casella di posta.",TA="L'account utente non esiste",BA="L'account utente non esiste",RA="Non è stato possibile trovare un utente con l'indirizzo e-mail fornito. Si prega di riprovare.",LA="Riprova.",UA="Convalida del codice",VA="Controllate la vostra casella di posta per le istruzioni di convalida dell'e-mail.",qA="Iscritta",MA="Fare clic sul pulsante per verificare l'indirizzo e-mail",HA="Convalidare l'indirizzo e-mail",DA="Convalidare l'indirizzo e-mail",FA="Verifica dell'account",KA="Verificare l'e-mail",WA="Benvenuti",GA="Benvenuto nel tuo account {{vendorName}}!",JA="Controllate la vostra e-mail all'indirizzo <0>{{email}}</0> e inserisca il codice a sei cifre che le abbiamo inviato.",ZA="Continuare con questo account",YA="Sì, continuare con {{text}}",XA="Sì, continuare con l'account esistente",QA={account_detected:V2,account_with_sso_provider:q2,agree_to:M2,and:H2,callback_url_mismatch:D2,callback_url_not_allowed:F2,check_email_title:K2,click_to_sign_up_description:W2,code_email_enter_code:G2,code_email_subject:J2,code_email_title:Z2,code_valid_30_minutes:Y2,confirm_password:X2,contact_support:Q2,contact_us:eS,continue:"Continua",continue_social_login:tS,continue_with:nS,continue_with_sso_provider_headline:rS,copyright:iS,copyright_sesamy:sS,create_account_description:oS,create_account_email_invalid:aS,create_account_passwords_didnt_match:cS,create_account_title:lS,create_account_weak_password:dS,create_new_account_link:uS,create_password_account_title:pS,currently_logged_in_as:fS,email:hS,email_or_phone_placeholder:gS,email_placeholder:mS,email_validated:_S,email_validated_cta:yS,email_verification_for_signup_sent_description:wS,email_verification_for_signup_sent_title:vS,enter_a_code_btn:bS,enter_email_for_verification_description:xS,enter_new_password_placeholder:kS,enter_password:SS,enter_password_description:AS,enter_your_password_btn:zS,expired_code:ES,fokus_info_message:IS,forgot_password_cta:CS,forgot_password_description:NS,forgot_password_email_sent:jS,forgot_password_link:$S,forgot_password_title:OS,go_back:PS,hide_password:TS,"invalid-email":"Email non valida",invalid_password:BS,invalid_session_body:RS,invalid_session_title:LS,link_email_click_to_login:US,link_email_login:VS,link_email_or_enter_code:qS,link_page_body:MS,link_page_headline:HS,logged_in_as:DS,login:FS,login_description:KS,login_description_code:WS,login_description_link:GS,logout:JS,no_use_another:ZS,or:YS,password:XS,password_has_been_reset:QS,password_has_been_reset_title:eA,password_reset_subject:tA,password_reset_title:nA,phone_placeholder:rA,privacy_policy:iA,redirecting:sA,reenter_new_password_placeholder:oA,register_password_account:aA,resend_code:cA,reset_password_cta:lA,reset_password_description:dA,reset_password_email_click_to_reset:uA,reset_password_email_cta:pA,reset_password_email_reset:fA,reset_password_subject:hA,reset_password_title:gA,send:mA,send_me_a_new_magic_link:_A,sent_code_spam:yA,"Server error: Invalid code":"Codice non valido",set_password:wA,show_password:vA,sign_in:bA,signup:xA,signup_success:kA,sms_code_text:SA,spotify_already_linked_body:AA,spotify_already_linked_cta:zA,spotify_already_linked_step1_body:EA,spotify_already_linked_step1_title:IA,spotify_already_linked_step2_body:CA,spotify_already_linked_step2_title:NA,spotify_already_linked_title:jA,support_info:$A,terms:OA,unverified_email:PA,user_account_does_not_exist:TA,user_not_found:BA,user_not_found_body:RA,user_not_found_cta:LA,validate_code:UA,validate_email_body:VA,validate_email_title:qA,verify_email_click_to_verify:MA,verify_email_subject:HA,verify_email_title:DA,verify_email_verify:FA,verify_your_email:KA,welcome:WA,welcome_to_your_account:GA,we_sent_a_code_to:JA,"Wrong email or verification code":{"":"Email o codice di verifica errati."},yes_continue:ZA,yes_continue_with:YA,yes_continue_with_existing_account:XA},e4="Konto oppdaget",t4="Vi har oppdaget at du allerede har opprettet en konto gjennom",n4="Ved å logge på godtar du våre",r4="og",i4="Callback-URLen samsvarer ikke",s4="Den oppgitte redirect_uri er ikke på listen over tillatte tilbakeringings-URLer.",o4="fortsett med bruker",a4="Klikk på knappen for å opprette en ny passordkonto.",c4="Skriv inn koden på {{vendorName}} for å fullføre påloggingen",l4="Velkommen til {{vendorName}} ! {{code}} er påloggingskoden",d4="Velkommen til {{vendorName}}! {{code}} er påloggingskoden",u4="Koden er gyldig i 30 minutter",p4="Bekreft passord",f4="Trenger hjelp?",h4="Kontakt oss",g4="eller fortsett med sosial konto",m4="Fortsett med {{provider}}",_4="Vil du fortsette med din eksisterende konto?",y4="Opphavsrett © 2023 SESAMY. Alle rettigheter forbeholdt.",w4="©2023 Sesamy",v4="Velg et passord med en blanding av store og små bokstaver, tall og symboler.",b4="Vennligst skriv inn en gyldig e-postadresse.",x4="Passordene stemte ikke overens. Prøv igjen.",k4="Velg passord",S4="Passordet må være på minst 8 tegn og inneholde minst én liten bokstav, én stor bokstav, ett tall og ett symbol.",A4="Opprett ny konto",z4="Registrer deg med passord",E4="Du er logget på som <0> {{email}}</0>",I4="E-post",C4="E-post eller telefonnummer",N4="E-postadresse",j4="E-postadressen din har blitt validert",$4="Skriv nå inn passordet ditt for å logge inn igjen",O4="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.",P4="E-postbekreftelse sendt",T4="Angi en kode",B4="Vi sender deg en bekreftelseskobling for å sikre at du eier denne e-postadressen.",R4="Skriv inn nytt passord",L4="Oppgi passord",U4="Skriv inn e-postadressen og passordet ditt for å logge inn.",V4="Skriv inn passordet ditt",q4="Den magiske lenken er utløpt. Vennligst klikk på knappen nedenfor for å motta en ny lenke i innboksen din.",M4="Hei! Vi oppdaterte påloggingsopplevelsen vår. <0>Klikk her for å lære mer om det.</0>",H4="Send e-post om tilbakestilling av passord",D4="Klikk på knappen nedenfor, så sender vi deg instruksjoner om hvordan du tilbakestiller passordet ditt.",F4="E-post om tilbakestilling av passord sendt",K4="Har du glemt passordet?",W4="Har du glemt passordet?",G4="Gå tilbake",J4="Skjul passord",Z4="Ugyldig passord",Y4=`Lenken er ikke lenger gyldig.
253
255
 
254
256
  Sørg for å åpne påloggingslenken i samme nettleser som du startet påloggingen med.
255
257
 
256
- Du kan klikke på lenken nedenfor for å starte en ny pålogging.`,G4="Ugyldig lenke",J4="Klikk på knappen for å logge inn",Z4="Logg inn",Y4="Eller skriv inn koden på {{vendorName}} for å fullføre påloggingen.",X4="Skriv inn e-postadressen din for å låse opp dette programmet på {{service}}",Q4="Koble kontoen din til {{service}}",e3="Du er innlogget som",t3="Logg inn",n3="Skriv inn e-postadressen din for å logge på.",r3="Skriv inn e-postadressen din og vi sender deg en påloggingskode.",i3="Skriv inn e-postadressen din og vi sender deg en påloggingslenke.",s3="Logg ut",o3="Nei, jeg vil bruke en annen konto",a3="eller",c3="Passord",l3="Passordet har blitt tilbakestilt",d3="Suksess",u3="Endre passord for {{vendorName}} kontoen din",p3="Endre passord for {{vendorName}} kontoen din",f3="Telefonnummer",h3="Personvernerklæring",g3="Omdirigerer",m3="Bekreft passord",_3="Registrer et nytt passord",y3="Send kode på nytt",w3="Endre passord",v3="Skriv inn det nye passordet for e-postkontoen nedenfor: ",b3="Klikk på knappen for å tilbakestille passordet ditt",x3="Klikk på knappen for å tilbakestille passordet ditt",k3="Tilbakestill passordet ditt",S3="Endre passord for {{vendorName}} -kontoen din",A3="Tilbakestill passord",z3="Send",E3="Send meg en ny magisk lenke",I3="Husk å sjekke søppelpostmappen din hvis e-posten ikke kom.",C3="Angi passord",N3="Vis passord",j3="Logg inn",$3="Påmelding",O3="Vellykket registrering",P3="{{code}} er innloggingskoden din for {{vendorName}}",T3="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.",B3="Gå til Spotifys innholdstilgangsside",R3='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.',L3="Trinn 1: Koble fra Spotify-kontoen din",U3="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.",V3="Trinn 2: Koble Spotify-kontoen din til Sesamy på nytt",q3="Oops! Spotify-kontoen din er allerede koblet",M3="Hvis du har spørsmål eller trenger hjelp, kan du kontakte supportteamet vårt",H3="vilkår",D3="E-postadressen din må bekreftes. Vi har sendt en ny e-post til innboksen din.",F3="Brukerkonto eksisterer ikke",K3="Brukerkonto eksisterer ikke",W3="Vi kunne ikke finne en bruker med den oppgitte e-postadressen. Vær så snill, prøv på nytt.",G3="Prøv igjen.",J3="Bekreft koden",Z3="Sjekk innboksen din for instruksjoner om e-postvalidering.",Y3="Registrerte seg",X3="Klikk på knappen for å bekrefte e-postadressen din",Q3="Bekreft e-postadressen din",ez="Bekreft e-postadressen din",tz="Bekreft konto",nz="Bekreft e-posten din",rz="Velkommen",iz="Velkommen til din brukerkonto hos {{vendorName}} !",sz="Vennligst sjekk e-posten din på <0>{{email}}</0> og skriv inn den sekssifrede koden som vi har sendt deg.",oz="Fortsett med denne kontoen",az="Ja, fortsett med {{text}}",cz="Ja, fortsett med eksisterende konto",lz={account_detected:ZA,account_with_sso_provider:YA,agree_to:XA,and:QA,callback_url_mismatch:e4,callback_url_not_allowed:t4,check_email_title:n4,click_to_sign_up_description:r4,code_email_enter_code:i4,code_email_subject:s4,code_email_title:o4,code_valid_30_minutes:a4,confirm_password:c4,contact_support:l4,contact_us:d4,continue:"Fortsette",continue_social_login:u4,continue_with:p4,continue_with_sso_provider_headline:f4,copyright:h4,copyright_sesamy:g4,create_account_description:m4,create_account_email_invalid:_4,create_account_passwords_didnt_match:y4,create_account_title:w4,create_account_weak_password:v4,create_new_account_link:b4,create_password_account_title:x4,currently_logged_in_as:k4,email:S4,email_or_phone_placeholder:A4,email_placeholder:z4,email_validated:E4,email_validated_cta:I4,email_verification_for_signup_sent_description:C4,email_verification_for_signup_sent_title:N4,enter_a_code_btn:j4,enter_email_for_verification_description:$4,enter_new_password_placeholder:O4,enter_password:P4,enter_password_description:T4,enter_your_password_btn:B4,expired_code:R4,fokus_info_message:L4,forgot_password_cta:U4,forgot_password_description:V4,forgot_password_email_sent:q4,forgot_password_link:M4,forgot_password_title:H4,go_back:D4,hide_password:F4,"invalid-email":"Ugyldig epost",invalid_password:K4,invalid_session_body:W4,invalid_session_title:G4,link_email_click_to_login:J4,link_email_login:Z4,link_email_or_enter_code:Y4,link_page_body:X4,link_page_headline:Q4,logged_in_as:e3,login:t3,login_description:n3,login_description_code:r3,login_description_link:i3,logout:s3,no_use_another:o3,or:a3,password:c3,password_has_been_reset:l3,password_has_been_reset_title:d3,password_reset_subject:u3,password_reset_title:p3,phone_placeholder:f3,privacy_policy:h3,redirecting:g3,reenter_new_password_placeholder:m3,register_password_account:_3,resend_code:y3,reset_password_cta:w3,reset_password_description:v3,reset_password_email_click_to_reset:b3,reset_password_email_cta:x3,reset_password_email_reset:k3,reset_password_subject:S3,reset_password_title:A3,send:z3,send_me_a_new_magic_link:E3,sent_code_spam:I3,"Server error: Invalid code":"Ugyldig kode",set_password:C3,show_password:N3,sign_in:j3,signup:$3,signup_success:O3,sms_code_text:P3,spotify_already_linked_body:T3,spotify_already_linked_cta:B3,spotify_already_linked_step1_body:R3,spotify_already_linked_step1_title:L3,spotify_already_linked_step2_body:U3,spotify_already_linked_step2_title:V3,spotify_already_linked_title:q3,support_info:M3,terms:H3,unverified_email:D3,user_account_does_not_exist:F3,user_not_found:K3,user_not_found_body:W3,user_not_found_cta:G3,validate_code:J3,validate_email_body:Z3,validate_email_title:Y3,verify_email_click_to_verify:X3,verify_email_subject:Q3,verify_email_title:ez,verify_email_verify:tz,verify_your_email:nz,welcome:rz,welcome_to_your_account:iz,we_sent_a_code_to:sz,"Wrong email or verification code":{"":"Feil e-post eller bekreftelseskode."},yes_continue:oz,yes_continue_with:az,yes_continue_with_existing_account:cz},dz="Fortsätt med existerande konto",uz="Det verkar som att du redan har skapat ett konto genom",pz="Genom att logga in godkänner du våra",fz="och",hz="Callback URL mismatch",gz="The provided redirect_uri is not in the list of allowed callback URLs.",mz="fortsätt med användaren",_z="Klicka på knappen för att skapa ett nytt lösenordskonto.",yz="Skriv in koden på {{vendorName}} för att slutföra inloggningen",wz="Välkommen till {{vendorName}}! {{code}} är koden för att logga in",vz="Välkommen till {{vendorName}}! {{code}} är koden för att logga in",bz="Koden är giltig i 30 minuter",xz="Bekräfta lösenord",kz="Behöver du hjälp?",Sz="Kontakta oss",Az="eller via sociala medier",zz="Fortsätt med {{provider}}",Ez="Vill du fortsätta med det här kontot?",Iz="Copyright © 2023 SESAMY. Alla rättigheter förbehållna.",Cz="©2023 Sesamy",Nz="Välj ett lösenord med en blandning av stora och små bokstäver, siffror och symboler.",jz="Ange en giltig e-postadress.",$z="Lösenorden stämde inte överens. Försök igen.",Oz="Välj lösenord",Pz="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.",Tz="Skapa nytt konto",Bz="Registrera dig med lösenord",Rz="Du är inloggad som <0>{{email}}</0>",Lz="E-postadress",Uz="E-post eller telefonnummer",Vz="E-postadress",qz="Din e-postadress har validerats",Mz="Ange nu ditt lösenord för att logga in igen",Hz="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.",Dz="E-postverifiering skickad",Fz="Logga in med kod",Kz="Vi skickar dig en verifieringslänk för att säkerställa att du äger den här e-postadressen.",Wz="Ange nytt lösenord",Gz="Ange lösenord",Jz="Ange din e-postadress och ditt lösenord för att logga in.",Zz="Logga in med lösenord",Yz="Länken är inte längre giltig. Klicka på knappen för att skicka en ny länk till din epost.",Xz="Vi har bytt inloggningssystem, <0>här kan du läsa mer om vad det innebär</0>",Qz="Skicka",e6="Klicka på knappen nedan så skickar vi instruktioner om hur du återställer ditt lösenord.",t6="Vi har skickat ett e-postmeddelande med instruktioner om hur du återställer ditt lösenord till den e-postadress du angav.",n6="Har du glömt lösenordet?",r6="Har du glömt lösenordet?",i6="Gå tillbaka",s6="Dölj lösenord",o6="Ogiltigt lösenord",a6=`Länken är inte längre giltig.
258
+ Du kan klikke på lenken nedenfor for å starte en ny pålogging.`,X4="Ugyldig lenke",Q4="Klikk på knappen for å logge inn",e3="Logg inn",t3="Eller skriv inn koden på {{vendorName}} for å fullføre påloggingen.",n3="Skriv inn e-postadressen din for å låse opp dette programmet på {{service}}",r3="Koble kontoen din til {{service}}",i3="Du er innlogget som",s3="Logg inn",o3="Skriv inn e-postadressen din for å logge på.",a3="Skriv inn e-postadressen din og vi sender deg en påloggingskode.",c3="Skriv inn e-postadressen din og vi sender deg en påloggingslenke.",l3="Logg ut",d3="Nei, jeg vil bruke en annen konto",u3="eller",p3="Passord",f3="Passordet har blitt tilbakestilt",h3="Suksess",g3="Endre passord for {{vendorName}} kontoen din",m3="Endre passord for {{vendorName}} kontoen din",_3="Telefonnummer",y3="Personvernerklæring",w3="Omdirigerer",v3="Bekreft passord",b3="Registrer et nytt passord",x3="Send kode på nytt",k3="Endre passord",S3="Skriv inn det nye passordet for e-postkontoen nedenfor: ",A3="Klikk på knappen for å tilbakestille passordet ditt",z3="Klikk på knappen for å tilbakestille passordet ditt",E3="Tilbakestill passordet ditt",I3="Endre passord for {{vendorName}} -kontoen din",C3="Tilbakestill passord",N3="Send",j3="Send meg en ny magisk lenke",$3="Husk å sjekke søppelpostmappen din hvis e-posten ikke kom.",O3="Angi passord",P3="Vis passord",T3="Logg inn",B3="Påmelding",R3="Vellykket registrering",L3="{{code}} er innloggingskoden din for {{vendorName}}",U3="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.",V3="Gå til Spotifys innholdstilgangsside",q3='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.',M3="Trinn 1: Koble fra Spotify-kontoen din",H3="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.",D3="Trinn 2: Koble Spotify-kontoen din til Sesamy på nytt",F3="Oops! Spotify-kontoen din er allerede koblet",K3="Hvis du har spørsmål eller trenger hjelp, kan du kontakte supportteamet vårt",W3="vilkår",G3="E-postadressen din må bekreftes. Vi har sendt en ny e-post til innboksen din.",J3="Brukerkonto eksisterer ikke",Z3="Brukerkonto eksisterer ikke",Y3="Vi kunne ikke finne en bruker med den oppgitte e-postadressen. Vær så snill, prøv på nytt.",X3="Prøv igjen.",Q3="Bekreft koden",ez="Sjekk innboksen din for instruksjoner om e-postvalidering.",tz="Registrerte seg",nz="Klikk på knappen for å bekrefte e-postadressen din",rz="Bekreft e-postadressen din",iz="Bekreft e-postadressen din",sz="Bekreft konto",oz="Bekreft e-posten din",az="Velkommen",cz="Velkommen til din brukerkonto hos {{vendorName}} !",lz="Vennligst sjekk e-posten din på <0>{{email}}</0> og skriv inn den sekssifrede koden som vi har sendt deg.",dz="Fortsett med denne kontoen",uz="Ja, fortsett med {{text}}",pz="Ja, fortsett med eksisterende konto",fz={account_detected:e4,account_with_sso_provider:t4,agree_to:n4,and:r4,callback_url_mismatch:i4,callback_url_not_allowed:s4,check_email_title:o4,click_to_sign_up_description:a4,code_email_enter_code:c4,code_email_subject:l4,code_email_title:d4,code_valid_30_minutes:u4,confirm_password:p4,contact_support:f4,contact_us:h4,continue:"Fortsette",continue_social_login:g4,continue_with:m4,continue_with_sso_provider_headline:_4,copyright:y4,copyright_sesamy:w4,create_account_description:v4,create_account_email_invalid:b4,create_account_passwords_didnt_match:x4,create_account_title:k4,create_account_weak_password:S4,create_new_account_link:A4,create_password_account_title:z4,currently_logged_in_as:E4,email:I4,email_or_phone_placeholder:C4,email_placeholder:N4,email_validated:j4,email_validated_cta:$4,email_verification_for_signup_sent_description:O4,email_verification_for_signup_sent_title:P4,enter_a_code_btn:T4,enter_email_for_verification_description:B4,enter_new_password_placeholder:R4,enter_password:L4,enter_password_description:U4,enter_your_password_btn:V4,expired_code:q4,fokus_info_message:M4,forgot_password_cta:H4,forgot_password_description:D4,forgot_password_email_sent:F4,forgot_password_link:K4,forgot_password_title:W4,go_back:G4,hide_password:J4,"invalid-email":"Ugyldig epost",invalid_password:Z4,invalid_session_body:Y4,invalid_session_title:X4,link_email_click_to_login:Q4,link_email_login:e3,link_email_or_enter_code:t3,link_page_body:n3,link_page_headline:r3,logged_in_as:i3,login:s3,login_description:o3,login_description_code:a3,login_description_link:c3,logout:l3,no_use_another:d3,or:u3,password:p3,password_has_been_reset:f3,password_has_been_reset_title:h3,password_reset_subject:g3,password_reset_title:m3,phone_placeholder:_3,privacy_policy:y3,redirecting:w3,reenter_new_password_placeholder:v3,register_password_account:b3,resend_code:x3,reset_password_cta:k3,reset_password_description:S3,reset_password_email_click_to_reset:A3,reset_password_email_cta:z3,reset_password_email_reset:E3,reset_password_subject:I3,reset_password_title:C3,send:N3,send_me_a_new_magic_link:j3,sent_code_spam:$3,"Server error: Invalid code":"Ugyldig kode",set_password:O3,show_password:P3,sign_in:T3,signup:B3,signup_success:R3,sms_code_text:L3,spotify_already_linked_body:U3,spotify_already_linked_cta:V3,spotify_already_linked_step1_body:q3,spotify_already_linked_step1_title:M3,spotify_already_linked_step2_body:H3,spotify_already_linked_step2_title:D3,spotify_already_linked_title:F3,support_info:K3,terms:W3,unverified_email:G3,user_account_does_not_exist:J3,user_not_found:Z3,user_not_found_body:Y3,user_not_found_cta:X3,validate_code:Q3,validate_email_body:ez,validate_email_title:tz,verify_email_click_to_verify:nz,verify_email_subject:rz,verify_email_title:iz,verify_email_verify:sz,verify_your_email:oz,welcome:az,welcome_to_your_account:cz,we_sent_a_code_to:lz,"Wrong email or verification code":{"":"Feil e-post eller bekreftelseskode."},yes_continue:dz,yes_continue_with:uz,yes_continue_with_existing_account:pz},hz="Fortsätt med existerande konto",gz="Det verkar som att du redan har skapat ett konto genom",mz="Genom att logga in godkänner du våra",_z="och",yz="Callback URL mismatch",wz="The provided redirect_uri is not in the list of allowed callback URLs.",vz="fortsätt med användaren",bz="Klicka på knappen för att skapa ett nytt lösenordskonto.",xz="Skriv in koden på {{vendorName}} för att slutföra inloggningen",kz="Välkommen till {{vendorName}}! {{code}} är koden för att logga in",Sz="Välkommen till {{vendorName}}! {{code}} är koden för att logga in",Az="Koden är giltig i 30 minuter",zz="Bekräfta lösenord",Ez="Behöver du hjälp?",Iz="Kontakta oss",Cz="eller via sociala medier",Nz="Fortsätt med {{provider}}",jz="Vill du fortsätta med det här kontot?",$z="Copyright © 2023 SESAMY. Alla rättigheter förbehållna.",Oz="©2023 Sesamy",Pz="Välj ett lösenord med en blandning av stora och små bokstäver, siffror och symboler.",Tz="Ange en giltig e-postadress.",Bz="Lösenorden stämde inte överens. Försök igen.",Rz="Välj lösenord",Lz="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.",Uz="Skapa nytt konto",Vz="Registrera dig med lösenord",qz="Du är inloggad som <0>{{email}}</0>",Mz="E-postadress",Hz="E-post eller telefonnummer",Dz="E-postadress",Fz="Din e-postadress har validerats",Kz="Ange nu ditt lösenord för att logga in igen",Wz="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.",Gz="E-postverifiering skickad",Jz="Logga in med kod",Zz="Vi skickar dig en verifieringslänk för att säkerställa att du äger den här e-postadressen.",Yz="Ange nytt lösenord",Xz="Ange lösenord",Qz="Ange din e-postadress och ditt lösenord för att logga in.",e6="Logga in med lösenord",t6="Länken är inte längre giltig. Klicka på knappen för att skicka en ny länk till din epost.",n6="Vi har bytt inloggningssystem, <0>här kan du läsa mer om vad det innebär</0>",r6="Skicka",i6="Klicka på knappen nedan så skickar vi instruktioner om hur du återställer ditt lösenord.",s6="Vi har skickat ett e-postmeddelande med instruktioner om hur du återställer ditt lösenord till den e-postadress du angav.",o6="Har du glömt lösenordet?",a6="Har du glömt lösenordet?",c6="Gå tillbaka",l6="Dölj lösenord",d6="Ogiltigt lösenord",u6=`Länken är inte längre giltig.
257
259
 
258
260
  Vänligen se till att öppna inloggningslänken i samma webbläsare som du startade inloggningen med.
259
261
 
260
- Du kan klicka på länken nedan för att starta en ny inloggning.`,c6="Ogiltig länk",l6="Klicka på knappen för att logga in",d6="Logga in",u6="Eller skriv in koden på {{vendorName}} för att slutföra inloggningen.",p6="Ange din epost för att låsa upp den här showen på {{service}}",f6="Koppla ditt konto till {{service}}",h6="Du är inloggad som",g6="Logga in",m6="Ange din e-postadress för att logga in.",_6="Ange din mejladress, så skickar vi en kod till dig som du kan logga in med.",y6="Ange din mejladress, så skickar vi en länk till dig som du kan logga in med.",w6="Logga ut",v6="Nej, jag vill använda ett annat konto",b6="eller",x6="Lösenord",k6="Lösenordet har återställts",S6="Framgång",A6="Byt lösenord för ditt {{vendorName}} konto",z6="Byt lösenord för ditt {{vendorName}} konto",E6="Telefonnummer",I6="Integritetspolicy",C6="Du skickas vidare",N6="Bekräfta lösenord",j6="Registrera ett nytt lösenord",$6="Skicka koden igen",O6="Ändra lösenord",P6="Ange ditt nya lösenord nedan för e-postkontot: ",T6="Klicka på knappen för att återställa ditt lösenord",B6="Klicka på knappen för att återställa ditt lösenord",R6="Återställ ditt lösenord",L6="Byt lösenord för ditt {{vendorName}} konto",U6="Återställ lösenord",V6="Skicka",q6="Skicka en ny inloggninglänk",M6="Kom ihåg att kontrollera din skräppost om du inte kan hitta mailet vi har skickat.",H6="Välj lösenord",D6="Visa lösenord",F6="Logga in",K6="Registrera dig",W6="Registrera dig framgångsrik",G6="{{code}} är din inloggningskod för {{vendorName}}",J6="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.",Z6="Gå till Spotify's Content Access sida",Y6=`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.`,X6="Steg 1: Avlänka ditt Spotify-konto",Q6="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.",eE="Steg 2: Koppla ditt Spotify-konto till Sesamy igen",tE="Oj! Ditt Spotify-konto är redan kopplat",nE="Om du har frågor eller behöver hjälp kan du kontakta vårt supportteam",rE="Villkor",iE="Din e-postadress behöver valideras. Vi har skickat ett nytt e-postmeddelande till din inkorg",sE="Kontot existerar inte",oE="Kontot extisterar inte",aE="Vi kan inte hitta en användare med denna eposten. Vänligen försök igen.",cE="Försök igen.",lE="Validera kod",dE="Kontrollera din inkorg för instruktioner om validering av e-post.",uE="Registrerad",pE="Klicka på knappen för att verifiera din e-postadress",fE="Bekräfta din e-postadress",hE="Bekräfta din e-postadress",gE="Verifiera konto",mE="Ange engångskod",_E="Välkommen",yE="Välkommen till ditt {{vendorName}}-konto!",wE="Vänligen kontrollera din e-post för <0>{{email}}</0> och ange den sexsiffriga koden som vi har skickat till dig.",vE="Fortsätt med konto",bE="Ja, fortsätt med {{text}}",xE="Ja, fortsätt med detta kontot",kE={account_detected:dz,account_with_sso_provider:uz,agree_to:pz,and:fz,callback_url_mismatch:hz,callback_url_not_allowed:gz,check_email_title:mz,click_to_sign_up_description:_z,code_email_enter_code:yz,code_email_subject:wz,code_email_title:vz,code_valid_30_minutes:bz,confirm_password:xz,contact_support:kz,contact_us:Sz,continue:"Fortsätt",continue_social_login:Az,continue_with:zz,continue_with_sso_provider_headline:Ez,copyright:Iz,copyright_sesamy:Cz,create_account_description:Nz,create_account_email_invalid:jz,create_account_passwords_didnt_match:$z,create_account_title:Oz,create_account_weak_password:Pz,create_new_account_link:Tz,create_password_account_title:Bz,currently_logged_in_as:Rz,email:Lz,email_or_phone_placeholder:Uz,email_placeholder:Vz,email_validated:qz,email_validated_cta:Mz,email_verification_for_signup_sent_description:Hz,email_verification_for_signup_sent_title:Dz,enter_a_code_btn:Fz,enter_email_for_verification_description:Kz,enter_new_password_placeholder:Wz,enter_password:Gz,enter_password_description:Jz,enter_your_password_btn:Zz,expired_code:Yz,fokus_info_message:Xz,forgot_password_cta:Qz,forgot_password_description:e6,forgot_password_email_sent:t6,forgot_password_link:n6,forgot_password_title:r6,go_back:i6,hide_password:s6,"invalid-email":"Ogiltig e-postadress",invalid_password:o6,invalid_session_body:a6,invalid_session_title:c6,link_email_click_to_login:l6,link_email_login:d6,link_email_or_enter_code:u6,link_page_body:p6,link_page_headline:f6,logged_in_as:h6,login:g6,login_description:m6,login_description_code:_6,login_description_link:y6,logout:w6,no_use_another:v6,or:b6,password:x6,password_has_been_reset:k6,password_has_been_reset_title:S6,password_reset_subject:A6,password_reset_title:z6,phone_placeholder:E6,privacy_policy:I6,redirecting:C6,reenter_new_password_placeholder:N6,register_password_account:j6,resend_code:$6,reset_password_cta:O6,reset_password_description:P6,reset_password_email_click_to_reset:T6,reset_password_email_cta:B6,reset_password_email_reset:R6,reset_password_subject:L6,reset_password_title:U6,send:V6,send_me_a_new_magic_link:q6,sent_code_spam:M6,"Server error: Invalid code":"Koden är inte giltig",set_password:H6,show_password:D6,sign_in:F6,signup:K6,signup_success:W6,sms_code_text:G6,spotify_already_linked_body:J6,spotify_already_linked_cta:Z6,spotify_already_linked_step1_body:Y6,spotify_already_linked_step1_title:X6,spotify_already_linked_step2_body:Q6,spotify_already_linked_step2_title:eE,spotify_already_linked_title:tE,support_info:nE,terms:rE,unverified_email:iE,user_account_does_not_exist:sE,user_not_found:oE,user_not_found_body:aE,user_not_found_cta:cE,validate_code:lE,validate_email_body:dE,validate_email_title:uE,verify_email_click_to_verify:pE,verify_email_subject:fE,verify_email_title:hE,verify_email_verify:gE,verify_your_email:mE,welcome:_E,welcome_to_your_account:yE,we_sent_a_code_to:wE,"Wrong email or verification code":{"":"Fel e-post eller verifieringskod."},yes_continue:vE,yes_continue_with:bE,yes_continue_with_existing_account:xE},SE="Wykryto konto",AE="Wykryliśmy, że użytkownik utworzył już konto za pośrednictwem",zE="Logując się, wyrażasz zgodę na nasze",EE="i",IE="Niezgodność adresu URL wywołania zwrotnego",CE="Podany adres redirect_uri nie znajduje się na liście dozwolonych adresów URL wywołania zwrotnego.",NE="kontynuować z użytkownikiem",jE="Kliknij przycisk, aby utworzyć nowe konto z hasłem.",$E="Wpisz kod na stronie {{vendorName}}, aby się zalogować.",OE="Witamy na {{vendorName}}! {{code}} to kod logowania do Twojego konta.",PE="Witamy na {{vendorName}}! {{code}} to kod logowania.",TE="Kod jest ważny przez 30 minut",BE="Potwierdź hasło",RE="Potrzebujesz pomocy?",LE="Skontaktuj się z nami",UE="lub kontynuować korzystanie z konta społecznościowego",VE="Kontynuuj {{provider}}",qE="Czy chcesz kontynuować korzystanie z istniejącego konta?",ME="Copyright © 2023 SESAMY. Wszelkie prawa zastrzeżone.",HE="©2023 Sesamy",DE="Wybierz hasło składające się z małych i wielkich liter, cyfr i symboli.",FE="Wprowadź prawidłowy adres e-mail.",KE="Hasła nie są zgodne. Spróbuj ponownie.",WE="Wybierz hasło",GE="Hasło musi mieć co najmniej 8 znaków i zawierać co najmniej jedną małą literę, jedną wielką literę, jedną cyfrę i jeden symbol.",JE="Utwórz nowe konto",ZE="Zarejestruj się przy użyciu hasła",YE="Jesteś obecnie zalogowany jako <0>{{email}}</0>",XE="E-mail",QE="E-mail lub numer telefonu",eI="Adres e-mail",tI="Twój adres e-mail został zweryfikowany",nI="Teraz wprowadź hasło, aby zalogować się ponownie",rI="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.",iI="Wysłano weryfikację e-mail",sI="Wprowadź kod",oI="Wyślemy Ci link weryfikacyjny, aby upewnić się, że posiadasz ten adres e-mail.",aI="Wprowadź nowe hasło",cI="Wprowadź hasło",lI="Wprowadź swój adres e-mail i hasło, aby się zalogować.",dI="Wprowadź hasło",uI="Magiczny link wygasł. Kliknij poniższy przycisk, aby otrzymać nowy link w skrzynce odbiorczej.",pI="Zaktualizowaliśmy sposób logowania. <0>Kliknij tutaj, aby dowiedzieć się więcej.</0>",fI="Wyślij wiadomość e-mail z resetem hasła",hI="Kliknij poniższy przycisk, a my wyślemy Ci instrukcje, jak zresetować hasło.",gI="Wysłano wiadomość e-mail z resetem hasła",mI="Zapomniałeś hasła?",_I="Zapomniałeś hasła?",yI="Wróć",wI="Ukryj hasło",vI="Nieprawidłowe hasło",bI=`Link jest już nieaktualny.
262
+ Du kan klicka på länken nedan för att starta en ny inloggning.`,p6="Ogiltig länk",f6="Klicka på knappen för att logga in",h6="Logga in",g6="Eller skriv in koden på {{vendorName}} för att slutföra inloggningen.",m6="Ange din epost för att låsa upp den här showen på {{service}}",_6="Koppla ditt konto till {{service}}",y6="Du är inloggad som",w6="Logga in",v6="Ange din e-postadress för att logga in.",b6="Ange din mejladress, så skickar vi en kod till dig som du kan logga in med.",x6="Ange din mejladress, så skickar vi en länk till dig som du kan logga in med.",k6="Logga ut",S6="Nej, jag vill använda ett annat konto",A6="eller",z6="Lösenord",E6="Lösenordet har återställts",I6="Framgång",C6="Byt lösenord för ditt {{vendorName}} konto",N6="Byt lösenord för ditt {{vendorName}} konto",j6="Telefonnummer",$6="Integritetspolicy",O6="Du skickas vidare",P6="Bekräfta lösenord",T6="Registrera ett nytt lösenord",B6="Skicka koden igen",R6="Ändra lösenord",L6="Ange ditt nya lösenord nedan för e-postkontot: ",U6="Klicka på knappen för att återställa ditt lösenord",V6="Klicka på knappen för att återställa ditt lösenord",q6="Återställ ditt lösenord",M6="Byt lösenord för ditt {{vendorName}} konto",H6="Återställ lösenord",D6="Skicka",F6="Skicka en ny inloggninglänk",K6="Kom ihåg att kontrollera din skräppost om du inte kan hitta mailet vi har skickat.",W6="Välj lösenord",G6="Visa lösenord",J6="Logga in",Z6="Registrera dig",Y6="Registrera dig framgångsrik",X6="{{code}} är din inloggningskod för {{vendorName}}",Q6="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.",eE="Gå till Spotify's Content Access sida",tE=`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.`,nE="Steg 1: Avlänka ditt Spotify-konto",rE="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.",iE="Steg 2: Koppla ditt Spotify-konto till Sesamy igen",sE="Oj! Ditt Spotify-konto är redan kopplat",oE="Om du har frågor eller behöver hjälp kan du kontakta vårt supportteam",aE="Villkor",cE="Din e-postadress behöver valideras. Vi har skickat ett nytt e-postmeddelande till din inkorg",lE="Kontot existerar inte",dE="Kontot extisterar inte",uE="Vi kan inte hitta en användare med denna eposten. Vänligen försök igen.",pE="Försök igen.",fE="Validera kod",hE="Kontrollera din inkorg för instruktioner om validering av e-post.",gE="Registrerad",mE="Klicka på knappen för att verifiera din e-postadress",_E="Bekräfta din e-postadress",yE="Bekräfta din e-postadress",wE="Verifiera konto",vE="Ange engångskod",bE="Välkommen",xE="Välkommen till ditt {{vendorName}}-konto!",kE="Vänligen kontrollera din e-post för <0>{{email}}</0> och ange den sexsiffriga koden som vi har skickat till dig.",SE="Fortsätt med konto",AE="Ja, fortsätt med {{text}}",zE="Ja, fortsätt med detta kontot",EE={account_detected:hz,account_with_sso_provider:gz,agree_to:mz,and:_z,callback_url_mismatch:yz,callback_url_not_allowed:wz,check_email_title:vz,click_to_sign_up_description:bz,code_email_enter_code:xz,code_email_subject:kz,code_email_title:Sz,code_valid_30_minutes:Az,confirm_password:zz,contact_support:Ez,contact_us:Iz,continue:"Fortsätt",continue_social_login:Cz,continue_with:Nz,continue_with_sso_provider_headline:jz,copyright:$z,copyright_sesamy:Oz,create_account_description:Pz,create_account_email_invalid:Tz,create_account_passwords_didnt_match:Bz,create_account_title:Rz,create_account_weak_password:Lz,create_new_account_link:Uz,create_password_account_title:Vz,currently_logged_in_as:qz,email:Mz,email_or_phone_placeholder:Hz,email_placeholder:Dz,email_validated:Fz,email_validated_cta:Kz,email_verification_for_signup_sent_description:Wz,email_verification_for_signup_sent_title:Gz,enter_a_code_btn:Jz,enter_email_for_verification_description:Zz,enter_new_password_placeholder:Yz,enter_password:Xz,enter_password_description:Qz,enter_your_password_btn:e6,expired_code:t6,fokus_info_message:n6,forgot_password_cta:r6,forgot_password_description:i6,forgot_password_email_sent:s6,forgot_password_link:o6,forgot_password_title:a6,go_back:c6,hide_password:l6,"invalid-email":"Ogiltig e-postadress",invalid_password:d6,invalid_session_body:u6,invalid_session_title:p6,link_email_click_to_login:f6,link_email_login:h6,link_email_or_enter_code:g6,link_page_body:m6,link_page_headline:_6,logged_in_as:y6,login:w6,login_description:v6,login_description_code:b6,login_description_link:x6,logout:k6,no_use_another:S6,or:A6,password:z6,password_has_been_reset:E6,password_has_been_reset_title:I6,password_reset_subject:C6,password_reset_title:N6,phone_placeholder:j6,privacy_policy:$6,redirecting:O6,reenter_new_password_placeholder:P6,register_password_account:T6,resend_code:B6,reset_password_cta:R6,reset_password_description:L6,reset_password_email_click_to_reset:U6,reset_password_email_cta:V6,reset_password_email_reset:q6,reset_password_subject:M6,reset_password_title:H6,send:D6,send_me_a_new_magic_link:F6,sent_code_spam:K6,"Server error: Invalid code":"Koden är inte giltig",set_password:W6,show_password:G6,sign_in:J6,signup:Z6,signup_success:Y6,sms_code_text:X6,spotify_already_linked_body:Q6,spotify_already_linked_cta:eE,spotify_already_linked_step1_body:tE,spotify_already_linked_step1_title:nE,spotify_already_linked_step2_body:rE,spotify_already_linked_step2_title:iE,spotify_already_linked_title:sE,support_info:oE,terms:aE,unverified_email:cE,user_account_does_not_exist:lE,user_not_found:dE,user_not_found_body:uE,user_not_found_cta:pE,validate_code:fE,validate_email_body:hE,validate_email_title:gE,verify_email_click_to_verify:mE,verify_email_subject:_E,verify_email_title:yE,verify_email_verify:wE,verify_your_email:vE,welcome:bE,welcome_to_your_account:xE,we_sent_a_code_to:kE,"Wrong email or verification code":{"":"Fel e-post eller verifieringskod."},yes_continue:SE,yes_continue_with:AE,yes_continue_with_existing_account:zE},IE="Wykryto konto",CE="Wykryliśmy, że użytkownik utworzył już konto za pośrednictwem",NE="Logując się, wyrażasz zgodę na nasze",jE="i",$E="Niezgodność adresu URL wywołania zwrotnego",OE="Podany adres redirect_uri nie znajduje się na liście dozwolonych adresów URL wywołania zwrotnego.",PE="kontynuować z użytkownikiem",TE="Kliknij przycisk, aby utworzyć nowe konto z hasłem.",BE="Wpisz kod na stronie {{vendorName}}, aby się zalogować.",RE="Witamy na {{vendorName}}! {{code}} to kod logowania do Twojego konta.",LE="Witamy na {{vendorName}}! {{code}} to kod logowania.",UE="Kod jest ważny przez 30 minut",VE="Potwierdź hasło",qE="Potrzebujesz pomocy?",ME="Skontaktuj się z nami",HE="lub kontynuować korzystanie z konta społecznościowego",DE="Kontynuuj {{provider}}",FE="Czy chcesz kontynuować korzystanie z istniejącego konta?",KE="Copyright © 2023 SESAMY. Wszelkie prawa zastrzeżone.",WE="©2023 Sesamy",GE="Wybierz hasło składające się z małych i wielkich liter, cyfr i symboli.",JE="Wprowadź prawidłowy adres e-mail.",ZE="Hasła nie są zgodne. Spróbuj ponownie.",YE="Wybierz hasło",XE="Hasło musi mieć co najmniej 8 znaków i zawierać co najmniej jedną małą literę, jedną wielką literę, jedną cyfrę i jeden symbol.",QE="Utwórz nowe konto",eI="Zarejestruj się przy użyciu hasła",tI="Jesteś obecnie zalogowany jako <0>{{email}}</0>",nI="E-mail",rI="E-mail lub numer telefonu",iI="Adres e-mail",sI="Twój adres e-mail został zweryfikowany",oI="Teraz wprowadź hasło, aby zalogować się ponownie",aI="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.",cI="Wysłano weryfikację e-mail",lI="Wprowadź kod",dI="Wyślemy Ci link weryfikacyjny, aby upewnić się, że posiadasz ten adres e-mail.",uI="Wprowadź nowe hasło",pI="Wprowadź hasło",fI="Wprowadź swój adres e-mail i hasło, aby się zalogować.",hI="Wprowadź hasło",gI="Magiczny link wygasł. Kliknij poniższy przycisk, aby otrzymać nowy link w skrzynce odbiorczej.",mI="Zaktualizowaliśmy sposób logowania. <0>Kliknij tutaj, aby dowiedzieć się więcej.</0>",_I="Wyślij wiadomość e-mail z resetem hasła",yI="Kliknij poniższy przycisk, a my wyślemy Ci instrukcje, jak zresetować hasło.",wI="Wysłano wiadomość e-mail z resetem hasła",vI="Zapomniałeś hasła?",bI="Zapomniałeś hasła?",xI="Wróć",kI="Ukryj hasło",SI="Nieprawidłowe hasło",AI=`Link jest już nieaktualny.
261
263
 
262
264
  Upewnij się, że otworzyłeś link logowania w tej samej przeglądarce, w której rozpocząłeś logowanie.
263
265
 
264
- Możesz kliknąć poniższy link, aby rozpocząć nowe logowanie.`,xI="Nieprawidłowy link",kI="Kliknij przycisk, aby się zalogować",SI="Zaloguj się",AI="Lub wprowadź kod na stronie {{vendorName}}, aby dokończyć logowanie.",zI="Wprowadź swój adres e-mail, aby odblokować ten program na {{service}}",EI="Połącz swoje konto z {{service}}",II="Jesteś zalogowany jako",CI="Logowanie",NI="Wprowadź swój adres e-mail, aby się zalogować.",jI="Wprowadź swój adres e-mail, a my wyślemy Ci kod logowania.",$I="Wprowadź swój adres e-mail, a my wyślemy Ci link do logowania.",OI="Wylogowanie",PI="Nie, chcę użyć innego konta",TI="lub",BI="Hasło",RI="Hasło zostało zresetowane",LI="Sukces",UI="Zmień hasło do konta {{vendorName}} ",VI="Zmiana hasła do konta {{vendorName}} ",qI="Numer telefonu",MI="Polityka prywatności",HI="Przekierowanie",DI="Potwierdź hasło",FI="Zarejestruj nowe hasło",KI="Wyślij ponownie kod",WI="Zmiana hasła",GI="Wprowadź poniżej nowe hasło do konta e-mail: ",JI="Kliknij przycisk, aby zresetować hasło",ZI="Kliknij przycisk, aby zresetować hasło",YI="Zmień hasło",XI="Zmiana hasła do konta {{vendorName}} ",QI="Resetowanie hasła",e5="Wyślij",t5="Wyślij mi nowy magiczny link",n5="Pamiętaj, aby sprawdzić folder spamu, jeśli wiadomość e-mail nie dotarła.",r5="Ustaw hasło",i5="Pokaż hasło",s5="Zaloguj się",o5="Rejestracja",a5="Rejestracja zakończona sukcesem",c5="{{code}} to kod logowania do {{vendorName}}",l5="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ć.",d5="Przejdź do strony dostępu do treści Spotify",u5='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.',p5="Krok 1: Odłącz swoje konto Spotify",f5="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.",h5="Krok 2: Połącz ponownie swoje konto Spotify z Sesamy",g5="Ups! Twoje konto Spotify jest już połączone",m5="Jeśli masz pytania lub potrzebujesz pomocy, skontaktuj się z nami",_5="Zasady i warunki",y5="Twój adres e-mail wymaga weryfikacji. Wysłaliśmy nową wiadomość e-mail na Twoją skrzynkę odbiorczą",w5="Konto użytkownika nie istnieje",v5="Konto użytkownika nie istnieje",b5="Nie mogliśmy znaleźć użytkownika o podanym adresie e-mail. Spróbuj ponownie.",x5="Spróbuj ponownie.",k5="Sprawdź poprawność kodu",S5="Sprawdź swoją skrzynkę odbiorczą, aby uzyskać instrukcje dotyczące weryfikacji wiadomości e-mail.",A5="Zarejestrowany",z5="Kliknij przycisk, aby zweryfikować swój adres e-mail",E5="Potwierdź swój adres e-mail",I5="Potwierdź swój adres e-mail",C5="Zweryfikuj konto",N5="Zweryfikuj swój adres e-mail",j5="Witamy",$5="Witamy na koncie {{vendorName}}!",O5="Sprawdź swoją skrzynkę e-mail pod adresem <0>{{email}}</0> i wprowadź sześciocyfrowy kod, który wysłaliśmy.",P5="Kontynuuj korzystanie z tego konta",T5="Tak, kontynuuj {{text}}",B5="Tak, kontynuuj korzystanie z istniejącego konta",R5={account_detected:SE,account_with_sso_provider:AE,agree_to:zE,and:EE,callback_url_mismatch:IE,callback_url_not_allowed:CE,check_email_title:NE,click_to_sign_up_description:jE,code_email_enter_code:$E,code_email_subject:OE,code_email_title:PE,code_valid_30_minutes:TE,confirm_password:BE,contact_support:RE,contact_us:LE,continue:"Kontynuuj",continue_social_login:UE,continue_with:VE,continue_with_sso_provider_headline:qE,copyright:ME,copyright_sesamy:HE,create_account_description:DE,create_account_email_invalid:FE,create_account_passwords_didnt_match:KE,create_account_title:WE,create_account_weak_password:GE,create_new_account_link:JE,create_password_account_title:ZE,currently_logged_in_as:YE,email:XE,email_or_phone_placeholder:QE,email_placeholder:eI,email_validated:tI,email_validated_cta:nI,email_verification_for_signup_sent_description:rI,email_verification_for_signup_sent_title:iI,enter_a_code_btn:sI,enter_email_for_verification_description:oI,enter_new_password_placeholder:aI,enter_password:cI,enter_password_description:lI,enter_your_password_btn:dI,expired_code:uI,fokus_info_message:pI,forgot_password_cta:fI,forgot_password_description:hI,forgot_password_email_sent:gI,forgot_password_link:mI,forgot_password_title:_I,go_back:yI,hide_password:wI,"invalid-email":"Nieprawidłowy adres e-mail",invalid_password:vI,invalid_session_body:bI,invalid_session_title:xI,link_email_click_to_login:kI,link_email_login:SI,link_email_or_enter_code:AI,link_page_body:zI,link_page_headline:EI,logged_in_as:II,login:CI,login_description:NI,login_description_code:jI,login_description_link:$I,logout:OI,no_use_another:PI,or:TI,password:BI,password_has_been_reset:RI,password_has_been_reset_title:LI,password_reset_subject:UI,password_reset_title:VI,phone_placeholder:qI,privacy_policy:MI,redirecting:HI,reenter_new_password_placeholder:DI,register_password_account:FI,resend_code:KI,reset_password_cta:WI,reset_password_description:GI,reset_password_email_click_to_reset:JI,reset_password_email_cta:ZI,reset_password_email_reset:YI,reset_password_subject:XI,reset_password_title:QI,send:e5,send_me_a_new_magic_link:t5,sent_code_spam:n5,"Server error: Invalid code":"Nieprawidłowy kod",set_password:r5,show_password:i5,sign_in:s5,signup:o5,signup_success:a5,sms_code_text:c5,spotify_already_linked_body:l5,spotify_already_linked_cta:d5,spotify_already_linked_step1_body:u5,spotify_already_linked_step1_title:p5,spotify_already_linked_step2_body:f5,spotify_already_linked_step2_title:h5,spotify_already_linked_title:g5,support_info:m5,terms:_5,unverified_email:y5,user_account_does_not_exist:w5,user_not_found:v5,user_not_found_body:b5,user_not_found_cta:x5,validate_code:k5,validate_email_body:S5,validate_email_title:A5,verify_email_click_to_verify:z5,verify_email_subject:E5,verify_email_title:I5,verify_email_verify:C5,verify_your_email:N5,welcome:j5,welcome_to_your_account:$5,we_sent_a_code_to:O5,"Wrong email or verification code":{"":"Nieprawidłowy adres e-mail lub kod weryfikacyjny."},yes_continue:P5,yes_continue_with:T5,yes_continue_with_existing_account:B5},L5="Zjištěný účet",U5="Zjistili jsme, že jste si již vytvořili účet prostřednictvím",V5="Přihlášením souhlasíte s našimi",q5="a",M5="Neshoda adresy URL zpětného volání",H5="Zadané redirect_uri není v seznamu povolených zpětných adres URL.",D5="pokračovat s uživatelem",F5="Klikněte na tlačítko pro vytvoření nového účtu s heslem.",K5="Pro dokončení přihlášení zadejte kód na adrese {{vendorName}}.",W5="Vítejte na {{vendorName}}! {{code}} je přihlašovací kód.",G5="Vítejte na {{vendorName}}! {{code}} je přihlašovací kód.",J5="Kód je platný po dobu 30 minut",Z5="Potvrzení hesla",Y5="Potřebujete pomoc?",X5="Kontaktujte nás",Q5="nebo pokračovat v sociálním účtu",eC="Pokračovat s {{provider}}",tC="Chcete pokračovat ve svém stávajícím účtu?",nC="Copyright © 2023 SESAMY. Všechna práva vyhrazena.",rC="©2023 Sesamy",iC="Zvolte heslo složené z velkých a malých písmen, číslic a symbolů.",sC="Zadejte prosím platnou e-mailovou adresu.",oC="Hesla se neshodovala. Zkuste to znovu.",aC="Zvolte heslo",cC="Heslo musí mít alespoň 8 znaků a obsahovat alespoň jedno malé písmeno, jedno velké písmeno, jednu číslici a jeden symbol.",lC="Vytvořit nový účet",dC="Zaregistrujte se pomocí hesla",uC="V současné době jste přihlášeni jako <0>{{email}}</0>",pC="E-mail",fC="E-mail nebo telefonní číslo",hC="E-mailová adresa",gC="Vaše e-mailová adresa byla ověřena",mC="Nyní zadejte své heslo a znovu se přihlaste",_C="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.",yC="Ověření e-mailem odesláno",wC="Zadejte kód",vC="Pošleme vám ověřovací odkaz, abychom se ujistili, že tuto e-mailovou adresu vlastníte.",bC="Zadejte nové heslo",xC="Zadejte heslo",kC="Pro přihlášení zadejte svou e-mailovou adresu a heslo.",SC="Zadejte své heslo",AC="Platnost kouzelného odkazu vypršela. Klikněte na tlačítko níže, abyste obdrželi nový odkaz do své e-mailové schránky.",zC="Ahoj! Aktualizovali jsme naše přihlašovací prostředí. <0>Klikněte sem a dozvíte se o něm více.</0>",EC="Odeslání e-mailu pro obnovení hesla",IC="Klikněte na tlačítko níže a my vám zašleme pokyny k obnovení hesla.",CC="Odeslání e-mailu s žádostí o obnovení hesla",NC="Zapomněli jste heslo?",jC="Zapomněli jste heslo?",$C="Vrátit se zpět",OC="Skrýt heslo",PC="Neplatné heslo",TC=`Odkaz již není platný.
266
+ Możesz kliknąć poniższy link, aby rozpocząć nowe logowanie.`,zI="Nieprawidłowy link",EI="Kliknij przycisk, aby się zalogować",II="Zaloguj się",CI="Lub wprowadź kod na stronie {{vendorName}}, aby dokończyć logowanie.",NI="Wprowadź swój adres e-mail, aby odblokować ten program na {{service}}",jI="Połącz swoje konto z {{service}}",$I="Jesteś zalogowany jako",OI="Logowanie",PI="Wprowadź swój adres e-mail, aby się zalogować.",TI="Wprowadź swój adres e-mail, a my wyślemy Ci kod logowania.",BI="Wprowadź swój adres e-mail, a my wyślemy Ci link do logowania.",RI="Wylogowanie",LI="Nie, chcę użyć innego konta",UI="lub",VI="Hasło",qI="Hasło zostało zresetowane",MI="Sukces",HI="Zmień hasło do konta {{vendorName}} ",DI="Zmiana hasła do konta {{vendorName}} ",FI="Numer telefonu",KI="Polityka prywatności",WI="Przekierowanie",GI="Potwierdź hasło",JI="Zarejestruj nowe hasło",ZI="Wyślij ponownie kod",YI="Zmiana hasła",XI="Wprowadź poniżej nowe hasło do konta e-mail: ",QI="Kliknij przycisk, aby zresetować hasło",e5="Kliknij przycisk, aby zresetować hasło",t5="Zmień hasło",n5="Zmiana hasła do konta {{vendorName}} ",r5="Resetowanie hasła",i5="Wyślij",s5="Wyślij mi nowy magiczny link",o5="Pamiętaj, aby sprawdzić folder spamu, jeśli wiadomość e-mail nie dotarła.",a5="Ustaw hasło",c5="Pokaż hasło",l5="Zaloguj się",d5="Rejestracja",u5="Rejestracja zakończona sukcesem",p5="{{code}} to kod logowania do {{vendorName}}",f5="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ć.",h5="Przejdź do strony dostępu do treści Spotify",g5='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.',m5="Krok 1: Odłącz swoje konto Spotify",_5="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.",y5="Krok 2: Połącz ponownie swoje konto Spotify z Sesamy",w5="Ups! Twoje konto Spotify jest już połączone",v5="Jeśli masz pytania lub potrzebujesz pomocy, skontaktuj się z nami",b5="Zasady i warunki",x5="Twój adres e-mail wymaga weryfikacji. Wysłaliśmy nową wiadomość e-mail na Twoją skrzynkę odbiorczą",k5="Konto użytkownika nie istnieje",S5="Konto użytkownika nie istnieje",A5="Nie mogliśmy znaleźć użytkownika o podanym adresie e-mail. Spróbuj ponownie.",z5="Spróbuj ponownie.",E5="Sprawdź poprawność kodu",I5="Sprawdź swoją skrzynkę odbiorczą, aby uzyskać instrukcje dotyczące weryfikacji wiadomości e-mail.",C5="Zarejestrowany",N5="Kliknij przycisk, aby zweryfikować swój adres e-mail",j5="Potwierdź swój adres e-mail",$5="Potwierdź swój adres e-mail",O5="Zweryfikuj konto",P5="Zweryfikuj swój adres e-mail",T5="Witamy",B5="Witamy na koncie {{vendorName}}!",R5="Sprawdź swoją skrzynkę e-mail pod adresem <0>{{email}}</0> i wprowadź sześciocyfrowy kod, który wysłaliśmy.",L5="Kontynuuj korzystanie z tego konta",U5="Tak, kontynuuj {{text}}",V5="Tak, kontynuuj korzystanie z istniejącego konta",q5={account_detected:IE,account_with_sso_provider:CE,agree_to:NE,and:jE,callback_url_mismatch:$E,callback_url_not_allowed:OE,check_email_title:PE,click_to_sign_up_description:TE,code_email_enter_code:BE,code_email_subject:RE,code_email_title:LE,code_valid_30_minutes:UE,confirm_password:VE,contact_support:qE,contact_us:ME,continue:"Kontynuuj",continue_social_login:HE,continue_with:DE,continue_with_sso_provider_headline:FE,copyright:KE,copyright_sesamy:WE,create_account_description:GE,create_account_email_invalid:JE,create_account_passwords_didnt_match:ZE,create_account_title:YE,create_account_weak_password:XE,create_new_account_link:QE,create_password_account_title:eI,currently_logged_in_as:tI,email:nI,email_or_phone_placeholder:rI,email_placeholder:iI,email_validated:sI,email_validated_cta:oI,email_verification_for_signup_sent_description:aI,email_verification_for_signup_sent_title:cI,enter_a_code_btn:lI,enter_email_for_verification_description:dI,enter_new_password_placeholder:uI,enter_password:pI,enter_password_description:fI,enter_your_password_btn:hI,expired_code:gI,fokus_info_message:mI,forgot_password_cta:_I,forgot_password_description:yI,forgot_password_email_sent:wI,forgot_password_link:vI,forgot_password_title:bI,go_back:xI,hide_password:kI,"invalid-email":"Nieprawidłowy adres e-mail",invalid_password:SI,invalid_session_body:AI,invalid_session_title:zI,link_email_click_to_login:EI,link_email_login:II,link_email_or_enter_code:CI,link_page_body:NI,link_page_headline:jI,logged_in_as:$I,login:OI,login_description:PI,login_description_code:TI,login_description_link:BI,logout:RI,no_use_another:LI,or:UI,password:VI,password_has_been_reset:qI,password_has_been_reset_title:MI,password_reset_subject:HI,password_reset_title:DI,phone_placeholder:FI,privacy_policy:KI,redirecting:WI,reenter_new_password_placeholder:GI,register_password_account:JI,resend_code:ZI,reset_password_cta:YI,reset_password_description:XI,reset_password_email_click_to_reset:QI,reset_password_email_cta:e5,reset_password_email_reset:t5,reset_password_subject:n5,reset_password_title:r5,send:i5,send_me_a_new_magic_link:s5,sent_code_spam:o5,"Server error: Invalid code":"Nieprawidłowy kod",set_password:a5,show_password:c5,sign_in:l5,signup:d5,signup_success:u5,sms_code_text:p5,spotify_already_linked_body:f5,spotify_already_linked_cta:h5,spotify_already_linked_step1_body:g5,spotify_already_linked_step1_title:m5,spotify_already_linked_step2_body:_5,spotify_already_linked_step2_title:y5,spotify_already_linked_title:w5,support_info:v5,terms:b5,unverified_email:x5,user_account_does_not_exist:k5,user_not_found:S5,user_not_found_body:A5,user_not_found_cta:z5,validate_code:E5,validate_email_body:I5,validate_email_title:C5,verify_email_click_to_verify:N5,verify_email_subject:j5,verify_email_title:$5,verify_email_verify:O5,verify_your_email:P5,welcome:T5,welcome_to_your_account:B5,we_sent_a_code_to:R5,"Wrong email or verification code":{"":"Nieprawidłowy adres e-mail lub kod weryfikacyjny."},yes_continue:L5,yes_continue_with:U5,yes_continue_with_existing_account:V5},M5="Zjištěný účet",H5="Zjistili jsme, že jste si již vytvořili účet prostřednictvím",D5="Přihlášením souhlasíte s našimi",F5="a",K5="Neshoda adresy URL zpětného volání",W5="Zadané redirect_uri není v seznamu povolených zpětných adres URL.",G5="pokračovat s uživatelem",J5="Klikněte na tlačítko pro vytvoření nového účtu s heslem.",Z5="Pro dokončení přihlášení zadejte kód na adrese {{vendorName}}.",Y5="Vítejte na {{vendorName}}! {{code}} je přihlašovací kód.",X5="Vítejte na {{vendorName}}! {{code}} je přihlašovací kód.",Q5="Kód je platný po dobu 30 minut",eC="Potvrzení hesla",tC="Potřebujete pomoc?",nC="Kontaktujte nás",rC="nebo pokračovat v sociálním účtu",iC="Pokračovat s {{provider}}",sC="Chcete pokračovat ve svém stávajícím účtu?",oC="Copyright © 2023 SESAMY. Všechna práva vyhrazena.",aC="©2023 Sesamy",cC="Zvolte heslo složené z velkých a malých písmen, číslic a symbolů.",lC="Zadejte prosím platnou e-mailovou adresu.",dC="Hesla se neshodovala. Zkuste to znovu.",uC="Zvolte heslo",pC="Heslo musí mít alespoň 8 znaků a obsahovat alespoň jedno malé písmeno, jedno velké písmeno, jednu číslici a jeden symbol.",fC="Vytvořit nový účet",hC="Zaregistrujte se pomocí hesla",gC="V současné době jste přihlášeni jako <0>{{email}}</0>",mC="E-mail",_C="E-mail nebo telefonní číslo",yC="E-mailová adresa",wC="Vaše e-mailová adresa byla ověřena",vC="Nyní zadejte své heslo a znovu se přihlaste",bC="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.",xC="Ověření e-mailem odesláno",kC="Zadejte kód",SC="Pošleme vám ověřovací odkaz, abychom se ujistili, že tuto e-mailovou adresu vlastníte.",AC="Zadejte nové heslo",zC="Zadejte heslo",EC="Pro přihlášení zadejte svou e-mailovou adresu a heslo.",IC="Zadejte své heslo",CC="Platnost kouzelného odkazu vypršela. Klikněte na tlačítko níže, abyste obdrželi nový odkaz do své e-mailové schránky.",NC="Ahoj! Aktualizovali jsme naše přihlašovací prostředí. <0>Klikněte sem a dozvíte se o něm více.</0>",jC="Odeslání e-mailu pro obnovení hesla",$C="Klikněte na tlačítko níže a my vám zašleme pokyny k obnovení hesla.",OC="Odeslání e-mailu s žádostí o obnovení hesla",PC="Zapomněli jste heslo?",TC="Zapomněli jste heslo?",BC="Vrátit se zpět",RC="Skrýt heslo",LC="Neplatné heslo",UC=`Odkaz již není platný.
265
267
 
266
268
  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.
267
269
 
268
- Kliknutím na odkaz níže můžete zahájit nové přihlášení.`,BC="Neplatný odkaz",RC="Kliknutím na tlačítko se přihlásíte",LC="Přihlášení",UC="Nebo zadejte kód na adrese {{vendorName}} a dokončete přihlášení.",VC="Zadejte svou e-mailovou adresu pro odemknutí tohoto pořadu na {{service}}",qC="Propojte svůj účet s {{service}}",MC="Jste přihlášeni jako",HC="Přihlášení",DC="Pro přihlášení zadejte svou e-mailovou adresu.",FC="Zadejte svou e-mailovou adresu a my vám zašleme přihlašovací kód.",KC="Zadejte svou e-mailovou adresu a my vám zašleme odkaz pro přihlášení.",WC="Odhlášení",GC="Ne, chci použít jiný účet",JC="nebo",ZC="Heslo",YC="Heslo bylo resetováno",XC="Úspěch",QC="Změna hesla k účtu {{vendorName}} ",eN="Změna hesla k účtu {{vendorName}} ",tN="Telefonní číslo",nN="Zásady ochrany osobních údajů",rN="Přesměrování",iN="Potvrzení hesla",sN="Registrace nového hesla",oN="Opětovné odeslání kódu",aN="Změna hesla",cN="Níže zadejte nové heslo k e-mailovému účtu: ",lN="Kliknutím na tlačítko obnovíte své heslo",dN="Kliknutím na tlačítko obnovíte své heslo",uN="Obnovení hesla",pN="Změna hesla k účtu {{vendorName}} ",fN="Obnovení hesla",hN="Odeslat",gN="Pošlete mi nový kouzelný odkaz",mN="Pokud e-mail nedorazil, nezapomeňte zkontrolovat složku nevyžádané pošty.",_N="Nastavení hesla",yN="Zobrazit heslo",wN="Přihlásit se",vN="Registrace",bN="Úspěšná registrace",xN="{{code}} je váš přihlašovací kód pro {{vendorName}}",kN="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.",SN="Přejděte na stránku Spotify pro přístup k obsahu",AN='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.',zN="Krok 1: Odpojení účtu Spotify",EN="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.",IN="Krok 2: Propojení účtu Spotify s aplikací Sesamy",CN="Ups! Váš účet Spotify je již propojen",NN="Pokud máte dotazy nebo potřebujete pomoc, můžete se obrátit na náš tým podpory.",jN="Podmínky a pravidla",$N="Vaši e-mailovou adresu je třeba ověřit. Do vaší e-mailové schránky jsme odeslali nový e-mail.",ON="Uživatelský účet neexistuje",PN="Uživatelský účet neexistuje",TN="Nepodařilo se nám najít uživatele se zadanou e-mailovou adresou. Zkuste to prosím znovu.",BN="Zkuste to znovu.",RN="Ověření kódu",LN="Pokyny k ověření e-mailu najdete ve své e-mailové schránce.",UN="Zaregistrovali jste se",VN="Klikněte na tlačítko pro ověření e-mailové adresy",qN="Ověřte svou e-mailovou adresu",MN="Ověřte svou e-mailovou adresu",HN="Ověření účtu",DN="Ověření e-mailu",FN="Vítejte na",KN="Vítejte na svém účtu {{vendorName}}!",WN="Zkontrolujte si prosím svůj e-mail na adrese <0>{{email}}</0> a zadejte šestimístný kód, který jsme vám zaslali.",GN="Pokračujte s tímto účtem",JN="Ano, pokračujte {{text}}",ZN="Ano, pokračujte ve stávajícím účtu",YN={account_detected:L5,account_with_sso_provider:U5,agree_to:V5,and:q5,callback_url_mismatch:M5,callback_url_not_allowed:H5,check_email_title:D5,click_to_sign_up_description:F5,code_email_enter_code:K5,code_email_subject:W5,code_email_title:G5,code_valid_30_minutes:J5,confirm_password:Z5,contact_support:Y5,contact_us:X5,continue:"Pokračovat",continue_social_login:Q5,continue_with:eC,continue_with_sso_provider_headline:tC,copyright:nC,copyright_sesamy:rC,create_account_description:iC,create_account_email_invalid:sC,create_account_passwords_didnt_match:oC,create_account_title:aC,create_account_weak_password:cC,create_new_account_link:lC,create_password_account_title:dC,currently_logged_in_as:uC,email:pC,email_or_phone_placeholder:fC,email_placeholder:hC,email_validated:gC,email_validated_cta:mC,email_verification_for_signup_sent_description:_C,email_verification_for_signup_sent_title:yC,enter_a_code_btn:wC,enter_email_for_verification_description:vC,enter_new_password_placeholder:bC,enter_password:xC,enter_password_description:kC,enter_your_password_btn:SC,expired_code:AC,fokus_info_message:zC,forgot_password_cta:EC,forgot_password_description:IC,forgot_password_email_sent:CC,forgot_password_link:NC,forgot_password_title:jC,go_back:$C,hide_password:OC,"invalid-email":"Neplatný e-mail",invalid_password:PC,invalid_session_body:TC,invalid_session_title:BC,link_email_click_to_login:RC,link_email_login:LC,link_email_or_enter_code:UC,link_page_body:VC,link_page_headline:qC,logged_in_as:MC,login:HC,login_description:DC,login_description_code:FC,login_description_link:KC,logout:WC,no_use_another:GC,or:JC,password:ZC,password_has_been_reset:YC,password_has_been_reset_title:XC,password_reset_subject:QC,password_reset_title:eN,phone_placeholder:tN,privacy_policy:nN,redirecting:rN,reenter_new_password_placeholder:iN,register_password_account:sN,resend_code:oN,reset_password_cta:aN,reset_password_description:cN,reset_password_email_click_to_reset:lN,reset_password_email_cta:dN,reset_password_email_reset:uN,reset_password_subject:pN,reset_password_title:fN,send:hN,send_me_a_new_magic_link:gN,sent_code_spam:mN,"Server error: Invalid code":"Neplatný kód",set_password:_N,show_password:yN,sign_in:wN,signup:vN,signup_success:bN,sms_code_text:xN,spotify_already_linked_body:kN,spotify_already_linked_cta:SN,spotify_already_linked_step1_body:AN,spotify_already_linked_step1_title:zN,spotify_already_linked_step2_body:EN,spotify_already_linked_step2_title:IN,spotify_already_linked_title:CN,support_info:NN,terms:jN,unverified_email:$N,user_account_does_not_exist:ON,user_not_found:PN,user_not_found_body:TN,user_not_found_cta:BN,validate_code:RN,validate_email_body:LN,validate_email_title:UN,verify_email_click_to_verify:VN,verify_email_subject:qN,verify_email_title:MN,verify_email_verify:HN,verify_your_email:DN,welcome:FN,welcome_to_your_account:KN,we_sent_a_code_to:WN,"Wrong email or verification code":{"":"Špatný e-mail nebo ověřovací kód."},yes_continue:GN,yes_continue_with:JN,yes_continue_with_existing_account:ZN},XN="Tili havaittu",QN="Olemme havainneet, että olet jo luonut tilin kautta",e8="Kirjautumalla sisään hyväksyt",t8="ja",n8="Takaisinkutsun URL-osoite ei vastaa toisiaan",r8="Annettu redirect_uri ei ole sallittujen takaisinsoitto-URL-osoitteiden luettelossa.",i8="jatka käyttäjän kanssa",s8="Klikkaa painiketta luodaksesi uuden salasanatilin.",o8="Kirjoita koodi osoitteessa {{vendorName}} kirjautumisen loppuun saattamiseksi.",a8="Tervetuloa osoitteeseen {{vendorName}}! {{code}} on kirjautumiskoodi.",c8="Tervetuloa osoitteeseen {{vendorName}}! {{code}} on kirjautumiskoodi.",l8="Koodi on voimassa 30 minuuttia",d8="Vahvista salasana",u8="Tarvitsetko apua?",p8="Ota yhteyttä",f8="tai jatka sosiaalisella tilillä",h8="Jatka {{provider}}",g8="Haluatko jatkaa olemassa olevalla tililläsi?",m8="Copyright © 2023 SESAMY. Kaikki oikeudet pidätetään.",_8="©2023 Sesamy",y8="Valitse salasana, jossa on isoja ja pieniä kirjaimia, numeroita ja symboleja.",w8="Kirjoita voimassa oleva sähköpostiosoite.",v8="Salasanat eivät vastanneet toisiaan. Yritä uudelleen.",b8="Valitse salasana",x8="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.",k8="Luo uusi tili",S8="Rekisteröidy salasanalla",A8="Olet tällä hetkellä kirjautuneena sisään nimellä <0>{{email}}</0>",z8="Sähköposti",E8="Sähköposti tai puhelinnumero",I8="Sähköpostiosoite",C8="Sähköpostiosoitteesi on vahvistettu",N8="Kirjoita nyt salasanasi kirjautuaksesi uudelleen",j8="Sähköposti on lähetetty osoitteeseen <0>{{email}}</0> jossa on vahvistuslinkki. Klikkaa linkkiä vahvistaaksesi sähköpostiosoitteesi ja asettaaksesi salasanan.",$8="Sähköpostivarmennus lähetetty",O8="Syötä koodi",P8="Lähetämme sinulle vahvistuslinkin varmistaaksemme, että omistat tämän sähköpostiosoitteen.",T8="Anna uusi salasana",B8="Anna salasana",R8="Anna sähköpostiosoitteesi ja salasanasi kirjautuaksesi sisään.",L8="Syötä salasanasi",U8="Taikalinkki on vanhentunut. Klikkaa alla olevaa painiketta saadaksesi uuden linkin sähköpostiisi.",V8="Hei! Päivitimme kirjautumiskokemuksemme. <0>Klikkaa tästä saadaksesi lisätietoja siitä.</0>",q8="Lähetä salasanan palautussähköposti",M8="Napsauta alla olevaa painiketta, niin lähetämme ohjeet salasanasi palauttamiseen.",H8="Salasanan palautussähköposti lähetetty",D8="Unohditko salasanan?",F8="Unohditko salasanan?",K8="Palaa takaisin",W8="Piilota salasana",G8="Virheellinen salasana",J8=`Linkki ei ole enää voimassa.
270
+ Kliknutím na odkaz níže můžete zahájit nové přihlášení.`,VC="Neplatný odkaz",qC="Kliknutím na tlačítko se přihlásíte",MC="Přihlášení",HC="Nebo zadejte kód na adrese {{vendorName}} a dokončete přihlášení.",DC="Zadejte svou e-mailovou adresu pro odemknutí tohoto pořadu na {{service}}",FC="Propojte svůj účet s {{service}}",KC="Jste přihlášeni jako",WC="Přihlášení",GC="Pro přihlášení zadejte svou e-mailovou adresu.",JC="Zadejte svou e-mailovou adresu a my vám zašleme přihlašovací kód.",ZC="Zadejte svou e-mailovou adresu a my vám zašleme odkaz pro přihlášení.",YC="Odhlášení",XC="Ne, chci použít jiný účet",QC="nebo",eN="Heslo",tN="Heslo bylo resetováno",nN="Úspěch",rN="Změna hesla k účtu {{vendorName}} ",iN="Změna hesla k účtu {{vendorName}} ",sN="Telefonní číslo",oN="Zásady ochrany osobních údajů",aN="Přesměrování",cN="Potvrzení hesla",lN="Registrace nového hesla",dN="Opětovné odeslání kódu",uN="Změna hesla",pN="Níže zadejte nové heslo k e-mailovému účtu: ",fN="Kliknutím na tlačítko obnovíte své heslo",hN="Kliknutím na tlačítko obnovíte své heslo",gN="Obnovení hesla",mN="Změna hesla k účtu {{vendorName}} ",_N="Obnovení hesla",yN="Odeslat",wN="Pošlete mi nový kouzelný odkaz",vN="Pokud e-mail nedorazil, nezapomeňte zkontrolovat složku nevyžádané pošty.",bN="Nastavení hesla",xN="Zobrazit heslo",kN="Přihlásit se",SN="Registrace",AN="Úspěšná registrace",zN="{{code}} je váš přihlašovací kód pro {{vendorName}}",EN="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.",IN="Přejděte na stránku Spotify pro přístup k obsahu",CN='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.',NN="Krok 1: Odpojení účtu Spotify",jN="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.",$N="Krok 2: Propojení účtu Spotify s aplikací Sesamy",ON="Ups! Váš účet Spotify je již propojen",PN="Pokud máte dotazy nebo potřebujete pomoc, můžete se obrátit na náš tým podpory.",TN="Podmínky a pravidla",BN="Vaši e-mailovou adresu je třeba ověřit. Do vaší e-mailové schránky jsme odeslali nový e-mail.",RN="Uživatelský účet neexistuje",LN="Uživatelský účet neexistuje",UN="Nepodařilo se nám najít uživatele se zadanou e-mailovou adresou. Zkuste to prosím znovu.",VN="Zkuste to znovu.",qN="Ověření kódu",MN="Pokyny k ověření e-mailu najdete ve své e-mailové schránce.",HN="Zaregistrovali jste se",DN="Klikněte na tlačítko pro ověření e-mailové adresy",FN="Ověřte svou e-mailovou adresu",KN="Ověřte svou e-mailovou adresu",WN="Ověření účtu",GN="Ověření e-mailu",JN="Vítejte na",ZN="Vítejte na svém účtu {{vendorName}}!",YN="Zkontrolujte si prosím svůj e-mail na adrese <0>{{email}}</0> a zadejte šestimístný kód, který jsme vám zaslali.",XN="Pokračujte s tímto účtem",QN="Ano, pokračujte {{text}}",e8="Ano, pokračujte ve stávajícím účtu",t8={account_detected:M5,account_with_sso_provider:H5,agree_to:D5,and:F5,callback_url_mismatch:K5,callback_url_not_allowed:W5,check_email_title:G5,click_to_sign_up_description:J5,code_email_enter_code:Z5,code_email_subject:Y5,code_email_title:X5,code_valid_30_minutes:Q5,confirm_password:eC,contact_support:tC,contact_us:nC,continue:"Pokračovat",continue_social_login:rC,continue_with:iC,continue_with_sso_provider_headline:sC,copyright:oC,copyright_sesamy:aC,create_account_description:cC,create_account_email_invalid:lC,create_account_passwords_didnt_match:dC,create_account_title:uC,create_account_weak_password:pC,create_new_account_link:fC,create_password_account_title:hC,currently_logged_in_as:gC,email:mC,email_or_phone_placeholder:_C,email_placeholder:yC,email_validated:wC,email_validated_cta:vC,email_verification_for_signup_sent_description:bC,email_verification_for_signup_sent_title:xC,enter_a_code_btn:kC,enter_email_for_verification_description:SC,enter_new_password_placeholder:AC,enter_password:zC,enter_password_description:EC,enter_your_password_btn:IC,expired_code:CC,fokus_info_message:NC,forgot_password_cta:jC,forgot_password_description:$C,forgot_password_email_sent:OC,forgot_password_link:PC,forgot_password_title:TC,go_back:BC,hide_password:RC,"invalid-email":"Neplatný e-mail",invalid_password:LC,invalid_session_body:UC,invalid_session_title:VC,link_email_click_to_login:qC,link_email_login:MC,link_email_or_enter_code:HC,link_page_body:DC,link_page_headline:FC,logged_in_as:KC,login:WC,login_description:GC,login_description_code:JC,login_description_link:ZC,logout:YC,no_use_another:XC,or:QC,password:eN,password_has_been_reset:tN,password_has_been_reset_title:nN,password_reset_subject:rN,password_reset_title:iN,phone_placeholder:sN,privacy_policy:oN,redirecting:aN,reenter_new_password_placeholder:cN,register_password_account:lN,resend_code:dN,reset_password_cta:uN,reset_password_description:pN,reset_password_email_click_to_reset:fN,reset_password_email_cta:hN,reset_password_email_reset:gN,reset_password_subject:mN,reset_password_title:_N,send:yN,send_me_a_new_magic_link:wN,sent_code_spam:vN,"Server error: Invalid code":"Neplatný kód",set_password:bN,show_password:xN,sign_in:kN,signup:SN,signup_success:AN,sms_code_text:zN,spotify_already_linked_body:EN,spotify_already_linked_cta:IN,spotify_already_linked_step1_body:CN,spotify_already_linked_step1_title:NN,spotify_already_linked_step2_body:jN,spotify_already_linked_step2_title:$N,spotify_already_linked_title:ON,support_info:PN,terms:TN,unverified_email:BN,user_account_does_not_exist:RN,user_not_found:LN,user_not_found_body:UN,user_not_found_cta:VN,validate_code:qN,validate_email_body:MN,validate_email_title:HN,verify_email_click_to_verify:DN,verify_email_subject:FN,verify_email_title:KN,verify_email_verify:WN,verify_your_email:GN,welcome:JN,welcome_to_your_account:ZN,we_sent_a_code_to:YN,"Wrong email or verification code":{"":"Špatný e-mail nebo ověřovací kód."},yes_continue:XN,yes_continue_with:QN,yes_continue_with_existing_account:e8},n8="Tili havaittu",r8="Olemme havainneet, että olet jo luonut tilin kautta",i8="Kirjautumalla sisään hyväksyt",s8="ja",o8="Takaisinkutsun URL-osoite ei vastaa toisiaan",a8="Annettu redirect_uri ei ole sallittujen takaisinsoitto-URL-osoitteiden luettelossa.",c8="jatka käyttäjän kanssa",l8="Klikkaa painiketta luodaksesi uuden salasanatilin.",d8="Kirjoita koodi osoitteessa {{vendorName}} kirjautumisen loppuun saattamiseksi.",u8="Tervetuloa osoitteeseen {{vendorName}}! {{code}} on kirjautumiskoodi.",p8="Tervetuloa osoitteeseen {{vendorName}}! {{code}} on kirjautumiskoodi.",f8="Koodi on voimassa 30 minuuttia",h8="Vahvista salasana",g8="Tarvitsetko apua?",m8="Ota yhteyttä",_8="tai jatka sosiaalisella tilillä",y8="Jatka {{provider}}",w8="Haluatko jatkaa olemassa olevalla tililläsi?",v8="Copyright © 2023 SESAMY. Kaikki oikeudet pidätetään.",b8="©2023 Sesamy",x8="Valitse salasana, jossa on isoja ja pieniä kirjaimia, numeroita ja symboleja.",k8="Kirjoita voimassa oleva sähköpostiosoite.",S8="Salasanat eivät vastanneet toisiaan. Yritä uudelleen.",A8="Valitse salasana",z8="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.",E8="Luo uusi tili",I8="Rekisteröidy salasanalla",C8="Olet tällä hetkellä kirjautuneena sisään nimellä <0>{{email}}</0>",N8="Sähköposti",j8="Sähköposti tai puhelinnumero",$8="Sähköpostiosoite",O8="Sähköpostiosoitteesi on vahvistettu",P8="Kirjoita nyt salasanasi kirjautuaksesi uudelleen",T8="Sähköposti on lähetetty osoitteeseen <0>{{email}}</0> jossa on vahvistuslinkki. Klikkaa linkkiä vahvistaaksesi sähköpostiosoitteesi ja asettaaksesi salasanan.",B8="Sähköpostivarmennus lähetetty",R8="Syötä koodi",L8="Lähetämme sinulle vahvistuslinkin varmistaaksemme, että omistat tämän sähköpostiosoitteen.",U8="Anna uusi salasana",V8="Anna salasana",q8="Anna sähköpostiosoitteesi ja salasanasi kirjautuaksesi sisään.",M8="Syötä salasanasi",H8="Taikalinkki on vanhentunut. Klikkaa alla olevaa painiketta saadaksesi uuden linkin sähköpostiisi.",D8="Hei! Päivitimme kirjautumiskokemuksemme. <0>Klikkaa tästä saadaksesi lisätietoja siitä.</0>",F8="Lähetä salasanan palautussähköposti",K8="Napsauta alla olevaa painiketta, niin lähetämme ohjeet salasanasi palauttamiseen.",W8="Salasanan palautussähköposti lähetetty",G8="Unohditko salasanan?",J8="Unohditko salasanan?",Z8="Palaa takaisin",Y8="Piilota salasana",X8="Virheellinen salasana",Q8=`Linkki ei ole enää voimassa.
269
271
 
270
272
  Varmista, että avaat kirjautumislinkin samalla selaimella, jolla aloitit kirjautumisen.
271
273
 
272
- Voit aloittaa uuden kirjautumisen klikkaamalla alla olevaa linkkiä.`,Z8="Virheellinen linkki",Y8="Kirjaudu sisään napsauttamalla painiketta",X8="Kirjaudu sisään",Q8="Tai kirjoita koodi osoitteessa {{vendorName}} kirjautumisen loppuun saattamiseksi.",ej="Kirjoita sähköpostiosoitteesi avataksesi tämän ohjelman osoitteessa {{service}}",tj="Yhdistä tilisi {{service}}",nj="Olet kirjautunut sisään nimellä",rj="Kirjaudu sisään",ij="Kirjoita sähköpostiosoitteesi kirjautuaksesi sisään.",sj="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumiskoodin.",oj="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumislinkin.",aj="Kirjaudu ulos",cj="Ei, haluan käyttää toista tiliä",lj="tai",dj="Salasana",uj="Salasana on nollattu",pj="Menestys",fj="Vaihda salasana tilillesi {{vendorName}} ",hj="Vaihda salasana tilillesi {{vendorName}} ",gj="Puhelinnumero",mj="Tietosuojakäytäntö",_j="Uudelleenohjaus",yj="Vahvista salasana",wj="Rekisteröi uusi salasana",vj="Lähetä koodi uudelleen",bj="Vaihda salasana",xj="Kirjoita alla oleva uusi salasanasi sähköpostitiliä varten: ",kj="Napsauta painiketta salasanasi palauttamiseksi",Sj="Napsauta painiketta salasanasi palauttamiseksi",Aj="Nollaa salasanasi",zj="Vaihda salasana tilillesi {{vendorName}} ",Ej="Nollaa salasana",Ij="Lähetä",Cj="Lähetä minulle uusi maaginen linkki",Nj="Muista tarkistaa roskapostikansiosi, jos sähköposti ei ole saapunut.",jj="Aseta salasana",$j="Näytä salasana",Oj="Kirjaudu sisään",Pj="Rekisteröityminen",Tj="Rekisteröidy onnistuneesti",Bj="{{code}} on kirjautumiskoodisi {{vendorName}}",Rj="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.",Lj="Siirry Spotifyn Content Access -sivulle",Uj='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ä.',Vj="Vaihe 1: Poista Spotify-tilisi linkitys",qj="Kun olet onnistuneesti irrottanut Spotify-tilisi, voit yhdistää sen uudelleen Sesamyn kanssa. Toista vain aiemmin tekemäsi vaiheet, jotka johtivat sinut tälle sivulle.",Mj="Vaihe 2: Yhdistä Spotify-tilisi uudelleen Sesamyn kanssa",Hj="Hups! Spotify-tilisi on jo linkitetty",Dj="Jos sinulla on kysyttävää tai tarvitset apua, voit ottaa yhteyttä tukitiimiimme.",Fj="Ehdot ja edellytykset",Kj="Sähköpostiosoitteesi on vahvistettava. Olemme lähettäneet uuden sähköpostiviestin sähköpostiisi.",Wj="Käyttäjätiliä ei ole olemassa",Gj="Käyttäjätiliä ei ole olemassa",Jj="Emme löytäneet käyttäjää, jolla on annettu sähköpostiosoite. Yritä uudelleen.",Zj="Yritä uudelleen.",Yj="Validoi koodi",Xj="Tarkista sähköpostin vahvistusohjeet postilaatikostasi.",Qj="Rekisteröitynyt",e$="Vahvista sähköpostiosoitteesi napsauttamalla painiketta",t$="Vahvista sähköpostiosoitteesi",n$="Vahvista sähköpostiosoitteesi",r$="Vahvista tili",i$="Vahvista sähköpostiosoitteesi",s$="Tervetuloa",o$="Tervetuloa tilillesi {{vendorName}}!",a$="Tarkista sähköpostisi osoitteesta <0>{{email}}</0> ja syötä lähettämämme kuusinumeroinen koodi.",c$="Jatka tällä tilillä",l$="Kyllä, jatka {{text}}",d$="Kyllä, jatka olemassa olevalla tilillä",u$={account_detected:XN,account_with_sso_provider:QN,agree_to:e8,and:t8,callback_url_mismatch:n8,callback_url_not_allowed:r8,check_email_title:i8,click_to_sign_up_description:s8,code_email_enter_code:o8,code_email_subject:a8,code_email_title:c8,code_valid_30_minutes:l8,confirm_password:d8,contact_support:u8,contact_us:p8,continue:"Jatka",continue_social_login:f8,continue_with:h8,continue_with_sso_provider_headline:g8,copyright:m8,copyright_sesamy:_8,create_account_description:y8,create_account_email_invalid:w8,create_account_passwords_didnt_match:v8,create_account_title:b8,create_account_weak_password:x8,create_new_account_link:k8,create_password_account_title:S8,currently_logged_in_as:A8,email:z8,email_or_phone_placeholder:E8,email_placeholder:I8,email_validated:C8,email_validated_cta:N8,email_verification_for_signup_sent_description:j8,email_verification_for_signup_sent_title:$8,enter_a_code_btn:O8,enter_email_for_verification_description:P8,enter_new_password_placeholder:T8,enter_password:B8,enter_password_description:R8,enter_your_password_btn:L8,expired_code:U8,fokus_info_message:V8,forgot_password_cta:q8,forgot_password_description:M8,forgot_password_email_sent:H8,forgot_password_link:D8,forgot_password_title:F8,go_back:K8,hide_password:W8,"invalid-email":"Virheellinen sähköpostiosoite",invalid_password:G8,invalid_session_body:J8,invalid_session_title:Z8,link_email_click_to_login:Y8,link_email_login:X8,link_email_or_enter_code:Q8,link_page_body:ej,link_page_headline:tj,logged_in_as:nj,login:rj,login_description:ij,login_description_code:sj,login_description_link:oj,logout:aj,no_use_another:cj,or:lj,password:dj,password_has_been_reset:uj,password_has_been_reset_title:pj,password_reset_subject:fj,password_reset_title:hj,phone_placeholder:gj,privacy_policy:mj,redirecting:_j,reenter_new_password_placeholder:yj,register_password_account:wj,resend_code:vj,reset_password_cta:bj,reset_password_description:xj,reset_password_email_click_to_reset:kj,reset_password_email_cta:Sj,reset_password_email_reset:Aj,reset_password_subject:zj,reset_password_title:Ej,send:Ij,send_me_a_new_magic_link:Cj,sent_code_spam:Nj,"Server error: Invalid code":"Virheellinen koodi",set_password:jj,show_password:$j,sign_in:Oj,signup:Pj,signup_success:Tj,sms_code_text:Bj,spotify_already_linked_body:Rj,spotify_already_linked_cta:Lj,spotify_already_linked_step1_body:Uj,spotify_already_linked_step1_title:Vj,spotify_already_linked_step2_body:qj,spotify_already_linked_step2_title:Mj,spotify_already_linked_title:Hj,support_info:Dj,terms:Fj,unverified_email:Kj,user_account_does_not_exist:Wj,user_not_found:Gj,user_not_found_body:Jj,user_not_found_cta:Zj,validate_code:Yj,validate_email_body:Xj,validate_email_title:Qj,verify_email_click_to_verify:e$,verify_email_subject:t$,verify_email_title:n$,verify_email_verify:r$,verify_your_email:i$,welcome:s$,welcome_to_your_account:o$,we_sent_a_code_to:a$,"Wrong email or verification code":{"":"Väärä sähköpostiosoite tai vahvistuskoodi."},yes_continue:c$,yes_continue_with:l$,yes_continue_with_existing_account:d$},p$=t=>{const{vendorSettings:e,authParams:n}=t,i=`/authorize?${new URLSearchParams({...n})}`;return y(Ue,{vendorSettings:e,title:T.t("user_not_found"),children:y("div",{className:"flex flex-1 flex-col justify-center",children:[y("p",{className:"mb-8 text-gray-300 text-lg",children:T.t("user_not_found_body")}),y(Ze,{Component:"a",href:i,children:T.t("user_not_found_cta")})]})})};T.init({supportedLngs:["en","it","nb","sv","pl","cs","fi"],fallbackLng:"en",resources:{en:{translation:T2},it:{translation:JA},nb:{translation:lz},sv:{translation:kE},pl:{translation:R5},cs:{translation:YN},fi:{translation:u$}}});function f$(t){const e=new o.OpenAPIHono;e.get("/",s=>s.json({name:"authhero"}));const n=Yv(t);e.route("/api/v2",n);const r=c1(t);e.route("/",r);const i=bx(t);return e.route("/u",i),{app:e,managementApp:n,oauthApp:r,universalApp:i,createX509Certificate:Zc}}exports.AppLogo=um;exports.Auth0Client=wf;exports.AuthorizationResponseMode=Rt;exports.AuthorizationResponseType=It;exports.Button=Ze;exports.CheckEmailPage=Im;exports.CodeChallengeMethod=Xs;exports.EmailValidatedPage=jm;exports.EnterCodePage=nl;exports.EnterPasswordPage=Xi;exports.ErrorMessage=Un;exports.Footer=pm;exports.ForgotPasswordPage=zm;exports.ForgotPasswordSentPage=Em;exports.Form=Wt;exports.GoBack=yt;exports.GoogleLogo=gm;exports.GrantType=Wn;exports.Icon=Ge;exports.IdentifierPage=Qc;exports.InvalidSession=Nm;exports.Layout=Ue;exports.LogTypes=ge;exports.Message=Qo;exports.PreSignUpConfirmationPage=$m;exports.PreSignUpPage=Cm;exports.ResetPasswordPage=Fn;exports.SignUpPage=Dn;exports.SocialButton=$r;exports.Spinner=hm;exports.Trans=Xo;exports.UnverifiedEmailPage=Am;exports.UserNotFoundPage=p$;exports.VippsLogo=mm;exports.applicationInsertSchema=is;exports.applicationSchema=mn;exports.auth0UserResponseSchema=St;exports.authParamsSchema=Mr;exports.baseUserSchema=Ys;exports.bordersSchema=Sf;exports.brandingSchema=za;exports.codeInsertSchema=gf;exports.codeSchema=h0;exports.codeTypeSchema=hf;exports.colorsSchema=Af;exports.connectionInsertSchema=ss;exports.connectionOptionsSchema=sl;exports.connectionSchema=Jt;exports.customDomainInsertSchema=ol;exports.customDomainSchema=Gt;exports.customDomainWithTenantIdSchema=g0;exports.emailProviderSchema=Vi;exports.fontDetailsSchema=hn;exports.fontsSchema=zf;exports.hookInsertSchema=as;exports.hookSchema=Kn;exports.identitySchema=uf;exports.init=f$;exports.injectTailwindCSS=vx;exports.jwksKeySchema=_f;exports.jwksSchema=al;exports.logSchema=cs;exports.loginSessionInsertSchema=yf;exports.loginSessionSchema=m0;exports.openIDConfigurationSchema=Ea;exports.pageBackgroundSchema=Ef;exports.parseUserId=k0;exports.passwordInsertSchema=vf;exports.passwordSchema=y0;exports.profileDataSchema=df;exports.promptSettingSchema=Ui;exports.refreshTokenInsertSchema=cl;exports.refreshTokenSchema=v0;exports.samlpAddon=pf;exports.sessionInsertSchema=xf;exports.sessionSchema=Qs;exports.signingKeySchema=Ia;exports.smsProviderSchema=x0;exports.smsSendParamsSchema=b0;exports.tailwindCss=xd;exports.tenantInsertSchema=os;exports.tenantSchema=Jn;exports.themeInsertSchema=Cf;exports.themeSchema=w0;exports.tokenResponseSchema=kf;exports.totalsSchema=an;exports.userInsertSchema=rs;exports.userResponseSchema=u0;exports.userSchema=il;exports.vendorSettingsSchema=ff;exports.verificationMethodsSchema=mf;exports.widgetSchema=If;
274
+ Voit aloittaa uuden kirjautumisen klikkaamalla alla olevaa linkkiä.`,ej="Virheellinen linkki",tj="Kirjaudu sisään napsauttamalla painiketta",nj="Kirjaudu sisään",rj="Tai kirjoita koodi osoitteessa {{vendorName}} kirjautumisen loppuun saattamiseksi.",ij="Kirjoita sähköpostiosoitteesi avataksesi tämän ohjelman osoitteessa {{service}}",sj="Yhdistä tilisi {{service}}",oj="Olet kirjautunut sisään nimellä",aj="Kirjaudu sisään",cj="Kirjoita sähköpostiosoitteesi kirjautuaksesi sisään.",lj="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumiskoodin.",dj="Anna sähköpostiosoitteesi, niin lähetämme sinulle kirjautumislinkin.",uj="Kirjaudu ulos",pj="Ei, haluan käyttää toista tiliä",fj="tai",hj="Salasana",gj="Salasana on nollattu",mj="Menestys",_j="Vaihda salasana tilillesi {{vendorName}} ",yj="Vaihda salasana tilillesi {{vendorName}} ",wj="Puhelinnumero",vj="Tietosuojakäytäntö",bj="Uudelleenohjaus",xj="Vahvista salasana",kj="Rekisteröi uusi salasana",Sj="Lähetä koodi uudelleen",Aj="Vaihda salasana",zj="Kirjoita alla oleva uusi salasanasi sähköpostitiliä varten: ",Ej="Napsauta painiketta salasanasi palauttamiseksi",Ij="Napsauta painiketta salasanasi palauttamiseksi",Cj="Nollaa salasanasi",Nj="Vaihda salasana tilillesi {{vendorName}} ",jj="Nollaa salasana",$j="Lähetä",Oj="Lähetä minulle uusi maaginen linkki",Pj="Muista tarkistaa roskapostikansiosi, jos sähköposti ei ole saapunut.",Tj="Aseta salasana",Bj="Näytä salasana",Rj="Kirjaudu sisään",Lj="Rekisteröityminen",Uj="Rekisteröidy onnistuneesti",Vj="{{code}} on kirjautumiskoodisi {{vendorName}}",qj="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.",Mj="Siirry Spotifyn Content Access -sivulle",Hj='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ä.',Dj="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.",Kj="Vaihe 2: Yhdistä Spotify-tilisi uudelleen Sesamyn kanssa",Wj="Hups! Spotify-tilisi on jo linkitetty",Gj="Jos sinulla on kysyttävää tai tarvitset apua, voit ottaa yhteyttä tukitiimiimme.",Jj="Ehdot ja edellytykset",Zj="Sähköpostiosoitteesi on vahvistettava. Olemme lähettäneet uuden sähköpostiviestin sähköpostiisi.",Yj="Käyttäjätiliä ei ole olemassa",Xj="Käyttäjätiliä ei ole olemassa",Qj="Emme löytäneet käyttäjää, jolla on annettu sähköpostiosoite. Yritä uudelleen.",e$="Yritä uudelleen.",t$="Validoi koodi",n$="Tarkista sähköpostin vahvistusohjeet postilaatikostasi.",r$="Rekisteröitynyt",i$="Vahvista sähköpostiosoitteesi napsauttamalla painiketta",s$="Vahvista sähköpostiosoitteesi",o$="Vahvista sähköpostiosoitteesi",a$="Vahvista tili",c$="Vahvista sähköpostiosoitteesi",l$="Tervetuloa",d$="Tervetuloa tilillesi {{vendorName}}!",u$="Tarkista sähköpostisi osoitteesta <0>{{email}}</0> ja syötä lähettämämme kuusinumeroinen koodi.",p$="Jatka tällä tilillä",f$="Kyllä, jatka {{text}}",h$="Kyllä, jatka olemassa olevalla tilillä",g$={account_detected:n8,account_with_sso_provider:r8,agree_to:i8,and:s8,callback_url_mismatch:o8,callback_url_not_allowed:a8,check_email_title:c8,click_to_sign_up_description:l8,code_email_enter_code:d8,code_email_subject:u8,code_email_title:p8,code_valid_30_minutes:f8,confirm_password:h8,contact_support:g8,contact_us:m8,continue:"Jatka",continue_social_login:_8,continue_with:y8,continue_with_sso_provider_headline:w8,copyright:v8,copyright_sesamy:b8,create_account_description:x8,create_account_email_invalid:k8,create_account_passwords_didnt_match:S8,create_account_title:A8,create_account_weak_password:z8,create_new_account_link:E8,create_password_account_title:I8,currently_logged_in_as:C8,email:N8,email_or_phone_placeholder:j8,email_placeholder:$8,email_validated:O8,email_validated_cta:P8,email_verification_for_signup_sent_description:T8,email_verification_for_signup_sent_title:B8,enter_a_code_btn:R8,enter_email_for_verification_description:L8,enter_new_password_placeholder:U8,enter_password:V8,enter_password_description:q8,enter_your_password_btn:M8,expired_code:H8,fokus_info_message:D8,forgot_password_cta:F8,forgot_password_description:K8,forgot_password_email_sent:W8,forgot_password_link:G8,forgot_password_title:J8,go_back:Z8,hide_password:Y8,"invalid-email":"Virheellinen sähköpostiosoite",invalid_password:X8,invalid_session_body:Q8,invalid_session_title:ej,link_email_click_to_login:tj,link_email_login:nj,link_email_or_enter_code:rj,link_page_body:ij,link_page_headline:sj,logged_in_as:oj,login:aj,login_description:cj,login_description_code:lj,login_description_link:dj,logout:uj,no_use_another:pj,or:fj,password:hj,password_has_been_reset:gj,password_has_been_reset_title:mj,password_reset_subject:_j,password_reset_title:yj,phone_placeholder:wj,privacy_policy:vj,redirecting:bj,reenter_new_password_placeholder:xj,register_password_account:kj,resend_code:Sj,reset_password_cta:Aj,reset_password_description:zj,reset_password_email_click_to_reset:Ej,reset_password_email_cta:Ij,reset_password_email_reset:Cj,reset_password_subject:Nj,reset_password_title:jj,send:$j,send_me_a_new_magic_link:Oj,sent_code_spam:Pj,"Server error: Invalid code":"Virheellinen koodi",set_password:Tj,show_password:Bj,sign_in:Rj,signup:Lj,signup_success:Uj,sms_code_text:Vj,spotify_already_linked_body:qj,spotify_already_linked_cta:Mj,spotify_already_linked_step1_body:Hj,spotify_already_linked_step1_title:Dj,spotify_already_linked_step2_body:Fj,spotify_already_linked_step2_title:Kj,spotify_already_linked_title:Wj,support_info:Gj,terms:Jj,unverified_email:Zj,user_account_does_not_exist:Yj,user_not_found:Xj,user_not_found_body:Qj,user_not_found_cta:e$,validate_code:t$,validate_email_body:n$,validate_email_title:r$,verify_email_click_to_verify:i$,verify_email_subject:s$,verify_email_title:o$,verify_email_verify:a$,verify_your_email:c$,welcome:l$,welcome_to_your_account:d$,we_sent_a_code_to:u$,"Wrong email or verification code":{"":"Väärä sähköpostiosoite tai vahvistuskoodi."},yes_continue:p$,yes_continue_with:f$,yes_continue_with_existing_account:h$},m$=t=>{const{vendorSettings:e,authParams:n}=t,i=`/authorize?${new URLSearchParams({...n})}`;return y(Ue,{vendorSettings:e,title:T.t("user_not_found"),children:y("div",{className:"flex flex-1 flex-col justify-center",children:[y("p",{className:"mb-8 text-gray-300 text-lg",children:T.t("user_not_found_body")}),y(Ze,{Component:"a",href:i,children:T.t("user_not_found_cta")})]})})};T.init({supportedLngs:["en","it","nb","sv","pl","cs","fi"],fallbackLng:"en",resources:{en:{translation:U2},it:{translation:QA},nb:{translation:fz},sv:{translation:EE},pl:{translation:q5},cs:{translation:t8},fi:{translation:g$}}});function _$(t){const e=new o.OpenAPIHono;e.get("/",s=>s.json({name:"authhero"}));const n=eb(t);e.route("/api/v2",n);const r=u1(t);e.route("/",r);const i=Ax(t);return e.route("/u",i),{app:e,managementApp:n,oauthApp:r,universalApp:i,createX509Certificate:Zc}}exports.AppLogo=hm;exports.Auth0Client=bf;exports.AuthorizationResponseMode=Rt;exports.AuthorizationResponseType=It;exports.Button=Ze;exports.CheckEmailPage=jm;exports.CodeChallengeMethod=Xs;exports.EmailValidatedPage=Pm;exports.EnterCodePage=nl;exports.EnterPasswordPage=Xi;exports.ErrorMessage=Un;exports.Footer=gm;exports.ForgotPasswordPage=Cm;exports.ForgotPasswordSentPage=Nm;exports.Form=Wt;exports.GoBack=yt;exports.GoogleLogo=ym;exports.GrantType=Wn;exports.Icon=Ge;exports.IdentifierPage=Qc;exports.InvalidSession=Om;exports.Layout=Ue;exports.LogTypes=ge;exports.Message=Qo;exports.PreSignUpConfirmationPage=Tm;exports.PreSignUpPage=$m;exports.ResetPasswordPage=Fn;exports.SignUpPage=Dn;exports.SocialButton=$r;exports.Spinner=_m;exports.Trans=Xo;exports.UnverifiedEmailPage=Im;exports.UserNotFoundPage=m$;exports.VippsLogo=wm;exports.applicationInsertSchema=is;exports.applicationSchema=mn;exports.auth0UserResponseSchema=St;exports.authParamsSchema=Mr;exports.baseUserSchema=Ys;exports.bordersSchema=zf;exports.brandingSchema=za;exports.codeInsertSchema=_f;exports.codeSchema=_0;exports.codeTypeSchema=mf;exports.colorsSchema=Ef;exports.connectionInsertSchema=ss;exports.connectionOptionsSchema=sl;exports.connectionSchema=Jt;exports.customDomainInsertSchema=ol;exports.customDomainSchema=Gt;exports.customDomainWithTenantIdSchema=y0;exports.emailProviderSchema=Vi;exports.fontDetailsSchema=hn;exports.fontsSchema=If;exports.hookInsertSchema=as;exports.hookSchema=Kn;exports.identitySchema=ff;exports.init=_$;exports.injectTailwindCSS=Sx;exports.jwksKeySchema=wf;exports.jwksSchema=al;exports.logSchema=cs;exports.loginSessionInsertSchema=vf;exports.loginSessionSchema=w0;exports.openIDConfigurationSchema=Ea;exports.pageBackgroundSchema=Cf;exports.parseUserId=z0;exports.passwordInsertSchema=xf;exports.passwordSchema=b0;exports.profileDataSchema=pf;exports.promptSettingSchema=Ui;exports.refreshTokenInsertSchema=cl;exports.refreshTokenSchema=k0;exports.samlpAddon=hf;exports.sessionInsertSchema=Sf;exports.sessionSchema=Qs;exports.signingKeySchema=Ia;exports.smsProviderSchema=A0;exports.smsSendParamsSchema=S0;exports.tailwindCss=xd;exports.tenantInsertSchema=os;exports.tenantSchema=Jn;exports.themeInsertSchema=jf;exports.themeSchema=x0;exports.tokenResponseSchema=Af;exports.totalsSchema=an;exports.userInsertSchema=rs;exports.userResponseSchema=h0;exports.userSchema=il;exports.vendorSettingsSchema=gf;exports.verificationMethodsSchema=yf;exports.widgetSchema=Nf;